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.

It works, thx a lot for the info. Btw your sign, do you known what css or js is required to round those borders off?--Jens Ingels (talk) 18:09, July 31, 2012 (UTC)


 * Use the border-radius property for rounded corners. You should also consider using -moz-border-radius and -webkit-border-radius for outdated browsers. My signature code is at User:Mathmagician/sig, it uses


 * Try using an anonymous function, like this:

Sam Wang 19:05, July 31, 2012 (UTC)

Will this code that above is used speedup the loading time? And thx for the info on the borders.--Jens Ingels (talk) 21:51, July 31, 2012 (UTC)


 * Sam's code won't speed up the loading time, no. It's just a formatting thing, that's all. When writing code, there's plenty of different ways to effectively do the same thing. The code you currently have is perfectly reasonable. It's not "slow" or "ugly" by any means, and I see no real need to change it further at this point (personal opinion).

Thx again for all info, I also didn't known that wikia supported css on that level. I already test things with inner glow, shadows, border and gradient. It just works all.--Jens Ingels (talk) 23:15, July 31, 2012 (UTC)