I am making an extension which should take a link as the user input only once. Then the entire extension keeps using that link on various functions in the JS file. When the user changes it, the value accessed by the js file also changes accordingly. I am using the following but it does not work for me
var pref_manager = Components.classes["@mozilla.org/preferencesservice;1"].getService(Components.interfaces.nsIPrefService)
function setInstance(){
if (pref_manager.prefHasUserValue("myvar"))
{
instance = pref_manager.getString("myvar");
alert(instance);
}
if(instance == null){
instance = prompt("Please enter webcenter host and port");
// Setting the value
pref_manager.setString("myvar", instance);
}
}
instance is the global variable in which i take the user input. The alert (instance) does not show up, which means there is some problem by the way i am saving the pref or extracting it. Can someone please help me with this. I have never worked with preferences before. so even if there are minor problems i might not be able to figure out.