From 7f1170187cc918b1b4f04e49a0d9961e4b4b50ba Mon Sep 17 00:00:00 2001 From: Bartek Fabiszewski Date: Sat, 13 Apr 2019 19:45:51 +0200 Subject: [PATCH] reorganize, document, clean javascript code --- css/main.css | 21 +- helpers/auth.php | 4 +- helpers/config.php | 97 ++- index.php | 144 ++-- js/admin.js | 206 ++--- js/api_gmaps.js | 432 ++++++---- js/api_openlayers.js | 815 ++++++++++--------- js/main.js | 1774 +++++++++++++++++++++++++++--------------- js/pass.js | 109 ++- js/track.js | 161 ++-- js/typedefs.js | 60 ++ 11 files changed, 2328 insertions(+), 1495 deletions(-) create mode 100644 js/typedefs.js diff --git a/css/main.css b/css/main.css index 4e5563c..1bf4b7f 100644 --- a/css/main.css +++ b/css/main.css @@ -28,6 +28,7 @@ body { a { color: #bce; text-decoration: none; + cursor: pointer; } :link, :visited { color: #bce; @@ -105,9 +106,19 @@ select { border-radius: 11px 0 0 11px; cursor: pointer; } - -#user, #track, #summary, #export, #import, #other, #units { +label[for=user] { + padding-top: 1em; + display: block; +} +.section { padding-bottom: 10px; + display: block; +} +.section:first-child { + padding-top: 1em; +} +#inputFile { + display: none; } #summary div { padding-top: .3em; @@ -190,16 +201,14 @@ select { background-color: white; opacity: 0.8; } -#close { +#chart_close { position: fixed; bottom: 175px; right: 175px; z-index: 10001; font-size: 0.8em; -} - -#close a, #close:link, #close:visited { color: #5070af; + cursor: pointer; } .mi { diff --git a/helpers/auth.php b/helpers/auth.php index 056fac4..68920cb 100644 --- a/helpers/auth.php +++ b/helpers/auth.php @@ -27,7 +27,9 @@ */ class uAuth { + /** @var bool Is user authenticated */ private $isAuthenticated = false; + /** @var uUser|null User */ public $user = null; public function __construct() { @@ -107,7 +109,7 @@ /** * Process log in request * - * @return void + * @return boolean */ public function checkLogin($login, $pass) { if (!is_null($login) && !is_null($pass)) { diff --git a/helpers/config.php b/helpers/config.php index 553b2ad..58733d2 100644 --- a/helpers/config.php +++ b/helpers/config.php @@ -27,59 +27,108 @@ * Handles config values */ class uConfig { - // version number + /** + * @var string Version number + */ static $version = "1.0-beta"; - // default map drawing framework + /** + * @var string Default map drawing framework + */ static $mapapi = "openlayers"; - // gmaps key + /** + * @var string|null Google maps key + */ static $gkey = null; - // openlayers additional map layers + /** + * @var array Openlayers additional map layers + */ static $ol_layers = []; - // default coordinates for initial map + /** + * @var float Default latitude for initial map + */ static $init_latitude = 52.23; + /** + * @var float Default longitude for initial map + */ static $init_longitude = 21.01; - // MySQL config - static $dbdsn = ""; // database dsn - static $dbuser = ""; // database user - static $dbpass = ""; // database pass - static $dbprefix = ""; // optional table names prefix, eg. "ulogger_" + /** + * @var string Database dsn + */ + static $dbdsn = ""; + /** + * @var string Database user + */ + static $dbuser = ""; + /** + * @var string Database pass + */ + static $dbpass = ""; + /** + * @var string Optional table names prefix, eg. "ulogger_" + */ + static $dbprefix = ""; - // require login/password authentication + /** + * @var bool Require login/password authentication + */ static $require_authentication = true; - // all users tracks are visible to authenticated user + /** + * @var bool All users tracks are visible to authenticated user + */ static $public_tracks = false; - // admin user who has access to all users locations - // none if empty + /** + * @var string Admin user who has access to all users locations + * none if empty + */ static $admin_user = ""; - // miniumum required length of user password + /** + * @var int Miniumum required length of user password + */ static $pass_lenmin = 12; - // required strength of user password - // 0 = no requirements, - // 1 = require mixed case letters (lower and upper), - // 2 = require mixed case and numbers - // 3 = require mixed case, numbers and non-alphanumeric characters + /** + * @var int Required strength of user password + * 0 = no requirements, + * 1 = require mixed case letters (lower and upper), + * 2 = require mixed case and numbers + * 3 = require mixed case, numbers and non-alphanumeric characters + */ static $pass_strength = 2; - // Default interval in seconds for live auto reload + /** + * @var int Default interval in seconds for live auto reload + */ static $interval = 10; - // Default language + /** + * @var string Default language code + */ static $lang = "en"; - // units + /** + * @var string Default units + */ static $units = "metric"; + /** + * @var int Stroke weight + */ static $strokeWeight = 2; + /** + * @var string Stroke color + */ static $strokeColor = '#ff0000'; + /** + * @var int Stroke opacity + */ static $strokeOpacity = 1; private static $fileLoaded = false; @@ -109,7 +158,7 @@ include_once($configFile); if (isset($mapapi)) { self::$mapapi = $mapapi; } - if (isset($gkey)) { self::$gkey = $gkey; } + if (isset($gkey) && !empty($gkey)) { self::$gkey = $gkey; } if (isset($ol_layers)) { self::$ol_layers = $ol_layers; } if (isset($init_latitude)) { self::$init_latitude = $init_latitude; } if (isset($init_longitude)) { self::$init_longitude = $init_longitude; } diff --git a/index.php b/index.php index 8f135ef..c26a2c0 100644 --- a/index.php +++ b/index.php @@ -73,51 +73,79 @@ ?> - + <?= $lang["title"] ?> - + isAdmin()): ?> - + isAuthenticated()): ?> - + - - - + + + + - +