diff --git a/css/main.css b/css/main.css index fa22c4a..4039d0e 100755 --- a/css/main.css +++ b/css/main.css @@ -164,8 +164,7 @@ select { padding-right: 20px; } #pfooter { - clear: both; - font-size: smaller; + font-size: .6rem; padding-top: 20px; } #bottom { diff --git a/js/main.js b/js/main.js index de4e18a..7a41fc9 100755 --- a/js/main.js +++ b/js/main.js @@ -190,6 +190,7 @@ function getPopupHtml(p, i, count) { '' + lang['tdistance'] + ' ' + (p.totalMeters.toKm() * factor_km).toFixed(2) + ' ' + unit_km + '
' + ''; } + olHack = (mapapi == 'openlayers') ? ' style="padding-bottom: 2rem"' : ''; popup = ''; + '
' + sprintf(lang['pointof'], i + 1, count) + '
' + + ''; return popup; } @@ -364,6 +365,7 @@ function setTime() { // dynamic change of map api var savedBounds; function loadMapAPI(api) { + mapapi = api; savedBounds = getBounds(); document.getElementById("map-canvas").innerHTML = ''; var url = new Array(); @@ -484,4 +486,15 @@ function removeOnClick(event) { if (!parent.classList.contains('dropdown')) { event.stopPropagation(); } -} \ No newline at end of file +} + +// naive approach, only %s, %d supported +function sprintf() { + var args = Array.prototype.slice.call(arguments); + var format = args.shift(); + var i = 0; + return format.replace(/%%|%s|%d/g, function(match) { + if (match == '%%') { return '%'; } + return (typeof args[i] != 'undefined') ? args[i++] : match; + }); +}; \ No newline at end of file diff --git a/lang/de.php b/lang/de.php index 70a8727..cce4f8c 100644 --- a/lang/de.php +++ b/lang/de.php @@ -35,8 +35,7 @@ $lang["altitude"] = "Höhe"; $lang["ttime"] = "Gesamte Zeit"; $lang["aspeed"] = "Durchschnittstempo"; $lang["tdistance"] = "Gesamt Entfernung"; -$lang["point"] = "Punkt"; //Punkt x von y -$lang["of"] = "von"; +$lang["pointof"] = "Punkt %d von %d"; $lang["summary"] = "Streckenzusammenfassung"; $lang["suser"] = "Wähle Benutzer"; $lang["logout"] = "Abmelden"; diff --git a/lang/en.php b/lang/en.php index 5283df5..6563bcc 100644 --- a/lang/en.php +++ b/lang/en.php @@ -37,8 +37,7 @@ $lang["altitude"] = "Altitude"; $lang["ttime"] = "Total time"; $lang["aspeed"] = "Average speed"; $lang["tdistance"] = "Total distance"; -$lang["point"] = "Point"; //Point x of y -$lang["of"] = "of"; +$lang["pointof"] = "Point %d of %d"; // e.g. Point 3 of 10 $lang["summary"] = "Trip summary"; $lang["suser"] = "select user"; $lang["logout"] = "Log out"; diff --git a/lang/es.php b/lang/es.php index 4e6dbad..360b264 100644 --- a/lang/es.php +++ b/lang/es.php @@ -35,8 +35,7 @@ $lang["altitude"] = "Altitud"; $lang["ttime"] = "Tiempo total"; $lang["aspeed"] = "Velocidad media"; $lang["tdistance"] = "Distancia total"; -$lang["point"] = "Punto"; //Point x of y -$lang["of"] = "de"; +$lang["pointof"] = "Punto %d de %d"; $lang["summary"] = "Resumen del viaje"; $lang["suser"] = "seleccione usuario"; $lang["logout"] = "Cerrar sesión"; diff --git a/lang/fr.php b/lang/fr.php index 779016a..5d0d27d 100644 --- a/lang/fr.php +++ b/lang/fr.php @@ -35,8 +35,7 @@ $lang["altitude"] = "Altitude"; $lang["ttime"] = "Temps total"; $lang["aspeed"] = "Vitesse moyenne"; $lang["tdistance"] = "Dist. totale"; -$lang["point"] = "Point"; //Point x of y -$lang["of"] = "de"; +$lang["pointof"] = "Point %d de %d"; $lang["summary"] = "Résumé du trajet"; $lang["suser"] = "Sélectionner un utilisateur"; $lang["logout"] = "Déconnexion"; diff --git a/lang/hu.php b/lang/hu.php index f3e789d..a275594 100644 --- a/lang/hu.php +++ b/lang/hu.php @@ -36,8 +36,7 @@ $lang["ttime"] = "Menetidő"; $lang["aspeed"] = "Átlagsebesség"; $lang["tdistance"] = "Megtett út"; $lang["suser"] = "Felhasználónév"; -$lang["point"] = "Rögzített pontok száma"; -$lang["of"] = "/"; +$lang["pointof"] = "Rögzített pontok száma %d / %d"; $lang["summary"] = "Utazás adatai"; $lang["logout"] = "Kilépés"; $lang["login"] = "Belépés"; diff --git a/lang/it.php b/lang/it.php index 8ad2683..776fbeb 100644 --- a/lang/it.php +++ b/lang/it.php @@ -35,8 +35,7 @@ $lang["altitude"] = "Altitudine"; $lang["ttime"] = "Tempo totale"; $lang["aspeed"] = "Velocità media"; $lang["tdistance"] = "Distanza totale"; -$lang["point"] = "Punto"; //Point x of y -$lang["of"] = "di"; +$lang["point"] = "Punto %d di %d"; $lang["summary"] = "Sommario"; $lang["suser"] = "scegli utente"; $lang["logout"] = "Esci"; diff --git a/lang/pl.php b/lang/pl.php index de0dc80..f8117e8 100644 --- a/lang/pl.php +++ b/lang/pl.php @@ -36,8 +36,7 @@ $lang["ttime"] = "Czas podróży"; $lang["aspeed"] = "Średnia prędkość"; $lang["tdistance"] = "Odległość"; $lang["suser"] = "wybierz login"; -$lang["point"] = "Punkt"; -$lang["of"] = "z"; +$lang["pointof"] = "Punkt %d z %d"; $lang["summary"] = "Podsumowanie"; $lang["logout"] = "Wyloguj"; $lang["login"] = "Zaloguj"; diff --git a/utils/download.php b/utils/download.php index 26d6ee2..b4f9772 100755 --- a/utils/download.php +++ b/utils/download.php @@ -29,9 +29,9 @@ require_once(ROOT_DIR . "/helpers/position.php"); */ function addStyle($xml, $name, $url) { $xml->startElement("Style"); - $xml->writeAttribute("id", $name."Style"); + $xml->writeAttribute("id", "{$name}Style"); $xml->startElement("IconStyle"); - $xml->writeAttribute("id", $name."Icon"); + $xml->writeAttribute("id", "{$name}Icon"); $xml->startElement("Icon"); $xml->writeElement("href", $url); $xml->endElement(); @@ -50,7 +50,7 @@ function toHMS($s) { $h = floor(($s % 86400) / 3600); $m = floor((($s % 86400) % 3600) / 60); $s = (($s % 86400) % 3600) % 60; - return (($d > 0) ? ($d." d ") : "").(substr("00".$h, -2)).":".(substr("00".$m, -2)).":".(substr("00".$s, -2)); + return (($d > 0) ? "$d d " : "") . sprintf("%02d:%02d:%02d", $h, $m, $s); } $type = isset($_REQUEST["type"]) ? $_REQUEST["type"] : "kml"; @@ -92,7 +92,7 @@ if ($trackId && $userId) { case "kml": default: header("Content-type: application/vnd.google-earth.kml+xml"); - header("Content-Disposition: attachment; filename=\"track" . $positionsArr[0]->trackId . ".kml\""); + header("Content-Disposition: attachment; filename=\"track{$positionsArr[0]->trackId}.kml\""); $xml = new XMLWriter(); $xml->openURI("php://output"); $xml->setIndent(true); @@ -128,26 +128,26 @@ if ($trackId && $userId) { if(++$i == count($positionsArr)) { $style = "#greenStyle"; } // last element $xml->startElement("Placemark"); - $xml->writeAttribute("id", "point_" . $position->id); + $xml->writeAttribute("id", "point_{$position->id}"); $description = - "
". - $lang["user"].": ".strtoupper($position->userLogin)."
".$lang["track"].": ".strtoupper($position->trackName). - "
". - "
". - "
".$lang["time"].": ".$position->time."
". - (!is_null($position->speed) ? "".$lang["speed"].": ".round($position->speed * 3.6 * $factor_kmh, 2)." ".$unit_kmh."
" : ""). - (!is_null($position->altitude) ? "".$lang["altitude"].": ".round($position->altitude * $factor_m)." ".$unit_m."
" : ""). - "".$lang["ttime"].": ".toHMS($totalSeconds)."
". - "".$lang["aspeed"].": ".(($totalSeconds != 0) ? round($totalMeters / $totalSeconds * 3.6 * $factor_kmh, 2) : 0)." ".$unit_kmh."
". - "".$lang["tdistance"].": ".round($totalMeters / 1000 * $factor_km, 2)." ".$unit_km."
"."
". - "
".$lang["point"]." ".$i." ".$lang["of"]." ".count($positionsArr)."
". + "
" . + "{$lang["user"]}: {$position->userLogin}
{$lang["track"]}: {$position->trackName}" . + "
" . + "
" . + "
{$lang["time"]}: {$position->time}
" . + (!is_null($position->speed) ? "{$lang["speed"]}: " . round($position->speed * 3.6 * $factor_kmh, 2) . " {$unit_kmh}
" : "") . + (!is_null($position->altitude) ? "{$lang["altitude"]}: " . round($position->altitude * $factor_m) . " {$unit_m}
" : "") . + "{$lang["ttime"]}: " . toHMS($totalSeconds) . "
" . + "{$lang["aspeed"]}: " . (($totalSeconds != 0) ? round($totalMeters / $totalSeconds * 3.6 * $factor_kmh, 2) : 0) . " {$unit_kmh}
" . + "{$lang["tdistance"]}: " . round($totalMeters / 1000 * $factor_km, 2) . " " . $unit_km . "
" . + "
" . sprintf($lang["pointof"], $i, count($positionsArr)) . "
" . "
"; $xml->startElement("description"); $xml->writeCData($description); $xml->endElement(); $xml->writeElement("styleUrl", $style); $xml->startElement("Point"); - $coordinate[$i] = $position->longitude.",".$position->latitude.(!is_null($position->altitude) ? ",".$position->altitude : ""); + $coordinate[$i] = "{$position->longitude},{$position->latitude}" . (!is_null($position->altitude) ? ",{$position->altitude}" : ""); $xml->writeElement("coordinates", $coordinate[$i]); $xml->endElement(); $xml->endElement(); @@ -206,14 +206,13 @@ if ($trackId && $userId) { $xml->writeElement("name", ++$i); $xml->startElement("desc"); $description = - $lang["user"].": ".strtoupper($position->userLogin)." ".$lang["track"].": ".strtoupper($position->trackName). - " ".$lang["time"].": ".$position->time. - (!is_null($position->speed) ? " ".$lang["speed"].": ".round($position->speed * 3.6 * $factor_kmh, 2)." ".$unit_kmh : ""). - (!is_null($position->altitude) ? " ".$lang["altitude"].": ".round($position->altitude * $factor_m)." ".$unit_m : ""). - " ".$lang["ttime"].": ".toHMS($totalSeconds)."". - " ".$lang["aspeed"].": ".(($totalSeconds != 0) ? round($totalMeters / $totalSeconds * 3.6 * $factor_kmh, 2) : 0)." ".$unit_kmh. - " ".$lang["tdistance"].": ".round($totalMeters / 1000 * $factor_km, 2)." ".$unit_km. - " ".$lang["point"]." ".$i." ".$lang["of"]." ".count($positionsArr); + "{$lang["user"]}: {$position->userLogin} {$lang["track"]}: {$position->trackName} {$lang["time"]}: {$position->time}" . + (!is_null($position->speed) ? " {$lang["speed"]}: " . round($position->speed * 3.6 * $factor_kmh, 2) . " {$unit_kmh}" : "") . + (!is_null($position->altitude) ? " {$lang["altitude"]}: " . round($position->altitude * $factor_m) . " {$unit_m}" : "") . + " {$lang["ttime"]}: " . toHMS($totalSeconds) . + " {$lang["aspeed"]}: " . (($totalSeconds != 0) ? round($totalMeters / $totalSeconds * 3.6 * $factor_kmh, 2) : 0) . " {$unit_kmh}" . + " {$lang["tdistance"]}: " . round($totalMeters / 1000 * $factor_km, 2) . " {$unit_km}" . + " " . sprintf($lang["pointof"], $i, count($positionsArr)); $xml->writeCData($description); $xml->endElement(); $xml->endElement();