From ae9e33a21dcde54c1b693f3412bde1abd60ca56a Mon Sep 17 00:00:00 2001 From: Robert Kaiser Date: Fri, 1 May 2015 02:22:06 +0200 Subject: [PATCH] remember active map style across sessions --- js/map.js | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/js/map.js b/js/map.js index 490bfac..10e7d46 100644 --- a/js/map.js +++ b/js/map.js @@ -172,6 +172,15 @@ function loadPrefs(aEvent) { gAction.removeEventListener(aEvent.type, loadPrefs, false); gAction.addEventListener("prefs-step", loadPrefs, false); gWaitCounter++; + gPrefs.get("active_map_style", function(aValue) { + if (aValue && gMapStyles[aValue]) { + gMap.activeMap = aValue; + } + gWaitCounter--; + var throwEv = new CustomEvent("prefs-step"); + gAction.dispatchEvent(throwEv); + }); + gWaitCounter++; gPrefs.get("position", function(aValue) { if (aValue && aValue.x && aValue.y && aValue.z) { gMap.pos = aValue; @@ -182,10 +191,12 @@ function loadPrefs(aEvent) { }); gWaitCounter++; gPrefs.get("center_map", function(aValue) { - if (aValue === undefined) + if (aValue === undefined) { document.getElementById("centerCheckbox").checked = true; - else + } + else { document.getElementById("centerCheckbox").checked = aValue; + } setCentering(document.getElementById("centerCheckbox")); gWaitCounter--; var throwEv = new CustomEvent("prefs-step"); @@ -193,10 +204,12 @@ function loadPrefs(aEvent) { }); gWaitCounter++; gPrefs.get("tracking_enabled", function(aValue) { - if (aValue === undefined) + if (aValue === undefined) { document.getElementById("trackCheckbox").checked = true; - else + } + else { document.getElementById("trackCheckbox").checked = aValue; + } gWaitCounter--; var throwEv = new CustomEvent("prefs-step"); gAction.dispatchEvent(throwEv); @@ -617,8 +630,9 @@ function xy2gps(aX, aY) { function setMapStyle() { var mapSel = document.getElementById("mapSelector"); - if (mapSel.selectedIndex >= 0 && gMap.activeMap != mapSel.value) { + if (!gWaitCounter && mapSel.selectedIndex >= 0 && gMap.activeMap != mapSel.value) { gMap.activeMap = mapSel.value; + gPrefs.set("active_map_style", gMap.activeMap); document.getElementById("copyright").innerHTML = gMapStyles[gMap.activeMap].copyright; showUI(); -- 2.43.0