Fix: wrong revision on content files / Blinking Icon in regattas list

This commit is contained in:
Timon Ostertun
2020-09-23 22:53:33 +02:00
parent b9a9cf6cf8
commit 062a7336ac
6 changed files with 66 additions and 19 deletions

View File

@@ -1331,7 +1331,6 @@ $(document).ready(function(){
colorsArray.forEach(function (gradientBodyValue) {$('.generated-styles').append('.body-'+gradientBodyValue[0]+'{background-image: linear-gradient(to bottom, '+gradientBodyValue[1]+' 0, '+gradientBodyValue[3]+' 100%)}')}); colorsArray.forEach(function (gradientBodyValue) {$('.generated-styles').append('.body-'+gradientBodyValue[0]+'{background-image: linear-gradient(to bottom, '+gradientBodyValue[1]+' 0, '+gradientBodyValue[3]+' 100%)}')});
} }
// TODO: Hier den site-specific code ausführen
initRegatten(); initRegatten();
hideLoader(); hideLoader();

View File

@@ -74,9 +74,9 @@ $(document).ready(function(){
deferredPrompt.userChoice deferredPrompt.userChoice
.then((choiceResult) => { .then((choiceResult) => {
if (choiceResult.outcome === 'accepted') { if (choiceResult.outcome === 'accepted') {
//console.log('User accepted the A2HS prompt'); console.log('User accepted the A2HS prompt');
} else { } else {
//console.log('User dismissed the A2HS prompt'); console.log('User dismissed the A2HS prompt');
} }
deferredPrompt = null; deferredPrompt = null;
}); });

View File

@@ -1,3 +1,4 @@
/*** REGATTAS LIST ***/
.regattas-list > div { .regattas-list > div {
padding-top: 1rem; padding-top: 1rem;
padding-bottom: 1rem; padding-bottom: 1rem;
@@ -40,4 +41,20 @@
.regattas-list > div > div:nth-child(3) > div:nth-child(2) { .regattas-list > div > div:nth-child(3) > div:nth-child(2) {
width: 25%; width: 25%;
text-align: right; text-align: right;
}
/*** BLINKING ICONS ***/
@keyframes fa-blink {
0% { opacity: 1; }
25% { opacity: 0.25; }
50% { opacity: 0.5; }
75% { opacity: 0.75; }
100% { opacity: 0; }
}
.fa-blink {
-webkit-animation: fa-blink .75s linear infinite;
-moz-animation: fa-blink .75s linear infinite;
-ms-animation: fa-blink .75s linear infinite;
-o-animation: fa-blink .75s linear infinite;
animation: fa-blink .75s linear infinite;
} }

View File

@@ -6,7 +6,7 @@
?> ?>
{ {
"version": "1.0", "version": "<?php echo PWA_VERSION; ?>",
"lang" : "de", "lang" : "de",
"name" : "Regatten.net <?php echo $_CLASS['name'] ?>", "name" : "Regatten.net <?php echo $_CLASS['name'] ?>",
"scope" : "<?php echo SERVER_ADDR; ?>/", "scope" : "<?php echo SERVER_ADDR; ?>/",

View File

@@ -32,29 +32,21 @@ var rows = [];
var today; var today;
async function drawTable () { async function drawTable () {
//setLoading(true, 'loading');
window.setTimeout(function () { window.setTimeout(function () {
var list = ''; var list = '';
rows.forEach(function (entry) { rows.forEach(function (entry) {
if (entry == null) { if (entry == null) {
list += '<div><div align="center" class="color-highlight"><b>Heute ist der ' + formatDate('d.m.Y', today) + '</b></div></div>'; list += '<div><div align="center" class="color-highlight"><b>Heute ist der ' + formatDate('d.m.Y', today) + '</b></div></div>';
//tbody += '<tr><td colspan="' + heuteLen + '" class="bg-highlight color-white">';
//tbody += 'Heute ist der ' + formatDate('d.m.Y', today);
//tbody += '</td></tr>';
} else if (search($('#input-search').val(), entry.keywords)) { } else if (search($('#input-search').val(), entry.keywords)) {
list += entry.content; list += entry.content;
} }
}); });
$('#div-regattas').html(list); $('#div-regattas').html(list);
//setLoading(false, 'loading');
}, 0); }, 0);
} }
async function regattaClicked(id) { async function regattaClicked(id) {
var regatta = await dbGetData('regattas', id); var regatta = await dbGetData('regattas', id);
console.log(regatta);
$('#menu-regatta').find('.menu-title').find('p').text(regatta.name); $('#menu-regatta').find('.menu-title').find('p').text(regatta.name);
@@ -277,10 +269,32 @@ var siteScript = async function() {
if ((entry['meldung'] != '') && (dateTo >= today) && (entry['meldungOffen'] == '1')) { if ((entry['meldung'] != '') && (dateTo >= today) && (entry['meldungOffen'] == '1')) {
var color = ''; var color = '';
if (entry['meldungSchluss'] != null) { if (entry['meldungSchluss'] != null) {
var ms = parseDate(entry['meldungSchluss']); var planning = null;
var diff = Math.round((ms - today) / 86400000); if (isLoggedIn()) {
if ((ms >= today) && (diff < 7)) var plannings = await dbGetDataIndex('plannings', 'regatta', entry['id']);
color = ' color-red2-dark'; for (id in plannings) {
if (plannings[id]['user'] == USER_ID) {
planning = plannings[id];
break;
}
}
}
if ((planning == null) || (planning['gemeldet'] == '0')) {
var ms = 0;
if (entry['meldungEarly'] != null) {
ms = parseDate(entry['meldungEarly']);
}
if (ms < today) {
ms = parseDate(entry['meldungSchluss']);
}
var diff = Math.round((ms - today) / 86400000);
if ((ms >= today) && (diff < 7)) {
color = ' color-red2-dark';
if (planning != null) {
color += ' fa-blink';
}
}
}
} }
icons.push('<i class="fas fa-file-signature' + color + '"></i>'); icons.push('<i class="fas fa-file-signature' + color + '"></i>');
} }

View File

@@ -24,13 +24,30 @@ workbox.core.setCacheNameDetails({
workbox.precaching.precacheAndRoute([ workbox.precaching.precacheAndRoute([
<?php <?php
// CONTENT // CONTENT
function getDirHash($path) {
$hash = '';
if ($dir = opendir($path)) {
while (($file = readdir($dir)) !== false) {
if ($file == '.') continue;
if ($file == '..') continue;
if (is_dir($path . '/' . $file)) {
$hash .= getDirHash($path . '/' . $file);
} else {
$hash .= md5_file($path . '/' . $file);
}
}
closedir($dir);
}
return $hash;
}
$hash = md5(getDirHash(__DIR__));
$path = __DIR__ . '/content/'; $path = __DIR__ . '/content/';
$dir = opendir($path); $dir = opendir($path);
while ($file = readdir($dir)) { while ($file = readdir($dir)) {
if (($file == '.') or ($file == '..') or (pathinfo($file, PATHINFO_EXTENSION) != 'php')) continue; if (($file == '.') or ($file == '..') or (pathinfo($file, PATHINFO_EXTENSION) != 'php')) continue;
$revision = filemtime($path . $file);
$file = SERVER_ADDR . '/' . pathinfo($file, PATHINFO_FILENAME); $file = SERVER_ADDR . '/' . pathinfo($file, PATHINFO_FILENAME);
echo "\t{url: '$file', revision: '$revision'},\n"; echo "\t{url: '$file', revision: '$hash'},\n";
} }
closedir($dir); closedir($dir);
@@ -63,7 +80,7 @@ workbox.precaching.precacheAndRoute([
} }
foreach ($filesToCache as $file) { foreach ($filesToCache as $file) {
$revision = filemtime(__DIR__ . $file); $revision = md5_file(__DIR__ . $file);
$file = SERVER_ADDR . $file; $file = SERVER_ADDR . $file;
echo "\t{url: '$file', revision: '$revision'},\n"; echo "\t{url: '$file', revision: '$revision'},\n";
} }