Difference between revisions of "User:Smashman/vector.js"

From Team Fortress Wiki
Jump to: navigation, search
(Update that thingy I had that went all old and stuff and stopped working)
 
Line 1: Line 1:
/** additional monobook scripts **/
+
mediaWiki.loader.using('mediawiki.util', function() {
hookEvent( 'load', displayTimer );
+
"use strict";
 
+
jQuery(function($) {
/**** function displayTimer.js
+
    // Double run protection.
* by Patrick Westerhoff [poke]
+
    if ($('#displayTimer, #showdate, #DisplayClockJS').length) return;
*/
+
function displayTimer ()
+
    var $parent = $('<span id="showdate" />'),
{
+
        $node = $('<a title="Purge the server cache and update the contents of this page." href="' + mediaWiki.util.wikiGetlink() + '?action=purge" />')
  if ( typeof( timerDisplay ) !== 'undefined' && timerDisplay === false )
+
          .appendTo($('<span style="font-weight: bold; text-transform: none;" />')
    return;
+
              .appendTo($parent)
 
+
          );
  var date;
+
    function updateDate() {
  var timerParent = document.getElementById( 'p-personal' ).getElementsByTagName( 'ul' )[0];
+
        $node.text(new Date().toUTCString().replace("GMT", "(UTC)").substr(5));
  var timerLink  = document.createElement( 'a' );
+
    }
  var timerObj    = document.createElement( 'li' );
+
  timerLink.href              = '/wiki/' + wgPageName + '?action=purge';
+
     if (mediaWiki.config.get('skin') === 'oasis') {
  timerLink.title             = 'Purge the server cache and update the contents of this page.'
+
        $('<li id="displayTimer" />').css('fontSize',  "12px").append($parent).appendTo('#GlobalNavigation');
  timerObj.id                  = 'pt-timer';
+
    } else {
  timerObj.style.textTransform = 'none';
+
        $('#p-personal ul').prepend($('<li id="displayTimer" />').append($parent));
  timerObj.appendChild( timerLink );
+
    }
  timerParent.insertBefore( timerObj, timerParent.firstChild );
+
     updateDate();
 
+
     window.setInterval(updateDate, 1000);
  function actualizeUTC ()
+
     $parent = null;
  {
+
});
    timerDate          = new Date();
+
});
    timerLink.innerHTML = ( timerDate.getUTCHours()   < 10 ? '0' : '' ) + timerDate.getUTCHours()  + ':'
 
                        + ( timerDate.getUTCMinutes() < 10 ? '0' : '' ) + timerDate.getUTCMinutes() + ':'
 
                        + ( timerDate.getUTCSeconds() < 10 ? '0' : '' ) + timerDate.getUTCSeconds() + ' (UTC)';
 
  }
 
 
 
  function actualizeCustom ()
 
  {
 
     timerDate          = new Date();
 
    timerDate.setMinutes( timerDate.getMinutes() + timerDate.getTimezoneOffset() + timerTimezone * 60 );
 
    timerLink.innerHTML = ( timerDate.getHours()  < 10 ? '0' : '' ) + timerDate.getHours()  + ':'
 
                        + ( timerDate.getMinutes() < 10 ? '0' : '' ) + timerDate.getMinutes() + ':'
 
                        + ( timerDate.getSeconds() < 10 ? '0' : '' ) + timerDate.getSeconds()
 
                        + ' (UTC' + ( timerTimezone < 0 ? '' : '+' ) + timerTimezone + ')';
 
  }
 
 
 
  // start
 
  if ( typeof( timerTimezone ) !== 'number' )
 
  {
 
     actualizeUTC();
 
     setInterval( actualizeUTC, 1000 );
 
  }
 
  else
 
  {
 
     actualizeCustom();
 
    setInterval( actualizeCustom, 1000 );
 
  }
 
}
 

Latest revision as of 17:10, 21 June 2014

mediaWiki.loader.using('mediawiki.util', function() {
"use strict";
jQuery(function($) {
    // Double run protection.
    if ($('#displayTimer, #showdate, #DisplayClockJS').length) return;
 
    var $parent = $('<span id="showdate" />'),
        $node = $('<a title="Purge the server cache and update the contents of this page." href="' + mediaWiki.util.wikiGetlink() + '?action=purge" />')
          .appendTo($('<span style="font-weight: bold; text-transform: none;" />')
              .appendTo($parent)
          );
    function updateDate() {
        $node.text(new Date().toUTCString().replace("GMT", "(UTC)").substr(5));
    }
 
    if (mediaWiki.config.get('skin') === 'oasis') { 
        $('<li id="displayTimer" />').css('fontSize',  "12px").append($parent).appendTo('#GlobalNavigation');
    } else {
        $('#p-personal ul').prepend($('<li id="displayTimer" />').append($parent));
    }
    updateDate();
    window.setInterval(updateDate, 1000);
    $parent = null;
});
});