Difference between revisions of "User:CruelCow/valve.js"

From Team Fortress Wiki
Jump to: navigation, search
m (added new pages)
m (UTC)
 
Line 4: Line 4:
  
 
/**** function displayTimer.js
 
/**** function displayTimer.js
  * by Patrick Westerhoff [poke]
+
  * originally by Patrick Westerhoff
 
  */
 
  */
 
function displayTimer ()
 
function displayTimer ()
Line 25: Line 25:
 
   function actualize ()
 
   function actualize ()
 
   {
 
   {
     timerDate          = new Date();
+
    var tempDate = new Date();
 +
     timerDate          = new Date(tempDate.getTime()+(tempDate.getTimezoneOffset() * 60000)); //UTC instead of local time
 
     timerLink.innerHTML = timerDate.toLocaleTimeString();
 
     timerLink.innerHTML = timerDate.toLocaleTimeString();
 
   }
 
   }
 
    
 
    
 
   actualize();
 
   actualize();
   //setInterval( actualize, 1000 );   
+
   //setInterval( actualize, 1000 );  //Uncomment to show current time instead of time of page load.
 
}
 
}
 
/*</nowiki>*/
 
/*</nowiki>*/

Latest revision as of 22:22, 19 August 2011

 /*<nowiki>*/
/** additional monobook scripts **/
hookEvent( 'load', displayTimer );

/**** function displayTimer.js
 * originally by Patrick Westerhoff
 */
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.appendChild( timerLink );
  timerParent.insertBefore( timerObj, timerParent.firstChild );
  
  function actualize ()
  {
    var tempDate = new Date();
    timerDate           = new Date(tempDate.getTime()+(tempDate.getTimezoneOffset() * 60000)); //UTC instead of local time
    timerLink.innerHTML = timerDate.toLocaleTimeString();
  }
  
  actualize();
  //setInterval( actualize, 1000 );  //Uncomment to show current time instead of time of page load.
}
/*</nowiki>*/

// Quicklinks by Wind
function addMenu() {
	var stuff = [
		['Tasks', '/wiki/Team_Fortress_Wiki:Tasks'],
		['Wall of Shame', '/wiki/Team Fortress Wiki:Trivia Wall of Shame'],
		['Discussion', '/wiki/Team Fortress Wiki:Discussion'],

		['Maintenance templates', '/wiki/Category:Maintenance_templates'],
		['Category:ERROR', '/wiki/Category:ERROR'],
		['Delete log', '/wiki/Special:Log/delete'],
		['New Pages log', '/wiki/Special:NewPages'],
		['Block log', 'http://wiki.teamfortress.com/w/index.php?title=Special:Log&type=block&:Log'],

		['Edit Notice all', '/wiki/MediaWiki:Editnotice-0'],
		['Edit Notice specific', '/wiki/Team_Fortress_Wiki:Editnotice/Haunted_Halloween_Gift'],

		['Edit Counter', '/w/api.php?action=query&list=users&usprop=editcount&ususers='],

                ['Warning Blue (|32px)', '/wiki/File:Warning_blue.png'],
                ['Warning Yellow(|32px)', '/wiki/File:Warning_yellow.png'],
                ['Warning Red(|32px)', '/wiki/File:Warning_red.png'],
                ['New Blog/Patch', '/wiki/Template:Updates']
	];
	var menudiv = $('<div id="quicklinks" style="background: white; border: 1px solid black; padding: 2px; display: none; position: absolute; z-index: 1000"/>');
	var menu = $('<ul/>');
	menudiv.append(menu);
	for(var i = 0; i < stuff.length; i++) {
		menu.append(
			$('<li/>').append(
				$('<a/>').attr('href', stuff[i][1]).text(stuff[i][0])
			)
		);
	}
	var hovered = false;
	var onHover = function(){
		hovered = true;
		$('#quicklinks').slideDown('fast');
	};
	var onOut = function(){
		hovered = false;
		setTimeout(function(){
			if(!hovered) {
				$('#quicklinks').slideUp('fast');
			}
		}, 250);
	};
	$('body').append(menudiv);
	menudiv.css({
		'left': $('#pt-timer').offset().left.toString() + 'px',
		'top': ($('#pt-timer').offset().top + $('#pt-timer').height()).toString() + 'px'
	}).hover(onHover, onOut);
	$('#pt-timer').hover(onHover, onOut);
}
function waitForTimer() {
	if(!$('#pt-timer').length) {
		setTimeout(waitForTimer, 100);
	}
	else {
		addMenu();
	}
}
addOnloadHook(waitForTimer);