Difference between revisions 74120 and 74121 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 liveClock.node = addPortletLink( 'p-personal', wgServer + wgScriptPath + '/index.php?title=' + encodeURIComponent(wgPageName) + '&action=purge', '', 'utcdate' ); liveClock.node.style.fontSize = 'larger'; liveClock.node.style.fontWeight = 'bolder'; showTime(); } addOnloadHook(liveClock) function showTime() { var dateNode = liveClock.node; if( !dateNode ) { return; } var now = new Date(); var hh = now.getUTCHours(); var mm = now.getUTCMinutes(); var ss = now.getUTCSeconds(); var time = ( hh < 10 ? '0' + hh : hh ) + ':' + ( mm < 10 ? '0' + mm : mm ) + ':' + ( ss < 10 ? '0' + ss : ss ); dateNode.firstChild.replaceChild( document.createTextNode( time ), dateNode.firstChild.firstChild ); window.setTimeout(showTime, 1000); } 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?diff=prev&oldid=74121.
![]() ![]() 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.
|