diff options
author | bfabiszewski <github@ushuaia.pl> | 2013-06-23 23:43:09 +0200 |
---|---|---|
committer | bfabiszewski <github@ushuaia.pl> | 2013-06-23 23:43:09 +0200 |
commit | 6549528204f8f01bf363a26081bb1a72df2cac65 (patch) | |
tree | 3bf2f00cd8e0c88df34d00d2dbdd31a928ba27ff /main.js | |
parent | bf662e9949165d792c8d3d4fc5b6b9d1fa1e6ab6 (diff) | |
download | RunnerUpLive-6549528204f8f01bf363a26081bb1a72df2cac65.zip |
store preferences in cookies
Diffstat (limited to 'main.js')
-rwxr-xr-x | main.js | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -278,6 +278,8 @@ function setTime() { clearInterval(auto); autoReload(); } + // save current state as default + setCookie('interval',interval,30); } } @@ -326,6 +328,8 @@ function waitAndInit(api) { loadTime = 0; zoomToBounds(savedBounds); loadTrack(userid,trackid,0); + // save current api as default + setCookie('api',api,30); } function addScript(url) { @@ -346,3 +350,26 @@ function isScriptLoaded(url) { } 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(); +} |