index fertig bis auf rank
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
else
|
||||
echo '<a href="' . LINK_PRE . $sp['backbutton'] . '" class="header-icon header-icon-1"><i class="fas fa-arrow-left"></i></a>';
|
||||
} ?>
|
||||
<a href="#" data-menu="menu-developer" class="header-icon header-icon-3"><i class="fas fa-code"></i></a>
|
||||
<a href="#" data-menu="menu-settings" class="header-icon header-icon-4"><i class="fas fa-cog"></i></a>
|
||||
</div>
|
||||
<div id="footer-bar" class="footer-bar-1">
|
||||
|
||||
@@ -129,6 +129,35 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="menu-developer" class="menu menu-box-bottom menu-box-detached rounded-m" data-menu-height="310">
|
||||
<div class="menu-title"><h1>Entwickler-Optionen</h1><p class="color-highlight"> </p><a href="#" class="close-menu"><i class="fa fa-times"></i></a></div>
|
||||
<div class="divider divider-margins mb-n2"></div>
|
||||
<div class="content">
|
||||
<div class="list-group list-custom-small">
|
||||
<a href="https://info.ostertun.net/regatten/beta">
|
||||
<i class="fa font-14 fa-info rounded-s bg-highlight color-white"></i>
|
||||
<span>Infos zur BETA</span>
|
||||
<i class="fa fa-angle-right"></i>
|
||||
</a>
|
||||
<a href="javascript:resetDb();">
|
||||
<i class="fa font-14 fa-database rounded-s bg-highlight color-white"></i>
|
||||
<span>Reset Database</span>
|
||||
<i class="fa fa-angle-right"></i>
|
||||
</a>
|
||||
<a href="javascript:resetCache();">
|
||||
<i class="fa font-14 fa-trash-alt rounded-s bg-highlight color-white"></i>
|
||||
<span>Reset Cache</span>
|
||||
<i class="fa fa-angle-right"></i>
|
||||
</a>
|
||||
<a href="https://report.regatten.net/" class="border-0">
|
||||
<i class="fa font-14 fa-bug rounded-s bg-highlight color-white"></i>
|
||||
<span>Problem melden</span>
|
||||
<i class="fa fa-angle-right"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="menu-login" class="menu menu-box-top menu-box-detached rounded-m" data-menu-height="270">
|
||||
<div class="content bottom-0">
|
||||
<h1 class="text-center mt-5 font-900">Login</h1>
|
||||
|
||||
@@ -49,6 +49,8 @@
|
||||
<script type="text/javascript" src="<?php echo SERVER_ADDR; ?>/client/scripts/bootstrap.min.js"></script>
|
||||
<script type="text/javascript" src="<?php echo SERVER_ADDR; ?>/client/scripts/strings.js.php"></script>
|
||||
<script type="text/javascript" src="<?php echo SERVER_ADDR; ?>/client/scripts/regatten.js.php"></script>
|
||||
<script type="text/javascript" src="<?php echo SERVER_ADDR; ?>/client/scripts/datetime.js"></script>
|
||||
<script type="text/javascript" src="<?php echo SERVER_ADDR; ?>/client/scripts/database.js"></script>
|
||||
<script type="text/javascript" src="<?php echo SERVER_ADDR; ?>/client/scripts/custom.js.php"></script>
|
||||
<script type="text/javascript" src="<?php echo SERVER_ADDR; ?>/client/scripts/pwa.js.php"></script>
|
||||
</body>
|
||||
|
||||
37
server/scripts.php
Normal file
37
server/scripts.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
class Scripts {
|
||||
|
||||
private $path;
|
||||
private $scripts;
|
||||
|
||||
function __construct($path) {
|
||||
if (substr($path, -1) != '/') $path .= '/';
|
||||
$this->path = $path;
|
||||
$this->scripts = [];
|
||||
}
|
||||
|
||||
function load($name, $params = []) {
|
||||
if (!isset($this->scripts[$name])) {
|
||||
$filename = $this->path . $name . '.js';
|
||||
if (file_exists($filename) and is_file($filename)) {
|
||||
$this->scripts[$name] = file_get_contents($filename);
|
||||
} else {
|
||||
return "<p>Script '$name' not found!</p>";
|
||||
}
|
||||
}
|
||||
|
||||
$script = $this->scripts[$name];
|
||||
while (($pos = strpos($script, '$$')) !== false) {
|
||||
$pos += 2;
|
||||
$pos2 = strpos($script, ';', $pos);
|
||||
if ($pos2 === false) return "<p>Syntax error in script '$name'!</p>";
|
||||
$ph = substr($script, $pos, $pos2 - $pos);
|
||||
if (!isset($params[$ph])) $params[$ph] = '';
|
||||
$script = str_replace('$$' . $ph . ';', $params[$ph], $script);
|
||||
}
|
||||
return '<script>' . $script . '</script>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
323
server/scripts/index.js
Normal file
323
server/scripts/index.js
Normal file
@@ -0,0 +1,323 @@
|
||||
var siteScript = async function() {
|
||||
if (isLoggedIn()) {
|
||||
$('#card-notloggedin').hide();
|
||||
|
||||
var user = await dbGetData('users', localStorage.getItem('auth_user'));
|
||||
var today = getToday();
|
||||
|
||||
// Favorites
|
||||
var watched = [];
|
||||
for (var i = 1; i <= 5; i ++) {
|
||||
sailor_id = user['sailor' + i];
|
||||
if (sailor_id != null) {
|
||||
watched.push(await dbGetData('sailors', sailor_id));
|
||||
}
|
||||
}
|
||||
if (watched.length > 0) {
|
||||
var year = (new Date()).getFullYear();
|
||||
$('#th-ranking').html('Rangliste ' + year);
|
||||
// TODO: get ranking
|
||||
tbody = '';
|
||||
for (i in watched) {
|
||||
sailor = watched[i];
|
||||
tbody += '<tr><td>' + sailor.name + '</td><td>';
|
||||
// TODO: check if ranking and output
|
||||
//tbody += '<i>nicht in der Rangliste</i>';
|
||||
tbody += '<i>Ranglisten werden aktuell noch nicht unterstützt</i>';
|
||||
tbody += '</td></tr>';
|
||||
}
|
||||
$('#table-favorites').find('tbody').html(tbody);
|
||||
$('#p-favorites').hide();
|
||||
$('#table-favorites').show();
|
||||
} else {
|
||||
$('#table-favorites').hide();
|
||||
$('#p-favorites').show();
|
||||
}
|
||||
$('#card-favorites').show();
|
||||
|
||||
// Your next
|
||||
var planningsDB = await dbGetDataIndex('plannings', 'user', user.id);
|
||||
var minDate = getToday();
|
||||
minDate.setDate(minDate.getDate() - 1);
|
||||
var maxDate = getToday();
|
||||
maxDate.setDate(maxDate.getDate() + 28);
|
||||
var regattas = await dbGetRegattasRange(minDate, maxDate);
|
||||
var plannings = [];
|
||||
for (i = planningsDB.length - 1; i >= 0; i --) {
|
||||
var planning = planningsDB[i];
|
||||
for (j in regattas) {
|
||||
var regatta = regattas[j];
|
||||
if (regatta.id == planning.regatta) {
|
||||
planning.regatta = regatta;
|
||||
plannings.push(planning);
|
||||
}
|
||||
}
|
||||
}
|
||||
plannings.sort(function (a, b) {
|
||||
if (a.regatta.date < b.regatta.date) return -1;
|
||||
if (a.regatta.date > b.regatta.date) return 1;
|
||||
return 0;
|
||||
});
|
||||
if (plannings.length > 0) {
|
||||
tbody = '';
|
||||
for (i in plannings) {
|
||||
var planning = plannings[i];
|
||||
var regatta = planning.regatta;
|
||||
var club = null;
|
||||
if (regatta['club'] != null)
|
||||
club = await dbGetData('clubs', regatta['club']);
|
||||
var dateFrom = regatta['dateFrom'];
|
||||
var dateTo = regatta['dateTo'];
|
||||
// TODO: get steuermann and crew
|
||||
var steuermann = '<i>noch unklar</i>';
|
||||
if (planning.steuermann !== null) {
|
||||
steuermann = (await dbGetData('sailors', planning.steuermann)).name;
|
||||
}
|
||||
var crew = [];
|
||||
if (planning.crew !== '') {
|
||||
crewIds = planning.crew.split(',');
|
||||
for (j in crewIds) {
|
||||
crew.push((await dbGetData('sailors', crewIds[j])).name);
|
||||
}
|
||||
}
|
||||
|
||||
// output
|
||||
tbody += '<tr>';
|
||||
|
||||
tbody += '<td><span style="white-space:nowrap;">' + formatDate("j. M 'y", dateFrom) + '<br>' + formatDate("j. M 'y", dateTo) + '</span></td>';
|
||||
|
||||
var content = '';
|
||||
if (club != null) {
|
||||
content = club['kurz'];
|
||||
if (club['website'] != '') {
|
||||
content = '<a href="' + club['website'] + '" target="_blank">' + content + '</a>';
|
||||
}
|
||||
}
|
||||
tbody += '<td>' + content + '<br>' + (regatta['canceled'] == 1 ? '<s>' : '') + regatta['name'] + (regatta['canceled'] == 1 ? '</s>' : '') + '</td>';
|
||||
|
||||
var buf = '';
|
||||
if (regatta['info'] != '') {
|
||||
buf += '<a target="_blank" href="' + regatta['info'] + '">Informationen</a>';
|
||||
}
|
||||
if ((regatta['meldung'] != '') && (dateTo >= today)) {
|
||||
buf += '<br><a target="_blank" href="' + regatta['meldung'] + '">Meldung</a>';
|
||||
|
||||
if ((planning != null) && (planning['gemeldet'] == "1")) {
|
||||
buf += ' <i>(du hast gemeldet)</i>';
|
||||
} else if (regatta['meldungOffen'] == "0") {
|
||||
buf += ' <i>(geschlossen)</i>';
|
||||
} else if (regatta['meldungSchluss'] != null) {
|
||||
early = false;
|
||||
if (regatta['meldungEarly'] != null) {
|
||||
ms = parseDate(regatta['meldungEarly']);
|
||||
if (ms >= today) {
|
||||
early = true;
|
||||
}
|
||||
}
|
||||
if (!early)
|
||||
ms = parseDate(regatta['meldungSchluss']);
|
||||
if (ms >= today) {
|
||||
diff = Math.round((ms - today) / 86400000);
|
||||
red = (diff < 7);
|
||||
if (diff <= 14) {
|
||||
txt = 'noch ' + diff + ' Tag' + (diff != 1 ? 'e' : '');
|
||||
} else if (diff < 35) {
|
||||
diff = Math.floor(diff / 7);
|
||||
txt = 'noch ' + diff + ' Woche' + (diff != 1 ? 'n' : '');
|
||||
} else {
|
||||
diff = Math.floor(diff / 30.5);
|
||||
txt = 'noch ' + diff + ' Monat' + (diff != 1 ? 'e' : '');
|
||||
}
|
||||
buf += ' <i>' + (red ? '<b><font style="color:red;">(' : '(') + txt + (early ? ' vergünstigt' : '') + (red ? ')</font></b>' : ')') + '</i>';
|
||||
} else {
|
||||
buf += ' <i>(Meldeschluss abgelaufen)</i>';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (regatta['bericht'] != '') {
|
||||
buf += '<br><a target="_blank" href="' + regatta['bericht'] + '">Bericht</a>';
|
||||
}
|
||||
if (regatta['oresults'] != '') {
|
||||
buf += '<br><a target="_blank" href="' + regatta['oresults'] + '">off. Ergebnisse</a>';
|
||||
}
|
||||
tbody += '<td>' + buf + '</td>';
|
||||
|
||||
tbody += '<td><span style="white-space:nowrap;">' + parseFloat(regatta['rlf']).toFixed(2) + '</span></td>';
|
||||
|
||||
tbody += '<td>' + steuermann + '<br>' + crew.join('<br>') + '</td>';
|
||||
|
||||
tbody += '</tr>';
|
||||
}
|
||||
$('#table-yournext').find('tbody').html(tbody);
|
||||
$('#p-yournext').hide();
|
||||
$('#table_yournext').show();
|
||||
} else {
|
||||
$('#table-yournext').hide();
|
||||
$('#p-yournext').show();
|
||||
}
|
||||
$('#card-yournext').show();
|
||||
} else {
|
||||
$('#card-favorites').hide();
|
||||
$('#card-yournext').hide();
|
||||
$('#card-notloggedin').show();
|
||||
}
|
||||
|
||||
// Next
|
||||
var minDate = getToday();
|
||||
minDate.setDate(minDate.getDate() - 1);
|
||||
var maxDate = getToday();
|
||||
maxDate.setDate(maxDate.getDate() + 14);
|
||||
var regattas = await dbGetRegattasRange(minDate, maxDate);
|
||||
if (regattas.length > 0) {
|
||||
tbody = '';
|
||||
for (i in regattas) {
|
||||
var regatta = regattas[i];
|
||||
var club = null;
|
||||
if (regatta['club'] != null)
|
||||
club = await dbGetData('clubs', regatta['club']);
|
||||
var plannings = await dbGetDataIndex('plannings', 'regatta', regatta['id']);
|
||||
var dateFrom = regatta['dateFrom'];
|
||||
var dateTo = regatta['dateTo'];
|
||||
|
||||
// output
|
||||
tbody += '<tr>';
|
||||
|
||||
tbody += '<td><span style="white-space:nowrap;">' + formatDate("j. M 'y", dateFrom) + '<br>' + formatDate("j. M 'y", dateTo) + '</span></td>';
|
||||
|
||||
var content = '';
|
||||
if (club != null) {
|
||||
content = club['kurz'];
|
||||
if (club['website'] != '') {
|
||||
content = '<a href="' + club['website'] + '" target="_blank">' + content + '</a>';
|
||||
}
|
||||
}
|
||||
tbody += '<td>' + content + '<br>' + (regatta['canceled'] == 1 ? '<s>' : '') + regatta['name'] + (regatta['canceled'] == 1 ? '</s>' : '') + '</td>';
|
||||
|
||||
var buf = '';
|
||||
if (regatta['info'] != '') {
|
||||
buf += '<a target="_blank" href="' + regatta['info'] + '">Informationen</a>';
|
||||
}
|
||||
if ((regatta['meldung'] != '') && (dateTo >= today)) {
|
||||
buf += '<br><a target="_blank" href="' + regatta['meldung'] + '">Meldung</a>';
|
||||
var planning = null;
|
||||
if (isLoggedIn()) {
|
||||
for (id in plannings) {
|
||||
if (plannings[id]['user'] == USER_ID) {
|
||||
planning = plannings[id];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((planning != null) && (planning['gemeldet'] == "1")) {
|
||||
buf += ' <i>(du hast gemeldet)</i>';
|
||||
} else if (regatta['meldungOffen'] == "0") {
|
||||
buf += ' <i>(geschlossen)</i>';
|
||||
} else if (regatta['meldungSchluss'] != null) {
|
||||
early = false;
|
||||
if (regatta['meldungEarly'] != null) {
|
||||
ms = parseDate(regatta['meldungEarly']);
|
||||
if (ms >= today) {
|
||||
early = true;
|
||||
}
|
||||
}
|
||||
if (!early)
|
||||
ms = parseDate(regatta['meldungSchluss']);
|
||||
if (ms >= today) {
|
||||
diff = Math.round((ms - today) / 86400000);
|
||||
red = (diff < 7);
|
||||
if (diff <= 14) {
|
||||
txt = 'noch ' + diff + ' Tag' + (diff != 1 ? 'e' : '');
|
||||
} else if (diff < 35) {
|
||||
diff = Math.floor(diff / 7);
|
||||
txt = 'noch ' + diff + ' Woche' + (diff != 1 ? 'n' : '');
|
||||
} else {
|
||||
diff = Math.floor(diff / 30.5);
|
||||
txt = 'noch ' + diff + ' Monat' + (diff != 1 ? 'e' : '');
|
||||
}
|
||||
buf += ' <i>' + (red ? '<b><font style="color:red;">(' : '(') + txt + (early ? ' vergünstigt' : '') + (red ? ')</font></b>' : ')') + '</i>';
|
||||
} else {
|
||||
buf += ' <i>(Meldeschluss abgelaufen)</i>';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (regatta['bericht'] != '') {
|
||||
buf += '<br><a target="_blank" href="' + regatta['bericht'] + '">Bericht</a>';
|
||||
}
|
||||
if (regatta['oresults'] != '') {
|
||||
buf += '<br><a target="_blank" href="' + regatta['oresults'] + '">off. Ergebnisse</a>';
|
||||
}
|
||||
tbody += '<td>' + buf + '</td>';
|
||||
|
||||
tbody += '<td><span style="white-space:nowrap;">' + parseFloat(regatta['rlf']).toFixed(2) + '</span></td>';
|
||||
|
||||
tbody += '</tr>';
|
||||
}
|
||||
$('#table-next').find('tbody').html(tbody);
|
||||
$('#p-next').hide();
|
||||
$('#table-next').show();
|
||||
} else {
|
||||
$('#table-next').hide();
|
||||
$('#p-next').show();
|
||||
}
|
||||
|
||||
// Last
|
||||
var minDate = getToday();
|
||||
minDate.setDate(minDate.getDate() - 14);
|
||||
var maxDate = getToday();
|
||||
maxDate.setDate(maxDate.getDate() - 1);
|
||||
var regattas = await dbGetRegattasRange(minDate, maxDate);
|
||||
var regattaResults = [];
|
||||
for (id in regattas) {
|
||||
var entry = regattas[id];
|
||||
var results = await dbGetDataIndex('results', 'regatta', entry['id']);
|
||||
regattaResults[entry['id']] = (results.length > 0);
|
||||
}
|
||||
if (regattas.length > 0) {
|
||||
tbody = '';
|
||||
for (i in regattas) {
|
||||
var regatta = regattas[i];
|
||||
var club = null;
|
||||
if (regatta['club'] != null)
|
||||
club = await dbGetData('clubs', regatta['club']);
|
||||
var dateFrom = regatta['dateFrom'];
|
||||
var dateTo = regatta['dateTo'];
|
||||
|
||||
// output
|
||||
tbody += '<tr>';
|
||||
|
||||
tbody += '<td><span style="white-space:nowrap;">' + formatDate("j. M 'y", dateFrom) + '<br>' + formatDate("j. M 'y", dateTo) + '</span></td>';
|
||||
|
||||
var content = '';
|
||||
if (club != null) {
|
||||
content = club['kurz'];
|
||||
if (club['website'] != '') {
|
||||
content = '<a href="' + club['website'] + '" target="_blank">' + content + '</a>';
|
||||
}
|
||||
}
|
||||
tbody += '<td>' + content + '<br>' + (regatta['canceled'] == 1 ? '<s>' : '') + regatta['name'] + (regatta['canceled'] == 1 ? '</s>' : '') + '</td>';
|
||||
|
||||
var buf = '';
|
||||
if (regatta['canceled'] == "1") {
|
||||
buf = '<i style="color:red;" class="fas fa-times"></i> Ausgefallen</td>';
|
||||
} else {
|
||||
if (regattaResults[regatta['id']]) {
|
||||
buf = '<i style="color:green;" class="fas fa-check"></i> <a href="' + LINK_PRE + 'result?regatta=' + regatta['id'] + '">Ergebnisse</a></td>';
|
||||
} else {
|
||||
buf = 'Nicht verfügbar';
|
||||
}
|
||||
}
|
||||
tbody += '<td>' + buf + '</td>';
|
||||
|
||||
tbody += '<td><span style="white-space:nowrap;">' + parseFloat(regatta['rlf']).toFixed(2) + '</span></td>';
|
||||
|
||||
tbody += '</tr>';
|
||||
}
|
||||
$('#table-last').find('tbody').html(tbody);
|
||||
$('#p-last').hide();
|
||||
$('#table-last').show();
|
||||
} else {
|
||||
$('#table-last').hide();
|
||||
$('#p-last').show();
|
||||
}
|
||||
}
|
||||
@@ -22,13 +22,13 @@
|
||||
}
|
||||
|
||||
$template = $this->templates[$name];
|
||||
while (($pos = strpos($template, '$')) !== false) {
|
||||
$pos ++;
|
||||
while (($pos = strpos($template, '$$')) !== false) {
|
||||
$pos += 2;
|
||||
$pos2 = strpos($template, ';', $pos);
|
||||
if ($pos2 === false) return "<p>Syntax error in template '$name'!</p>";
|
||||
$ph = substr($template, $pos, $pos2 - $pos);
|
||||
if (!isset($params[$ph])) $params[$ph] = '';
|
||||
$template = str_replace('$' . $ph . ';', $params[$ph], $template);
|
||||
$template = str_replace('$$' . $ph . ';', $params[$ph], $template);
|
||||
}
|
||||
return $template;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<a id="$html-id;" class="btn btn-full rounded-s text-uppercase font-900 shadow-m bg-highlight $css-class;" href="$1;">
|
||||
$0;
|
||||
<a id="$$html-id;" class="btn btn-full rounded-s text-uppercase font-900 shadow-m bg-highlight $$css-class;" href="$$1;">
|
||||
$$0;
|
||||
</a>
|
||||
@@ -1,5 +1,5 @@
|
||||
<div id="$html-id;" class="card card-style">
|
||||
<div class="content $css-class;">
|
||||
$0;
|
||||
<div id="$$html-id;" class="card card-style">
|
||||
<div class="content $$css-class;">
|
||||
$$0;
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,3 +1,3 @@
|
||||
<i class="fa fa-exclamation-triangle fa-8x color-red2-dark"></i>
|
||||
<h1 class="fa-6x mt-5 font-900">$0;</h1>
|
||||
<h4 class="mb-5 mt-3">$1;</h4>
|
||||
<h1 class="fa-6x mt-5 font-900">$$0;</h1>
|
||||
<h4 class="mb-5 mt-3">$$1;</h4>
|
||||
@@ -1,10 +1,10 @@
|
||||
<div style="width: 100%; overflow-x: auto;">
|
||||
<table id="$html-id;" class="table table-striped table-bordered $css-class;">
|
||||
<table id="$$html-id;" class="table table-striped table-bordered $$css-class;">
|
||||
<thead>
|
||||
$0;
|
||||
$$0;
|
||||
</thead>
|
||||
<tbody>
|
||||
$1;
|
||||
$$1;
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
Reference in New Issue
Block a user