diff --git a/client/scripts/database.js b/client/scripts/database.js index 88c1219..627eace 100644 --- a/client/scripts/database.js +++ b/client/scripts/database.js @@ -1,4 +1,4 @@ -const DB_VERSION = 6; +const DB_VERSION = 7; const USER_ID = localStorage.getItem('auth_user'); const USER_NAME = localStorage.getItem('auth_username'); @@ -351,7 +351,7 @@ function dbGetRanking(minDate, maxDate, jugend, jugstrict) { if (sailors[i].german == '0') { sailors.splice(i, 1); } else if (jugend) { - if (((sailors[i].year != null) && (sailors[i].year < (formatDate('Y', maxDate) - YOUTH_AGE))) || + if (((sailors[i].year != null) && (sailors[i].year < (formatDate('Y', maxDate) - (await dbGetClassProp('youth-age'))))) || ((sailors[i].year == null) && (jugstrict))) { sailors.splice(i, 1); } @@ -417,6 +417,27 @@ function dbSettingsSet(key, value) { } } +function dbGetClassProp(key) { + return new Promise(function(resolve) { + if (canUseLocalDB) { + var request = db.transaction('class').objectStore('class').get(key); + request.onsuccess = function (event) { + resolve(typeof request.result != 'undefined' ? request.result.value : null); + } + } else { + getJSON(QUERY_URL + 'get_class_prop?key=' + key, function (code, data) { + if (code == 200) { + resolve(data.value); + } else { + log("[db] Something went wrong (HTTP " + code + ")"); + fail(strings.error_network, 5000); + resolve(null); + } + }); + } + }); +} + async function updateSyncStatus() { var lastSync = await dbGetData('update_times', 'last_sync'); lastSync = new Date(lastSync.time * 1000); @@ -503,7 +524,7 @@ function sync() { localTimes[entry['table']] = entry['time']; }); - syncInProgress = 11; + syncInProgress = 12; var syncOkay = true; log("[db] Sync Start"); $('#i-sync').addClass('fa-spin'); @@ -533,6 +554,24 @@ function sync() { getJSON(QUERY_URL + 'get_update_time', function (code, serverTimes) { if (code == 200) { + // CLASS + getJSON(QUERY_URL + 'get_class', function (code, data) { + if (code == 200) { + var os = db.transaction('class', 'readwrite').objectStore('class'); + log(data); + for (key in data) { + os.put({ key: key, value: data[key] }); + } + syncInProgress --; + log('[db] class synced, remaining:', syncInProgress); + } else { + log("[db] class: Something went wrong (HTTP " + code + ")"); + syncOkay = false; + syncInProgress --; + log('[db] class failed, remaining:', syncInProgress); + } + }); + // CLUBS if (localTimes['clubs'] < serverTimes['clubs']) { getJSON(QUERY_URL + 'get_clubs?changed-after=' + localTimes['clubs'], function (code, data) { @@ -1065,6 +1104,11 @@ function initDatabase() { osUpdateTimes.add({ table: 'news', time: 0 }); } + if ((oldVersion < 7) && (newVersion >= 7)) { + log('[db] to version 7'); + var osClass = db.createObjectStore('class', { keyPath: 'key' }); + } + // Force resync after db update if (oldVersion >= 1) { var osUpdateTimes = upgradeTransaction.objectStore('update_times'); diff --git a/client/scripts/regatten.js.php b/client/scripts/regatten.js.php index 87484af..3205b33 100644 --- a/client/scripts/regatten.js.php +++ b/client/scripts/regatten.js.php @@ -10,8 +10,6 @@ const QUERY_URL = ''; const BOATCLASS = ''; const LINK_PRE = '/'; -const YOUTH_AGE = ''; -const YOUTH_GERMAN_NAME = ''; const PUSH_SERVER_KEY = ''; var consoleOutput = []; diff --git a/index.php b/index.php index 69f3a2a..517e8c9 100644 --- a/index.php +++ b/index.php @@ -1,13 +1,13 @@ 'Regatten.net ' . $_CLASS['name'], // This is the page title 'backbutton' => false, // Show a back button (true, false, string). If a string is given, the back button is a link to this page. @@ -37,12 +37,12 @@ 'menus' => '', // Additional menus go here 'scripts' => '' // Site specific scripts ]; - + $tpl = new Templates(__DIR__ . '/server/templates/'); $scripts = new Scripts(__DIR__ . '/server/scripts/'); - + require_once(__DIR__ . '/server/content/' . $site . '.php'); - + require_once(__DIR__ . '/server/buildpage.php'); - -?> \ No newline at end of file + +?> diff --git a/server/content/index.php b/server/content/index.php index acd380f..e1a0c6d 100644 --- a/server/content/index.php +++ b/server/content/index.php @@ -80,7 +80,8 @@ $sp['output'] .= $tpl->load('card', [$content]); // Regattas Menu - $items = '
'; + $items = ''; + $items .= ''; $items .= $tpl->load('menu/item-icon', ['Saison-Planungen', '', 'html-id' => 'menu-item-plannings', 'icon' => 'fa-calendar-alt']); $items .= $tpl->load('menu/item-icon', ['Ergebnisse', '', 'html-id' => 'menu-item-results', 'icon' => 'fa-poll']); $items .= $tpl->load('menu/item-icon', ['Bericht', '', 'html-id' => 'menu-item-bericht', 'icon' => 'fa-book']); diff --git a/server/content/planning.php b/server/content/planning.php index 5f2a026..01ac587 100644 --- a/server/content/planning.php +++ b/server/content/planning.php @@ -27,7 +27,8 @@ $sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-regattas', 'css-class' => 'show-loggedin']); // Menu - $items = ''; + $items = ''; + $items .= ''; $items .= $tpl->load('menu/item-icon', ['Status bearbeiten', '#', 'html-id' => 'menu-item-status', 'icon' => 'fa-edit']); $items .= $tpl->load('menu/item-icon', ['Saison-Planungen', '', 'html-id' => 'menu-item-plannings', 'icon' => 'fa-calendar-alt']); $items .= $tpl->load('menu/item-icon', ['Ergebnisse', '', 'html-id' => 'menu-item-results', 'icon' => 'fa-poll']); diff --git a/server/content/planning_view.php b/server/content/planning_view.php index ba8b855..1670a5e 100644 --- a/server/content/planning_view.php +++ b/server/content/planning_view.php @@ -20,7 +20,8 @@ $sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-regattas']); // Menu - $items = ''; + $items = ''; + $items .= ''; $items .= $tpl->load('menu/item-icon', ['Saison-Planungen', '', 'html-id' => 'menu-item-plannings', 'icon' => 'fa-calendar-alt']); $items .= $tpl->load('menu/item-icon', ['Ergebnisse', '', 'html-id' => 'menu-item-results', 'icon' => 'fa-poll']); $items .= $tpl->load('menu/item-icon', ['Bericht', '', 'html-id' => 'menu-item-bericht', 'icon' => 'fa-book']); diff --git a/server/content/regattas.php b/server/content/regattas.php index 3254a2c..36be855 100644 --- a/server/content/regattas.php +++ b/server/content/regattas.php @@ -1,28 +1,31 @@ Regatten"; - + $content .= $tpl->load('select', ['html-id' => 'select-year', 'placeholder' => 'Jahr', 'css-class' => 'mt-3 mb-0']); $content .= $tpl->load('input', ['html-id' => 'input-from', 'placeholder' => 'Von', 'type' => 'date', 'css-class' => 'mt-3']); $content .= $tpl->load('input', ['html-id' => 'input-to', 'placeholder' => 'Bis', 'type' => 'date']); $content .= $tpl->load('button', ['Anzeigen', '#', 'html-id' => 'button-show']); - + $sp['output'] .= $tpl->load('card', [$content]); - + // Regattas $content = ''; $content .= $tpl->load('input', ['html-id' => 'input-search', 'placeholder' => 'Suche', 'type' => 'text', 'css-class' => 'mt-2']); $content .= ''; - + $sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-regattas']); - + + $sp['output'] .= $tpl->load('card', ['', 'html-id' => 'card-special']); + // Menu - $items = ''; + $items = ''; + $items .= ''; $items .= $tpl->load('menu/item-icon', ['Saison-Planungen', '', 'html-id' => 'menu-item-plannings', 'icon' => 'fa-calendar-alt']); $items .= $tpl->load('menu/item-icon', ['Ergebnisse', '', 'html-id' => 'menu-item-results', 'icon' => 'fa-poll']); $items .= $tpl->load('menu/item-icon', ['Bericht', '', 'html-id' => 'menu-item-bericht', 'icon' => 'fa-book']); @@ -31,8 +34,8 @@ $items .= $tpl->load('menu/item-icon', ['offizielle Ergebnisse', '', 'html-id' => 'menu-item-oresults', 'icon' => 'fa-poll']); $items .= $tpl->load('menu/item-icon', ['Vereins-Website', '', 'html-id' => 'menu-item-clubwebsite', 'icon' => 'fa-globe']); $sp['menus'] .= $tpl->load('menu/bottom', [$items, 'html-id' => 'menu-regatta', 'title' => 'Regatta-Details', 'height' => 320]); - + $sp['scripts'] .= $scripts->load('onRegattaClicked'); $sp['scripts'] .= $scripts->load('regattas'); - -?> \ No newline at end of file + +?> diff --git a/server/scripts/index.js b/server/scripts/index.js index 438b91e..1477283 100644 --- a/server/scripts/index.js +++ b/server/scripts/index.js @@ -188,6 +188,9 @@ var siteScript = async function() { list += '