User:Connel MacKenzie/clock.js

/* User preferences clock */

insertBeforeNum = 7; insertBeforeArr = new Array("", "pt-userpage", "pt-mytalk", "pt-preferences", "pt-watchlist", "pt-mycontris", "pt-logout", ""); insertBefore = insertBeforeArr[insertBeforeNum];

function makeTime { var doTime  = ( wiktGetPrefCookie( 'WiktionaryPreferencesTime' ) ); var lastElem = document.getElementById( 'pt-logout' ) ; if ( !lastElem ) lastElem = document.getElementById( 'pt-login' ) ; if ( !doTime ) return; var li = document.createElement( 'li' ); li.id = 'pt-time'; var mySpan = document.createElement( 'span' ); mySpan.appendChild( document.createTextNode( 'date and time' ) ); li.appendChild( mySpan ); if ( insertBefore ) { var before = document.getElementById( insertBefore ); before.appendChild( li, before ); } else { // append to end (right) of list lastElem.parentNode.appendChild( li ); } getTime; }

function getTime {   var doTime  = ( wiktGetPrefCookie( 'WiktionaryPreferencesTime' ) ); var timeGMT = new Date; var time   = timeGMT.toLocaleString; if ( getCookie( 'WiktionaryPreferencesTimeUTC' ) == 'true' ) { time = timeGMT.toUTCString; }   datePlace   = document.getElementById('pt-time').childNodes[0].childNodes[0]; datePlace.replaceData(0, datePlace.length, time); if ( wiktGetPrefCookie( 'WiktionaryPreferencesTickClock' ) == "true" ) { doTime = window.setTimeout("getTime", 1000); } }

addOnloadHook( makeTime );