Revision 74120 of "MediaWiki:Gadget-UTCLiveClock.js" on viwikibooks// Gadget Horloge (heure UTC)
// Paramètre personnalisable dans le script personnel de l'utilisateur :
// clockWithSeconds = booléen indiquant si les secondes doivent être affichées :
// true : afficher les secondes (par défaut) -> HH:MM:SS
// false : ne pas afficher les secondes -> HH:MM
// addPortletLink
// -> (li)(span)(a ...)...(/a)(/span)(/li)
function liveClock()
{
if (typeof(UTCLiveClockConfig)=='undefined') UTCLiveClockConfig = {};
var portletId = UTCLiveClockConfig.portletId || 'p-personal';
var nextNode = UTCLiveClockConfig.nextNodeId ? document.getElementById(UTCLiveClockConfig.nextNodeId) : undefined;
// node : <li><span><a>...</a></span></li>
var node = addPortletLink( portletId, localurl(wgPageName,"action=purge"), '', 'utcdate', undefined, undefined, nextNode );
node.style.fontSize = 'larger';
node.style.fontWeight = 'bolder';
// liveClock.node : <a>...</a>
liveClock.node = node.firstChild.firstChild;
liveClock.withSecond = ((typeof(clockWithSeconds)=='undefined') || clockWithSeconds);
showTime();
}
addOnloadHook(liveClock);
function showTime()
{
var dateNode = liveClock.node; // <a>...</a>
if( !dateNode ) return;
var now = new Date();
if (typeof(LiveClockOffset)!='undefined') now.setTime(now.getTime()+LiveClockOffset);
var hh = now.getUTCHours();
var mm = now.getUTCMinutes();
var ss = now.getUTCSeconds();
var ms = now.getUTCMilliseconds(); // Pour ajustement de l'heure du prochain appel
var time = ( hh < 10 ? '0' + hh : hh ) + ':' + ( mm < 10 ? '0' + mm : mm );
if (liveClock.withSecond) time += ':' + ( ss < 10 ? '0' + ss : ss );
dateNode.replaceChild( document.createTextNode( time ), dateNode.firstChild );
window.setTimeout(showTime, 1100-ms); // Pour démarrer à 100 ms dans la seconde
}All content in the above text box is licensed under the Creative Commons Attribution-ShareAlike license Version 4 and was originally sourced from https://vi.wikibooks.org/w/index.php?oldid=74120.
![]() ![]() This site is not affiliated with or endorsed in any way by the Wikimedia Foundation or any of its affiliates. In fact, we fucking despise them.
|