store preferences in cookies
This commit is contained in:
parent
bf662e9949
commit
6549528204
@ -65,13 +65,21 @@ function init() {
|
|||||||
'http://b.osm.trail.pl/osmapa.pl/${z}/${x}/${y}.png',
|
'http://b.osm.trail.pl/osmapa.pl/${z}/${x}/${y}.png',
|
||||||
'http://c.osm.trail.pl/osmapa.pl/${z}/${x}/${y}.png']);
|
'http://c.osm.trail.pl/osmapa.pl/${z}/${x}/${y}.png']);
|
||||||
map.addLayer(osmapa);
|
map.addLayer(osmapa);
|
||||||
|
}
|
||||||
|
if (layer_ump==1) {
|
||||||
|
// UMP
|
||||||
|
var ump = new OpenLayers.Layer.OSM('UMP',
|
||||||
|
['http://1.tiles.ump.waw.pl/ump_tiles/${z}/${x}/${y}.png',
|
||||||
|
'http://2.tiles.ump.waw.pl/ump_tiles/${z}/${x}/${y}.png',
|
||||||
|
'http://3.tiles.ump.waw.pl/ump_tiles/${z}/${x}/${y}.png']);
|
||||||
|
map.addLayer(ump);
|
||||||
}
|
}
|
||||||
var position = new OpenLayers.LonLat(21.01,52.23).transform(wgs84, mercator);
|
var position = new OpenLayers.LonLat(21.01,52.23).transform(wgs84, mercator);
|
||||||
var zoom = 8;
|
var zoom = 8;
|
||||||
map.setCenter(position, zoom);
|
map.setCenter(position, zoom);
|
||||||
// init layers
|
// init layers
|
||||||
layerTrack = new OpenLayers.Layer.Vector( 'Track' );
|
layerTrack = new OpenLayers.Layer.Vector('Track');
|
||||||
layerMarkers = new OpenLayers.Layer.Markers( 'Markers' );
|
layerMarkers = new OpenLayers.Layer.Markers('Markers');
|
||||||
}
|
}
|
||||||
function displayTrack(xml,update) {
|
function displayTrack(xml,update) {
|
||||||
altitudes.length = 0;
|
altitudes.length = 0;
|
||||||
@ -167,8 +175,8 @@ function setMarker(p,i,posLen) {
|
|||||||
return function() {
|
return function() {
|
||||||
// remove popups
|
// remove popups
|
||||||
if (map.popups.length>0) {
|
if (map.popups.length>0) {
|
||||||
for (var i = map.popups.length-1; i>=0; i-- ) {
|
for (var j = map.popups.length-1; j>=0; j-- ) {
|
||||||
map.removePopup(map.popups[i])
|
map.removePopup(map.popups[j])
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// show popup
|
// show popup
|
||||||
|
5
auth.php
5
auth.php
@ -18,6 +18,11 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
require_once("config.php");
|
require_once("config.php");
|
||||||
|
// if is set cookie overwrite config value
|
||||||
|
if (isset($_COOKIE["phpTrackme_api"])) { $mapapi = $_COOKIE["phpTrackme_api"]; }
|
||||||
|
if (isset($_COOKIE["phpTrackme_lang"])) { $lang = $_COOKIE["phpTrackme_lang"]; }
|
||||||
|
if (isset($_COOKIE["phpTrackme_units"])) { $units = $_COOKIE["phpTrackme_units"]; }
|
||||||
|
if (isset($_COOKIE["phpTrackme_interval"])) { $interval = $_COOKIE["phpTrackme_interval"]; }
|
||||||
require_once("lang.php");
|
require_once("lang.php");
|
||||||
$mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
|
$mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
|
||||||
if ($mysqli->connect_errno) {
|
if ($mysqli->connect_errno) {
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
* License along with this program; if not, write to the Free Software
|
* License along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
$version = "2.1";
|
$version = "2.2";
|
||||||
|
|
||||||
// default map drawing framework
|
// default map drawing framework
|
||||||
// (gmaps = google maps, openlayers = openlayers/osm)
|
// (gmaps = google maps, openlayers = openlayers/osm)
|
||||||
@ -31,6 +31,8 @@ $layer_ocm = 1;
|
|||||||
$layer_mq = 1;
|
$layer_mq = 1;
|
||||||
// osmapa.pl (0 = no, 1 = yes)
|
// osmapa.pl (0 = no, 1 = yes)
|
||||||
$layer_osmapa = 1;
|
$layer_osmapa = 1;
|
||||||
|
// UMP (0 = no, 1 = yes)
|
||||||
|
$layer_ump = 1;
|
||||||
|
|
||||||
// you may set your google maps api key
|
// you may set your google maps api key
|
||||||
// this is not obligatory by now
|
// this is not obligatory by now
|
||||||
|
33
index.php
33
index.php
@ -71,13 +71,35 @@ $track_form .= '
|
|||||||
$api_form = '
|
$api_form = '
|
||||||
<u>'.$lang_api.'</u><br />
|
<u>'.$lang_api.'</u><br />
|
||||||
<form>
|
<form>
|
||||||
<select name="track" onchange="loadMapAPI(this.options[this.selectedIndex].value);">
|
<select name="api" onchange="loadMapAPI(this.options[this.selectedIndex].value);">
|
||||||
<option value="gmaps"'.(($mapapi=="gmaps")?' selected':'').'>Google Maps</option>
|
<option value="gmaps"'.(($mapapi=="gmaps")?' selected':'').'>Google Maps</option>
|
||||||
<option value="openlayers"'.(($mapapi=="openlayers")?' selected':'').'>OpenLayers</option>
|
<option value="openlayers"'.(($mapapi=="openlayers")?' selected':'').'>OpenLayers</option>
|
||||||
</select>
|
</select>
|
||||||
</form>
|
</form>
|
||||||
';
|
';
|
||||||
|
|
||||||
|
// language select form
|
||||||
|
$lang_form = '
|
||||||
|
<u>'.$lang_language.'</u><br />
|
||||||
|
<form>
|
||||||
|
<select name="units" onchange="setLang(this.options[this.selectedIndex].value);">
|
||||||
|
<option value="en"'.(($lang=="en")?' selected':'').'>English</option>
|
||||||
|
<option value="pl"'.(($lang=="pl")?' selected':'').'>Polski</option>
|
||||||
|
<option value="de"'.(($lang=="de")?' selected':'').'>Deutsch</option>
|
||||||
|
</select>
|
||||||
|
</form>
|
||||||
|
';
|
||||||
|
// units select form
|
||||||
|
$units_form = '
|
||||||
|
<u>'.$lang_units.'</u><br />
|
||||||
|
<form>
|
||||||
|
<select name="units" onchange="setUnits(this.options[this.selectedIndex].value);">
|
||||||
|
<option value="metric"'.(($units=="metric")?' selected':'').'>'.$lang_metric.'</option>
|
||||||
|
<option value="imperial"'.(($units=="imperial")?' selected':'').'>'.$lang_imperial.'</option>
|
||||||
|
</select>
|
||||||
|
</form>
|
||||||
|
';
|
||||||
|
|
||||||
print
|
print
|
||||||
'<!DOCTYPE html>
|
'<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
@ -109,6 +131,7 @@ print
|
|||||||
var layer_ocm = "'.$layer_ocm.'";
|
var layer_ocm = "'.$layer_ocm.'";
|
||||||
var layer_mq = "'.$layer_mq.'";
|
var layer_mq = "'.$layer_mq.'";
|
||||||
var layer_osmapa = "'.$layer_osmapa.'";
|
var layer_osmapa = "'.$layer_osmapa.'";
|
||||||
|
var layer_ump = "'.$layer_ump.'";
|
||||||
</script>
|
</script>
|
||||||
<script type="text/javascript" src="main.js"></script>
|
<script type="text/javascript" src="main.js"></script>
|
||||||
';
|
';
|
||||||
@ -149,8 +172,14 @@ print '
|
|||||||
<div id="api">
|
<div id="api">
|
||||||
'.$api_form.'
|
'.$api_form.'
|
||||||
</div>
|
</div>
|
||||||
|
<div id="lang">
|
||||||
|
'.$lang_form.'
|
||||||
|
</div>
|
||||||
|
<div id="units">
|
||||||
|
'.$units_form.'
|
||||||
|
</div>
|
||||||
<div id="export">
|
<div id="export">
|
||||||
<u>'.$lang_download.'</u><br />
|
<u>'.$lang_download.'</u><br />
|
||||||
<a href="javascript:void(0);" onclick="load(\'kml\',userid,trackid)">kml</a><br />
|
<a href="javascript:void(0);" onclick="load(\'kml\',userid,trackid)">kml</a><br />
|
||||||
<a href="javascript:void(0);" onclick="load(\'gpx\',userid,trackid)">gpx</a><br />
|
<a href="javascript:void(0);" onclick="load(\'gpx\',userid,trackid)">gpx</a><br />
|
||||||
</div>
|
</div>
|
||||||
|
12
lang.php
12
lang.php
@ -48,6 +48,10 @@ switch($lang) {
|
|||||||
$lang_language = "Language";
|
$lang_language = "Language";
|
||||||
$lang_newinterval = "Enter new interval value (seconds)";
|
$lang_newinterval = "Enter new interval value (seconds)";
|
||||||
$lang_api = "Map API";
|
$lang_api = "Map API";
|
||||||
|
$lang_language = "Language";
|
||||||
|
$lang_units = "Units";
|
||||||
|
$lang_metric = "Metric";
|
||||||
|
$lang_imperial = "Imperial/US";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "pl":
|
case "pl":
|
||||||
@ -79,6 +83,10 @@ switch($lang) {
|
|||||||
$lang_language = "Język";
|
$lang_language = "Język";
|
||||||
$lang_newinterval = "Podaj częstotliwość odświeżania (w sekundach)";
|
$lang_newinterval = "Podaj częstotliwość odświeżania (w sekundach)";
|
||||||
$lang_api = "Map API";
|
$lang_api = "Map API";
|
||||||
|
$lang_language = "Język";
|
||||||
|
$lang_units = "Jednostki";
|
||||||
|
$lang_metric = "Metryczne";
|
||||||
|
$lang_imperial = "Anglosaskie";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "de":
|
case "de":
|
||||||
@ -110,6 +118,10 @@ switch($lang) {
|
|||||||
$lang_language = "Sprache";
|
$lang_language = "Sprache";
|
||||||
$lang_newinterval = "Neuen Intervall-Wert eingeben (in Sekunden)";
|
$lang_newinterval = "Neuen Intervall-Wert eingeben (in Sekunden)";
|
||||||
$lang_api = "Karten API";
|
$lang_api = "Karten API";
|
||||||
|
$lang_language = "Sprache";
|
||||||
|
$lang_units = "Maßsystem";
|
||||||
|
$lang_metric = "Metrisches";
|
||||||
|
$lang_imperial = "Angloamerikanisches";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
2
main.css
2
main.css
@ -81,7 +81,7 @@ select {
|
|||||||
background-color: #666;
|
background-color: #666;
|
||||||
color: lightgray;
|
color: lightgray;
|
||||||
}
|
}
|
||||||
#user, #trip, #summary, #export, #other, #api {
|
#user, #trip, #summary, #export, #other, #units {
|
||||||
padding-bottom: 10px;
|
padding-bottom: 10px;
|
||||||
}
|
}
|
||||||
#login {
|
#login {
|
||||||
|
27
main.js
27
main.js
@ -278,6 +278,8 @@ function setTime() {
|
|||||||
clearInterval(auto);
|
clearInterval(auto);
|
||||||
autoReload();
|
autoReload();
|
||||||
}
|
}
|
||||||
|
// save current state as default
|
||||||
|
setCookie('interval',interval,30);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,6 +328,8 @@ function waitAndInit(api) {
|
|||||||
loadTime = 0;
|
loadTime = 0;
|
||||||
zoomToBounds(savedBounds);
|
zoomToBounds(savedBounds);
|
||||||
loadTrack(userid,trackid,0);
|
loadTrack(userid,trackid,0);
|
||||||
|
// save current api as default
|
||||||
|
setCookie('api',api,30);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addScript(url) {
|
function addScript(url) {
|
||||||
@ -346,3 +350,26 @@ function isScriptLoaded(url) {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setCookie(name,value,days) {
|
||||||
|
if (days) {
|
||||||
|
var date = new Date();
|
||||||
|
date.setTime(date.getTime()+(days*24*60*60*1000));
|
||||||
|
var expires = '; expires='+date.toGMTString();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var expires = '';
|
||||||
|
}
|
||||||
|
document.cookie = 'phpTrackme_'+name+'='+value+expires+'; path=/';
|
||||||
|
}
|
||||||
|
|
||||||
|
function setLang(lang) {
|
||||||
|
setCookie('lang',lang,30);
|
||||||
|
location.reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
function setUnits(unit) {
|
||||||
|
units = unit;
|
||||||
|
setCookie('units',unit,30);
|
||||||
|
location.reload();
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user