Recent Widgets


Register for DashboardWidgets

Recent Forums Posts

Partners


iCompositions

MacDesktops.net

RSS Showcase
RSS Comments
RSS Forums

This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies. Posted in: Widget Central

Widget works but still get console errors

Author Message
JohnGaver



Joined: 17 May 2005
Posts: 20
Location: Texas

Posted: Thu Jun 16, 2005 - 2:24 am    Post subject: Widget works but still get console errors Reply with quote

I have a widget that does everything that I designed it to do, but it is still giving two console errors and the errors appear to be related to Apple written code. Here are the errors:

Quote:
2005-06-16 01:55:05.496 DashboardClient[373] (com.actionamerica.dashboard.WhamBamTramRamCounter) undefined: Can't find variable: timerInterval (line: 0)


Quote:
2005-06-16 01:55:05.613 DashboardClient[373] bindings/objc/WebScriptObject.mm:214:[373] JavaScript exception: Can't find variable: timerInterval


I am using timer code, exactly as written on the Apple developer site. Here it is:

Quote:
if (window.widget) {
widget.onhide = onhide;
widget.onshow = onshow;
}

function onshow() {
if (timerInterval == null) {
timerInterval = setInterval("updateTime(true);", 1000);
}
}

function onhide() {
if (timerInterval != null) {
clearInterval(timerInterval);
timerInterval = null;
}
}


Since the widget does all that I expect of it, including timed events, this is more of an aesthetics issue than a problem. I just don't like to release something that leaves a trail of errors, even if those errors don't affect the functioning of the widget.

Any ideas???
View user's profile Send private message Send e-mail Visit poster's website Widgets
Ludge



Joined: 09 May 2005
Posts: 98
Location: UK

Posted: Thu Jun 16, 2005 - 5:12 am    Post subject: Reply with quote

Before any of that code, have you declared the timerInterval variable?

If not, right at the top of your code, add the line:

Code:
var timerInterval = null


That should clear them up.
_________________
BatteryInfo widget
AdiumList widget.
View user's profile Send private message Send e-mail Visit poster's website AIM Address Widgets
JohnGaver



Joined: 17 May 2005
Posts: 20
Location: Texas

Posted: Thu Jun 16, 2005 - 4:50 pm    Post subject: Setting var timerInterval = null causes real problems Reply with quote

Thanks, Ludge.

I already tried adding that line. In fact, I added the semi-colon, too.

I tried putting it in the setup() function, as well as at the top of the file, outside of any function. Both cases actually created many console "ERRORS", as opposed to the "EXCEPTION" that I get without it.

It's strange, since the code that I am using comes directly off of the Apple Developer site.
View user's profile Send private message Send e-mail Visit poster's website Widgets
Mayhem



Joined: 18 May 2005
Posts: 63
Location: Stockholm, Sweden

Posted: Thu Jun 16, 2005 - 5:10 pm    Post subject: Reply with quote

As you intend the variable to be global it must be declared outside any function, if that doesn't work you're doing something else wrong.
_________________
Give me one more medicated peaceful moment
View user's profile Send private message Send e-mail Visit poster's website MSN MessengerWidgets
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.

 
Powered by phpBB © 2001, 2002 phpBB Group