Hi
this is a part of code:
When I call linksize.saveConfig via linksize.firstTimeConfigure it
works and inserts value
but when I call it via linksize.closeConfig it doesn't update value.

var CONFIG;     // MAIN CONFIGURATION
var DONE=false; //Once RUN Flag
var CONFIG_ELEMENTS={'gray':null,'conf':null};

linksize={
        JSON :{
          encode : function(input) {
            if (!input) return null
            switch (input.constructor) {
              case String: return '"' + input + '"'
              case Number: return input.toString()
              case Array :
                var buf = []
                for (i in input)
                  buf.push(linksize.JSON.encode(input[i]))
                    return '[' + buf.join(', ') + ']'
              case Object:
                var buf = []
                for (k in input)
                    buf.push('"'+k+'"' + ' : ' + linksize.JSON.encode(input[k]))
                    return '{ ' + buf.join(', ') + '} '
              default:
                return 'null'
            }
          },
          decode : function(input){
                if (!input) return 'null';
                return eval("(" + input + ")");
          }
        },
        firstTimeConfigure : function (){
                var ftc = {
                        'extlist': new Array("rar","jpg"),
                        'exclude_domains': new 
Array("rapidshare.com","www.rapidshare.com")
                }
                linksize.saveConfig(ftc);
                return ftc;
        },
        preload : function (){
                CONFIG = linksize.loadConfig();
                if(CONFIG=='null')
                        CONFIG=linksize.firstTimeConfigure();
        },
        loadConfig : function (){
                return linksize.JSON.decode(GM_getValue("linksize_config"));
        },
        saveConfig : function (VALUES){
                if(VALUES){
                        
GM_setValue("linksize_config",linksize.JSON.encode(VALUES));
                }else{
                        
GM_setValue("linksize_config",linksize.JSON.encode(CONFIG));
                }
        },
        closeConfig:function(saveChanges){
                if(saveChanges){
        
CONFIG.extlist=document.getElementById('linksize_inc_ext').value.split(",");
        
CONFIG.exclude_domains=document.getElementById('linksize_exc_domains').value.split(",");
                        linksize.saveConfig(CONFIG);
                }
                
CONFIG_ELEMENTS.gray.parentNode.removeChild(CONFIG_ELEMENTS.gray);
                
CONFIG_ELEMENTS.conf.parentNode.removeChild(CONFIG_ELEMENTS.conf);
        }
}


On Mar 27, 2:16 am, cc <[email protected]> wrote:
> On 2010-03-26 14:00, Snigger wrote:
>
> > Hi
> > I have an object named "CONFIG"
> > And I'm trying to save the my CONFIG by encoding it into JSON
> > the first time save works but I can't update the value by:
>
> What exactly happens to let you know that it doesn't work -- do you get
> an error in Error Console? does it blank out the value of myconfig (as
> seen in about:config)? does it simply leave the value the same as before?
>
> > GM_setValue("myconfig",JSON.encode(VALUES));
>
> VALUES, or CONFIG? Make up your mind, please; if you're using both
> variables, that might be part of the problem.
>
> > What's wrong?
>
> I don't know yet -- can you post more of the code?
>
> --
> cc | pseudonymous |<http://carlclark.mp/>

-- 
You received this message because you are subscribed to the Google Groups 
"greasemonkey-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/greasemonkey-users?hl=en.

Reply via email to