Skip to content

Instantly share code, notes, and snippets.

@gregglind
Created July 26, 2012 19:27
Show Gist options
  • Save gregglind/3184010 to your computer and use it in GitHub Desktop.
Save gregglind/3184010 to your computer and use it in GitHub Desktop.
possible prefs setting from addon main
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