Can not make the settings from the sidebar gadget get applied

Posted by Daniel on Stack Overflow See other posts from Stack Overflow or by Daniel
Published on 2011-01-07T09:31:56Z Indexed on 2011/01/07 13:53 UTC
Read the original article Hit count: 282

Hey guys,

OK, I am not an expert at Sidebar Gadgets, but I have this project I will have to make for school. Have tried to solve it on my own but I got really stuck.

I will have to use the Cirip API (Cirip.ro being a kind of Twitter), and for the use of the API I have to input the username. I do so by means of the Settings, but when closing the settings there is no effect.

Here is the code, but it's pretty messy. I am not a web programmer so javascript/html is new to me.

http://www.box.net/shared/7yogevhzrr

Thank you for your remark, Andy.

From gadget.js

function setUserName(userNameSet){

    userName = userNameSet;
}

function getUserName(){

    return userName;
}

function settingsClosed(event)
{

    if(event.closeAction == event.Action.commit)
    {   
        var user = System.Gadget.Settings.read("userName");
    if(user != "")
    {
        setUserName(user);
    }

}

From settings.js

document.onreadystatechange = function DoInit()
{    

    if(document.readyState=="complete")
    {
        var user = System.Gadget.Settings.read("userName");

        if(user != "")
        {
            userBox.value = user;
        }       
    }        
}

// --------------------------------------------------------------------
// Handle the Settings dialog closed event.
// event = System.Gadget.Settings.ClosingEvent argument.
// --------------------------------------------------------------------



System.Gadget.onSettingsClosing = function(event)
{

    if (event.closeAction == event.Action.commit)
    {
        var user = userBox.value;
        if(user != "")
        {
              System.Gadget.Settings.write("userName", user);
        }
        event.cancel = false;
    }
}

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about html