Difference between revisions of "MediaWiki:Monobook.js"

From EncyclopAtys

Jump to: navigation, search
(Blanked the page)
m (Reverted edits by Nysha (Talk) to last revision by CeNobiteElf)
Line 1: Line 1:
 +
/*<nowiki>*/
 +
/* Any JavaScript here will be loaded for users using the MonoBook skin */
 +
/** additional monobook scripts **/
 +
hookEvent( 'load', displayTimer );
  
 +
/**** function displayTimer.js
 +
* by Patrick Westerhoff [poke]
 +
*/
 +
function displayTimer ()
 +
{
 +
  if ( typeof( timerDisplay ) !== 'undefined' && timerDisplay === false )
 +
    return;
 +
 
 +
  var date;
 +
  var timerParent = document.getElementById( 'p-personal' ).getElementsByTagName( 'ul' )[0];
 +
  var timerLink  = document.createElement( 'a' );
 +
  var timerObj    = document.createElement( 'li' );
 +
  timerLink.href              = '/wiki/' + wgPageName + '?action=purge';
 +
  timerLink.title              = 'Purge the server cache and update the contents of this page.'
 +
  timerObj.id                  = 'pt-timer';
 +
  timerObj.style.textTransform = 'none';
 +
  timerObj.style.fontWeight    = 'bold';
 +
  timerObj.style.fontSize      = '110%';
 +
  timerObj.appendChild( timerLink );
 +
  timerParent.insertBefore( timerObj, timerParent.firstChild );
 +
 
 +
  function actualizeUTC ()
 +
  {
 +
    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 );
 +
  }
 +
}
 +
/*</nowiki>*/

Revision as of 22:05, 30 December 2009

 /*<nowiki>*/
/* Any JavaScript here will be loaded for users using the MonoBook skin */
/** additional monobook scripts **/
hookEvent( 'load', displayTimer );

/**** function displayTimer.js
 * by Patrick Westerhoff [poke]
 */
function displayTimer ()
{
  if ( typeof( timerDisplay ) !== 'undefined' && timerDisplay === false )
    return;
  
  var date;
  var timerParent = document.getElementById( 'p-personal' ).getElementsByTagName( 'ul' )[0];
  var timerLink   = document.createElement( 'a' );
  var timerObj    = document.createElement( 'li' );
  timerLink.href               = '/wiki/' + wgPageName + '?action=purge';
  timerLink.title              = 'Purge the server cache and update the contents of this page.'
  timerObj.id                  = 'pt-timer';
  timerObj.style.textTransform = 'none';
  timerObj.style.fontWeight    = 'bold';
  timerObj.style.fontSize      = '110%';
  timerObj.appendChild( timerLink );
  timerParent.insertBefore( timerObj, timerParent.firstChild );
  
  function actualizeUTC ()
  {
    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 );
  }
}
/*</nowiki>*/