Well, I'm not an expert at Sidebar Gadgets, but I have this project that I will have to do for school. Tried to solve it on my own, but I'm really stuck.
I will need to use the Cirip API (Cirip.ro is a kind of Twitter), and to use the API I have to enter the username. I do this using the settings, but when I close the settings, the effect does not work.
Here is the code, but it's pretty dirty. I am not a web programmer, so javascript / html is new to me.
http://www.box.net/shared/7yogevhzrr
EDIT: Okay, so I narrowed it down a bit and optimized my code here, but it still doesn't work. I made it as simple as possible.
In the main html, I have this:
<script language="javascript">
document.write(getUserName());
</script>
In the gadget.js file:
var userName;
document.onreadystatechange = function DoInit() {
document.body.style.width = 251;
document.body.style.height= 351;
document.body.style.margin=2;
userName="danieliuhasz";
System.Gadget.settingsUI = "settings.html";
System.Gadget.onSettingsClosing = settingsClosed;
}
function setUserName(userNameSet){
userName = userNameSet;
}
function getUserName(){
return userName;
}
function settingsClosed()
{
var username = System.Gadget.Settings.read("username");
setUserName(username);
}
In the settings.html file:
<body>
Username:<br />
<input name="userBox" type="text" maxlength="50" />
</body>
In settings.js:
document.onreadystatechange = function DoInit()
{
if(document.readyState=="complete")
{
var user = System.Gadget.Settings.read("userName");
if(user != "")
{
userBox.value = user;
}
}
}
System.Gadget.onSettingsClosing = function(event)
{
if (event.closeAction == event.Action.commit)
{
var username = userBox.value;
if(username != "")
{
System.Gadget.Settings.write("username", username);
System.Gadget.document.parentWindow.settingsClosed();
}
}
}
. "undefined".