Difference between revisions of "MediaWiki:Atystry.js"

From Ryzom Commons

Jump to: navigation, search
m (Undo revision 16142 by SirCotare (talk))
(Fix code later)
 
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 );
 
βˆ’
 
βˆ’
  var ariimg = document.createElement('img');
 
βˆ’
  var ari = document.createElement( 'li' );
 
βˆ’
  ariimg.src = "http://www.3025-game.de/special/Realmstatus_ryzom.php?shard=ari&rnd"+Math.random();
 
βˆ’
  ariimg.style.height = "13px";
 
βˆ’
  var aritext = document.createTextNode(" Arispotle");
 
βˆ’
  ari.appendChild(ariimg);
 
βˆ’
  ari.appendChild(aritext);
 
βˆ’
  timerParent.insertBefore( ari, timerParent.firstChild );
 
βˆ’
 
βˆ’
  var leaimg = document.createElement('img');
 
βˆ’
  var lea = document.createElement( 'li' );
 
βˆ’
  leaimg.src = "http://www.3025-game.de/special/Realmstatus_ryzom.php?shard=lea&rnd"+Math.random();
 
βˆ’
  leaimg.style.height = "13px";
 
βˆ’
  var leatext = document.createTextNode(" Leanon");
 
βˆ’
  lea.appendChild(leaimg);
 
βˆ’
  lea.appendChild(leatext);
 
βˆ’
  timerParent.insertBefore( lea, timerParent.firstChild );
 
βˆ’
 
βˆ’
  var aniimg = document.createElement('img');
 
βˆ’
  var ani = document.createElement( 'li' );
 
βˆ’
  aniimg.src = "http://www.3025-game.de/special/Realmstatus_ryzom.php?shard=ani&rnd"+Math.random();
 
βˆ’
  aniimg.style.height = "13px";
 
βˆ’
  var anitext = document.createTextNode(" Aniro");
 
βˆ’
  ani.appendChild(aniimg);
 
βˆ’
  ani.appendChild(anitext);
 
βˆ’
  timerParent.insertBefore( ani, 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>*/
 

Latest revision as of 13:36, 22 October 2017