Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2bf623733d | ||
|
|
60caf85daa | ||
|
|
eddcff9e39 | ||
|
|
967ad50755 | ||
|
|
a437d05647 | ||
|
|
658bfcc4a8 | ||
|
|
b5b1897dac | ||
|
|
b32b5e3c00 | ||
|
|
08e5afeb6e | ||
|
|
364fd6fea0 | ||
|
|
4143545117 | ||
|
|
9e30ed5e9c | ||
|
|
9d1ba271f3 | ||
|
|
8eff91f28b |
@@ -12,7 +12,7 @@ RewriteRule ^(.*)server(.*)$ / [R=301,L,NC]
|
||||
### CONTENT LOADER
|
||||
|
||||
# Keep this subfolders untouched
|
||||
RewriteRule ^(api)($|/) - [L]
|
||||
#RewriteRule ^(api)($|/) - [L]
|
||||
|
||||
# Show site
|
||||
RewriteRule ^([^\.]*)$ index.php?request=$1 [QSA]
|
||||
@@ -1,8 +0,0 @@
|
||||
RewriteEngine on
|
||||
# root directory:
|
||||
RewriteBase /projects/RegattenApp/api/
|
||||
|
||||
|
||||
|
||||
# Show site
|
||||
RewriteRule ^(.*)$ index.php?request=$1 [QSA]
|
||||
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
// DATABASE Credentials
|
||||
define('DB_USER', 'regattenwebsite');
|
||||
define('DB_PASS', 'RBpOv4YYtZKWIGcN');
|
||||
define('DB_HOST', 'localhost');
|
||||
define('DB_DATABASE', 'regattenwebsite');
|
||||
|
||||
define('DB_CHANGE_TIME', true);
|
||||
define('DB_USE_UTF8', true); // use utf-8 in DB requests
|
||||
|
||||
// DATABASE Table names
|
||||
define('DB_TABLE_USERS', 'users');
|
||||
define('DB_TABLE_LOGINS', 'logins');
|
||||
define('DB_TABLE_KEEPLOGGEDIN', 'keeploggedin');
|
||||
define('DB_TABLE_RESET', 'rstpw');
|
||||
|
||||
define('DB_TABLE_CLUBS', 'regatta_clubs');
|
||||
define('DB_TABLE_SUFFIX_BOATS', '_boats');
|
||||
define('DB_TABLE_SUFFIX_SAILORS', '_sailors');
|
||||
define('DB_TABLE_SUFFIX_PLANNING', '_planning');
|
||||
define('DB_TABLE_SUFFIX_REGATTAS', '_regattas');
|
||||
define('DB_TABLE_SUFFIX_RESULTS', '_results');
|
||||
define('DB_TABLE_TRIM_BOATS', 'trim_boats');
|
||||
define('DB_TABLE_TRIM_USERS', 'trim_users');
|
||||
define('DB_TABLE_TRIM_TRIMS', 'trim_trims');
|
||||
define('DB_TABLE_NEWS', 'news');
|
||||
define('DB_TABLE_UPDATETIMES', '_updatetimes');
|
||||
|
||||
// OUTGOING MAILS - Credentials for outgoing mails
|
||||
define('MAIL_SMTP_HOST', 'ssl://ostertun.net'); // SMTP Server address
|
||||
define('MAIL_SMTP_PORT', 465); // port to use
|
||||
define('MAIL_FROM_ADDRESS', 'no-reply@regatten.net'); // address to send mails from
|
||||
define('MAIL_USERNAME', MAIL_FROM_ADDRESS); // if true: username
|
||||
define('MAIL_PASSWORD', 'pVc05j_3'); // & password
|
||||
|
||||
?>
|
||||
157
api/database.php
157
api/database.php
@@ -1,157 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
|
||||
Mysql Database Support
|
||||
----------------------
|
||||
|
||||
Required defines:
|
||||
- DB_HOST (STRING)
|
||||
- DB_USER (STRING)
|
||||
- DB_PASS (STRING)
|
||||
- DB_DATABASE (STRING)
|
||||
- DB_USE_UTF8 (BOOL)
|
||||
- DB_CHANGE_TIME (BOOL)
|
||||
|
||||
Required functions:
|
||||
- logE (in /_global/log.php)
|
||||
|
||||
*/
|
||||
|
||||
$mysqli = mysqli_connect(DB_HOST, DB_USER, DB_PASS);
|
||||
|
||||
if ($mysqli === false) {
|
||||
logE("database", "Could not connect to database\n" . mysqli_connect_error);
|
||||
die('Error: Could not connect to database');
|
||||
}
|
||||
|
||||
mysqli_select_db($mysqli, DB_DATABASE);
|
||||
if (DB_USE_UTF8) {
|
||||
mysqli_set_charset($mysqli, 'utf8');
|
||||
}
|
||||
|
||||
function db_get_data($mysqli, $table, $fields = '*', $where = false, $limit = false) {
|
||||
$rest = '';
|
||||
if ($where != false) {
|
||||
$rest .= ' WHERE ' . $where;
|
||||
}
|
||||
if ($limit != false) {
|
||||
$rest .= sprintf(' LIMIT %d', $limit);
|
||||
}
|
||||
$query = 'SELECT ' . $fields . ' FROM ' . mysqli_real_escape_string($mysqli, $table) . $rest . ';';
|
||||
$response = mysqli_query($mysqli, $query);
|
||||
|
||||
if ($response !== false) {
|
||||
$result = array();
|
||||
if ($response->num_rows > 0) {
|
||||
$i = 0;
|
||||
while ($row = $response->fetch_assoc()) {
|
||||
if (isset($row['id'])) {
|
||||
$id = $row['id'];
|
||||
} else {
|
||||
$id = $i;
|
||||
$i ++;
|
||||
}
|
||||
foreach ($row as $key => $value) {
|
||||
$result[$id][$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
} else {
|
||||
logE("database", "get_data\nInvalid request\n" . $query . "\n" . mysqli_error($mysqli));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function db_update_data($mysqli, $table, $data, $where, $limit = false) {
|
||||
$rest = '';
|
||||
if ($where != false) {
|
||||
$rest .= ' WHERE ' . $where;
|
||||
}
|
||||
if ($limit != false) {
|
||||
$rest .= sprintf(' LIMIT %d', $limit);
|
||||
}
|
||||
$set = '';
|
||||
$first = true;
|
||||
foreach ($data as $key => $value) {
|
||||
if ($first) {
|
||||
$first = false;
|
||||
} else {
|
||||
$set .= ', ';
|
||||
}
|
||||
if ($value === null) {
|
||||
$set .= '`' . mysqli_real_escape_string($mysqli, $key) . '`=NULL';
|
||||
} else {
|
||||
$set .= '`' . mysqli_real_escape_string($mysqli, $key) . '`="' . mysqli_real_escape_string($mysqli, $value) . '"';
|
||||
}
|
||||
}
|
||||
if (defined('DB_CHANGE_TIME')) $set .= ', `changed`=NOW()';
|
||||
$query = 'UPDATE ' . mysqli_real_escape_string($mysqli, $table) . ' SET ' . $set . $rest . ';';
|
||||
$response = mysqli_query($mysqli, $query);
|
||||
|
||||
if ($response === false) {
|
||||
logE("database", "update_data\nInvalid request\n" . $query . "\n" . mysqli_error($mysqli));
|
||||
} elseif (defined('DB_CHANGE_TIME')) {
|
||||
mysqli_query($mysqli, 'UPDATE `_updatetimes` SET `update`=NOW() WHERE `table`="' . mysqli_real_escape_string($mysqli, $table) . '";');
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
function db_insert_data($mysqli, $table, $data) {
|
||||
$fields = '';
|
||||
$values = '';
|
||||
$first = true;
|
||||
foreach ($data as $key => $value) {
|
||||
if ($first) {
|
||||
$first = false;
|
||||
} else {
|
||||
$fields .= ', ';
|
||||
$values .= ', ';
|
||||
}
|
||||
$fields .= '`' . mysqli_real_escape_string($mysqli, $key) . '`';
|
||||
if ($value === null) {
|
||||
$values .= 'NULL';
|
||||
} else {
|
||||
$values .= '"' . mysqli_real_escape_string($mysqli, $value) . '"';
|
||||
}
|
||||
}
|
||||
if (defined('DB_CHANGE_TIME')) {
|
||||
$fields .= ', `changed`';
|
||||
$values .= ', NOW()';
|
||||
}
|
||||
$query = 'INSERT INTO `' . mysqli_real_escape_string($mysqli, $table) . '` (' . $fields . ') VALUES (' . $values . ');';
|
||||
$response = mysqli_query($mysqli, $query);
|
||||
if ($response === false) {
|
||||
logE("database", "insert_data\nInvalid request\n" . $query . "\n" . mysqli_error($mysqli));
|
||||
} else {
|
||||
$response = mysqli_insert_id($mysqli);
|
||||
if (defined('DB_CHANGE_TIME')) {
|
||||
mysqli_query($mysqli, 'UPDATE `_updatetimes` SET `update`=NOW() WHERE `table`="' . mysqli_real_escape_string($mysqli, $table) . '";');
|
||||
}
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
function db_delete_data($mysqli, $table, $where, $limit = false) {
|
||||
$rest = '';
|
||||
if ($where != false) {
|
||||
$rest .= ' WHERE ' . $where;
|
||||
}
|
||||
if ($limit != false) {
|
||||
$rest .= sprintf(' LIMIT %d', $limit);
|
||||
}
|
||||
$query = 'DELETE FROM `' . mysqli_real_escape_string($mysqli, $table) . '`' . $rest . ';';
|
||||
$response = mysqli_query($mysqli, $query);
|
||||
if ($response === false) {
|
||||
logE("database", "delete_data\nInvalid request\n" . $query . "\n" . mysqli_error($mysqli));
|
||||
} elseif (defined('DB_CHANGE_TIME')) {
|
||||
mysqli_query($mysqli, 'UPDATE `_updatetimes` SET `update`=NOW() WHERE `table`="' . mysqli_real_escape_string($mysqli, $table) . '";');
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,450 +0,0 @@
|
||||
<?php
|
||||
|
||||
function get_db_entry($mysqli, $table, $id = false, $order = false) {
|
||||
if ($id === false) {
|
||||
return db_get_data($mysqli, $table, '*', ($order !== false ? ('1=1 ORDER BY ' . $order) : false));
|
||||
} else {
|
||||
$result = db_get_data($mysqli, $table, '*', '`id` = "' . mysqli_real_escape_string($mysqli, $id) . '"', 1);
|
||||
if (($result === false) or (count($result) != 1))
|
||||
return false;
|
||||
else
|
||||
return array_values($result)[0];
|
||||
}
|
||||
}
|
||||
|
||||
function get_club($mysqli, $id = false) {
|
||||
return get_db_entry($mysqli, DB_TABLE_CLUBS, $id, '`kurz` ASC');
|
||||
}
|
||||
|
||||
function get_boat($mysqli, $id = false) {
|
||||
return get_db_entry($mysqli, BOATCLASS . DB_TABLE_SUFFIX_BOATS, $id, '`sailnumber` ASC');
|
||||
}
|
||||
|
||||
function get_sailor($mysqli, $id = false) {
|
||||
return get_db_entry($mysqli, BOATCLASS . DB_TABLE_SUFFIX_SAILORS, $id, '`name` ASC');
|
||||
}
|
||||
|
||||
function get_planning($mysqli, $userId = false, $regattaId = false) {
|
||||
$where = '';
|
||||
$limit = false;
|
||||
if ($userId !== false) {
|
||||
$where .= '(`user`="' . mysqli_real_escape_string($mysqli, $userId) . '")';
|
||||
}
|
||||
if (($userId !== false) and ($regattaId !== false)) {
|
||||
$where .= ' AND ';
|
||||
$limit = 1;
|
||||
}
|
||||
if ($regattaId !== false) {
|
||||
$where .= '(`regatta`="' . mysqli_real_escape_string($mysqli, $regattaId) . '")';
|
||||
}
|
||||
if ($where == '') $where = false;
|
||||
if ($limit === false) {
|
||||
return db_get_data($mysqli, BOATCLASS . DB_TABLE_SUFFIX_PLANNING, '*', $where);
|
||||
} else {
|
||||
$result = db_get_data($mysqli, BOATCLASS . DB_TABLE_SUFFIX_PLANNING, '*', $where, 1);
|
||||
if (($result === false) or (count($result) != 1))
|
||||
return false;
|
||||
else
|
||||
return array_values($result)[0];
|
||||
}
|
||||
}
|
||||
|
||||
function get_regatta($mysqli, $id = false) {
|
||||
return get_db_entry($mysqli, BOATCLASS . DB_TABLE_SUFFIX_REGATTAS, $id, '`date` ASC');
|
||||
}
|
||||
|
||||
function get_result($mysqli, $regattaId = false) {
|
||||
if ($regattaId === false) {
|
||||
return db_get_data($mysqli, BOATCLASS . DB_TABLE_SUFFIX_RESULTS);
|
||||
} else {
|
||||
return db_get_data($mysqli, BOATCLASS . DB_TABLE_SUFFIX_RESULTS, '*', '`regatta` = "' . mysqli_real_escape_string($mysqli, $regattaId) . '"');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function get_regattas_range($mysqli, $from, $to) {
|
||||
return db_get_data($mysqli, BOATCLASS . DB_TABLE_SUFFIX_REGATTAS, '*', '(`date` >= "' . date('Y-m-d', $from) . '") AND (`date` <= "' . date('Y-m-d', $to) . '") ORDER BY `date`');
|
||||
}
|
||||
|
||||
function get_regatta_years($mysqli) {
|
||||
$query = 'SELECT DISTINCT(YEAR(`date`)) as year FROM ' . BOATCLASS . DB_TABLE_SUFFIX_REGATTAS . ' ORDER BY `date`;';
|
||||
$response = mysqli_query($mysqli, $query);
|
||||
|
||||
if ($response !== false) {
|
||||
$result = array();
|
||||
if ($response->num_rows > 0) {
|
||||
while ($row = $response->fetch_assoc()) {
|
||||
$result[] = $row['year'];
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
} else {
|
||||
logE("functions", "get_data\nInvalid request\n" . $query . "\n" . mysqli_error($mysqli));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function get_result_calculated($mysqli, $regatta_id) {
|
||||
$regatta = get_regatta($mysqli, $regatta_id);
|
||||
if ($regatta === false) {
|
||||
return false;
|
||||
}
|
||||
$results = get_result($mysqli, $regatta_id);
|
||||
if ($results !== false) {
|
||||
|
||||
// *** Replace , with .
|
||||
foreach ($results as $key => $value) {
|
||||
for ($i = 1; $i <= $regatta['races']; $i ++) {
|
||||
$results[$key]['race' . $i] = str_replace(',', '.', $results[$key]['race' . $i]);
|
||||
}
|
||||
}
|
||||
|
||||
// *** Calculation ***
|
||||
$gemeldet = count($results);
|
||||
|
||||
$sortarray = array();
|
||||
foreach ($results as $key => $value) {
|
||||
$results[$key]['finished'] = false;
|
||||
$results[$key]['values'] = array();
|
||||
$results[$key]['values_all'] = array();
|
||||
$results[$key]['texts'] = array();
|
||||
$copy = array();
|
||||
for ($i = 1; $i <= $regatta['races']; $i ++) {
|
||||
if (is_numeric($value['race' . $i])) {
|
||||
$results[$key]['values'][$i] = $value['race' . $i];
|
||||
$results[$key]['texts'][$i] = $value['race' . $i];
|
||||
$copy[$i] = $value['race' . $i];
|
||||
$results[$key]['finished'] = true;
|
||||
} else {
|
||||
switch ($value['race' . $i]) {
|
||||
// Nicht gestartet
|
||||
case 'DNC': $results[$key]['values'][$i] = $gemeldet + 1; $copy[$i] = $gemeldet + 1; break; // Did not come
|
||||
case 'DNS': $results[$key]['values'][$i] = $gemeldet + 1; $copy[$i] = $gemeldet + 1; break; // Did not started
|
||||
// Startfehler
|
||||
case 'OCS': $results[$key]['values'][$i] = $gemeldet + 1; $copy[$i] = $gemeldet + 1; /*$results[$key]['finished'] = true;*/ break; // On course site
|
||||
// Muss v. Hand case 'ZFP': $results[$key]['values'][$i] = $gemeldet + 1; $copy[$i] = $gemeldet + 1; $results[$key]['finished'] = true; break; // Z-Flag penalty (20% nach 30.2)
|
||||
case 'UFD': $results[$key]['values'][$i] = $gemeldet + 1; $copy[$i] = $gemeldet + 1; /*$results[$key]['finished'] = true;*/ break; // Uniform Flag Disqualified (disqu. nach 30.3)
|
||||
case 'BFD': $results[$key]['values'][$i] = $gemeldet + 1; $copy[$i] = $gemeldet + 1; /*$results[$key]['finished'] = true;*/ break; // Black Flag Disqualified (disqu. nach 30.4)
|
||||
// Nicht durch Ziel gegangen
|
||||
case 'DNF': $results[$key]['values'][$i] = $gemeldet + 1; $copy[$i] = $gemeldet + 1; break; // Did not finish
|
||||
case 'RET': $results[$key]['values'][$i] = $gemeldet + 1; $copy[$i] = $gemeldet + 1; break; // Retired (Aufgegeben)
|
||||
case 'RAF': $results[$key]['values'][$i] = $gemeldet + 1; $copy[$i] = $gemeldet + 1; /*$results[$key]['finished'] = true;*/ break; // Retired after finish
|
||||
// Disqualifizierun
|
||||
case 'DSQ': $results[$key]['values'][$i] = $gemeldet + 1; $copy[$i] = $gemeldet + 1; /*$results[$key]['finished'] = true;*/ break; // Disqualified
|
||||
case 'DNE': $results[$key]['values'][$i] = $gemeldet + 1; $copy[$i] = -1; /*$results[$key]['finished'] = true;*/ break; // Disqualified, not excludable (disqu. kann nach 90.3(b) nicht gestrichen werden)
|
||||
case 'DGM': $results[$key]['values'][$i] = $gemeldet + 1; $copy[$i] = -2; /*$results[$key]['finished'] = true;*/ break; // Disqualification Gross Missconduct (kann nach 69.1(b)(2) nicht gestr. werden, grobes Fehlverhalten)
|
||||
// Wiedergutmachung
|
||||
// Muss v. Hand case 'RDG': $results[$key]['values'][$i] = $gemeldet + 1; $copy[$i] = $gemeldet + 1; $results[$key]['finished'] = true; break; // Redress given (Wiedergutmachung gewährt)
|
||||
// Strafen
|
||||
// Muss v. Hand case 'SCP': $results[$key]['values'][$i] = $gemeldet + 1; $copy[$i] = $gemeldet + 1; $results[$key]['finished'] = true; break; // Wertungsstrafe nach 44.3(a) (20%)
|
||||
// Muss v. Hand case 'DPI': $results[$key]['values'][$i] = $gemeldet + 1; $copy[$i] = $gemeldet + 1; $results[$key]['finished'] = true; break; // Punktstrafe nach Ermessen der Jury
|
||||
// Unbekannt
|
||||
default: $results[$key]['values'][$i] = 0; $copy[$i] = 0; break;
|
||||
}
|
||||
|
||||
if ($results[$key]['values'][$i] != 0) {
|
||||
$results[$key]['texts'][$i] = $value['race' . $i] . ' (' . $results[$key]['values'][$i] . ')';
|
||||
} else {
|
||||
$results[$key]['texts'][$i] = $value['race' . $i] . ' (Unknown - 0)';
|
||||
}
|
||||
}
|
||||
}
|
||||
$results[$key]['values_all'] = $results[$key]['values'];
|
||||
for ($s = 0; $s < $regatta['streicher']; $s ++) {
|
||||
$max = max($copy);
|
||||
for ($i = 1; $i <= $regatta['races']; $i ++) {
|
||||
if ($copy[$i] == $max) {
|
||||
$copy[$i] = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$brutto = $netto = 0;
|
||||
for ($i = 1; $i <= $regatta['races']; $i ++) {
|
||||
$brutto += $results[$key]['values_all'][$i];
|
||||
if ($copy[$i] == -1) { $results[$key]['values'][$i] = $gemeldet + 1; }
|
||||
elseif ($copy[$i] == -2) { $results[$key]['values'][$i] = $gemeldet + 1; }
|
||||
else { $results[$key]['values'][$i] = $copy[$i]; }
|
||||
if ($results[$key]['values'][$i] == 0) {
|
||||
$results[$key]['texts'][$i] = '[' . $results[$key]['texts'][$i] . ']';
|
||||
}
|
||||
$netto += $results[$key]['values'][$i];
|
||||
}
|
||||
$results[$key]['brutto'] = $brutto;
|
||||
$results[$key]['netto'] = $netto;
|
||||
|
||||
if ($results[$key]['finished']) {
|
||||
$sortarray[$key] = 0;
|
||||
} else {
|
||||
$sortarray[$key] = 1;
|
||||
}
|
||||
$sortarray[$key] /*.*/= sprintf("%08.2f", $netto);
|
||||
$temp = $results[$key]['values'];
|
||||
sort($temp);
|
||||
$i = 0;
|
||||
foreach ($temp as $val) {
|
||||
if ($i < $regatta['races']) {
|
||||
$sortarray[$key] .= sprintf("%07.2f", $val);
|
||||
}
|
||||
$i ++;
|
||||
}
|
||||
for ($i = $regatta['races']; $i > 0; $i --) {
|
||||
$sortarray[$key] .= sprintf("%07.2f", $results[$key]['values_all'][$i]);
|
||||
}
|
||||
$results[$key]['sortvalue'] = $sortarray[$key];
|
||||
}
|
||||
array_multisort($sortarray, $results);
|
||||
$i = 1;
|
||||
foreach ($results as $key => $value) {
|
||||
if (($i > 1) and ($sortarray[$key] == $sortarray[$lastkey])) {
|
||||
$results[$key]['place'] = $results[$lastkey]['place'];
|
||||
} else {
|
||||
$results[$key]['place'] = $i;
|
||||
}
|
||||
$i ++;
|
||||
$lastkey = $key;
|
||||
}
|
||||
unset ($sortarray);
|
||||
|
||||
return $results;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function update_result_cache($mysqli, $regatta_id) {
|
||||
$regatta = get_regatta($mysqli, $regatta_id);
|
||||
if ($regatta === false) return;
|
||||
$results = get_result_calculated($mysqli, $regatta['id']);
|
||||
if ($results === false) return;
|
||||
|
||||
// count finished boats
|
||||
$fb = 0;
|
||||
foreach ($results as $result) {
|
||||
if ($result['finished']) {
|
||||
$fb ++;
|
||||
}
|
||||
}
|
||||
|
||||
db_update_data($mysqli, BOATCLASS . DB_TABLE_SUFFIX_REGATTAS, ['finishedBoats' => $fb], '`id`="' . $regatta['id'] . '"', 1);
|
||||
|
||||
foreach ($results as $result) {
|
||||
if ($fb == 0) {
|
||||
$rlp = 0;
|
||||
} else {
|
||||
$rlp = 100 * $regatta['rlf'] * (($fb + 1 - $result['place']) / $fb);
|
||||
}
|
||||
db_update_data($mysqli, BOATCLASS . DB_TABLE_SUFFIX_RESULTS, ['place' => $result['place'], 'rlp' => $rlp], '`id`="' . $result['id'] . '"', 1);
|
||||
}
|
||||
}
|
||||
|
||||
function get_ranking($mysqli, $from, $to, $jugend = false, $jugstrict = false) {
|
||||
global $rankNoResults, $_CLASSES;
|
||||
$rankNoResults = array();
|
||||
|
||||
$sailors = get_sailor($mysqli);
|
||||
$regattas = get_regattas_range($mysqli, $from, $to);
|
||||
|
||||
if (($sailors !== false) and ($regattas !== false)) {
|
||||
foreach ($sailors as $key => $sailor) {
|
||||
$sailors[$key]['regattas'] = array();
|
||||
$sailors[$key]['tmp_rlp'] = array();
|
||||
}
|
||||
|
||||
foreach ($regattas as $regatta) {
|
||||
$date = strtotime($regatta['date']);
|
||||
|
||||
// regatta has to be min. 2 days to be ranking-regatta
|
||||
if ($regatta['length'] < 2) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$results = get_result($mysqli, $regatta['id']);
|
||||
if ($results === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (count($results) <= 0) {
|
||||
if (strtotime('+' . ($regatta['length']-1) . ' days', $date) <= time()) {
|
||||
if (!$regatta['canceled']) {
|
||||
$rankNoResults[] = $regatta;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// in one race there must be at least 10 boats started
|
||||
$ok = false;
|
||||
for ($i = 1; $i <= $regatta['races']; $i ++) {
|
||||
$temp = 0;
|
||||
foreach ($results as $result) {
|
||||
if (($result['race' . $i] != 'DNC') and ($result['race' . $i] != 'DNS')) {
|
||||
$temp ++;
|
||||
}
|
||||
}
|
||||
if ($temp >= 10) {
|
||||
$ok = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$ok) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$fb = $regatta['finishedBoats'];
|
||||
|
||||
// add regatta to each sailor
|
||||
foreach ($results as $result) {
|
||||
if ($result['rlp'] == 0) {
|
||||
continue;
|
||||
}
|
||||
// check if crew is youth
|
||||
//if ($jugend) {
|
||||
// $crew = explode(',', $result['crew']);
|
||||
// $okay = true;
|
||||
// foreach ($crew as $sailor) {
|
||||
// if (($sailor == '') or !isset($sailors[$sailor])) continue;
|
||||
// $sailor = $sailors[$sailor];
|
||||
// if ((($sailor['year'] !== null) and ($sailor['year'] < (date('Y', $date) - $_CLASSES[BOATCLASS]['youth-age']))) or
|
||||
// (($sailor['year'] === null) and ($jugstrict))) {
|
||||
// $okay = false;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// if (!$okay) continue;
|
||||
//}
|
||||
// calc m
|
||||
if ($regatta['m'] > 0) {
|
||||
$m = $regatta['m'];
|
||||
} elseif ($regatta['races'] <= 4) {
|
||||
$m = $regatta['races'];
|
||||
} else {
|
||||
if (($regatta['length'] > 2) and ($regatta['races'] >= 6)) {
|
||||
$m = 5;
|
||||
} else {
|
||||
$m = 4;
|
||||
}
|
||||
}
|
||||
$rlp = $result['rlp'];
|
||||
$sailors[$result['steuermann']]['regattas'][$regatta['id']] = array(
|
||||
'regatta' => $regatta['id'],
|
||||
'boat' => $result['boat'],
|
||||
'crew' => $result['crew'],
|
||||
'place' => $result['place'],
|
||||
'fb' => $fb,
|
||||
'rlp' => $rlp,
|
||||
'used' => 0,
|
||||
'm' => $m
|
||||
);
|
||||
for ($i = 0; $i < $m; $i ++) {
|
||||
array_push($sailors[$result['steuermann']]['tmp_rlp'], array($regatta['id'], $rlp));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($sailors as $key => $sailor) {
|
||||
if ($sailor['german'] == 0) {
|
||||
unset($sailors[$key]);
|
||||
} elseif ($jugend) {
|
||||
if ((($sailor['year'] !== null) and ($sailor['year'] < (date('Y', $to) - $_CLASSES[BOATCLASS]['youth-age']))) or
|
||||
(($sailor['year'] === null) and ($jugstrict))) {
|
||||
unset($sailors[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$sortarray = array();
|
||||
|
||||
foreach ($sailors as $key => $sailor) {
|
||||
// sort rlps desc
|
||||
$sort = array();
|
||||
foreach ($sailor['tmp_rlp'] as $key2 => $value) {
|
||||
$sort[$key2] = $value[1];
|
||||
}
|
||||
array_multisort($sort, SORT_DESC, $sailors[$key]['tmp_rlp']);
|
||||
// calc mean. rlp
|
||||
$sum = 0;
|
||||
$cnt = 0;
|
||||
foreach ($sailors[$key]['tmp_rlp'] as $value) {
|
||||
$sum += $value[1];
|
||||
$sailors[$key]['regattas'][$value[0]]['used'] ++;
|
||||
$cnt ++;
|
||||
if ($cnt >= 9) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
unset($sailors[$key]['tmp_rlp']);
|
||||
if ($cnt > 0) {
|
||||
$rlp = $sum / $cnt;
|
||||
$sailors[$key]['rlp'] = $rlp;
|
||||
$sailors[$key]['m'] = $cnt;
|
||||
} else {
|
||||
unset($sailors[$key]);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($rlp == 0) {
|
||||
$sortarray[$key] = $cnt;
|
||||
} else {
|
||||
$sortarray[$key] = $cnt * 1000 + $rlp;
|
||||
}
|
||||
}
|
||||
array_multisort($sortarray, SORT_DESC, $sailors);
|
||||
unset($sortarray);
|
||||
|
||||
$i = 1;
|
||||
foreach ($sailors as $key => $sailor) {
|
||||
$sailors[$key]['rank'] = $i;
|
||||
$i ++;
|
||||
}
|
||||
|
||||
return $sailors;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function get_trim_boat($mysqli, $id = false) {
|
||||
return get_db_entry($mysqli, DB_TABLE_TRIM_BOATS, $id);
|
||||
}
|
||||
|
||||
function get_trim_boat_users($mysqli, $id) {
|
||||
$result = db_get_data($mysqli, DB_TABLE_TRIM_USERS, '*', '`boat` = "' . mysqli_real_escape_string($mysqli, $id) . '"');
|
||||
if ($result === false)
|
||||
return false;
|
||||
else
|
||||
return $result;
|
||||
}
|
||||
|
||||
function get_trim_user_boats($mysqli, $id) {
|
||||
$boats = db_get_data($mysqli, DB_TABLE_TRIM_USERS, '*', '`user` = "' . mysqli_real_escape_string($mysqli, $id) . '"');
|
||||
if ($boats === false) {
|
||||
return false;
|
||||
} else {
|
||||
$result = [];
|
||||
foreach ($boats as $value) {
|
||||
$result[$value['boat']] = get_trim_boat($mysqli, $value['boat']);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
function trim_is_boat_user($mysqli, $user, $boat) {
|
||||
$res = db_get_data($mysqli, DB_TABLE_TRIM_USERS, '*', '`user` = "' . mysqli_real_escape_string($mysqli, $user) . '" AND `boat` = "' . mysqli_real_escape_string($mysqli, $boat) . '"');
|
||||
return ($res !== false) and (count($res) == 1);
|
||||
}
|
||||
|
||||
function get_trim_trim($mysqli, $id = false) {
|
||||
return get_db_entry($mysqli, DB_TABLE_TRIM_TRIMS, $id);
|
||||
}
|
||||
|
||||
function get_trim_boat_trims($mysqli, $id) {
|
||||
$result = db_get_data($mysqli, DB_TABLE_TRIM_TRIMS, '*', '`boat` = "' . mysqli_real_escape_string($mysqli, $id) . '"');
|
||||
if ($result === false) {
|
||||
return false;
|
||||
} else {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
466
api/index.php
466
api/index.php
@@ -1,466 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once(__DIR__ . '/../server/config.php');
|
||||
require_once(__DIR__ . '/config.php');
|
||||
require_once(__DIR__ . '/../server/log.php');
|
||||
require_once(__DIR__ . '/database.php');
|
||||
require_once(__DIR__ . '/login.php');
|
||||
require_once(__DIR__ . '/functions.php');
|
||||
|
||||
$request = false;
|
||||
if (isset($_GET['request'])) {
|
||||
$request = explode('/', $_GET['request']);
|
||||
}
|
||||
if ($request === false) {
|
||||
$request = array();
|
||||
}
|
||||
if (count($request) >= 1) {
|
||||
$action = array_shift($request);
|
||||
} else {
|
||||
$action = '';
|
||||
}
|
||||
|
||||
define('DONE_OKAY', 0);
|
||||
define('DONE_EMPTY', 1);
|
||||
define('DONE_DATABASE', 2);
|
||||
define('DONE_UNAUTHORIZED', 3);
|
||||
define('DONE_BAD_REQUEST', 4);
|
||||
define('DONE_CONFLICT', 5);
|
||||
define('DONE_SERVER_ERROR', 6);
|
||||
function done($donecode, $content = null) {
|
||||
switch ($donecode) {
|
||||
case DONE_OKAY:
|
||||
header('HTTP/1.0 200 OK');
|
||||
break;
|
||||
case DONE_EMPTY:
|
||||
header('HTTP/1.0 204 No Content');
|
||||
break;
|
||||
case DONE_DATABASE:
|
||||
header('HTTP/1.0 500 Internal Server Error');
|
||||
if ($content === null) {
|
||||
$content = array('error' => 'database error');
|
||||
}
|
||||
break;
|
||||
case DONE_UNAUTHORIZED:
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
if ($content === null) {
|
||||
$content = array('error' => 'unauthorized');
|
||||
}
|
||||
break;
|
||||
case DONE_BAD_REQUEST:
|
||||
header('HTTP/1.0 400 Bad Request');
|
||||
if ($content === null) {
|
||||
$content = array('error' => 'bad request');
|
||||
}
|
||||
break;
|
||||
case DONE_CONFLICT:
|
||||
header('HTTP/1.0 409 Conflict');
|
||||
break;
|
||||
case DONE_SERVER_ERROR:
|
||||
header('HTTP/1.0 500 Internal Server Error');
|
||||
break;
|
||||
default:
|
||||
header('HTTP/1.0 500 Internal Server Error');
|
||||
break;
|
||||
}
|
||||
header('Content-Type: application/json');
|
||||
if ($content !== null) {
|
||||
echo json_encode($content);
|
||||
} else {
|
||||
echo '{ }';
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['auth']['id'], $_REQUEST['auth']['hash'])) {
|
||||
$user_id = auth_check($mysqli, $_REQUEST['auth']['id'], $_REQUEST['auth']['hash']);
|
||||
} else {
|
||||
$user_id = false;
|
||||
}
|
||||
|
||||
function isLoggedIn() {
|
||||
global $user_id;
|
||||
return $user_id !== false;
|
||||
}
|
||||
|
||||
function checkLoggedIn() {
|
||||
if (!isLoggedIn()) done(DONE_UNAUTHORIZED, ['error' => 'permission denied']);
|
||||
}
|
||||
|
||||
function checkRequest($param) {
|
||||
if (!isset($_REQUEST[$param])) done(DONE_BAD_REQUEST, ['error' => 'missing parameter: ' . $param]);
|
||||
}
|
||||
|
||||
function replaceChanged($array) {
|
||||
return array_map(function ($entry) {
|
||||
unset($entry['changed']);
|
||||
return $entry;
|
||||
}, $array);
|
||||
}
|
||||
|
||||
$whereString = false;
|
||||
if (isset($_REQUEST['index'], $_REQUEST['value'])) {
|
||||
$whereString = '`' . mysqli_real_escape_string($mysqli, $_REQUEST['index']) . '`="' . mysqli_real_escape_string($mysqli, $_REQUEST['value']) . '"';
|
||||
}
|
||||
|
||||
function sendEntries($table) {
|
||||
global $mysqli, $whereString;
|
||||
$response = db_get_data($mysqli, $table, '*', $whereString);
|
||||
if ($response === false) done(DONE_DATABASE);
|
||||
$keys = array_keys($response);
|
||||
if (isset($_REQUEST['changed-after'])) {
|
||||
$response = db_get_data($mysqli, $table, '*', '`changed` > "' . mysqli_real_escape_string($mysqli, date('Y-m-d H:i:s', $_REQUEST['changed-after'])) . '"' . ($whereString ? (' AND ' . $whereString) : ''));
|
||||
if ($response === false) done(DONE_DATABASE);
|
||||
}
|
||||
$response = array_values($response);
|
||||
done(DONE_OKAY, array('data' => replaceChanged($response), 'keys' => $keys));
|
||||
}
|
||||
|
||||
function sendEntry($table) {
|
||||
global $mysqli;
|
||||
checkRequest('id');
|
||||
$response = db_get_data($mysqli, $table, '*', '`id` = "' . mysqli_real_escape_string($mysqli, $_REQUEST['id']) . '"');
|
||||
if ($response === false) done(DONE_DATABASE);
|
||||
if (count($response) != 1) done(DONE_BAD_REQUEST, ['error' => 'id not found']);
|
||||
$response = array_values($response)[0];
|
||||
unset($response['changed']);
|
||||
done(DONE_OKAY, ['data' => $response]);
|
||||
}
|
||||
|
||||
switch ($action) {
|
||||
|
||||
case 'login':
|
||||
checkRequest('username');
|
||||
checkRequest('password');
|
||||
checkRequest('device');
|
||||
$auth = auth_login($mysqli, $_REQUEST['username'], $_REQUEST['password'], $_REQUEST['device']);
|
||||
if ($auth === false) done(DONE_UNAUTHORIZED);
|
||||
done(DONE_OKAY, $auth);
|
||||
break;
|
||||
|
||||
case 'logout':
|
||||
checkLoggedIn();
|
||||
auth_logout($mysqli, $_REQUEST['auth']['id']);
|
||||
done(DONE_OKAY);
|
||||
break;
|
||||
|
||||
case 'get_update_time':
|
||||
$times = array();
|
||||
$response = db_get_data($mysqli, DB_TABLE_UPDATETIMES, '`update`', '`table` = "' . DB_TABLE_CLUBS . '"', 1);
|
||||
if (($response !== false) and (count($response) > 0)) {
|
||||
$times['clubs'] = strtotime(array_values($response)[0]['update']);
|
||||
} else {
|
||||
done(DONE_DATABASE);
|
||||
}
|
||||
$response = db_get_data($mysqli, DB_TABLE_UPDATETIMES, '`update`', '`table` = "' . BOATCLASS . DB_TABLE_SUFFIX_BOATS . '"', 1);
|
||||
if (($response !== false) and (count($response) > 0)) {
|
||||
$times['boats'] = strtotime(array_values($response)[0]['update']);
|
||||
} else {
|
||||
done(DONE_DATABASE);
|
||||
}
|
||||
$response = db_get_data($mysqli, DB_TABLE_UPDATETIMES, '`update`', '`table` = "' . BOATCLASS . DB_TABLE_SUFFIX_SAILORS . '"', 1);
|
||||
if (($response !== false) and (count($response) > 0)) {
|
||||
$times['sailors'] = strtotime(array_values($response)[0]['update']);
|
||||
} else {
|
||||
done(DONE_DATABASE);
|
||||
}
|
||||
$response = db_get_data($mysqli, DB_TABLE_UPDATETIMES, '`update`', '`table` = "' . BOATCLASS . DB_TABLE_SUFFIX_REGATTAS . '"', 1);
|
||||
if (($response !== false) and (count($response) > 0)) {
|
||||
$times['regattas'] = strtotime(array_values($response)[0]['update']);
|
||||
} else {
|
||||
done(DONE_DATABASE);
|
||||
}
|
||||
$response = db_get_data($mysqli, DB_TABLE_UPDATETIMES, '`update`', '`table` = "' . BOATCLASS . DB_TABLE_SUFFIX_RESULTS . '"', 1);
|
||||
if (($response !== false) and (count($response) > 0)) {
|
||||
$times['results'] = strtotime(array_values($response)[0]['update']);
|
||||
} else {
|
||||
done(DONE_DATABASE);
|
||||
}
|
||||
$response = db_get_data($mysqli, DB_TABLE_UPDATETIMES, '`update`', '`table` = "' . BOATCLASS . DB_TABLE_SUFFIX_PLANNING . '"', 1);
|
||||
if (($response !== false) and (count($response) > 0)) {
|
||||
$times['plannings'] = strtotime(array_values($response)[0]['update']);
|
||||
} else {
|
||||
done(DONE_DATABASE);
|
||||
}
|
||||
$response = db_get_data($mysqli, DB_TABLE_UPDATETIMES, '`update`', '`table` = "' . DB_TABLE_TRIM_BOATS . '"', 1);
|
||||
if (($response !== false) and (count($response) > 0)) {
|
||||
$times['trim_boats'] = strtotime(array_values($response)[0]['update']);
|
||||
} else {
|
||||
done(DONE_DATABASE);
|
||||
}
|
||||
$response = db_get_data($mysqli, DB_TABLE_UPDATETIMES, '`update`', '`table` = "' . DB_TABLE_TRIM_USERS . '"', 1);
|
||||
if (($response !== false) and (count($response) > 0)) {
|
||||
$times['trim_users'] = strtotime(array_values($response)[0]['update']);
|
||||
} else {
|
||||
done(DONE_DATABASE);
|
||||
}
|
||||
$response = db_get_data($mysqli, DB_TABLE_UPDATETIMES, '`update`', '`table` = "' . DB_TABLE_TRIM_TRIMS . '"', 1);
|
||||
if (($response !== false) and (count($response) > 0)) {
|
||||
$times['trim_trims'] = strtotime(array_values($response)[0]['update']);
|
||||
} else {
|
||||
done(DONE_DATABASE);
|
||||
}
|
||||
$response = db_get_data($mysqli, DB_TABLE_UPDATETIMES, '`update`', '`table` = "' . DB_TABLE_USERS . '"', 1);
|
||||
if (($response !== false) and (count($response) > 0)) {
|
||||
$times['users'] = strtotime(array_values($response)[0]['update']);
|
||||
} else {
|
||||
done(DONE_DATABASE);
|
||||
}
|
||||
done(DONE_OKAY, $times);
|
||||
break;
|
||||
|
||||
case 'get_clubs':
|
||||
sendEntries(DB_TABLE_CLUBS);
|
||||
break;
|
||||
|
||||
case 'get_club':
|
||||
sendEntry(DB_TABLE_CLUBS);
|
||||
break;
|
||||
|
||||
case 'get_boats':
|
||||
sendEntries(BOATCLASS . DB_TABLE_SUFFIX_BOATS);
|
||||
break;
|
||||
|
||||
case 'get_boat':
|
||||
sendEntry(BOATCLASS . DB_TABLE_SUFFIX_BOATS);
|
||||
break;
|
||||
|
||||
case 'get_sailors':
|
||||
sendEntries(BOATCLASS . DB_TABLE_SUFFIX_SAILORS);
|
||||
break;
|
||||
|
||||
case 'get_sailor':
|
||||
sendEntry(BOATCLASS . DB_TABLE_SUFFIX_SAILORS);
|
||||
break;
|
||||
|
||||
case 'get_years':
|
||||
$response = get_regatta_years($mysqli);
|
||||
if ($response === false) done(DONE_DATABASE);
|
||||
foreach ($response as $key => $value)
|
||||
$response[$key] = ['year' => $value];
|
||||
done(DONE_OKAY, ['data' => $response]);
|
||||
break;
|
||||
|
||||
case 'get_regattas':
|
||||
sendEntries(BOATCLASS . DB_TABLE_SUFFIX_REGATTAS);
|
||||
break;
|
||||
|
||||
case 'get_regatta':
|
||||
sendEntry(BOATCLASS . DB_TABLE_SUFFIX_REGATTAS);
|
||||
break;
|
||||
|
||||
case 'get_results':
|
||||
sendEntries(BOATCLASS . DB_TABLE_SUFFIX_RESULTS);
|
||||
break;
|
||||
|
||||
case 'get_result':
|
||||
sendEntry(BOATCLASS . DB_TABLE_SUFFIX_RESULTS);
|
||||
break;
|
||||
|
||||
case 'get_plannings':
|
||||
$response = db_get_data($mysqli, BOATCLASS . DB_TABLE_SUFFIX_PLANNING, '*', $whereString);
|
||||
if ($response === false) done(DONE_DATABASE);
|
||||
$keys = array_keys($response);
|
||||
if (isset($_REQUEST['changed-after'])) {
|
||||
$response = db_get_data($mysqli, BOATCLASS . DB_TABLE_SUFFIX_PLANNING, '*', '`changed` > "' . mysqli_real_escape_string($mysqli, date('Y-m-d H:i:s', $_REQUEST['changed-after'])) . '"' . ($whereString ? (' AND ' . $whereString) : ''));
|
||||
if ($response === false) done(DONE_DATABASE);
|
||||
}
|
||||
$response = array_map(function ($entry) {
|
||||
global $user_id;
|
||||
if (($user_id === false) or ($entry['user'] != $user_id)) {
|
||||
unset($entry['gemeldet'], $entry['bezahlt']);
|
||||
}
|
||||
return $entry;
|
||||
}, $response);
|
||||
$response = array_values($response);
|
||||
done(DONE_OKAY, array('data' => replaceChanged($response), 'keys' => $keys));
|
||||
break;
|
||||
|
||||
case 'get_planning':
|
||||
checkRequest('id');
|
||||
$response = db_get_data($mysqli, BOATCLASS . DB_TABLE_SUFFIX_PLANNING, '*', '`id` = "' . mysqli_real_escape_string($mysqli, $_REQUEST['id']) . '"');
|
||||
if ($response === false) done(DONE_DATABASE);
|
||||
if (count($response) != 1) done(DONE_BAD_REQUEST, ['error' => 'id not found']);
|
||||
$response = array_values($response)[0];
|
||||
if (($user_id === false) or ($response['user'] != $user_id)) {
|
||||
unset($response['gemeldet'], $response['bezahlt']);
|
||||
}
|
||||
unset($response['changed']);
|
||||
done(DONE_OKAY, ['data' => $response]);
|
||||
break;
|
||||
|
||||
case 'get_trim_boats':
|
||||
checkLoggedIn();
|
||||
$users = db_get_data($mysqli, DB_TABLE_TRIM_USERS, 'boat', '`user`="' . $user_id . '"');
|
||||
$boats = implode(',', array_column($users, 'boat'));
|
||||
if ($boats == '') {
|
||||
done(DONE_OKAY, array('data' => [], 'keys' => []));
|
||||
}
|
||||
$response = db_get_data($mysqli, DB_TABLE_TRIM_BOATS, '*', '`id` IN (' . $boats . ')' . ($whereString ? (' AND ' . $whereString) : ''));
|
||||
if ($response === false) done(DONE_DATABASE);
|
||||
$keys = array_keys($response);
|
||||
if (isset($_REQUEST['changed-after'])) {
|
||||
$response = db_get_data($mysqli, DB_TABLE_TRIM_BOATS, '*', '`id` IN (' . $boats . ') AND `changed` > "' . mysqli_real_escape_string($mysqli, date('Y-m-d H:i:s', $_REQUEST['changed-after'])) . '"' . ($whereString ? (' AND ' . $whereString) : ''));
|
||||
if ($response === false) done(DONE_DATABASE);
|
||||
}
|
||||
$response = array_values($response);
|
||||
done(DONE_OKAY, array('data' => replaceChanged($response), 'keys' => $keys));
|
||||
break;
|
||||
|
||||
case 'get_trim_boat':
|
||||
checkLoggedIn();
|
||||
checkRequest('id');
|
||||
$response = db_get_data($mysqli, DB_TABLE_TRIM_BOATS, '*', '`id` = "' . mysqli_real_escape_string($mysqli, $_REQUEST['id']) . '"');
|
||||
if ($response === false) done(DONE_DATABASE);
|
||||
if (count($response) != 1) done(DONE_BAD_REQUEST, ['error' => 'id not found']);
|
||||
$response = array_values($response)[0];
|
||||
if (count(db_get_data($mysqli, DB_TABLE_TRIM_USERS, 'id', '`user`="' . $user_id . '" AND `boat`="' . $response['id'] . '"')) != 1)
|
||||
done(DONE_BAD_REQUEST, ['error' => 'id not found']);
|
||||
unset($response['changed']);
|
||||
done(DONE_OKAY, ['data' => $response]);
|
||||
break;
|
||||
|
||||
case 'get_trim_users':
|
||||
checkLoggedIn();
|
||||
$users = db_get_data($mysqli, DB_TABLE_TRIM_USERS, 'boat', '`user`="' . $user_id . '"');
|
||||
$boats = implode(',', array_column($users, 'boat'));
|
||||
if ($boats == '') {
|
||||
done(DONE_OKAY, array('data' => [], 'keys' => []));
|
||||
}
|
||||
$response = db_get_data($mysqli, DB_TABLE_TRIM_USERS, '*', '`boat` IN (' . $boats . ')' . ($whereString ? (' AND ' . $whereString) : ''));
|
||||
if ($response === false) done(DONE_DATABASE);
|
||||
$keys = array_keys($response);
|
||||
if (isset($_REQUEST['changed-after'])) {
|
||||
$response = db_get_data($mysqli, DB_TABLE_TRIM_USERS, '*', '`boat` IN (' . $boats . ') AND `changed` > "' . mysqli_real_escape_string($mysqli, date('Y-m-d H:i:s', $_REQUEST['changed-after'])) . '"' . ($whereString ? (' AND ' . $whereString) : ''));
|
||||
if ($response === false) done(DONE_DATABASE);
|
||||
}
|
||||
$response = array_values($response);
|
||||
done(DONE_OKAY, array('data' => replaceChanged($response), 'keys' => $keys));
|
||||
break;
|
||||
|
||||
case 'get_trim_user':
|
||||
checkLoggedIn();
|
||||
checkRequest('id');
|
||||
$response = db_get_data($mysqli, DB_TABLE_TRIM_USERS, '*', '`id` = "' . mysqli_real_escape_string($mysqli, $_REQUEST['id']) . '"');
|
||||
if ($response === false) done(DONE_DATABASE);
|
||||
if (count($response) != 1) done(DONE_BAD_REQUEST, ['error' => 'id not found']);
|
||||
$response = array_values($response)[0];
|
||||
if (count(db_get_data($mysqli, DB_TABLE_TRIM_USERS, 'id', '`user`="' . $user_id . '" AND `boat`="' . $response['boat'] . '"')) != 1)
|
||||
done(DONE_BAD_REQUEST, ['error' => 'id not found']);
|
||||
unset($response['changed']);
|
||||
done(DONE_OKAY, ['data' => $response]);
|
||||
break;
|
||||
|
||||
case 'get_trim_trims':
|
||||
checkLoggedIn();
|
||||
$users = db_get_data($mysqli, DB_TABLE_TRIM_USERS, 'boat', '`user`="' . $user_id . '"');
|
||||
$boats = implode(',', array_column($users, 'boat'));
|
||||
if ($boats == '') {
|
||||
done(DONE_OKAY, array('data' => [], 'keys' => []));
|
||||
}
|
||||
$response = db_get_data($mysqli, DB_TABLE_TRIM_TRIMS, '*', '`boat` IN (' . $boats . ')' . ($whereString ? (' AND ' . $whereString) : ''));
|
||||
if ($response === false) done(DONE_DATABASE);
|
||||
$keys = array_keys($response);
|
||||
if (isset($_REQUEST['changed-after'])) {
|
||||
$response = db_get_data($mysqli, DB_TABLE_TRIM_TRIMS, '*', '`boat` IN (' . $boats . ') AND `changed` > "' . mysqli_real_escape_string($mysqli, date('Y-m-d H:i:s', $_REQUEST['changed-after'])) . '"' . ($whereString ? (' AND ' . $whereString) : ''));
|
||||
if ($response === false) done(DONE_DATABASE);
|
||||
}
|
||||
$response = array_values($response);
|
||||
done(DONE_OKAY, array('data' => replaceChanged($response), 'keys' => $keys));
|
||||
break;
|
||||
|
||||
case 'get_trim_trim':
|
||||
checkLoggedIn();
|
||||
checkRequest('id');
|
||||
$response = db_get_data($mysqli, DB_TABLE_TRIM_TRIMS, '*', '`id` = "' . mysqli_real_escape_string($mysqli, $_REQUEST['id']) . '"');
|
||||
if ($response === false) done(DONE_DATABASE);
|
||||
if (count($response) != 1) done(DONE_BAD_REQUEST, ['error' => 'id not found']);
|
||||
$response = array_values($response)[0];
|
||||
if (count(db_get_data($mysqli, DB_TABLE_TRIM_USERS, 'id', '`user`="' . $user_id . '" AND `boat`="' . $response['boat'] . '"')) != 1)
|
||||
done(DONE_BAD_REQUEST, ['error' => 'id not found']);
|
||||
unset($response['changed']);
|
||||
done(DONE_OKAY, ['data' => $response]);
|
||||
break;
|
||||
|
||||
case 'get_users':
|
||||
$followFields = '';
|
||||
for ($i = 1; $i <= 5; $i ++) $followFields .= ',' . BOATCLASS . '_sailor' . $i . ' AS sailor' . $i;
|
||||
$response = db_get_data($mysqli, DB_TABLE_USERS, 'id,username,email' . $followFields, $whereString);
|
||||
if ($response === false) done(DONE_DATABASE);
|
||||
$keys = array_keys($response);
|
||||
if (isset($_REQUEST['changed-after'])) {
|
||||
$response = db_get_data($mysqli, DB_TABLE_USERS, 'id,username,email,' . $followFields, '`changed` > "' . mysqli_real_escape_string($mysqli, date('Y-m-d H:i:s', $_REQUEST['changed-after'])) . '"' . ($whereString ? (' AND ' . $whereString) : ''));
|
||||
if ($response === false) done(DONE_DATABASE);
|
||||
}
|
||||
$response = array_map(function ($entry) {
|
||||
global $user_id;
|
||||
if ($entry['id'] != $user_id) {
|
||||
$entry = ['id' => $entry['id'], 'username' => $entry['username']];
|
||||
}
|
||||
return $entry;
|
||||
}, $response);
|
||||
$response = array_values($response);
|
||||
done(DONE_OKAY, array('data' => replaceChanged($response), 'keys' => $keys));
|
||||
break;
|
||||
|
||||
case 'get_user':
|
||||
checkRequest('id');
|
||||
$followFields = '';
|
||||
for ($i = 1; $i <= 5; $i ++) $followFields .= ',' . BOATCLASS . '_sailor' . $i . ' AS sailor' . $i;
|
||||
$response = db_get_data($mysqli, DB_TABLE_USERS, 'id,username,email' . $followFields, '`id` = "' . mysqli_real_escape_string($mysqli, $_REQUEST['id']) . '"');
|
||||
if ($response === false) done(DONE_DATABASE);
|
||||
if (count($response) != 1) done(DONE_BAD_REQUEST, ['error' => 'id not found']);
|
||||
$response = array_values($response)[0];
|
||||
if ($response['id'] != $user_id) {
|
||||
$response = ['id' => $response['id'], 'username' => $response['username']];
|
||||
}
|
||||
unset($response['changed']);
|
||||
done(DONE_OKAY, ['data' => $response]);
|
||||
break;
|
||||
|
||||
case 'add_subscription':
|
||||
checkRequest('subscription');
|
||||
$data = [
|
||||
'auth' => PUSH_AUTH,
|
||||
'subscription' => $_REQUEST['subscription']
|
||||
];
|
||||
$ch = curl_init('https://push.ostertun.net/add_subscription');
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
$result = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
if ($result == "OK")
|
||||
done(DONE_OKAY);
|
||||
else {
|
||||
logE('add_subscription', $result);
|
||||
done(DONE_SERVER_ERROR);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'remove_subscription':
|
||||
checkRequest('subscription');
|
||||
$data = [
|
||||
'auth' => PUSH_AUTH,
|
||||
'subscription' => $_REQUEST['subscription']
|
||||
];
|
||||
$ch = curl_init('https://push.ostertun.net/remove_subscription');
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
$result = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
if ($result == "OK")
|
||||
done(DONE_OKAY);
|
||||
else {
|
||||
logE('remove_subscription', $result);
|
||||
done(DONE_SERVER_ERROR);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
done(DONE_BAD_REQUEST, ['error' => 'action invalid']);
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
107
api/login.php
107
api/login.php
@@ -1,107 +0,0 @@
|
||||
<?php
|
||||
|
||||
function get_user($mysqli, $username = null) {
|
||||
if ($username === null) {
|
||||
return db_get_data($mysqli, DB_TABLE_USERS);
|
||||
} else {
|
||||
$user = db_get_data($mysqli, DB_TABLE_USERS, '*', '`username` = "' . mysqli_real_escape_string($mysqli, $username) . '"', 1);
|
||||
if (($user === false) or (count($user) != 1)) return false;
|
||||
return array_values($user)[0];
|
||||
}
|
||||
}
|
||||
|
||||
function get_user_by_id($mysqli, $user_id) {
|
||||
$res = db_get_data($mysqli, DB_TABLE_USERS, '*', '`id` = "' . mysqli_real_escape_string($mysqli, $user_id) . '"', 1);
|
||||
if (($res !== false) and (count($res) == 1)) {
|
||||
return array_values($res)[0];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//function signup($mysqli, $username, $email, $password) {
|
||||
// if (($username == '') or ($email == '') or ($password == '')) {
|
||||
// return 1;
|
||||
// }
|
||||
// if (get_user($mysqli, $username) !== false) {
|
||||
// return 1;
|
||||
// }
|
||||
// $salt = hash('sha512', uniqid(openssl_random_pseudo_bytes(16), true));
|
||||
// $hashpassword = hash('sha512', $password . $salt);
|
||||
//
|
||||
// $user = array();
|
||||
// $user['username'] = $username;
|
||||
// $user['email'] = $email;
|
||||
// $user['password'] = $hashpassword;
|
||||
// $user['salt'] = $salt;
|
||||
// if (db_insert_data($mysqli, DB_TABLE_USERS, $user) !== false) {
|
||||
// $values = array();
|
||||
// $values['USERNAME'] = $username;
|
||||
// $message = createMail('signup', STRING_SIGNUP_EMAIL_SUBJECT, $values);
|
||||
// smtp_send_mail(['Regatten.net', MAIL_FROM_ADDRESS], [[$username, $email]], [], [], STRING_SIGNUP_EMAIL_SUBJECT, $message, [['Content-Type', 'text/html; charset="UTF-8"']]);
|
||||
// // Analytics
|
||||
// matomo_event('Login', 'SignUp', $username);
|
||||
// return true;
|
||||
// } else {
|
||||
// return 2;
|
||||
// }
|
||||
//}
|
||||
|
||||
function get_perm($mysqli, $user_id) {
|
||||
if ($user_id !== false) {
|
||||
$result = get_user_by_id($mysqli, $user_id);
|
||||
if ($result !== false) {
|
||||
return $result[DB_FIELD_PERM];
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// ### NEW LOGIN ####################################
|
||||
|
||||
function auth_login($mysqli, $username, $password, $device) {
|
||||
$user = get_user($mysqli, $username);
|
||||
if ($user === false) {
|
||||
// User does not exist
|
||||
return false;
|
||||
}
|
||||
$hashpassword = hash('sha512', $password . $user['salt']);
|
||||
if ($hashpassword !== $user['password']) {
|
||||
// Password incorrect
|
||||
return false;
|
||||
}
|
||||
// All correct
|
||||
$auth = [];
|
||||
$auth['user'] = $user['id'];
|
||||
$auth['username'] = $user['username'];
|
||||
$auth['auth'] = str_replace('/', '-', str_replace('+', '_', base64_encode(openssl_random_pseudo_bytes(24))));
|
||||
$salt = base64_encode(openssl_random_pseudo_bytes(24));
|
||||
$hash = hash('sha512', $auth['auth'] . $salt);
|
||||
$data = [
|
||||
'user' => $user['id'],
|
||||
'salt' => $salt,
|
||||
'authhash' => $hash,
|
||||
'device' => $device
|
||||
];
|
||||
$auth['id'] = db_insert_data($mysqli, DB_TABLE_LOGINS, $data);
|
||||
return $auth;
|
||||
}
|
||||
|
||||
function auth_logout($mysqli, $id) {
|
||||
db_delete_data($mysqli, DB_TABLE_LOGINS, 'id = "' . mysqli_real_escape_string($mysqli, $id) . '"', 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
function auth_check($mysqli, $id, $hash) {
|
||||
$auth = db_get_data($mysqli, DB_TABLE_LOGINS, '*', 'id="' . mysqli_real_escape_string($mysqli, $id) . '"', 1);
|
||||
if (($auth === false) or (count($auth) != 1)) return false;
|
||||
$auth = array_values($auth)[0];
|
||||
$hash = hash('sha512', $hash . $auth['salt']);
|
||||
if ($hash != $auth['authhash']) return false;
|
||||
db_update_data($mysqli, DB_TABLE_LOGINS, ['id' => $auth['id']], 'id="' . $auth['id'] . '"', 1); // update changed field => last login
|
||||
return $auth['user'];
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -188,7 +188,7 @@ $(document).ready(function(){
|
||||
});
|
||||
|
||||
//Generating Cookies
|
||||
function createCookie(e, t, n) {if (n) {var o = new Date;o.setTime(o.getTime() + 48 * n * 60 * 3600 * 1e3);var r = "; expires=" + o.toGMTString()} else var r = "";document.cookie = e + "=" + t + r + "; path=/"}
|
||||
function createCookie(e, t, n) {if (n) {var o = new Date;o.setTime(o.getTime() + n * 365 * 24 * 3600 * 1e3);var r = "; expires=" + o.toGMTString()} else var r = "";document.cookie = e + "=" + t + r + "; path=/"}
|
||||
function readCookie(e) {for (var t = e + "=", n = document.cookie.split(";"), o = 0; o < n.length; o++) {for (var r = n[o];" " == r.charAt(0);) r = r.substring(1, r.length);if (0 == r.indexOf(t)) return r.substring(t.length, r.length)}return null}
|
||||
function eraseCookie(e) {createCookie(e, "", -1)}
|
||||
|
||||
@@ -215,8 +215,8 @@ $(document).ready(function(){
|
||||
}
|
||||
},150);
|
||||
})
|
||||
if (readCookie('sticky_dark_mode')) {darkSwitch.prop('checked', true); $('body').removeClass('detect-theme').removeClass('theme-light').addClass('theme-dark');}
|
||||
if (readCookie('sticky_light_mode')) {darkSwitch.prop('checked', false); $('body').removeClass('detect-theme').removeClass('theme-dark').addClass('theme-light');}
|
||||
if (readCookie('sticky_dark_mode')) {createCookie('sticky_dark_mode', true, 1); darkSwitch.prop('checked', true); $('body').removeClass('detect-theme').removeClass('theme-light').addClass('theme-dark');}
|
||||
if (readCookie('sticky_light_mode')) {createCookie('sticky_light_mode', true, 1); darkSwitch.prop('checked', false); $('body').removeClass('detect-theme').removeClass('theme-dark').addClass('theme-light');}
|
||||
|
||||
|
||||
//Auto Dark Mode
|
||||
@@ -1331,6 +1331,20 @@ $(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%)}')});
|
||||
}
|
||||
|
||||
function welcomeOk() {
|
||||
createCookie('sticky_welcome_banner', true, 1);
|
||||
$('#menu-welcome').hideMenu();
|
||||
$('.menu-hider').removeClass('no-click');
|
||||
}
|
||||
function showWelcome() {
|
||||
if (!readCookie('sticky_welcome_banner')) {
|
||||
$('.menu-hider').addClass('no-click');
|
||||
$('#menu-welcome').showMenu();
|
||||
}
|
||||
}
|
||||
$('#menu-welcome-a-okay').click(welcomeOk);
|
||||
showWelcome();
|
||||
|
||||
initRegatten();
|
||||
|
||||
hideLoader();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const DB_VERSION = 3;
|
||||
const DB_VERSION = 4;
|
||||
|
||||
const USER_ID = localStorage.getItem('auth_user');
|
||||
const USER_NAME = localStorage.getItem('auth_username');
|
||||
@@ -256,6 +256,147 @@ function dbGetResultCalculated(regatta) {
|
||||
});
|
||||
}
|
||||
|
||||
function dbGetRanking(minDate, maxDate, jugend, jugstrict) {
|
||||
return new Promise(async function(resolve) {
|
||||
var rankNoResults = [];
|
||||
|
||||
var sailors = await dbGetData('sailors');
|
||||
var regattas = await dbGetRegattasRange(minDate, maxDate);
|
||||
|
||||
var sailorIds = {};
|
||||
for (s in sailors) {
|
||||
sailorIds[sailors[s].id] = s;
|
||||
}
|
||||
|
||||
for (var i in sailors) {
|
||||
sailors[i].regattas = {};
|
||||
sailors[i].tmp_rlp = [];
|
||||
}
|
||||
|
||||
for (var i in regattas) {
|
||||
var regatta = regattas[i];
|
||||
|
||||
// regatta has to be min. 2 days to be ranking regatta
|
||||
if (regatta.length < 2) continue;
|
||||
|
||||
var results = await dbGetDataIndex('results', 'regatta', regatta.id);
|
||||
if (results.length <= 0) {
|
||||
if (regatta.dateTo <= getToday()) {
|
||||
if (regatta.canceled == '0') {
|
||||
rankNoResults.push(regatta);
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// in one race there must be at least 10 boats started
|
||||
var ok = false;
|
||||
for (var j = 1; j <= regatta.races; j ++) {
|
||||
var temp = 0;
|
||||
for (var r in results) {
|
||||
if ((results[r]['race' + j] != 'DNC') && (results[r]['race' + j] != 'DNS')) {
|
||||
temp ++;
|
||||
}
|
||||
}
|
||||
if (temp >= 10) {
|
||||
ok = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!ok) continue;
|
||||
|
||||
var fb = regatta.finishedBoats;
|
||||
|
||||
// calc m
|
||||
var m;
|
||||
if (regatta.m > 0) {
|
||||
m = regatta.m;
|
||||
} else if (regatta.races <= 4) {
|
||||
m = regatta.races;
|
||||
} else {
|
||||
if ((regatta.length > 2) && (regatta.races >= 6)) {
|
||||
m = 5;
|
||||
} else {
|
||||
m = 4;
|
||||
}
|
||||
}
|
||||
|
||||
// add regatta to each sailor
|
||||
for (var r in results) {
|
||||
var result = results[r];
|
||||
|
||||
if (result.rlp == 0) continue;
|
||||
|
||||
// check if crew is youth
|
||||
// TODO: not used
|
||||
|
||||
sailors[sailorIds[result.steuermann]].regattas[regatta.id] = {
|
||||
regatta: regatta.id,
|
||||
boat: result.boat,
|
||||
crew: result.crew,
|
||||
place: result.place,
|
||||
fb: fb,
|
||||
rlp: result.rlp,
|
||||
used: 0,
|
||||
m: m
|
||||
};
|
||||
for (var j = 0; j < m; j ++) {
|
||||
sailors[sailorIds[result.steuermann]].tmp_rlp.push([regatta.id, result.rlp]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// remove not german or not youth sailors
|
||||
for (var i = sailors.length - 1; i >= 0; i --) {
|
||||
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))) ||
|
||||
((sailors[i].year == null) && (jugstrict))) {
|
||||
sailors.splice(i, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = sailors.length - 1; i >= 0; i --) {
|
||||
// sort rlps desc
|
||||
sailors[i].tmp_rlp.sort(function (a,b) {
|
||||
return b[1] - a[1];
|
||||
});
|
||||
|
||||
// calc mean rlp
|
||||
var sum = 0;
|
||||
var cnt = 0;
|
||||
for (var t in sailors[i].tmp_rlp) {
|
||||
var r = sailors[i].tmp_rlp[t];
|
||||
sum += parseFloat(r[1]);
|
||||
sailors[i].regattas[r[0]].used ++;
|
||||
cnt ++;
|
||||
if (cnt >= 9) break;
|
||||
}
|
||||
delete sailors[i].tmp_rlp;
|
||||
if (cnt > 0) {
|
||||
var rlp = sum / cnt;
|
||||
sailors[i].rlp = rlp;
|
||||
sailors[i].m = cnt;
|
||||
} else {
|
||||
sailors.splice(i, 1);
|
||||
}
|
||||
}
|
||||
|
||||
sailors.sort(function (a,b) {
|
||||
if (a.m != b.m) return b.m - a.m;
|
||||
return b.rlp - a.rlp;
|
||||
});
|
||||
|
||||
for (var i = 0; i < sailors.length; i ++) {
|
||||
sailors[i].rank = (i + 1);
|
||||
}
|
||||
|
||||
resolve([sailors, rankNoResults]);
|
||||
});
|
||||
}
|
||||
|
||||
async function updateSyncStatus() { // TODO
|
||||
// var syncStatus = document.getElementById('syncstatus');
|
||||
// var lastSync = await dbGetData('update_times', 'last_sync');
|
||||
@@ -283,6 +424,14 @@ async function updateSyncStatus() { // TODO
|
||||
|
||||
async function runPageScript() {
|
||||
if (canUseLocalDB) {
|
||||
var osUpdateTimes = db.transaction('update_times').objectStore('update_times');
|
||||
osUpdateTimes.get('loggedin').onsuccess = function (event) {
|
||||
var status = event.target.result.status;
|
||||
if (status != isLoggedIn()) {
|
||||
resetDb();
|
||||
location.reload();
|
||||
}
|
||||
};
|
||||
updateSyncStatus();
|
||||
}
|
||||
if (typeof updateSyncStatusTimer == 'undefined') { // TODO
|
||||
@@ -291,6 +440,7 @@ async function runPageScript() {
|
||||
updateSyncStatusTimer = window.setInterval(updateSyncStatus, 10000);
|
||||
} else {
|
||||
// syncStatus.innerHTML = 'Keine Offline-Nutzung möglich.';
|
||||
$('#i-sync').parent().hide();
|
||||
updateSyncStatusTimer = null;
|
||||
}
|
||||
// syncStatus.style.display = 'block';
|
||||
@@ -341,7 +491,7 @@ function sync() {
|
||||
|
||||
// CLUBS
|
||||
if (localTimes['clubs'] < serverTimes['clubs']) {
|
||||
getJSON(QUERY_URL + 'get_clubs?changer-after=' + localTimes['clubs'], function (code, data) {
|
||||
getJSON(QUERY_URL + 'get_clubs?changed-after=' + localTimes['clubs'], function (code, data) {
|
||||
if (code == 200) {
|
||||
var os = db.transaction('clubs', 'readwrite').objectStore('clubs');
|
||||
console.log(data);
|
||||
@@ -373,7 +523,7 @@ function sync() {
|
||||
|
||||
// BOATS
|
||||
if (localTimes['boats'] < serverTimes['boats']) {
|
||||
getJSON(QUERY_URL + 'get_boats?changer-after=' + localTimes['boats'], function (code, data) {
|
||||
getJSON(QUERY_URL + 'get_boats?changed-after=' + localTimes['boats'], function (code, data) {
|
||||
if (code == 200) {
|
||||
var os = db.transaction('boats', 'readwrite').objectStore('boats');
|
||||
console.log(data);
|
||||
@@ -405,7 +555,7 @@ function sync() {
|
||||
|
||||
// SAILORS
|
||||
if (localTimes['sailors'] < serverTimes['sailors']) {
|
||||
getJSON(QUERY_URL + 'get_sailors?changer-after=' + localTimes['sailors'], function (code, data) {
|
||||
getJSON(QUERY_URL + 'get_sailors?changed-after=' + localTimes['sailors'], function (code, data) {
|
||||
if (code == 200) {
|
||||
var os = db.transaction('sailors', 'readwrite').objectStore('sailors');
|
||||
console.log(data);
|
||||
@@ -437,7 +587,7 @@ function sync() {
|
||||
|
||||
// REGATTAS
|
||||
if (localTimes['regattas'] < serverTimes['regattas']) {
|
||||
getJSON(QUERY_URL + 'get_regattas?changer-after=' + localTimes['regattas'], function (code, data) {
|
||||
getJSON(QUERY_URL + 'get_regattas?changed-after=' + localTimes['regattas'], function (code, data) {
|
||||
if (code == 200) {
|
||||
var os = db.transaction('regattas', 'readwrite').objectStore('regattas');
|
||||
console.log(data);
|
||||
@@ -485,7 +635,7 @@ function sync() {
|
||||
|
||||
// RESULTS
|
||||
if (localTimes['results'] < serverTimes['results']) {
|
||||
getJSON(QUERY_URL + 'get_results?changer-after=' + localTimes['results'], function (code, data) {
|
||||
getJSON(QUERY_URL + 'get_results?changed-after=' + localTimes['results'], function (code, data) {
|
||||
if (code == 200) {
|
||||
var os = db.transaction('results', 'readwrite').objectStore('results');
|
||||
console.log(data);
|
||||
@@ -517,7 +667,7 @@ function sync() {
|
||||
|
||||
// PLANNINGS
|
||||
if (localTimes['plannings'] < serverTimes['plannings']) {
|
||||
getJSON(QUERY_URL + 'get_plannings?changer-after=' + localTimes['plannings'], function (code, data) {
|
||||
getJSON(QUERY_URL + 'get_plannings?changed-after=' + localTimes['plannings'], function (code, data) {
|
||||
if (code == 200) {
|
||||
var os = db.transaction('plannings', 'readwrite').objectStore('plannings');
|
||||
console.log(data);
|
||||
@@ -550,7 +700,7 @@ function sync() {
|
||||
if (isLoggedIn()) {
|
||||
// TRIM_BOATS
|
||||
if (localTimes['trim_boats'] < serverTimes['trim_boats']) {
|
||||
getJSON(QUERY_URL + 'get_trim_boats?changer-after=' + localTimes['trim_boats'], function (code, data) {
|
||||
getJSON(QUERY_URL + 'get_trim_boats?changed-after=' + localTimes['trim_boats'], function (code, data) {
|
||||
if (code == 200) {
|
||||
var os = db.transaction('trim_boats', 'readwrite').objectStore('trim_boats');
|
||||
console.log(data);
|
||||
@@ -582,7 +732,7 @@ function sync() {
|
||||
|
||||
// TRIM_USERS
|
||||
if (localTimes['trim_users'] < serverTimes['trim_users']) {
|
||||
getJSON(QUERY_URL + 'get_trim_users?changer-after=' + localTimes['trim_users'], function (code, data) {
|
||||
getJSON(QUERY_URL + 'get_trim_users?changed-after=' + localTimes['trim_users'], function (code, data) {
|
||||
if (code == 200) {
|
||||
var os = db.transaction('trim_users', 'readwrite').objectStore('trim_users');
|
||||
console.log(data);
|
||||
@@ -614,7 +764,7 @@ function sync() {
|
||||
|
||||
// TRIM_TRIMS
|
||||
if (localTimes['trim_trims'] < serverTimes['trim_trims']) {
|
||||
getJSON(QUERY_URL + 'get_trim_trims?changer-after=' + localTimes['trim_trims'], function (code, data) {
|
||||
getJSON(QUERY_URL + 'get_trim_trims?changed-after=' + localTimes['trim_trims'], function (code, data) {
|
||||
if (code == 200) {
|
||||
var os = db.transaction('trim_trims', 'readwrite').objectStore('trim_trims');
|
||||
console.log(data);
|
||||
@@ -650,7 +800,7 @@ function sync() {
|
||||
|
||||
// USERS
|
||||
if (localTimes['users'] < serverTimes['users']) {
|
||||
getJSON(QUERY_URL + 'get_users?changer-after=' + localTimes['users'], function (code, data) {
|
||||
getJSON(QUERY_URL + 'get_users?changed-after=' + localTimes['users'], function (code, data) {
|
||||
if (code == 200) {
|
||||
var os = db.transaction('users', 'readwrite').objectStore('users');
|
||||
console.log(data);
|
||||
@@ -732,6 +882,8 @@ function initDatabase() {
|
||||
var lastSync = event.target.result.time;
|
||||
if (lastSync > 0) {
|
||||
runPageScript();
|
||||
} else {
|
||||
db.transaction('update_times', 'readwrite').objectStore('update_times').put({ table: 'loggedin', status: isLoggedIn() });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -795,6 +947,12 @@ function initDatabase() {
|
||||
osUpdateTimes.put({ table: 'regattas', time: 0 });
|
||||
}
|
||||
|
||||
if ((oldVersion < 4) && (newVersion >= 4)) {
|
||||
console.log('to version 4');
|
||||
var osUpdateTimes = upgradeTransaction.objectStore('update_times');
|
||||
osUpdateTimes.add({ table: 'loggedin', status: isLoggedIn() });
|
||||
}
|
||||
|
||||
var osUpdateTimes = upgradeTransaction.objectStore('update_times');
|
||||
osUpdateTimes.put({ table: 'last_sync', time: 0 });
|
||||
}
|
||||
@@ -802,3 +960,29 @@ function initDatabase() {
|
||||
runPageScript();
|
||||
}
|
||||
}
|
||||
|
||||
function resetDb(silent = true) {
|
||||
$('#menu-developer').hideMenu();
|
||||
if (canUseLocalDB) {
|
||||
showLoader();
|
||||
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
||||
osUpdateTimes.put({ table: 'last_sync', time: 0 });
|
||||
osUpdateTimes.put({ table: 'clubs', time: 0 });
|
||||
osUpdateTimes.put({ table: 'boats', time: 0 });
|
||||
osUpdateTimes.put({ table: 'sailors', time: 0 });
|
||||
osUpdateTimes.put({ table: 'regattas', time: 0 });
|
||||
osUpdateTimes.put({ table: 'results', time: 0 });
|
||||
osUpdateTimes.put({ table: 'plannings', time: 0 });
|
||||
osUpdateTimes.put({ table: 'trim_boats', time: 0 });
|
||||
osUpdateTimes.put({ table: 'trim_users', time: 0 });
|
||||
osUpdateTimes.put({ table: 'trim_trims', time: 0 });
|
||||
osUpdateTimes.put({ table: 'users', time: 0 });
|
||||
console.log('DB update times reset');
|
||||
if (!silent)
|
||||
toastInfo('The database was reset. Please reload or close this tab.<br>At the next visit, a full sync will be performed.');
|
||||
hideLoader();
|
||||
} else {
|
||||
if (!silent)
|
||||
toastWarn('Your device does not support storing data locally. All data is fetched directly from our server.<br>As a result, you can not reset your database.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ $(document).ready(function(){
|
||||
|
||||
|
||||
//Creating Cookie System for PWA Hide
|
||||
function createCookie(e, t, n) {if (n) {var o = new Date;o.setTime(o.getTime() + 48 * n * 60 * 60 * 1e3);var r = "; expires=" + o.toGMTString()} else var r = "";document.cookie = e + "=" + t + r + "; path=/"}
|
||||
function createCookie(e, t, n) {if (n) {var o = new Date;o.setTime(o.getTime() + n * 365 * 24 * 3600 * 1e3);var r = "; expires=" + o.toGMTString()} else var r = "";document.cookie = e + "=" + t + r + "; path=/"}
|
||||
function readCookie(e) {for (var t = e + "=", n = document.cookie.split(";"), o = 0; o < n.length; o++) {for (var r = n[o];" " == r.charAt(0);) r = r.substring(1, r.length);if (0 == r.indexOf(t)) return r.substring(t.length, r.length)}return null}
|
||||
function eraseCookie(e) {createCookie(e, "", -1)}
|
||||
|
||||
|
||||
@@ -6,9 +6,11 @@
|
||||
|
||||
?>
|
||||
|
||||
const QUERY_URL = '<?php echo SERVER_ADDR; ?>/api/';
|
||||
const QUERY_URL = '<?php echo QUERY_URL; ?>';
|
||||
const BOATCLASS = '<?php echo BOATCLASS; ?>';
|
||||
const LINK_PRE = '<?php echo SERVER_ADDR; ?>/';
|
||||
const YOUTH_AGE = '<?php echo $_CLASS['youth-age']; ?>';
|
||||
const YOUTH_GERMAN_NAME = '<?php echo $_CLASS['youth-german-name']; ?>';
|
||||
|
||||
var randomId = function() { return '_' + Math.random().toString(36).substr(2, 9); }
|
||||
|
||||
@@ -67,7 +69,7 @@ var updateBadge = function (name, val) {
|
||||
var makeToast = function (color, icon, text, time) {
|
||||
var id = 'snackbar' + randomId();
|
||||
var delay = (time > 0 ? 'data-delay="' + time + '" data-autohide="true"' : 'data-autohide="false"');
|
||||
var div = '<div id="' + id + '" class="snackbar-toast ' + color + '" ' + delay + '>';
|
||||
var div = '<div id="' + id + '" class="snackbar-toast pt-3 pb-3 ' + color + '" ' + delay + ' style="line-height: 2em;">';
|
||||
div += '<i class="fa ' + icon + ' mr-3"></i>' + text + '</div>';
|
||||
$('#page').append(div);
|
||||
$('#' + id).toast('show');
|
||||
@@ -200,26 +202,6 @@ var logout = function() {
|
||||
});
|
||||
}
|
||||
|
||||
function resetDb() {
|
||||
$('#menu-developer').hideMenu();
|
||||
if (canUseLocalDB) {
|
||||
showLoader();
|
||||
var request = window.indexedDB.deleteDatabase('regatten_app_db_' + BOATCLASS);
|
||||
request.onerror = function (event) {
|
||||
console.log("Cannot open DB: " + event.target.errorCode);
|
||||
toastError('There was an error deleting your database.<br>Please report this to <a href="mailto:dev@regatten.net">dev@regatten.net</a>');
|
||||
hideLoader();
|
||||
};
|
||||
request.onsuccess = function (event) {
|
||||
console.log('DB deleted');
|
||||
toastInfo('The database was deleted. Please reload or close this tab.<br>At the next visit, a new database will be created.');
|
||||
hideLoader();
|
||||
}
|
||||
} else {
|
||||
toastWarn('Your device does not support storing data locally. All data is fetched directly from our server.<br>As a result, you can not reset your database.');
|
||||
}
|
||||
}
|
||||
|
||||
function resetCache() {
|
||||
$('#menu-developer').hideMenu();
|
||||
navigator.serviceWorker.getRegistrations().then(function (registrations) {
|
||||
|
||||
@@ -43,6 +43,107 @@
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
/*** RANKING LIST ***/
|
||||
.ranking-list > div {
|
||||
padding-top: 1rem;
|
||||
padding-bottom: 1rem;
|
||||
border-bottom: 1px solid #dee2e6;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.ranking-list > div:last-child {
|
||||
border: 0;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
.ranking-list div {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.ranking-list > div > div > div {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.ranking-list > div > div:nth-child(1) > div:nth-child(1) {
|
||||
width: 25%;
|
||||
}
|
||||
.ranking-list > div > div:nth-child(1) > div:nth-child(2) {
|
||||
width: 50%;
|
||||
text-align: right;
|
||||
}
|
||||
.ranking-list > div > div:nth-child(1) > div:nth-child(3) {
|
||||
width: 25%;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.ranking-list > div > div:nth-child(2) > div:nth-child(1) {
|
||||
width: 75%;
|
||||
}
|
||||
.ranking-list > div > div:nth-child(2) > div:nth-child(2) {
|
||||
width: 25%;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
/*** RANKING DETAIL LIST ***/
|
||||
.ranking-detail-list > div {
|
||||
padding-top: 1rem;
|
||||
padding-bottom: 1rem;
|
||||
border-bottom: 1px solid #dee2e6;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.ranking-detail-list > div:last-child {
|
||||
border: 0;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
.ranking-detail-list div {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.ranking-detail-list > div > div > div {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.ranking-detail-list > div > div:nth-child(2) > div:nth-child(1) {
|
||||
width: 50%;
|
||||
}
|
||||
.ranking-detail-list > div > div:nth-child(2) > div:nth-child(2) {
|
||||
width: 25%;
|
||||
text-align: right;
|
||||
}
|
||||
.ranking-detail-list > div > div:nth-child(2) > div:nth-child(3) {
|
||||
width: 25%;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.ranking-detail-list > div > div:nth-child(3) {
|
||||
border-bottom: 1px dashed #dee2e6;
|
||||
}
|
||||
.ranking-detail-list > div > div:nth-child(3) > div:nth-child(1) {
|
||||
width: 50%;
|
||||
}
|
||||
.ranking-detail-list > div > div:nth-child(3) > div:nth-child(2) {
|
||||
width: 50%;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.ranking-detail-list > div > div:nth-child(4) > div:nth-child(1) {
|
||||
width: 50%;
|
||||
}
|
||||
.ranking-detail-list > div > div:nth-child(4) > div:nth-child(2) {
|
||||
width: 50%;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.ranking-detail-list > div > div:nth-child(n+5) > div:nth-child(1) {
|
||||
width: 75%;
|
||||
}
|
||||
.ranking-detail-list > div > div:nth-child(n+5) > div:nth-child(2) {
|
||||
width: 25%;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
/*** NORMAL LIST ***/
|
||||
.normal-list > div {
|
||||
padding-top: 1rem;
|
||||
|
||||
@@ -4254,7 +4254,7 @@ code {
|
||||
}
|
||||
|
||||
/*Contact Form*/
|
||||
.menu input[type="text"] {
|
||||
/*.menu input[type="text"] {
|
||||
height: 35px;
|
||||
line-height: 35px;
|
||||
}
|
||||
@@ -4271,7 +4271,7 @@ code {
|
||||
.menu .form-field label {
|
||||
font-size: 12px;
|
||||
margin-bottom: -10px;
|
||||
}
|
||||
}*/
|
||||
|
||||
.form-field span {
|
||||
position: absolute;
|
||||
|
||||
@@ -4,18 +4,15 @@
|
||||
error_reporting(0); // disable error reporting in browser
|
||||
define('SEND_ERRORS', true); // send errors via log
|
||||
|
||||
define('BOATCLASS', 'pirat');
|
||||
|
||||
date_default_timezone_set('Europe/Berlin');
|
||||
define('SERVER_PATH', '/subfolder'); // path to root directory
|
||||
define('SERVER_ADDR', 'https://' . $_SERVER['SERVER_NAME'] . SERVER_PATH); // path to root directory
|
||||
define('QUERY_URL', 'http://' . $_SERVER['SERVER_NAME'] . '/api/' . BOATCLASS . '/'); // url to api backend
|
||||
define('LOGGING_APIKEY', 'xxx'); // Apikey for Logging API -> get from ostertun.net/logging
|
||||
|
||||
// PUSH SERVER
|
||||
define('PUSH_AUTH', 'xxxxxxx'); // auth string for push.ostertun.net
|
||||
define('PUSH_SERVERKEY', 'xxxxxxx'); // server key from push.ostertun.net
|
||||
|
||||
define('BOATCLASS', 'pirat');
|
||||
|
||||
// BOAT CLASSES
|
||||
// BOAT CLASS
|
||||
$_CLASS = array(
|
||||
'name' => 'Pirat',
|
||||
'desc' => 'eine vom DSV geförderte Jugendmeisterschaftsklasse',
|
||||
|
||||
19
server/content/account.php
Normal file
19
server/content/account.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
// TODO: Create site
|
||||
|
||||
$sp['title'] = 'Seite noch nicht unterstuuml;tzt - Regatten.net ' . $_CLASS['name'];
|
||||
$sp['backbutton'] = true;
|
||||
|
||||
$content = $tpl->load('error', ['404', 'Seite existiert noch nicht']);
|
||||
$content .= '<p>';
|
||||
$content .= 'Die gesuchte Seite ist leider noch nicht verfügbar.<br>';
|
||||
$content .= 'Wir arbeiten daran, sie schnellstmöglich zur Verfügung zu stellen.<br>';
|
||||
$content .= 'Wie wäre es mit der Homepage?';
|
||||
$content .= '</p>';
|
||||
$content .= $tpl->load('button', ['Zur Startseite', LINK_PRE . 'index', 'css-class' => 'mb-3']);
|
||||
$content .= $tpl->load('button', ['Kontakt', LINK_PRE . 'contact']);
|
||||
|
||||
$sp['output'] = $tpl->load('card', [$content, 'css-class' => 'text-center pt-3']);
|
||||
|
||||
?>
|
||||
@@ -31,10 +31,14 @@
|
||||
$sp['output'] .= $tpl->load('pagination', ['html-id' => 'pagination']);
|
||||
|
||||
// Menu
|
||||
// TODO: add entries for jump2rank jump2club
|
||||
$items = $tpl->load('menu/item-icon', ['', '#', 'html-id' => 'menu-item-boatname', 'icon' => 'fa-edit']);
|
||||
$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-boat', 'title' => 'Boots-Details', 'height' => 320]);
|
||||
$items .= $tpl->load('menu/item-icon', ['Vereins-Website', '', 'html-id' => 'menu-item-clubwebsite', 'icon' => 'fa-globe', 'css-class' => 'border-0']);
|
||||
$sp['menus'] .= $tpl->load('menu/bottom', [$items, 'html-id' => 'menu-boat', 'title' => 'Boots-Details', 'height' => 200]);
|
||||
|
||||
$items = '<p class="mb-2 mt-1" style="line-height: 1.5em;">Bitte trage hier den Bootsnamen ein:</p>';
|
||||
$items .= $tpl->load('input', ['html-id' => 'input-editboatname', 'placeholder' => 'Bootsname', 'type' => 'text']);
|
||||
$items .= $tpl->load('button', ['Speichern', '#', 'html-id' => 'button-editboatname']);
|
||||
$sp['menus'] .= $tpl->load('menu/bottom', [$items, 'html-id' => 'menu-editboatname', 'height' => 240]);
|
||||
|
||||
$sp['scripts'] .= $scripts->load('pagination', ['pageChange', 'page', 'pageCount', 'pagination']);
|
||||
$sp['scripts'] .= $scripts->load('boats');
|
||||
|
||||
65
server/content/calc.php
Normal file
65
server/content/calc.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
$sp['title'] = 'RLP Rechner - Regatten.net ' . $_CLASS['name'];
|
||||
$sp['backbutton'] = 'index';
|
||||
$sp['activenav'] = 5;
|
||||
|
||||
// Title
|
||||
$content = "<h1>RLP Rechner</h1>";
|
||||
$content .= '<p>Einfach Ranglistenpunkte berechnen</p>';
|
||||
|
||||
$sp['output'] .= $tpl->load('card', [$content]);
|
||||
|
||||
// Inputs
|
||||
$content = $tpl->load('input', ['html-id' => 'input-rlf', 'placeholder' => 'Ranglistenfaktor (rlf)', 'type' => 'number']);
|
||||
$content .= $tpl->load('input', ['html-id' => 'input-m', 'placeholder' => 'Multiplikator (m)', 'type' => 'number']);
|
||||
$content .= $tpl->load('input', ['html-id' => 'input-fb', 'placeholder' => 'Gezeitete Boote (fb)', 'type' => 'number']);
|
||||
$content .= $tpl->load('input', ['html-id' => 'input-pl', 'placeholder' => 'Platzierung (pl)', 'type' => 'number']);
|
||||
$content .= $tpl->load('button', ['Hinzufügen', '#', 'html-id' => 'button-add']);
|
||||
|
||||
$sp['output'] .= $tpl->load('card', [$content]);
|
||||
|
||||
// Table
|
||||
$thead = '<tr><th>RLF</th><th>m</th><th>fb</th><th>pl</th><th>RLP</th><th></th></tr>';
|
||||
$content = $tpl->load('table', [$thead, 'html-id' => 'table-races']);
|
||||
$content .= '<p id="p-result"></p>';
|
||||
|
||||
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-races']);
|
||||
|
||||
// Infos
|
||||
$content = '<h2>Hinweise zum Ausfüllen</h2>';
|
||||
$content .= '<p><b>Ranglistenfaktor (RLF)</b><br>';
|
||||
$content .= 'Der Ranglistenfaktor ist ein von der KV vorgegebener Faktor zwischen 1,0 und 1,6 zur Gewichtung der Regatten.<br>';
|
||||
$content .= 'Du findest ihn in der <a href="' . LINK_PRE . 'regattas">Regatten-Liste</a>.';
|
||||
$content .= '</p>';
|
||||
$content .= '<p><b>Multiplikator (m)</b><br>';
|
||||
$content .= 'Der Multiplikator gibt an, wie oft eine Regatta in die Wertung eingeht.<br>';
|
||||
$content .= 'Er ist abhängig von den tatsächlich gesegelten Wettfahrten. Dabei gilt:<br>';
|
||||
$content .= '<b>1</b> Wettfahrt => <b>m = 1</b><br>';
|
||||
$content .= '<b>2</b> Wettfahrten => <b>m = 2</b><br>';
|
||||
$content .= '<b>3</b> Wettfahrten => <b>m = 3</b><br>';
|
||||
$content .= '<b>4 oder mehr</b> Wettfahrten => <b>m = 4</b><br>';
|
||||
$content .= 'Ist die Regatta für mehr als 2 Tage ausgeschrieben, gilt außerdem:<br>';
|
||||
$content .= '<b>6 oder mehr</b> Wettfahrten => <b>m = 5</b>';
|
||||
$content .= '</p>';
|
||||
$content .= '<p><b>Gezeitete Boote (fb)</b><br>';
|
||||
$content .= 'Die Anzahl der Boote, die in mindestens einer Wettfahrt ins Ziel gefahren sind.';
|
||||
$content .= '</p>';
|
||||
$content .= '<p><b>Platzierung (pl)</b><br>';
|
||||
$content .= 'Deine Platzierung in den Endergebnissen';
|
||||
$content .= '</p>';
|
||||
|
||||
$sp['output'] .= $tpl->load('card', [$content]);
|
||||
|
||||
$content = '<h2>Berechnung</h2>';
|
||||
$content .= '<p>Die Ranglistenpunkte (RLP) für eine Regatta berechnen sich nach folgender Formel:<br>';
|
||||
$content .= '<i>RLP = RLF * 100 * ((fb + 1 - pl) / fb)</i><br>';
|
||||
$content .= 'Diese Ranglistenpunkte können je nach Multiplikator bis zu 5 mal in die Wertung eingehen.<br>';
|
||||
$content .= 'Der Mittelwert der 9 besten Wertungen ergibt die Ranglistenpunkte.';
|
||||
$content .= '</p>';
|
||||
|
||||
$sp['output'] .= $tpl->load('card', [$content]);
|
||||
|
||||
$sp['scripts'] .= $scripts->load('calc');
|
||||
|
||||
?>
|
||||
@@ -20,9 +20,8 @@
|
||||
$sp['output'] .= $tpl->load('pagination', ['html-id' => 'pagination']);
|
||||
|
||||
// Menu
|
||||
// TODO: add entries for jump2rank jump2club
|
||||
$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-club', 'title' => 'Vereins-Details', 'height' => 320]);
|
||||
$items = $tpl->load('menu/item-icon', ['Vereins-Website', '', 'html-id' => 'menu-item-clubwebsite', 'icon' => 'fa-globe', 'css-class' => 'border-0']);
|
||||
$sp['menus'] .= $tpl->load('menu/bottom', [$items, 'html-id' => 'menu-club', 'title' => 'Vereins-Details', 'height' => 160]);
|
||||
|
||||
$sp['scripts'] .= $scripts->load('pagination', ['pageChange', 'page', 'pageCount', 'pagination']);
|
||||
$sp['scripts'] .= $scripts->load('clubs');
|
||||
|
||||
38
server/content/contact.php
Normal file
38
server/content/contact.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
$sp['title'] = 'Kontakt - Regatten.net ' . $_CLASS['name'];
|
||||
$sp['backbutton'] = true;
|
||||
$sp['activenav'] = 5;
|
||||
|
||||
// TITLE
|
||||
$content = '<h1>Kontakt</h1>';
|
||||
|
||||
$sp['output'] .= $tpl->load('card', [$content]);
|
||||
|
||||
// Info
|
||||
$content = '<p>';
|
||||
$content .= 'Du hast eine Frage? Du hast einen Fehler in unserer Software oder in den gespeicherten Daten gefunden? Du willst Regatten.net auch für Deine Bootsklasse nutzen?<br>';
|
||||
$content .= 'Egal was es ist, lass es uns wissen! Schreibe uns eine Mail an <a href="mailto:info@regatten.net">info@regatten.net</a> oder nutze einfach dieses Kontakt-Formular.<br>';
|
||||
$content .= 'Wir werden Deine Anfrage so schnell wie möglich bearbeiten.';
|
||||
$content .= '</p>';
|
||||
$content .= '<p>';
|
||||
$content .= 'Alternativ erreichst Du uns auch telefonisch unter <a href="tel:+4941039659768">+49 (0) 4103 965 976 8</a><br>';
|
||||
$content .= 'Mo-Fr: 7-20 Uhr<br>';
|
||||
$content .= 'Sa: 9-17 Uhr';
|
||||
$content .= '</p>';
|
||||
|
||||
$sp['output'] .= $tpl->load('card', [$content]);
|
||||
|
||||
// Formular
|
||||
$content = '<h2>Kontakt-Formular</h2>';
|
||||
$content .= $tpl->load('input', ['html-id' => 'input-name', 'placeholder' => 'Dein Name', 'type' => 'text']);
|
||||
$content .= $tpl->load('input', ['html-id' => 'input-email', 'placeholder' => 'Email-Adresse', 'type' => 'email']);
|
||||
$content .= $tpl->load('input', ['html-id' => 'input-subject', 'placeholder' => 'Betreff', 'type' => 'text']);
|
||||
$content .= $tpl->load('textarea', ['html-id' => 'input-message', 'placeholder' => 'Deine Nachricht']);
|
||||
$content .= $tpl->load('button', ['Senden', '#', 'html-id' => 'button-send']);
|
||||
|
||||
$sp['output'] .= $tpl->load('card', [$content]);
|
||||
|
||||
$sp['scripts'] .= $scripts->load('contact');
|
||||
|
||||
?>
|
||||
@@ -60,11 +60,11 @@
|
||||
$content = '<h2>Regatta-Kalender</h2>';
|
||||
$content .= '<p>Du willst alle Regatta-Termine in deinem Kalender, aber nicht alles abtippen?<br>Kein Problem! Abonniere einfach unseren ics-Kalender.</p>';
|
||||
$content .= '<p><b>Nur die Regatten, zu denen Du gehst?</b><br>Auch kein Problem! ';
|
||||
$content .= '<span class="show-loggedin">Erstelle einfach eine <a href="' . LINK_PRE . 'planning">Saison-Planung</a> und abonniere Deinen persönlichen Kalender.</span>';
|
||||
$content .= '<span class="show-notloggedin"><a href="#" data-menu="menu-signup">Registriere Dich einfach kostenlos</a>, erstelle eine Saison-Planung und wir erstellen Dir einen persönlichen Kalender.</span>';
|
||||
$content .= '<font class="show-loggedin">Erstelle einfach eine <a href="' . LINK_PRE . 'planning">Saison-Planung</a> und abonniere Deinen persönlichen Kalender.</font>';
|
||||
$content .= '<font class="show-notloggedin"><a href="#" data-menu="menu-signup">Registriere Dich einfach kostenlos</a>, erstelle eine Saison-Planung und wir erstellen Dir einen persönlichen Kalender.</font>';
|
||||
$content .= '</p>';
|
||||
$content .= $tpl->load('button', ['<i class="fas fa-calendar-alt"></i> Regatta-Kalender', 'https://regatten.net/client/calendar/' . BOATCLASS . '/everything.ics', 'css-class' => 'mb-2']);
|
||||
$content .= $tpl->load('button', ['<i class="fas fa-calendar-alt"></i> Kalender für <span class="replace-username"></span>', 'https://regatten.net/client/calendar/' . BOATCLASS . '/user_%USERID%.ics', 'css-class' => 'show-loggedin replace-userid-href']);
|
||||
$content .= $tpl->load('button', ['<i class="fas fa-calendar-alt"></i> Kalender für <font class="replace-username"></font>', 'https://regatten.net/client/calendar/' . BOATCLASS . '/user_%USERID%.ics', 'css-class' => 'show-loggedin replace-userid-href']);
|
||||
|
||||
$sp['output'] .= $tpl->load('card', [$content]);
|
||||
|
||||
|
||||
19
server/content/news.php
Normal file
19
server/content/news.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
// TODO: Create site
|
||||
|
||||
$sp['title'] = 'Seite noch nicht unterstuuml;tzt - Regatten.net ' . $_CLASS['name'];
|
||||
$sp['backbutton'] = true;
|
||||
|
||||
$content = $tpl->load('error', ['404', 'Seite existiert noch nicht']);
|
||||
$content .= '<p>';
|
||||
$content .= 'Die gesuchte Seite ist leider noch nicht verfügbar.<br>';
|
||||
$content .= 'Wir arbeiten daran, sie schnellstmöglich zur Verfügung zu stellen.<br>';
|
||||
$content .= 'Wie wäre es mit der Homepage?';
|
||||
$content .= '</p>';
|
||||
$content .= $tpl->load('button', ['Zur Startseite', LINK_PRE . 'index', 'css-class' => 'mb-3']);
|
||||
$content .= $tpl->load('button', ['Kontakt', LINK_PRE . 'contact']);
|
||||
|
||||
$sp['output'] = $tpl->load('card', [$content, 'css-class' => 'text-center pt-3']);
|
||||
|
||||
?>
|
||||
19
server/content/planning.php
Normal file
19
server/content/planning.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
// TODO: Create site
|
||||
|
||||
$sp['title'] = 'Seite noch nicht unterstuuml;tzt - Regatten.net ' . $_CLASS['name'];
|
||||
$sp['backbutton'] = true;
|
||||
|
||||
$content = $tpl->load('error', ['404', 'Seite existiert noch nicht']);
|
||||
$content .= '<p>';
|
||||
$content .= 'Die gesuchte Seite ist leider noch nicht verfügbar.<br>';
|
||||
$content .= 'Wir arbeiten daran, sie schnellstmöglich zur Verfügung zu stellen.<br>';
|
||||
$content .= 'Wie wäre es mit der Homepage?';
|
||||
$content .= '</p>';
|
||||
$content .= $tpl->load('button', ['Zur Startseite', LINK_PRE . 'index', 'css-class' => 'mb-3']);
|
||||
$content .= $tpl->load('button', ['Kontakt', LINK_PRE . 'contact']);
|
||||
|
||||
$sp['output'] = $tpl->load('card', [$content, 'css-class' => 'text-center pt-3']);
|
||||
|
||||
?>
|
||||
19
server/content/planning_edit.php
Normal file
19
server/content/planning_edit.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
// TODO: Create site
|
||||
|
||||
$sp['title'] = 'Seite noch nicht unterstuuml;tzt - Regatten.net ' . $_CLASS['name'];
|
||||
$sp['backbutton'] = true;
|
||||
|
||||
$content = $tpl->load('error', ['404', 'Seite existiert noch nicht']);
|
||||
$content .= '<p>';
|
||||
$content .= 'Die gesuchte Seite ist leider noch nicht verfügbar.<br>';
|
||||
$content .= 'Wir arbeiten daran, sie schnellstmöglich zur Verfügung zu stellen.<br>';
|
||||
$content .= 'Wie wäre es mit der Homepage?';
|
||||
$content .= '</p>';
|
||||
$content .= $tpl->load('button', ['Zur Startseite', LINK_PRE . 'index', 'css-class' => 'mb-3']);
|
||||
$content .= $tpl->load('button', ['Kontakt', LINK_PRE . 'contact']);
|
||||
|
||||
$sp['output'] = $tpl->load('card', [$content, 'css-class' => 'text-center pt-3']);
|
||||
|
||||
?>
|
||||
19
server/content/planning_list.php
Normal file
19
server/content/planning_list.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
// TODO: Create site
|
||||
|
||||
$sp['title'] = 'Seite noch nicht unterstuuml;tzt - Regatten.net ' . $_CLASS['name'];
|
||||
$sp['backbutton'] = true;
|
||||
|
||||
$content = $tpl->load('error', ['404', 'Seite existiert noch nicht']);
|
||||
$content .= '<p>';
|
||||
$content .= 'Die gesuchte Seite ist leider noch nicht verfügbar.<br>';
|
||||
$content .= 'Wir arbeiten daran, sie schnellstmöglich zur Verfügung zu stellen.<br>';
|
||||
$content .= 'Wie wäre es mit der Homepage?';
|
||||
$content .= '</p>';
|
||||
$content .= $tpl->load('button', ['Zur Startseite', LINK_PRE . 'index', 'css-class' => 'mb-3']);
|
||||
$content .= $tpl->load('button', ['Kontakt', LINK_PRE . 'contact']);
|
||||
|
||||
$sp['output'] = $tpl->load('card', [$content, 'css-class' => 'text-center pt-3']);
|
||||
|
||||
?>
|
||||
19
server/content/planning_view.php
Normal file
19
server/content/planning_view.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
// TODO: Create site
|
||||
|
||||
$sp['title'] = 'Seite noch nicht unterstuuml;tzt - Regatten.net ' . $_CLASS['name'];
|
||||
$sp['backbutton'] = true;
|
||||
|
||||
$content = $tpl->load('error', ['404', 'Seite existiert noch nicht']);
|
||||
$content .= '<p>';
|
||||
$content .= 'Die gesuchte Seite ist leider noch nicht verfügbar.<br>';
|
||||
$content .= 'Wir arbeiten daran, sie schnellstmöglich zur Verfügung zu stellen.<br>';
|
||||
$content .= 'Wie wäre es mit der Homepage?';
|
||||
$content .= '</p>';
|
||||
$content .= $tpl->load('button', ['Zur Startseite', LINK_PRE . 'index', 'css-class' => 'mb-3']);
|
||||
$content .= $tpl->load('button', ['Kontakt', LINK_PRE . 'contact']);
|
||||
|
||||
$sp['output'] = $tpl->load('card', [$content, 'css-class' => 'text-center pt-3']);
|
||||
|
||||
?>
|
||||
46
server/content/rank.php
Normal file
46
server/content/rank.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
$sp['title'] = 'Ranglisten - Regatten.net ' . $_CLASS['name'];
|
||||
$sp['backbutton'] = 'index';
|
||||
$sp['activenav'] = 3;
|
||||
|
||||
// Title, Inputs
|
||||
$content = "<h1>Ranglisten</h1>";
|
||||
|
||||
$options = '<option value="year">Jahres-Rangliste</option>';
|
||||
$options .= '<option value="youth">Jugend-Rangliste</option>';
|
||||
$options .= '<option value="idjm">' . $_CLASS['youth-german-name'] . '-Rangliste</option>';
|
||||
$options .= '<option value="user">Benutzerdefiniert</option>';
|
||||
$content .= $tpl->load('select', ['html-id' => 'select-type', 'placeholder' => 'Rangliste', 'options' => $options, 'css-class' => 'mt-3 mb-0']);
|
||||
$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']);
|
||||
$chbox = $tpl->load('checkbox', ['html-id' => 'input-jugend', 'placeholder' => 'Jugend']);
|
||||
$content .= '<div class="mb-3" style="display:inline-block; width:50%;">' . $chbox . '</div>';
|
||||
$chbox = $tpl->load('checkbox', ['html-id' => 'input-jugstrict', 'placeholder' => 'Streng']);
|
||||
$content .= '<div class="mb-3" style="display:inline-block; width:50%;">' . $chbox . '</div>';
|
||||
$content .= $tpl->load('button', ['Anzeigen', '#', 'html-id' => 'button-show']);
|
||||
|
||||
$sp['output'] .= $tpl->load('card', [$content]);
|
||||
|
||||
// No Results
|
||||
$content = '<h2 class="color-white">ACHTUNG</h2>';
|
||||
$content .= '<p class="color-white">Zu folgenden Regatten wurden noch keine Ergebnisse hinterlegt:</p>';
|
||||
$content .= '<ul id="ul-noresults"></ul>';
|
||||
|
||||
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-noresults', 'css-class' => 'bg-red2-dark']);
|
||||
|
||||
// Ranking
|
||||
$content = $tpl->load('input', ['html-id' => 'input-search', 'placeholder' => 'Suche', 'type' => 'text']);
|
||||
$content .= '<div id="div-rank" class="ranking-list mb-0"></div>';
|
||||
|
||||
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-rank']);
|
||||
|
||||
// Menu
|
||||
$items = '<p id="menu-item-text" class="mb-2 mt-1" style="line-height: 1.5em;"></p>';
|
||||
$items .= '<div id="div-details" class="ranking-detail-list mb-3" style="line-height: 2em;"></div>';
|
||||
$sp['menus'] .= $tpl->load('menu/bottom', [$items, 'html-id' => 'menu-rank', 'title' => 'Ranglisten-Details', 'height' => 500]);
|
||||
|
||||
$sp['scripts'] .= $scripts->load('rank');
|
||||
|
||||
?>
|
||||
31
server/content/regatta_plan.php
Normal file
31
server/content/regatta_plan.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
$sp['title'] = 'Saison-Planung - Regatten.net ' . $_CLASS['name'];
|
||||
$sp['backbutton'] = 'regattas';
|
||||
$sp['activenav'] = 2;
|
||||
|
||||
// Title, Inputs
|
||||
$content = '<h1 id="h1-title"></h1>';
|
||||
$content .= '<p id="p-title"></p>';
|
||||
|
||||
$sp['output'] .= $tpl->load('card', [$content]);
|
||||
|
||||
// Plannings
|
||||
$content = '<p id="p-info" class="mb-0"></p>';
|
||||
$thead = '<tr><th>Benutzer</th><th>Steuermann/-frau</th><th>Crew</th></tr>';
|
||||
$content .= $tpl->load('table', [$thead, 'html-id' => 'table-plannings', 'css-class' => 'mb-0 text-nowrap']);
|
||||
|
||||
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-plannings']);
|
||||
|
||||
// Info
|
||||
$content = '<p>Du planst, hier hinzufahren, aber stehst nicht auf dieser Liste?<br>';
|
||||
$content .= 'Das kannst Du ändern! ';
|
||||
$content .= '<font class="show-loggedin">Erstelle einfach <a href="' . LINK_PRE . 'planning">hier</a> Deine eigene Saison-Planung.</font>';
|
||||
$content .= '<font class="show-notloggedin"><a href="#" data-menu="menu-login">Melde Dich an</a> oder <a href="#" data-menu="menu-signup">registriere Dich kostenlos</a> und erstelle Deine eigene Saison-Planung.</font>';
|
||||
$content .= '</p>';
|
||||
|
||||
$sp['output'] .= $tpl->load('card', [$content]);
|
||||
|
||||
$sp['scripts'] .= $scripts->load('regatta_plan');
|
||||
|
||||
?>
|
||||
21
server/content/result.php
Normal file
21
server/content/result.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
$sp['title'] = 'Ergebnisse - Regatten.net ' . $_CLASS['name'];
|
||||
$sp['backbutton'] = true;
|
||||
$sp['activenav'] = 2;
|
||||
|
||||
// Title, Inputs
|
||||
$content = '<h1 id="h1-title"></h1>';
|
||||
$content .= '<p id="p-title"></p>';
|
||||
|
||||
$sp['output'] .= $tpl->load('card', [$content]);
|
||||
|
||||
// Results
|
||||
$content = '<p id="p-info" class="mb-0"></p>';
|
||||
$content .= $tpl->load('table', ['html-id' => 'table-results', 'css-class' => 'mb-0 text-nowrap']);
|
||||
|
||||
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-results']);
|
||||
|
||||
$sp['scripts'] .= $scripts->load('result');
|
||||
|
||||
?>
|
||||
@@ -31,10 +31,14 @@
|
||||
$sp['output'] .= $tpl->load('pagination', ['html-id' => 'pagination']);
|
||||
|
||||
// Menu
|
||||
// TODO: add entries for jump2rank jump2club
|
||||
$items = $tpl->load('menu/item-icon', ['', '#', 'html-id' => 'menu-item-year', 'icon' => 'fa-edit']);
|
||||
$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-sailor', 'title' => 'Segler-Details', 'height' => 320]);
|
||||
$items .= $tpl->load('menu/item-icon', ['Vereins-Website', '', 'html-id' => 'menu-item-clubwebsite', 'icon' => 'fa-globe', 'css-class' => 'border-0']);
|
||||
$sp['menus'] .= $tpl->load('menu/bottom', [$items, 'html-id' => 'menu-sailor', 'title' => 'Segler-Details', 'height' => 200]);
|
||||
|
||||
$items = '<p class="mb-2 mt-1" style="line-height: 1.5em;">Bitte trage hier den Jahrgang ein:</p>';
|
||||
$items .= $tpl->load('input', ['html-id' => 'input-edityear', 'placeholder' => 'Jahrgang', 'type' => 'number']);
|
||||
$items .= $tpl->load('button', ['Speichern', '#', 'html-id' => 'button-edityear']);
|
||||
$sp['menus'] .= $tpl->load('menu/bottom', [$items, 'html-id' => 'menu-edityear', 'height' => 240]);
|
||||
|
||||
$sp['scripts'] .= $scripts->load('pagination', ['pageChange', 'page', 'pageCount', 'pagination']);
|
||||
$sp['scripts'] .= $scripts->load('sailors');
|
||||
|
||||
19
server/content/trim_boat.php
Normal file
19
server/content/trim_boat.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
// TODO: Create site
|
||||
|
||||
$sp['title'] = 'Seite noch nicht unterstuuml;tzt - Regatten.net ' . $_CLASS['name'];
|
||||
$sp['backbutton'] = true;
|
||||
|
||||
$content = $tpl->load('error', ['404', 'Seite existiert noch nicht']);
|
||||
$content .= '<p>';
|
||||
$content .= 'Die gesuchte Seite ist leider noch nicht verfügbar.<br>';
|
||||
$content .= 'Wir arbeiten daran, sie schnellstmöglich zur Verfügung zu stellen.<br>';
|
||||
$content .= 'Wie wäre es mit der Homepage?';
|
||||
$content .= '</p>';
|
||||
$content .= $tpl->load('button', ['Zur Startseite', LINK_PRE . 'index', 'css-class' => 'mb-3']);
|
||||
$content .= $tpl->load('button', ['Kontakt', LINK_PRE . 'contact']);
|
||||
|
||||
$sp['output'] = $tpl->load('card', [$content, 'css-class' => 'text-center pt-3']);
|
||||
|
||||
?>
|
||||
19
server/content/trim_boat_edit.php
Normal file
19
server/content/trim_boat_edit.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
// TODO: Create site
|
||||
|
||||
$sp['title'] = 'Seite noch nicht unterstuuml;tzt - Regatten.net ' . $_CLASS['name'];
|
||||
$sp['backbutton'] = true;
|
||||
|
||||
$content = $tpl->load('error', ['404', 'Seite existiert noch nicht']);
|
||||
$content .= '<p>';
|
||||
$content .= 'Die gesuchte Seite ist leider noch nicht verfügbar.<br>';
|
||||
$content .= 'Wir arbeiten daran, sie schnellstmöglich zur Verfügung zu stellen.<br>';
|
||||
$content .= 'Wie wäre es mit der Homepage?';
|
||||
$content .= '</p>';
|
||||
$content .= $tpl->load('button', ['Zur Startseite', LINK_PRE . 'index', 'css-class' => 'mb-3']);
|
||||
$content .= $tpl->load('button', ['Kontakt', LINK_PRE . 'contact']);
|
||||
|
||||
$sp['output'] = $tpl->load('card', [$content, 'css-class' => 'text-center pt-3']);
|
||||
|
||||
?>
|
||||
19
server/content/trim_list.php
Normal file
19
server/content/trim_list.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
// TODO: Create site
|
||||
|
||||
$sp['title'] = 'Seite noch nicht unterstuuml;tzt - Regatten.net ' . $_CLASS['name'];
|
||||
$sp['backbutton'] = true;
|
||||
|
||||
$content = $tpl->load('error', ['404', 'Seite existiert noch nicht']);
|
||||
$content .= '<p>';
|
||||
$content .= 'Die gesuchte Seite ist leider noch nicht verfügbar.<br>';
|
||||
$content .= 'Wir arbeiten daran, sie schnellstmöglich zur Verfügung zu stellen.<br>';
|
||||
$content .= 'Wie wäre es mit der Homepage?';
|
||||
$content .= '</p>';
|
||||
$content .= $tpl->load('button', ['Zur Startseite', LINK_PRE . 'index', 'css-class' => 'mb-3']);
|
||||
$content .= $tpl->load('button', ['Kontakt', LINK_PRE . 'contact']);
|
||||
|
||||
$sp['output'] = $tpl->load('card', [$content, 'css-class' => 'text-center pt-3']);
|
||||
|
||||
?>
|
||||
19
server/content/trim_trim_add.php
Normal file
19
server/content/trim_trim_add.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
// TODO: Create site
|
||||
|
||||
$sp['title'] = 'Seite noch nicht unterstuuml;tzt - Regatten.net ' . $_CLASS['name'];
|
||||
$sp['backbutton'] = true;
|
||||
|
||||
$content = $tpl->load('error', ['404', 'Seite existiert noch nicht']);
|
||||
$content .= '<p>';
|
||||
$content .= 'Die gesuchte Seite ist leider noch nicht verfügbar.<br>';
|
||||
$content .= 'Wir arbeiten daran, sie schnellstmöglich zur Verfügung zu stellen.<br>';
|
||||
$content .= 'Wie wäre es mit der Homepage?';
|
||||
$content .= '</p>';
|
||||
$content .= $tpl->load('button', ['Zur Startseite', LINK_PRE . 'index', 'css-class' => 'mb-3']);
|
||||
$content .= $tpl->load('button', ['Kontakt', LINK_PRE . 'contact']);
|
||||
|
||||
$sp['output'] = $tpl->load('card', [$content, 'css-class' => 'text-center pt-3']);
|
||||
|
||||
?>
|
||||
19
server/content/trim_trim_edit.php
Normal file
19
server/content/trim_trim_edit.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
// TODO: Create site
|
||||
|
||||
$sp['title'] = 'Seite noch nicht unterstuuml;tzt - Regatten.net ' . $_CLASS['name'];
|
||||
$sp['backbutton'] = true;
|
||||
|
||||
$content = $tpl->load('error', ['404', 'Seite existiert noch nicht']);
|
||||
$content .= '<p>';
|
||||
$content .= 'Die gesuchte Seite ist leider noch nicht verfügbar.<br>';
|
||||
$content .= 'Wir arbeiten daran, sie schnellstmöglich zur Verfügung zu stellen.<br>';
|
||||
$content .= 'Wie wäre es mit der Homepage?';
|
||||
$content .= '</p>';
|
||||
$content .= $tpl->load('button', ['Zur Startseite', LINK_PRE . 'index', 'css-class' => 'mb-3']);
|
||||
$content .= $tpl->load('button', ['Kontakt', LINK_PRE . 'contact']);
|
||||
|
||||
$sp['output'] = $tpl->load('card', [$content, 'css-class' => 'text-center pt-3']);
|
||||
|
||||
?>
|
||||
@@ -130,7 +130,7 @@
|
||||
</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="menu-title"><h1>Entwickler-Optionen</h1><p class="color-highlight">Version <?php echo PWA_VERSION; ?></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">
|
||||
@@ -139,7 +139,7 @@
|
||||
<span>Infos zur BETA</span>
|
||||
<i class="fa fa-angle-right"></i>
|
||||
</a>
|
||||
<a href="javascript:resetDb();">
|
||||
<a href="javascript:resetDb(false);">
|
||||
<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>
|
||||
@@ -187,6 +187,25 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="menu-welcome" class="menu menu-box-bottom" style="height: 70vh">
|
||||
<div class="content bottom-0">
|
||||
<h1 class="text-center font-900">Willkommen</h1>
|
||||
<p>
|
||||
Diese App befindet sich zur Zeit noch in der Entwicklungs-Phase.<br>
|
||||
Dadurch kann es vorkommen, dass bestimmte Funktionen noch nicht richtig funktionieren.<br>
|
||||
Wenn Dir etwas ungewöhnlich vorkommt, melde uns dies bitte. Klicke dazu auf das Entwickler-Icon oben links und wähle "Problem melden".<br>
|
||||
Vielen Dank für Deine Unterstützung!
|
||||
</p>
|
||||
<p>
|
||||
Mehr Informationen findest Du <a href="https://info.ostertun.net/regatten/beta">hier</a>.
|
||||
</p>
|
||||
<p>
|
||||
Mit der Nutzung dieser App erklärst Du Dich außerdem damit einverstanden, dass wir Cookies einsetzen.
|
||||
</p>
|
||||
<a id="menu-welcome-a-okay" class="btn btn-m mt-2 mb-3 btn-full bg-green2-dark text-uppercase font-900" href="#">Alles klar</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="menu-update">
|
||||
<div class="content bottom-0">
|
||||
<p class="text-center mt-5"><i class="fa fa-sync-alt fa-7x color-highlight fa-spin"></i></p>
|
||||
|
||||
@@ -5,18 +5,64 @@ var page = 1;
|
||||
var pageCount = 0;
|
||||
const showCount = 25;
|
||||
|
||||
async function onEditBoatnameClick() {
|
||||
var id = $('#button-editboatname').attr('data-boat-id');
|
||||
var name = $('#input-editboatname').val();
|
||||
if (name != '') {
|
||||
showLoader();
|
||||
$.ajax({
|
||||
url: QUERY_URL + 'add_boatname',
|
||||
method: 'POST',
|
||||
data: {
|
||||
boat: id,
|
||||
name: name
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
if (xhr.status == 0) {
|
||||
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um den Bootsnamen zu bearbeiten');
|
||||
} else {
|
||||
console.log('EditBoatname: unbekannter Fehler', status, error);
|
||||
console.log(xhr);
|
||||
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
|
||||
}
|
||||
hideLoader();
|
||||
},
|
||||
success: function (data, status, xhr) {
|
||||
if ('status' in data) {
|
||||
if (data.status == 'added') {
|
||||
toastOk('Bootsnamen erfolgreich hinzugefügt');
|
||||
sync();
|
||||
} else {
|
||||
toastInfo('Wir prüfen Deine Anfrage und korrigieren den Bootsnamen schnellstmöglich', 5000);
|
||||
}
|
||||
} else {
|
||||
toastOk('Erfolgreich');
|
||||
}
|
||||
hideLoader();
|
||||
}
|
||||
});
|
||||
}
|
||||
$('#menu-editboatname').hideMenu();
|
||||
}
|
||||
|
||||
async function onListClicked(id) {
|
||||
var boat = await dbGetData('boats', id);
|
||||
|
||||
$('#menu-boat').find('.menu-title').find('p').text(boat.sailnumber);
|
||||
|
||||
// Edit Boatname
|
||||
// TODO: create menu for edit boatname
|
||||
$('#button-editboatname').attr('data-boat-id', boat.id);
|
||||
$('#menu-editboatname').find('.menu-title').find('p').text(boat.sailnumber);
|
||||
if (boat['name'] == '') {
|
||||
$('#menu-item-boatname').find('span').text('Bootsnamen hinzufügen');
|
||||
$('#menu-editboatname').find('.menu-title').find('h1').text('Bootsnamen hinzufügen');
|
||||
$('#input-editboatname').val('');
|
||||
} else {
|
||||
$('#menu-item-boatname').find('span').text('Bootsnamen bearbeiten');
|
||||
$('#menu-editboatname').find('.menu-title').find('h1').text('Bootsnamen bearbeiten');
|
||||
$('#input-editboatname').val(boat.name);
|
||||
}
|
||||
$('#input-editboatname').trigger('focusin').trigger('focusout');
|
||||
|
||||
// club website
|
||||
var clubwebsite = '';
|
||||
@@ -86,6 +132,8 @@ var siteScript = async function() {
|
||||
firstCall = false;
|
||||
initPagination();
|
||||
$('#input-search').on('input', reSearch);
|
||||
$('#menu-item-boatname').click(function(){ $('#menu-boat').hideMenu(); $('#menu-editboatname').showMenu(); });
|
||||
$('#button-editboatname').click(onEditBoatnameClick);
|
||||
}
|
||||
|
||||
var results = await dbGetData('boats');
|
||||
|
||||
92
server/scripts/calc.js
Normal file
92
server/scripts/calc.js
Normal file
@@ -0,0 +1,92 @@
|
||||
var races = [];
|
||||
var firstCall = true;
|
||||
|
||||
function reCalc() {
|
||||
setTimeout(function(){
|
||||
if (races.length > 0) {
|
||||
$('#card-races').show();
|
||||
$('#p-result').text('Berechne...');
|
||||
var rlps = [];
|
||||
var tbody = '';
|
||||
for (var i = 0; i < races.length; i ++) {
|
||||
tbody += '<tr>';
|
||||
tbody += '<td>' + races[i].rlf + '</td>';
|
||||
tbody += '<td>' + races[i].m + '</td>';
|
||||
tbody += '<td>' + races[i].fb + '</td>';
|
||||
tbody += '<td>' + races[i].pl + '</td>';
|
||||
tbody += '<td>' + races[i].rlp.toFixed(3) + '</td>';
|
||||
tbody += '<td><a href="#" onclick="removeRace(' + i + ')" class="btn rounded-s text-uppercase font-900 shadow-m bg-highlight"><i class="fas fa-times"></i></a></td>';
|
||||
tbody += '</tr>';
|
||||
for (var j = 0; j < races[i].m; j ++) {
|
||||
rlps.push(races[i].rlp);
|
||||
}
|
||||
}
|
||||
$('#table-races').find('tbody').html(tbody);
|
||||
rlps.sort(function (a,b) {
|
||||
return b-a;
|
||||
});
|
||||
var sum = 0;
|
||||
var cnt = Math.min(rlps.length, 9);
|
||||
for (var i = 0; i < cnt; i ++) {
|
||||
sum += rlps[i];
|
||||
}
|
||||
$('#p-result').html('<b>' + (sum / cnt).toFixed(3) + '</b> Punkte aus <b>' + cnt + '</b> Wertungen.');
|
||||
} else {
|
||||
$('#card-races').hide();
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
|
||||
function addRace() {
|
||||
var rlf = parseFloat($('#input-rlf').val().replace(',', '.'));
|
||||
var m = parseFloat($('#input-m').val());
|
||||
var fb = parseFloat($('#input-fb').val());
|
||||
var pl = parseFloat($('#input-pl').val().replace(',', '.'));
|
||||
|
||||
if (isNaN(rlf) || (rlf < 1) || (rlf > 1.6)) {
|
||||
toastError('RLF ungültig');
|
||||
return;
|
||||
}
|
||||
if (isNaN(m) || (m < 1) || (m > 5)) {
|
||||
toastError('m ungültig');
|
||||
return;
|
||||
}
|
||||
if (isNaN(fb) || (fb < 1)) {
|
||||
toastError('fb ungültig');
|
||||
return;
|
||||
}
|
||||
if (isNaN(pl) || (pl < 1) || (pl > (fb + 1))) {
|
||||
toastError('pl ungültig');
|
||||
return;
|
||||
}
|
||||
|
||||
var race = {
|
||||
rlf: rlf,
|
||||
m: m,
|
||||
fb: fb,
|
||||
pl: pl,
|
||||
rlp: (100 * rlf * ((fb + 1 - pl) / fb))
|
||||
};
|
||||
|
||||
$('#input-rlf').val('');
|
||||
$('#input-m').val('');
|
||||
$('#input-fb').val('');
|
||||
$('#input-pl').val('');
|
||||
|
||||
races.push(race);
|
||||
reCalc();
|
||||
}
|
||||
|
||||
function removeRace(id) {
|
||||
if ((id >= 0) && (id < races.length)) races.splice(id, 1);
|
||||
reCalc();
|
||||
}
|
||||
|
||||
var siteScript = async function () {
|
||||
if (firstCall) {
|
||||
firstCall = false;
|
||||
$('#button-add').click(addRace);
|
||||
}
|
||||
reCalc();
|
||||
hideLoader();
|
||||
}
|
||||
49
server/scripts/contact.js
Normal file
49
server/scripts/contact.js
Normal file
@@ -0,0 +1,49 @@
|
||||
function sendMessage() {
|
||||
var name = $('#input-name').val();
|
||||
var email = $('#input-email').val();
|
||||
var subject = $('#input-subject').val();
|
||||
var message = $('#input-message').val();
|
||||
|
||||
if ((name == '') || (email == '') || (subject == '') || (message == '')) {
|
||||
toastError('Bitte fülle alle Felder aus!');
|
||||
return;
|
||||
}
|
||||
|
||||
showLoader();
|
||||
$.ajax({
|
||||
url: QUERY_URL + 'contact',
|
||||
method: 'POST',
|
||||
data: {
|
||||
name: name,
|
||||
email: email,
|
||||
subject: subject,
|
||||
message: message
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
if (xhr.status == 0) {
|
||||
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um eine Nachricht zu versenden');
|
||||
} else {
|
||||
console.log('Contact: unbekannter Fehler', status, error);
|
||||
console.log(xhr);
|
||||
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
|
||||
}
|
||||
hideLoader();
|
||||
},
|
||||
success: function (data, status, xhr) {
|
||||
toastOk('Nachricht erfolgreich versandt!');
|
||||
$('#input-subject').val('');
|
||||
$('#input-message').val('');
|
||||
hideLoader();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var siteScript = async function () {
|
||||
if (isLoggedIn()) {
|
||||
var user = await dbGetData('users', USER_ID);
|
||||
$('#input-name').val(user.username).trigger('focusin').trigger('focusout');
|
||||
$('#input-email').val(user.email).trigger('focusin').trigger('focusout');
|
||||
}
|
||||
$('#button-send').click(sendMessage);
|
||||
hideLoader();
|
||||
}
|
||||
@@ -19,14 +19,23 @@ var siteScript = async function() {
|
||||
if (watched.length > 0) {
|
||||
var year = (new Date()).getFullYear();
|
||||
$('#th-ranking').html('Rangliste ' + year);
|
||||
// TODO: get ranking
|
||||
var ranking = (await dbGetRanking(parseDate('01.12.' + (year - 1)), parseDate('30.11.' + year), false, false))[0];
|
||||
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>';
|
||||
var rank = null;
|
||||
for (r in ranking) {
|
||||
if (ranking[r].id == sailor.id) {
|
||||
rank = ranking[r].rank;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (rank == null) {
|
||||
tbody += '<i>nicht in der Rangliste</i>';
|
||||
} else {
|
||||
tbody += '<b>' + rank + '.</b> Platz';
|
||||
}
|
||||
tbody += '</td></tr>';
|
||||
}
|
||||
$('#table-favorites').find('tbody').html(tbody);
|
||||
|
||||
359
server/scripts/rank.js
Normal file
359
server/scripts/rank.js
Normal file
@@ -0,0 +1,359 @@
|
||||
function onDetailClicked(regatta) {
|
||||
location.href = LINK_PRE + 'result?regatta=' + regatta;
|
||||
}
|
||||
|
||||
async function onRankingClicked(id) {
|
||||
var sailor = null;
|
||||
for (var i in ranking) {
|
||||
if (ranking[i].id == id) {
|
||||
sailor = ranking[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (sailor == null) return;
|
||||
|
||||
$('#menu-rank').find('.menu-title').find('p').text(sailor.name);
|
||||
if (lastRanking != null) {
|
||||
var lastRank;
|
||||
if (sailor.id in lastRanking) {
|
||||
lastRank = lastRanking[sailor.id] + '.';
|
||||
} else {
|
||||
lastRank = 'nicht in der Rangliste';
|
||||
}
|
||||
$('#menu-item-text').text('Vorheriges Jahr: ' + lastRank);
|
||||
$('#menu-item-text').show();
|
||||
} else {
|
||||
$('#menu-item-text').hide();
|
||||
}
|
||||
|
||||
list = '';
|
||||
for (var i in sailor.regattas) {
|
||||
var entry = sailor.regattas[i];
|
||||
var regatta = entry.regatta;
|
||||
var boat = await dbGetData('boats', entry.boat);
|
||||
|
||||
var dateFrom = parseDate(regatta.date);
|
||||
var dateTo = parseDate(regatta.date);
|
||||
dateTo.setDate(dateTo.getDate() + Math.max(parseInt(regatta.length) - 1, 0));
|
||||
|
||||
list += '<div onclick="onDetailClicked(' + regatta.id + ')">';
|
||||
|
||||
// ZEILE 1
|
||||
list += '<div><b>' + regatta.name + '</b></div>';
|
||||
|
||||
// ZEILE 2
|
||||
list += '<div>';
|
||||
|
||||
// DATE
|
||||
list += '<div>' + formatDate('d.m.Y', dateFrom) + ' - ' + formatDate('d.m.Y', dateTo) + '</div>';
|
||||
|
||||
// m
|
||||
list += '<div>m: ' + entry.m + '</div>';
|
||||
|
||||
// rlf
|
||||
list += '<div>RLF: ' + parseFloat(regatta.rlf).toFixed(2) + '</div>';
|
||||
|
||||
list += '</div>';
|
||||
|
||||
// ZEILE 3
|
||||
list += '<div>';
|
||||
|
||||
// Place
|
||||
list += '<div>Platz ' + entry.place + ' / ' + entry.fb + '</div>';
|
||||
|
||||
// rlp
|
||||
var color;
|
||||
if (entry.used == 0) { color = 'color-red2-dark'; }
|
||||
else if (entry.used == entry.m) { color = 'color-green2-dark'; }
|
||||
else { color = 'color-yellow2-dark'; }
|
||||
list += '<div>Punkte: ' + entry.used + ' x <b class="' + color + '">' + parseFloat(entry.rlp).toFixed(2) + '</b></div>';
|
||||
|
||||
list += '</div>';
|
||||
|
||||
// ZEILE 4
|
||||
list += '<div>';
|
||||
|
||||
// Sailnumber
|
||||
list += '<div>' + boat.sailnumber + '</div>';
|
||||
|
||||
// Boatname
|
||||
list += '<div>' + boat.name + '</div>';
|
||||
|
||||
list += '</div>';
|
||||
|
||||
// ZEILE 5...
|
||||
var crew = entry.crew.split(',');
|
||||
for (var c in crew) {
|
||||
var cr = await dbGetData('sailors', crew[c]);
|
||||
if (cr != null) {
|
||||
list += '<div>';
|
||||
|
||||
// Name
|
||||
list += '<div>' + cr.name + '</div>';
|
||||
|
||||
// Year
|
||||
list += '<div>' + ((cr.year != null) ? ('(' + cr.year + ')') : '') + '</div>';
|
||||
|
||||
list += '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
list += '</div>';
|
||||
}
|
||||
$('#div-details').html(list);
|
||||
|
||||
$('#menu-rank').showMenu();
|
||||
$('#menu-rank').scrollTop(0);
|
||||
}
|
||||
|
||||
async function selectChange(callSiteScript = true) {
|
||||
var type = $('#select-type').val();
|
||||
var year = parseInt($('#select-year').val());
|
||||
if (type == "user") {
|
||||
$('#select-year').parent().hide();
|
||||
$('#input-from').parent().show();
|
||||
$('#input-to').parent().show();
|
||||
$('#input-jugend').parent().parent().show();
|
||||
$('#input-jugstrict').parent().parent().show();
|
||||
$('#button-show').show();
|
||||
} else {
|
||||
$('#select-year').parent().show();
|
||||
$('#input-from').parent().hide();
|
||||
$('#input-to').parent().hide();
|
||||
$('#input-jugend').parent().parent().hide();
|
||||
$('#input-jugstrict').parent().parent().hide();
|
||||
$('#button-show').hide();
|
||||
|
||||
var from, to, jugend, jugstrict;
|
||||
switch (type) {
|
||||
case 'year':
|
||||
from = (year - 1) + '-12-01';
|
||||
to = year + '-11-30';
|
||||
jugend = jugstrict = false;
|
||||
break;
|
||||
case 'youth':
|
||||
from = (year - 1) + '-12-01';
|
||||
to = year + '-11-30';
|
||||
jugend = jugstrict = true;
|
||||
break;
|
||||
case 'idjm':
|
||||
var beginn = null;
|
||||
var regattas = await dbGetData('regattas');
|
||||
regattas.sort(function(a,b){ return b.date.localeCompare(a.date); });
|
||||
for (var r in regattas) {
|
||||
var regatta = regattas[r];
|
||||
var date = parseDate(regatta.date);
|
||||
if ((date < parseDate('01.01.' + year)) || (date > parseDate('31.12.' + year))) {
|
||||
continue;
|
||||
}
|
||||
if (regatta.name.indexOf(YOUTH_GERMAN_NAME) >= 0) {
|
||||
beginn = ((regatta.meldungSchluss != null) ? parseDate(regatta.meldungSchluss) : date);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (beginn != null) {
|
||||
from = new Date(beginn);
|
||||
from.setFullYear(from.getFullYear() - 1);
|
||||
from.setDate(from.getDate() - 13);
|
||||
from = formatDate('Y-m-d', from);
|
||||
to = new Date(beginn);
|
||||
to.setDate(to.getDate() - 14);
|
||||
to = formatDate('Y-m-d', to);
|
||||
jugend = true;
|
||||
jugstrict = false;
|
||||
} else {
|
||||
$('#div-rank').html('Keine ' + YOUTH_GERMAN_NAME + ' gefunden!');
|
||||
$('#input-search').parent().hide();
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$('#input-from').val(from);
|
||||
$('#input-to').val(to);
|
||||
$('#input-jugend').prop('checked', jugend);
|
||||
$('#input-jugstrict').prop('checked', jugstrict);
|
||||
|
||||
if (callSiteScript && (typeof siteScript === 'function'))
|
||||
siteScript();
|
||||
}
|
||||
}
|
||||
|
||||
function initSelects() {
|
||||
var type = findGetParameter('type');
|
||||
var year = findGetParameter('year');
|
||||
if (type === null) type = 'year';
|
||||
if (year === null) year = new Date().getFullYear();
|
||||
|
||||
$('#select-type').val(type);
|
||||
|
||||
$('#select-year').html('<option value="' + year + '">' + year + '</option>');
|
||||
$('#select-year').val(year);
|
||||
|
||||
selectChange(false);
|
||||
}
|
||||
|
||||
var firstCall = true;
|
||||
var rows = [];
|
||||
var ranking;
|
||||
var lastRanking;
|
||||
|
||||
async function drawList () {
|
||||
window.setTimeout(function () {
|
||||
var list = '';
|
||||
rows.forEach(function (entry) {
|
||||
if (entry == null) {
|
||||
list += '<div><div align="center" class="color-highlight" style="white-space:normal;"><b>Ende der Rangliste gemäß DSV-Ranglistenverordnung (min. m = 9 Wertungen)</b></div></div>';
|
||||
} else if (search($('#input-search').val(), entry.keywords)) {
|
||||
list += entry.content;
|
||||
}
|
||||
});
|
||||
$('#div-rank').html(list);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
var siteScript = async function() {
|
||||
if (firstCall) {
|
||||
firstCall = false;
|
||||
initSelects();
|
||||
$('#select-type').change(selectChange);
|
||||
$('#select-year').change(selectChange);
|
||||
$('#button-show').click(siteScript);
|
||||
$('#input-search').on('input', drawList);
|
||||
}
|
||||
|
||||
var minDate = parseDate($('#input-from').val());
|
||||
var maxDate = parseDate($('#input-to').val());
|
||||
var jugend = $('#input-jugend').prop('checked');
|
||||
var jugstrict = $('#input-jugstrict').prop('checked');
|
||||
var dbRanking = await dbGetRanking(minDate, maxDate, jugend, jugstrict);
|
||||
ranking = dbRanking[0];
|
||||
|
||||
lastRanking = null;
|
||||
if (($('#select-type').val() == 'year') || ($('#select-type').val() == 'youth')) {
|
||||
lastRanking = {};
|
||||
var lYear = parseInt($('#select-year').val()) - 1;
|
||||
var lMinDate = parseDate((lYear - 1) + '-12-01');
|
||||
var lMaxDate = parseDate(lYear + '-11-30');
|
||||
var lDbRanking = (await dbGetRanking(lMinDate, lMaxDate, jugend, jugstrict))[0];
|
||||
for (var i in lDbRanking) {
|
||||
lastRanking[lDbRanking[i].id] = lDbRanking[i].rank;
|
||||
}
|
||||
}
|
||||
|
||||
var selectedYear = $('#select-year').val();
|
||||
|
||||
var years = await dbGetData('years');
|
||||
years.sort(function (a, b) {
|
||||
if (a['year'] > b['year']) return -1;
|
||||
if (a['year'] < b['year']) return 1;
|
||||
return 0;
|
||||
});
|
||||
var options = '';
|
||||
for (id in years) {
|
||||
var year = years[id]['year'];
|
||||
options += '<option value="' + year + '">' + year + '</option>';
|
||||
}
|
||||
$('#select-year').html(options);
|
||||
$('#select-year').val(selectedYear);
|
||||
|
||||
if (dbRanking[1].length > 0) {
|
||||
$('#card-noresults').show();
|
||||
list = '';
|
||||
for (id in dbRanking[1]) {
|
||||
list += '<li>';
|
||||
list += dbRanking[1][id].name;
|
||||
list += '</li>';
|
||||
}
|
||||
$('#ul-noresults').html(list);
|
||||
} else {
|
||||
$('#card-noresults').hide();
|
||||
}
|
||||
|
||||
var count = ranking.length;
|
||||
if (count > 0) {
|
||||
$('#input-search').parent().show();
|
||||
|
||||
var dsvEnd = false;
|
||||
|
||||
rows = [];
|
||||
|
||||
for (id in ranking) {
|
||||
var entry = ranking[id];
|
||||
|
||||
for (var i in entry.regattas) {
|
||||
entry.regattas[i].regatta = await dbGetData('regattas', entry.regattas[i].regatta);
|
||||
}
|
||||
entry.regattas = Object.values(entry.regattas);
|
||||
entry.regattas.sort(function (a,b) {
|
||||
return a.regatta.date.localeCompare(b.regatta.date);
|
||||
});
|
||||
|
||||
var club = null;
|
||||
if (entry['club'] != null)
|
||||
club = await dbGetData('clubs', entry['club']);
|
||||
|
||||
var row = { keywords: [], content: '' };
|
||||
row.keywords.push(entry['name']);
|
||||
if (entry['year'] != null) row.keywords.push(entry['year']);
|
||||
if (club != null) row.keywords.push(club['kurz'], club['name']);
|
||||
|
||||
if (!dsvEnd && (entry.m < 9)) {
|
||||
rows.push(null);
|
||||
dsvEnd = true;
|
||||
}
|
||||
|
||||
row.content += '<div onclick="onRankingClicked(' + entry['id'] + ');">';
|
||||
|
||||
// ZEILE 1
|
||||
row.content += '<div>';
|
||||
|
||||
// Rank
|
||||
var icon = '';
|
||||
if (lastRanking != null) {
|
||||
if (entry.id in lastRanking) {
|
||||
if (entry.rank < lastRanking[entry.id]) { icon = 'color-green2-dark fa-caret-up'; }
|
||||
else if (entry.rank > lastRanking[entry.id]) { icon = 'color-red2-dark fa-caret-down'; }
|
||||
else { icon = 'color-yellow2-dark fa-minus'; }
|
||||
} else {
|
||||
icon = 'color-green2-dark fa-caret-up';
|
||||
}
|
||||
icon = '<i class="font-16 fas ' + icon + '" style="width: 1.1em; text-align: center;"></i> ';
|
||||
}
|
||||
row.content += '<div>' + icon + '<b>' + entry.rank + '.</b></div>';
|
||||
|
||||
// m
|
||||
row.content += '<div>m = ' + entry.m + '</div>';
|
||||
|
||||
// rlp
|
||||
row.content += '<div>' + entry.rlp.toFixed(3) + '</div>';
|
||||
|
||||
row.content += '</div>';
|
||||
|
||||
// ZEILE 2
|
||||
row.content += '<div>';
|
||||
|
||||
// Name
|
||||
row.content += '<div><b>' + entry.name + '</b></div>';
|
||||
|
||||
// Year
|
||||
row.content += '<div>' + ((entry.year != null) ? ('(' + entry.year + ')') : '') + '</div>';
|
||||
|
||||
row.content += '</div></div>';
|
||||
|
||||
rows.push(row);
|
||||
}
|
||||
|
||||
if (!dsvEnd) {
|
||||
rows.push(null);
|
||||
}
|
||||
|
||||
drawList();
|
||||
|
||||
} else {
|
||||
$('#div-rank').html('Keine Ergebnisse gefunden!');
|
||||
$('#input-search').parent().hide();
|
||||
}
|
||||
|
||||
hideLoader();
|
||||
}
|
||||
65
server/scripts/regatta_plan.js
Normal file
65
server/scripts/regatta_plan.js
Normal file
@@ -0,0 +1,65 @@
|
||||
var siteScript = async function() {
|
||||
var regattaId = findGetParameter('regatta');
|
||||
if (regattaId == null) {
|
||||
$('#h1-title').text('Regatta nicht gefunden');
|
||||
hideLoader();
|
||||
return;
|
||||
}
|
||||
var regatta = await dbGetData('regattas', regattaId);
|
||||
if (regatta == null) {
|
||||
$('#h1-title').text('Regatta nicht gefunden');
|
||||
hideLoader();
|
||||
return;
|
||||
}
|
||||
var dateFrom = parseDate(regatta['date']);
|
||||
var dateTo = parseDate(regatta['date']);
|
||||
dateTo.setDate(dateTo.getDate() + Math.max(parseInt(regatta['length']) - 1, 0));
|
||||
|
||||
$('#h1-title').text(regatta.name);
|
||||
if (regatta.length < 1) {
|
||||
if (formatDate('d.m', dateFrom) == '01.01') {
|
||||
$('#p-title').html('<font class="color-red2-dark">Datum noch unklar</font>');
|
||||
} else {
|
||||
$('#p-title').html(formatDate('d.m.Y', dateFrom) + ' - <font class="color-red2-dark">Datum nicht final</font>');
|
||||
}
|
||||
} else {
|
||||
$('#p-title').html(formatDate('d.m.Y', dateFrom) + ' - ' + formatDate('d.m.Y', dateTo));
|
||||
}
|
||||
|
||||
var plannings = await dbGetDataIndex('plannings', 'regatta', regatta.id);
|
||||
if (plannings.length > 0) {
|
||||
$('#table-plannings').show();
|
||||
$('#p-info').hide();
|
||||
var tbody = '';
|
||||
for (var p in plannings) {
|
||||
var planning = plannings[p];
|
||||
|
||||
tbody += '<tr>';
|
||||
|
||||
tbody += '<td>' + (await dbGetData('users', planning.user)).username + '</td>';
|
||||
|
||||
if (planning.steuermann != null) {
|
||||
tbody += '<td>' + (await dbGetData('sailors', planning.steuermann)).name + '</td>';
|
||||
} else {
|
||||
tbody += '<td>(noch unklar)</td>';
|
||||
}
|
||||
|
||||
var crew = [];
|
||||
var cr = planning.crew.split(',');
|
||||
for (c in cr) {
|
||||
var s = await dbGetData('sailors', cr[c]);
|
||||
if (s != null) crew.push(s.name);
|
||||
}
|
||||
tbody += '<td>' + crew.join('<br>') + '</td>';
|
||||
|
||||
tbody += '</tr>';
|
||||
}
|
||||
$('#table-plannings').find('tbody').html(tbody);
|
||||
} else {
|
||||
$('#p-info').text('Niemand plant bisher, hier hinzufahren!');
|
||||
$('#p-info').show();
|
||||
$('#table-plannings').hide();
|
||||
}
|
||||
|
||||
hideLoader();
|
||||
}
|
||||
77
server/scripts/result.js
Normal file
77
server/scripts/result.js
Normal file
@@ -0,0 +1,77 @@
|
||||
var siteScript = async function() {
|
||||
var regattaId = findGetParameter('regatta');
|
||||
if (regattaId == null) {
|
||||
$('#h1-title').text('Regatta nicht gefunden');
|
||||
hideLoader();
|
||||
return;
|
||||
}
|
||||
var regatta = await dbGetData('regattas', regattaId);
|
||||
if (regatta == null) {
|
||||
$('#h1-title').text('Regatta nicht gefunden');
|
||||
hideLoader();
|
||||
return;
|
||||
}
|
||||
var dateFrom = parseDate(regatta['date']);
|
||||
var dateTo = parseDate(regatta['date']);
|
||||
dateTo.setDate(dateTo.getDate() + Math.max(parseInt(regatta['length']) - 1, 0));
|
||||
|
||||
$('#h1-title').text(regatta.name);
|
||||
$('#p-title').text(formatDate('d.m.Y', dateFrom) + ' - ' + formatDate('d.m.Y', dateTo));
|
||||
|
||||
var results = await dbGetResultCalculated(regatta);
|
||||
if (results.length > 0) {
|
||||
var m;
|
||||
if (regatta.m > 0) {
|
||||
m = regatta.m;
|
||||
} else if (regatta.races <= 4) {
|
||||
m = regatta.races;
|
||||
} else {
|
||||
if ((regatta.length > 2) && (regatta.races >= 6)) {
|
||||
m = 5;
|
||||
} else {
|
||||
m = 4;
|
||||
}
|
||||
}
|
||||
$('#p-info').text(regatta.races + ' Wettfahrten, ' + regatta.streicher + ' Streicher, m = ' + m);
|
||||
|
||||
$('#table-results').show();
|
||||
var thead = '<tr><th>#</th><th>Boot</th><th>Crew</th><th></th>';
|
||||
for (var i = 1; i <= regatta.races; i ++) thead += '<th>WF ' + i + '</th>';
|
||||
thead += '<th></th><th>Summe</th><th>Netto</th><th>#</th><th>RLP</th></tr>';
|
||||
$('#table-results').find('thead').html(thead);
|
||||
|
||||
var tbody = '';
|
||||
for (var r in results) {
|
||||
var result = results[r];
|
||||
var boat = await dbGetData('boats', result.boat);
|
||||
var steuermann = (await dbGetData('sailors', result.steuermann)).name;
|
||||
var cr = result.crew.split(',');
|
||||
var crew = [];
|
||||
for (c in cr) {
|
||||
var s = await dbGetData('sailors', cr[c]);
|
||||
if (s != null) crew.push(s.name);
|
||||
}
|
||||
|
||||
tbody += '<tr>';
|
||||
tbody += '<td>' + result.place + '.</td>';
|
||||
tbody += '<td>' + boat.sailnumber + '<br>' + boat.name + '</td>';
|
||||
tbody += '<td>' + steuermann + '<br>' + crew.join('<br>') + '</td>';
|
||||
tbody += '<td></td>';
|
||||
for (var i = 0; i < regatta.races; i ++) {
|
||||
tbody += '<td>' + result.texts[i] + '</td>';
|
||||
}
|
||||
tbody += '<td></td>';
|
||||
tbody += '<td>' + result.brutto + '</td>';
|
||||
tbody += '<td>' + result.netto + '</td>';
|
||||
tbody += '<td>' + result.place + '.</td>';
|
||||
tbody += '<td>' + parseFloat(result.rlp).toFixed(2) + '</td>';
|
||||
tbody += '</tr>';
|
||||
}
|
||||
$('#table-results').find('tbody').html(tbody);
|
||||
} else {
|
||||
$('#p-info').text('Keine Ergebnisse gefunden.');
|
||||
$('#table-results').hide();
|
||||
}
|
||||
|
||||
hideLoader();
|
||||
}
|
||||
@@ -5,18 +5,64 @@ var page = 1;
|
||||
var pageCount = 0;
|
||||
const showCount = 25;
|
||||
|
||||
async function onEditYearClick() {
|
||||
var id = $('#button-edityear').attr('data-sailor-id');
|
||||
var year = $('#input-edityear').val();
|
||||
if (year != '') {
|
||||
showLoader();
|
||||
$.ajax({
|
||||
url: QUERY_URL + 'add_year',
|
||||
method: 'POST',
|
||||
data: {
|
||||
sailor: id,
|
||||
year: year
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
if (xhr.status == 0) {
|
||||
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um den Jahrgang zu bearbeiten');
|
||||
} else {
|
||||
console.log('EditYear: unbekannter Fehler', status, error);
|
||||
console.log(xhr);
|
||||
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
|
||||
}
|
||||
hideLoader();
|
||||
},
|
||||
success: function (data, status, xhr) {
|
||||
if ('status' in data) {
|
||||
if (data.status == 'added') {
|
||||
toastOk('Jahrgang erfolgreich hinzugefügt');
|
||||
sync();
|
||||
} else {
|
||||
toastInfo('Wir prüfen Deine Anfrage und korrigieren den Jahrgang schnellstmöglich', 5000);
|
||||
}
|
||||
} else {
|
||||
toastOk('Erfolgreich');
|
||||
}
|
||||
hideLoader();
|
||||
}
|
||||
});
|
||||
}
|
||||
$('#menu-edityear').hideMenu();
|
||||
}
|
||||
|
||||
async function onListClicked(id) {
|
||||
var sailor = await dbGetData('sailors', id);
|
||||
|
||||
$('#menu-sailor').find('.menu-title').find('p').text(sailor.name);
|
||||
|
||||
// Edit Year
|
||||
// TODO: create menu for edit year
|
||||
$('#button-edityear').attr('data-sailor-id', sailor.id);
|
||||
$('#menu-edityear').find('.menu-title').find('p').text(sailor.name);
|
||||
if (sailor['year'] == null) {
|
||||
$('#menu-item-year').find('span').text('Jahrgang hinzufügen');
|
||||
$('#menu-edityear').find('.menu-title').find('h1').text('Jahrgang hinzufügen');
|
||||
$('#input-edityear').val('');
|
||||
} else {
|
||||
$('#menu-item-year').find('span').text('Jahrgang bearbeiten');
|
||||
$('#menu-edityear').find('.menu-title').find('h1').text('Jahrgang bearbeiten');
|
||||
$('#input-edityear').val(sailor.year);
|
||||
}
|
||||
$('#input-edityear').trigger('focusin').trigger('focusout');
|
||||
|
||||
// club website
|
||||
var clubwebsite = '';
|
||||
@@ -86,6 +132,8 @@ var siteScript = async function() {
|
||||
firstCall = false;
|
||||
initPagination();
|
||||
$('#input-search').on('input', reSearch);
|
||||
$('#menu-item-year').click(function(){ $('#menu-sailor').hideMenu(); $('#menu-edityear').showMenu(); });
|
||||
$('#button-edityear').click(onEditYearClick);
|
||||
}
|
||||
|
||||
var results = await dbGetData('sailors');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<div id="$$html-id;" class="card card-style">
|
||||
<div class="content $$css-class;">
|
||||
<div id="$$html-id;" class="card card-style $$css-class;">
|
||||
<div class="content">
|
||||
$$0;
|
||||
</div>
|
||||
</div>
|
||||
5
server/templates/checkbox.html
Normal file
5
server/templates/checkbox.html
Normal file
@@ -0,0 +1,5 @@
|
||||
<div class="fac fac-checkbox fac-blue $$css-class;">
|
||||
<span></span>
|
||||
<input id="$$html-id;" type="checkbox" $$checked; />
|
||||
<label for="$$html-id;">$$placeholder;</label>
|
||||
</div>
|
||||
@@ -1,4 +1,4 @@
|
||||
<div class="input-style input-style-2 input-required">
|
||||
<div class="input-style input-style-2 input-required $$css-class;">
|
||||
<span class="color-highlight">$$placeholder;</span>
|
||||
<input id="$$html-id;" class="form-control $$css-class;" type="$$type;" placeholder="$$placeholder;" value="$$value;" />
|
||||
<input id="$$html-id;" class="form-control" type="$$type;" placeholder="$$placeholder;" value="$$value;" />
|
||||
</div>
|
||||
@@ -1,6 +1,6 @@
|
||||
<div class="input-style input-style-2 input-required">
|
||||
<div class="input-style input-style-2 input-required $$css-class;">
|
||||
<span class="color-highlight input-style-1-active">$$placeholder;</span>
|
||||
<select id="$$html-id;" class="form-control $$css-class;">
|
||||
<select id="$$html-id;" class="form-control">
|
||||
$$options;
|
||||
</select>
|
||||
</div>
|
||||
@@ -1,4 +1,4 @@
|
||||
<div class="input-style input-style-2 input-required">
|
||||
<div class="input-style input-style-2 input-required $$css-class;">
|
||||
<span class="color-highlight">$$placeholder;</span>
|
||||
<textarea id="$$html-id;" class="form-control $$css-class;" placeholder="$$placeholder;">$$value;</textarea>
|
||||
<textarea id="$$html-id;" class="form-control pt-3 pb-3" placeholder="$$placeholder;" style="height: 10em; line-height: 1.5em;">$$value;</textarea>
|
||||
</div>
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
define('PWA_VERSION', '1.3');
|
||||
define('PWA_VERSION', '1.5');
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user