User talk:Ilmari Karonen/liveclock.js
Legacy JavaScript
Template:JS migration
Hello! This script has been detected as using deprecated parameters that need to be replaced with the updated version. Examples include addOnloadHook( ... )
needs to be replaced with $( ... )
or $( function() { ... } )
(depending on use); all wgGlobalVariables need to be properly gotten with mw.config.get( 'wgGlobalVariable' )
; and addPortletLink
needs to be called with mw.util.addPortletLink
. Please see MW:ResourceLoader/Legacy JavaScript for details. Thank you. — {{U|Technical 13}} (e • t • c)
21:30, 19 January 2015 (UTC)
![]() | It is requested that an edit be made to the interface-protected user page at User:Ilmari Karonen/liveclock.js. (edit · history · last · links · protection log)
This template must be followed by a complete and specific description of the request, that is, specify what text should be removed and a verbatim copy of the text that should replace it. "Please change X" is not acceptable and will be rejected; the request must be of the form "please change X to Y".
The edit may be made by any interface administrator. Remember to change the |
I'm finally trying to clean up my browser developer console warnings and I happen to use this script. :-) --MZMcBride (talk) 03:38, 10 March 2016 (UTC)
- Technical 13 and MZMcBride how about moving to a page that isn't a subpage of a basically retired user? — xaosflux Talk 03:49, 10 March 2016 (UTC)
- I think Ilmari is still around-ish. Digging up the old discussion, my guess is that mw:MediaWiki:Gadget-UTCLiveClock.js is probably fine to use these days. Maybe I should just switch to that. --MZMcBride (talk) 04:07, 10 March 2016 (UTC)
The gadget kind of sucks. It unconditionally includes the seconds and it has dumb default formatting that requires more code to override. I don't really want to move this script in case people are relying on its current location. Can an admin please update the page contents with what's below? It should resolve most of the console warnings. (addOnloadHook
still needs to be addressed, but we can do that later.) Thanks! --MZMcBride (talk) 20:47, 12 March 2016 (UTC)
/* To turn on seconds display, add the following line to your monobook.js:
window.liveClockShowSeconds = true;
*/
addOnloadHook(function () {
var tabNode = mw.util.addPortletLink(
"p-personal",
mw.config.get( 'wgScript' ) + "?title=" + encodeURIComponent( mw.config.get( 'wgPageName' ) ) + "&action=purge",
"",
"utcdate"
);
var linkNode = tabNode.getElementsByTagName("a")[0];
var updateTimeSeconds = function () {
var now = new Date ();
var h = now.getUTCHours();
var m = now.getUTCMinutes();
var s = now.getUTCSeconds() + (now.getUTCMilliseconds() >= 500 ? 1 : 0);
linkNode.innerHTML = (h<10?"0":"") + h + (m<10?":0":":") + m + (s<10?":0":":") + s;
setTimeout(updateTimeSeconds, 1500 - ((now.getTime() + 500) % 1000));
};
var updateTimeMinutes = function () {
var now = new Date ();
var h = now.getUTCHours();
var m = now.getUTCMinutes() + (now.getUTCSeconds() >= 30 ? 1 : 0);
linkNode.innerHTML = (h<10?"0":"") + h + (m<10?":0":":") + m;
setTimeout(updateTimeMinutes, 90000 - ((now.getTime() + 30000) % 60000));
};
if (window.liveClockShowSeconds) updateTimeSeconds();
else updateTimeMinutes();
});