Created
July 26, 2012 19:27
-
-
Save gregglind/3184010 to your computer and use it in GitHub Desktop.
possible prefs setting from addon main
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const myprefs = require("simple-prefs").prefs; | |
const prefs = require("simple-prefs"); | |
const preferencesservice = require("preferences-service"); | |
var main = function(options,callback) { | |
// debug mode | |
console.log(JSON.stringify(options.staticArgs)); | |
setprefs(options.staticArgs.prefs); | |
}; | |
var setprefs = function (prefs,prefix='+') { | |
if (! prefs) {return}; | |
var n = prefix.length; | |
Object.keys(prefs).forEach( | |
function(k){ | |
let v = prefs[k]; | |
if (k.indexOf(prefix) == 0) { // | |
myprefs[k.slice(n)] = v | |
} else { // regular pref | |
preferencesservice.set(k,v); | |
} | |
} | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment