User:Johnny Jupiter/monobook.js

From Homestar Runner Wiki

< User:Johnny Jupiter(Difference between revisions)
Jump to: navigation, search
 
Line 3: Line 3:
   var hours = time.getUTCHours();
   var hours = time.getUTCHours();
   var hours = hours - 6
   var hours = hours - 6
 +
  if (hours < 0) { hours = hours + 24; }
   if (hours < 10) { hours = "0" + hours; }
   if (hours < 10) { hours = "0" + hours; }
   var minutes = time.getUTCMinutes();
   var minutes = time.getUTCMinutes();

Current revision as of 01:19, 21 January 2011

function getTime() {
  var time = new Date();
  var hours = time.getUTCHours();
  var hours = hours - 6
  if (hours < 0) { hours = hours + 24; }
  if (hours < 10) { hours = "0" + hours; }
  var minutes = time.getUTCMinutes();
  if (minutes < 10) { minutes = "0" + minutes; }
  var seconds = time.getUTCSeconds();
  if (seconds < 10) { seconds = "0" + seconds; }
  var currentTime = hours + ":" + minutes + ":" + seconds;
  document.getElementById('pt-time').childNodes[0].childNodes[0].replaceData(0, 8, currentTime);
  doTime = window.setTimeout("getTime()", 1000);
}
function makeTime() {
  var div = document.createElement( 'div' );
  div.id = 'pt-time';
  var mySpan = document.createElement( 'span' );
  mySpan.appendChild( document.createTextNode( '00:00:00 CST' ) );
  div.appendChild( mySpan );
  document.getElementById( 'globalWrapper' ).parentNode.appendChild( div );
  doTime = window.setTimeout("getTime()", 1000);
}
if (window.addEventListener) window.addEventListener ('load', makeTime, false);
else if (window.attachEvent) window.attachEvent ('onload', makeTime);
Personal tools