Forum:Clock extension question (how to add an if user-logged in)

Hi, I'm back with another problem. This time it goes about an clock that I replaced inside the navbar above. But there's an problem. I want that the clock only show up when your logged in but the code doesn't seem to work. I probaly did something totaly wrong. Does someone knowns an fix? Here's the page of the problem:.

The bug is probably with the if inside an if code:

--Jens Ingels (talk) 12:49, July 30, 2012 (UTC)

To make it only show for logged-in users, replace the line that says $( liveClock ); with if (wgUserName) { $( liveClock ); }

Also, I recommend moving the "showTime" function to the top of the script. The reason is because it's called by "liveClock", but it's not defined until after it's called. This is potentially a problem in JavaScript because the function could be called before it's defined, in which case that would generate an error.