Fix defaulting of prefs
This commit is contained in:
		
							parent
							
								
									4dca2e8e33
								
							
						
					
					
						commit
						a6616e5637
					
				
							
								
								
									
										4
									
								
								edit.js
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								edit.js
									
									
									
									
									
								
							|  | @ -19,7 +19,7 @@ function setupCodeMirror(textarea) { | |||
| 		mode: 'css', | ||||
| 		lineNumbers: true, | ||||
| 		lineWrapping: true, | ||||
| 		smartIndent: localStorage["smart-indent"] == null || localStorage["smart-indent"] == "true" | ||||
| 		smartIndent: (typeof localStorage["smart-indent"] == "undefined") || localStorage["smart-indent"] == "true" | ||||
| 	}); | ||||
| 	editors.push(cm); | ||||
| } | ||||
|  | @ -125,7 +125,7 @@ window.addEventListener("load", init, false); | |||
| 
 | ||||
| function init() { | ||||
| 	tE("sections-help", "helpAlt", "alt"); | ||||
| 	loadPrefs(["smart-indent"]); | ||||
| 	loadPrefs({"smart-indent": "true"}); | ||||
| 	var params = getParams(); | ||||
| 	if (!params.id) { // match should be 2 - one for the whole thing, one for the parentheses
 | ||||
| 		// This is an add
 | ||||
|  |  | |||
|  | @ -15,7 +15,7 @@ function showStyles(styles) { | |||
| 	styles.map(createStyleElement).forEach(function(e) { | ||||
| 		installed.appendChild(e); | ||||
| 	}); | ||||
| 	loadPrefs(["show-badge"]); | ||||
| 	loadPrefs({"show-badge": "true"}); | ||||
| } | ||||
| 
 | ||||
| function createStyleElement(style) { | ||||
|  |  | |||
|  | @ -153,9 +153,10 @@ function changePref(event) { | |||
| 	notifyAllTabs({method: "prefChanged", prefName: el.id, value: value}); | ||||
| } | ||||
| 
 | ||||
| function loadPrefs(prefNames) { | ||||
| 	prefNames.forEach(function(id) { | ||||
| 		var value = localStorage[id]; | ||||
| // Accepts a hash of pref name to default value
 | ||||
| function loadPrefs(prefs) { | ||||
| 	for (var id in prefs) { | ||||
| 		var value = typeof localStorage[id] == "undefined" ? prefs[id] : localStorage[id]; | ||||
| 		var el = document.getElementById(id); | ||||
| 		if (isCheckbox(el)) { | ||||
| 			if (value == "true") { | ||||
|  | @ -165,5 +166,5 @@ function loadPrefs(prefNames) { | |||
| 			el.value = value; | ||||
| 		} | ||||
| 		el.addEventListener("change", changePref); | ||||
| 	}); | ||||
| 	} | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user