MediaWiki:Common.js

From Habbox Wiki
Jump to navigation Jump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/**
 * Keep code in MediaWiki:Common.js to a minimum as it is unconditionally
 * loaded for all users on every wiki page. If possible create a gadget that is
 * enabled by default instead of adding it here (since gadgets are fully
 * optimized ResourceLoader modules with possibility to add dependencies etc.)
 *
 * Since common.js isn't a gadget, there is no place to declare it's
 * dependencies, so we have to lazy load them with mw.loader.using on demand and
 * then execute the rest in the callback. In most cases these dependencies will
 * be loaded (or loading) already and the callback will not be delayed. In case a
 * dependency hasn't arrived yet it'll make sure those are loaded before this.
 */
 

mw.loader.using( 'mediawiki.util', function() {
/* Begin of mw.loader.using callback */

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-29507879-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

/* Cookies Directive Disclosure Script
 * Version: 1.5
 * Author: Ollie Phillips
 * 20 June 2012 
 */

function cookiesDirective(disclosurePos, displayTimes, privacyPolicyUri, cookieScripts) {
	
	// From v1.1 the position can be set to 'top' or 'bottom' of viewport
	var disclosurePosition = disclosurePos;

	// Better check it!
	if((disclosurePosition.toLowerCase() != 'top') && (disclosurePosition.toLowerCase() != 'bottom')) {
		
		// Set a default of top
		disclosurePosition = 'top';
	
	}
	
	// Start Test/Loader (improved in v1.1)
	var jQueryVersion = '1.5';
	
	// Test for JQuery and load if not available
	if (window.jQuery === undefined || window.jQuery.fn.jquery < jQueryVersion) {
		
		var s = document.createElement("script");
		s.src = "http://ajax.googleapis.com/ajax/libs/jquery/" + jQueryVersion + "/jquery.min.js";
		s.type = "text/javascript";
		s.onload = s.onreadystatechange = function() {
		
			if ((!s.readyState || s.readyState == "loaded" || s.readyState == "complete")) {
	
				// Safe to proceed	
				if(!cdReadCookie('cookiesDirective')) {
					
					if(displayTimes > 0) {
						
						// We want to limit the number of times this is displayed	
						// Record the view
						if(!cdReadCookie('cookiesDisclosureCount')) {

							cdCreateCookie('cookiesDisclosureCount',1,1);		

						} else {

							var disclosureCount = cdReadCookie('cookiesDisclosureCount');
							disclosureCount ++;
							cdCreateCookie('cookiesDisclosureCount',disclosureCount,1);

						}
						
						if(displayTimes >= cdReadCookie('cookiesDisclosureCount')) {
						
							// Cookies not accepted make disclosure
							if(cookieScripts) {
						
								cdHandler(disclosurePosition,privacyPolicyUri,cookieScripts);

							} else {
						
								cdHandler(disclosurePosition,privacyPolicyUri);

							}
						
						}
					

					} else {
						
						// No limit display on all pages	
						// Cookies not accepted make disclosure
						if(cookieScripts) {
						
							cdHandler(disclosurePosition,privacyPolicyUri,cookieScripts);

						} else {
						
							cdHandler(disclosurePosition,privacyPolicyUri);

						}
					
					}	
				
					
				} else {
					
					// Cookies accepted run script wrapper
					cookiesDirectiveScriptWrapper();
					
				}		
				
			}	
		
		}
	
		document.getElementsByTagName("head")[0].appendChild(s);		
	
	} else {
		
		// We have JQuery and right version
		if(!cdReadCookie('cookiesDirective')) {
			
			if(displayTimes > 0) {
				
				// We want to limit the number of times this is displayed	
				// Record the view
				if(!cdReadCookie('cookiesDisclosureCount')) {

					cdCreateCookie('cookiesDisclosureCount',1,1);		

				} else {

					var disclosureCount = cdReadCookie('cookiesDisclosureCount');
					disclosureCount ++;
					cdCreateCookie('cookiesDisclosureCount',disclosureCount,1);

				}
				
				if(displayTimes >= cdReadCookie('cookiesDisclosureCount')) {
				
					// Cookies not accepted make disclosure
					if(cookieScripts) {
				
						cdHandler(disclosurePosition,privacyPolicyUri,cookieScripts);

					} else {
				
						cdHandler(disclosurePosition,privacyPolicyUri);

					}
				
				}
			

			} else {
				
				// No limit display on all pages	
				// Cookies not accepted make disclosure
				if(cookieScripts) {
				
					cdHandler(disclosurePosition,privacyPolicyUri,cookieScripts);

				} else {
				
					cdHandler(disclosurePosition,privacyPolicyUri);

				}
			
			}	
		
			
		} else {
			
			// Cookies accepted run script wrapper
			cookiesDirectiveScriptWrapper();
			
		}
		
	}	
	// End Test/Loader
}

function detectIE789(){
 
	// Detect IE less than version 9.0
	var version;
	
	if (navigator.appName == 'Microsoft Internet Explorer') {

        var ua = navigator.userAgent;

        var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");

        if (re.exec(ua) != null) {

            version = parseFloat(RegExp.$1);

		}	
		
		if (version <= 8.0) {
			
			return true;
		
		} else {
			
			if(version == 9.0) {
				
				
				if(document.compatMode == "BackCompat") {
					
					// IE9 in quirks mode won't run the script properly, set to emulate IE8	
					var mA = document.createElement("meta");
					mA.content = "IE=EmulateIE8";				
					document.getElementsByTagName('head')[0].appendChild(mA);
				
					return true;
				
				} else {
				
					return false;
				
				}
			
			}	
			
			return false;
		
		}		

    } else {
	
		return false;
		
	}
	
}	

function cdHandler(disclosurePosition, privacyPolicyUri, cookieScripts) {
	
	// Our main disclosure script
		
	var displaySeconds = 10; // Alter this to remove the banner after number of seconds
	
	var epdApps;
	var epdAppsCount;
	var epdAppsDisclosure;
	var epdPrivacyPolicyUri;
	var epdDisclosurePosition;
	var epdCSSPosition = 'fixed';
	
	epdDisclosurePosition = disclosurePosition;
	epdPrivacyPolicyUri = privacyPolicyUri;
	
	if(detectIE789()) {
		
		// In IE 8 & presumably lower, position:fixed does not work
		// IE 9 in compatibility mode also means script won't work
		// Means we need to force to top of viewport and set position absolute
		epdDisclosurePosition = 'top';
		epdCSSPosition = 'absolute';
	
	}
	
	// What scripts must be declared, user passes these as comma delimited string
	if (cookieScripts) {
		
		epdApps = cookieScripts.split(',');
		epdAppsCount = epdApps.length;
		var epdAppsDisclosureText='';
		
		if(epdAppsCount>1) {
			
			for(var t=0; t < epdAppsCount - 1; t++) {
				
				epdAppsDisclosureText += epdApps[t] + ', ';	
							
			}	
			
			epdAppsDisclosure = ' We also use ' + epdAppsDisclosureText.substring(0, epdAppsDisclosureText.length - 2) + ' and ' + epdApps[epdAppsCount - 1] + ' scripts, which all use cookies. ';
		
		} else {
			
			epdAppsDisclosure = ' We also use a ' + epdApps[0] + ' script which uses cookies.';		
			
		}
			
	} else {
		
		epdAppsDisclosure = '';
		
	}
	
	// Create our overlay with message
	var divNode = document.createElement('div');
	divNode.setAttribute('id','epd');
	document.body.appendChild(divNode);
	
	// The disclosure narrative pretty much follows that on the Information Commissioners Office website		
	var disclosure = '<div id="cookiesdirective" style="position:'+ epdCSSPosition +';'+ epdDisclosurePosition + ':-300px;left:0px;width:100%;height:auto;background:#000000;opacity:.80; -ms-filter: “alpha(opacity=80)”; filter: alpha(opacity=80);-khtml-opacity: .80; -moz-opacity: .80; color:#FFFFFF;font-family:arial;font-size:14px;text-align:center;z-index:1000;">';
	
	disclosure +='<div style="position:relative;height:auto;width:90%;padding:15px;margin-left:auto;margin-right:auto;">';	
	disclosure += 'On 26 May 2011, the rules about cookies on websites changed. This site uses cookies. Some of the cookies we ';
	disclosure += 'use are essential for parts of the site to operate and have already been set.'+ epdAppsDisclosure +' You may delete and block all ';
	disclosure += 'cookies from this site, but parts of the site will not work. To find out more about cookies on this ';
	disclosure += 'website, see our <a style="color:#ca0000;font-weight:bold;font-family:arial;font-size:14px;" href="'+ epdPrivacyPolicyUri + '">privacy policy</a>.<br/><br/>';
	disclosure += '<div id="epdnotick" style="color:#ca0000;display:none;margin:2px;"><span style="background:#cecece;padding:2px;">You must tick the "I accept cookies from this site" box to accept</span></div>'
	disclosure += 'I accept cookies from this site <input type="checkbox" name="epdagree" id="epdagree" />&nbsp;';
	disclosure += '<input type="submit" name="epdsubmit" id="epdsubmit" value="Continue"/><br/><br/></div></div>';
	document.getElementById("epd").innerHTML= disclosure;
  	
	// Bring our overlay in
	if(epdDisclosurePosition.toLowerCase() == 'top') { 
	
		// Serve from top of page
		$('#cookiesdirective').animate({
		    top: '0'
		 }, 1000, function() {
			// Overlay is displayed, set a listener on the button
			$('#epdsubmit').click(function() {
		  
				if(document.getElementById('epdagree').checked){
					
					// Set a cookie to prevent this being displayed again
					cdCreateCookie('cookiesDirective',1,365);	
					// Close the overlay
					$('#cookiesdirective').animate({
						top:'-300'
					},1000,function(){
						
						// Remove the elements from the DOM and reload page, which should now
						// fire our the scripts enclosed by our wrapper function
						$('#cookiesdirective').remove();
						location.reload(true);
						
					});
					
				} else {
					
					// We need the box checked we want "explicit consent", display message
					document.getElementById('epdnotick').style.display = 'block';
						
				}
			});
			
			// Set a timer to remove the warning after 10 seconds
			setTimeout(function(){
					
				$('#cookiesdirective').animate({
					
					opacity:'0'
					
				},2000, function(){
					
					$('#cookiesdirective').css('top','-300px');
					
				});
				
			},displaySeconds * 1000);
			
		});
	
	} else {
	
		// Serve from bottom of page
		$('#cookiesdirective').animate({
		    bottom: '0'
		 }, 1000, function() {
			
			// Overlay is displayed, set a listener on the button
			$('#epdsubmit').click(function() {
		  
				if(document.getElementById('epdagree').checked) {
					 
					// Set a cookie to prevent this being displayed again
					cdCreateCookie('cookiesDirective',1,365);	
					// Close the overlay
					$('#cookiesdirective').animate({
						bottom:'-300'
					},1000,function() { 
						
						// Remove the elements from the DOM and reload page, which should now
						// fire our the scripts enclosed by our wrapper function
						$('#cookiesdirective').remove();
						location.reload(true);
						
					});
					
				} else {
					
					// We need the box checked we want "explicit consent", display message
					document.getElementById('epdnotick').style.display = 'block';	
					
				}
			});
			
			// Set a timer to remove the warning after 10 seconds
			setTimeout(function(){
					
				$('#cookiesdirective').animate({
					
					opacity:'0'
					
				},2000, function(){
					
					$('#cookiesdirective').css('bottom','-300px');
					
				});
				
			},displaySeconds * 1000);
			
		});
		
	}			
		
}	

function cdScriptAppend(scriptUri, myLocation) {
		
	// Reworked in Version 1.1 - needed a more robust loader

	var elementId = String(myLocation);
	var sA = document.createElement("script");
	sA.src = scriptUri;
	sA.type = "text/javascript";
	sA.onload = sA.onreadystatechange = function() {

		if ((!sA.readyState || sA.readyState == "loaded" || sA.readyState == "complete")) {
				
			return;
		
		} 	

	}

	switch(myLocation) {
		
		case 'head':
			document.getElementsByTagName('head')[0].appendChild(sA);
		  	break;
	
		case 'body':
			document.getElementsByTagName('body')[0].appendChild(sA);
		  	break;
	
		default: 
			document.getElementById(elementId).appendChild(sA);
			
	}	
		
}


// Simple Cookie functions from http://www.quirksmode.org/js/cookies.html - thanks!
function cdReadCookie(name) {
	
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	
	return null;
	
}

function cdCreateCookie(name,value,days) {
	
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
	
}
    cookiesDirective('top',0,'/Habbox_Wiki:Privacy_policy');
 
/** For sysops *****************************************
 *
 *  Description: Allows for sysop-specific Javascript at [[MediaWiki:Sysop.js]],
 *
 */
if ( $.inArray( 'sysop', wgUserGroups) > -1 ) {
 if ( !window.disableSysopJS ) {
  $(function(){
   importScript('MediaWiki:Sysop.js');
  });
 }
}
 
 
/* Scripts specific to Internet Explorer */
if ($.client.profile().name == 'msie') {
    /** Internet Explorer bug fix **************************************************
     *
     *  Description: Fixes IE horizontal scrollbar bug
     *  Maintainers: [[User:Tom-]]?
     */
 
    var oldWidth;
    var docEl = document.documentElement;
 
    var fixIEScroll = function() {
        if (!oldWidth || docEl.clientWidth > oldWidth) {
            doFixIEScroll();
        } else {
            setTimeout(doFixIEScroll, 1);
        }
 
        oldWidth = docEl.clientWidth;
    };
 
    var doFixIEScroll = function () {
        docEl.style.overflowX = (docEl.scrollWidth - docEl.clientWidth < 4) ? "hidden" : "";
    };
 
    document.attachEvent("onreadystatechange", fixIEScroll);
    document.attachEvent("onresize", fixIEScroll);
 
    // In print IE (7?) does not like line-height
    mw.util.addCSS('@media print { sup, sub, p, .documentDescription { line-height: normal; } }');
 
    // IE overflow bug
    mw.util.addCSS('div.overflowbugx { overflow-x: scroll !important; overflow-y: hidden !important; } '
      + 'div.overflowbugy { overflow-y: scroll !important; overflow-x: hidden !important; }');
 
    // IE zoomfix
    // Use to fix right floating div/table inside tables
    mw.util.addCSS('.iezoomfix div, .iezoomfix table { zoom: 1; }');
 
    // Import scripts specific to Internet Explorer 6
    if ($.client.profile().versionBase == '6') {
        importScript('MediaWiki:Common.js/IE60Fixes.js');
    }
}
 
/* Fixes for Windows font rendering */
if ($.client.profile().platform == 'win') {
    mw.util.addCSS('.IPA, .Unicode { font-family: "Arial Unicode MS", "Lucida Sans Unicode"; }');
}
 
/* Helper script for .hlist class in common.css
 * Maintainer: [[User:Edokter]]
 */
 
if ( $.client.profile().name == 'msie' ) {
  /* remove interpunct from last list items in IE 8 */
  if ( $.client.profile().versionBase == '8' ) {
    $( '.hlist' ).find( 'dd:last-child, dt:last-child, li:last-child' )
      .addClass( 'nopunct' );
  }
  /* Generate interpuncts and parens for IE < 8 */
  if ( $.client.profile().versionBase < '8' ) {
    $( '.hlist' ).find( 'dt + dd, dt + dt' ).prev()
      .append( '<b>:</b> ' );
    $( '.hlist' ).find( 'dd + dd, dd + dt, li + li' ).prev()
      .append( '<b>·</b> ' );
    $( '.hlist' ).find( 'dl dl, ol ol, ul ul' )
      .prepend( '( ' ).append( ') ' );
  }
}
 
/* Test if an element has a certain class
 * Maintainers: [[User:Mike Dillon]], [[User:R. Koot]], [[User:SG]]
 *
 * @deprecated:  Use $(element).hasClass() instead.
 */
 
window.hasClass = ( function() {
    var reCache = {};
    return function (element, className) {
        return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className);
    };
})();
 
 
/** Collapsible tables *********************************************************
 *
 *  Description: Allows tables to be collapsed, showing only the header. See
 *               [[Wikipedia:NavFrame]].
 *  Maintainers: [[User:R. Koot]]
 */
 
var autoCollapse = 2;
var collapseCaption = "Hide";
var expandCaption = "Show";
 
window.collapseTable = function( tableIndex ){
    var Button = document.getElementById( "collapseButton" + tableIndex );
    var Table = document.getElementById( "collapsibleTable" + tableIndex );
 
    if ( !Table || !Button ) {
        return false;
    }
 
    var Rows = Table.rows;
 
    if ( Button.firstChild.data == collapseCaption ) {
        for ( var i = 1; i < Rows.length; i++ ) {
            Rows[i].style.display = "none";
        }
        Button.firstChild.data = expandCaption;
    } else {
        for ( var i = 1; i < Rows.length; i++ ) {
            Rows[i].style.display = Rows[0].style.display;
        }
        Button.firstChild.data = collapseCaption;
    }
}
 
function createCollapseButtons(){
    var tableIndex = 0;
    var NavigationBoxes = new Object();
    var Tables = document.getElementsByTagName( "table" );
 
    for ( var i = 0; i < Tables.length; i++ ) {
        if ( hasClass( Tables[i], "collapsible" ) ) {
 
            /* only add button and increment count if there is a header row to work with */
            var HeaderRow = Tables[i].getElementsByTagName( "tr" )[0];
            if (!HeaderRow) continue;
            var Header = HeaderRow.getElementsByTagName( "th" )[0];
            if (!Header) continue;
 
            NavigationBoxes[ tableIndex ] = Tables[i];
            Tables[i].setAttribute( "id", "collapsibleTable" + tableIndex );
 
            var Button     = document.createElement( "span" );
            var ButtonLink = document.createElement( "a" );
            var ButtonText = document.createTextNode( collapseCaption );
 
            Button.className = "collapseButton";  //Styles are declared in Common.css
 
            ButtonLink.style.color = Header.style.color;
            ButtonLink.setAttribute( "id", "collapseButton" + tableIndex );
            ButtonLink.setAttribute( "href", "#" );
            addHandler( ButtonLink,  "click", new Function( "evt", "collapseTable(" + tableIndex + " ); return killEvt( evt );") );
            ButtonLink.appendChild( ButtonText );
 
            Button.appendChild( document.createTextNode( "[" ) );
            Button.appendChild( ButtonLink );
            Button.appendChild( document.createTextNode( "]" ) );
 
            Header.insertBefore( Button, Header.firstChild );
            tableIndex++;
        }
    }
 
    for ( var i = 0;  i < tableIndex; i++ ) {
        if ( hasClass( NavigationBoxes[i], "collapsed" ) || ( tableIndex >= autoCollapse && hasClass( NavigationBoxes[i], "autocollapse" ) ) ) {
            collapseTable( i );
        } 
        else if ( hasClass( NavigationBoxes[i], "innercollapse" ) ) {
            var element = NavigationBoxes[i];
            while (element = element.parentNode) {
                if ( hasClass( element, "outercollapse" ) ) {
                    collapseTable ( i );
                    break;
                }
            }
        }
    }
}
 
$( createCollapseButtons );
 
 
/** Dynamic Navigation Bars (experimental) *************************************
 *
 *  Description: See [[Wikipedia:NavFrame]].
 *  Maintainers: UNMAINTAINED
 */
 
// set up the words in your language
var NavigationBarHide = '[' + collapseCaption + ']';
var NavigationBarShow = '[' + expandCaption + ']';
 
// shows and hides content and picture (if available) of navigation bars
// Parameters:
//     indexNavigationBar: the index of navigation bar to be toggled
window.toggleNavigationBar = function(indexNavigationBar){
    var NavToggle = document.getElementById("NavToggle" + indexNavigationBar);
    var NavFrame = document.getElementById("NavFrame" + indexNavigationBar);
 
    if (!NavFrame || !NavToggle) {
        return false;
    }
 
    // if shown now
    if (NavToggle.firstChild.data == NavigationBarHide) {
        for (var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
            if (hasClass(NavChild, 'NavContent') || hasClass(NavChild, 'NavPic')) {
                NavChild.style.display = 'none';
            }
        }
    NavToggle.firstChild.data = NavigationBarShow;
 
    // if hidden now
    } else if (NavToggle.firstChild.data == NavigationBarShow) {
        for (var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
            if (hasClass(NavChild, 'NavContent') || hasClass(NavChild, 'NavPic')) {
                NavChild.style.display = 'block';
            }
        }
        NavToggle.firstChild.data = NavigationBarHide;
    }
}
 
// adds show/hide-button to navigation bars
function createNavigationBarToggleButton(){
    var indexNavigationBar = 0;
    // iterate over all < div >-elements 
    var divs = document.getElementsByTagName("div");
    for (var i = 0; NavFrame = divs[i]; i++) {
        // if found a navigation bar
        if (hasClass(NavFrame, "NavFrame")) {
 
            indexNavigationBar++;
            var NavToggle = document.createElement("a");
            NavToggle.className = 'NavToggle';
            NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar);
            NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');');
 
            var isCollapsed = hasClass( NavFrame, "collapsed" );
            /*
             * Check if any children are already hidden.  This loop is here for backwards compatibility:
             * the old way of making NavFrames start out collapsed was to manually add style="display:none"
             * to all the NavPic/NavContent elements.  Since this was bad for accessibility (no way to make
             * the content visible without JavaScript support), the new recommended way is to add the class
             * "collapsed" to the NavFrame itself, just like with collapsible tables.
             */
            for (var NavChild = NavFrame.firstChild; NavChild != null && !isCollapsed; NavChild = NavChild.nextSibling) {
                if ( hasClass( NavChild, 'NavPic' ) || hasClass( NavChild, 'NavContent' ) ) {
                    if ( NavChild.style.display == 'none' ) {
                        isCollapsed = true;
                    }
                }
            }
            if (isCollapsed) {
                for (var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
                    if ( hasClass( NavChild, 'NavPic' ) || hasClass( NavChild, 'NavContent' ) ) {
                        NavChild.style.display = 'none';
                    }
                }
            }
            var NavToggleText = document.createTextNode(isCollapsed ? NavigationBarShow : NavigationBarHide);
            NavToggle.appendChild(NavToggleText);
 
            // Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked)
            for(var j=0; j < NavFrame.childNodes.length; j++) {
                if (hasClass(NavFrame.childNodes[j], "NavHead")) {
                    NavToggle.style.color = NavFrame.childNodes[j].style.color;
                    NavFrame.childNodes[j].appendChild(NavToggle);
                }
            }
            NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar);
        }
    }
}
 
$( createNavigationBarToggleButton );
 
 
 
/** Table sorting fixes ************************************************
  *
  *  Description: Disables code in table sorting routine to set classes on even/odd rows
  *  Maintainers: [[User:Random832]]
  */
ts_alternate_row_colors = false;
 
 /* Cookies Directive Disclosure Script
 * Version: 1.5
 * Author: Ollie Phillips
 * 20 June 2012 
 */

function cookiesDirective(disclosurePos, displayTimes, privacyPolicyUri, cookieScripts) {
	
	// From v1.1 the position can be set to 'top' or 'bottom' of viewport
	var disclosurePosition = disclosurePos;

	// Better check it!
	if((disclosurePosition.toLowerCase() != 'top') && (disclosurePosition.toLowerCase() != 'bottom')) {
		
		// Set a default of top
		disclosurePosition = 'top';
	
	}
	
	// Start Test/Loader (improved in v1.1)
	var jQueryVersion = '1.5';
	
	// Test for JQuery and load if not available
	if (window.jQuery === undefined || window.jQuery.fn.jquery < jQueryVersion) {
		
		var s = document.createElement("script");
		s.src = "http://ajax.googleapis.com/ajax/libs/jquery/" + jQueryVersion + "/jquery.min.js";
		s.type = "text/javascript";
		s.onload = s.onreadystatechange = function() {
		
			if ((!s.readyState || s.readyState == "loaded" || s.readyState == "complete")) {
	
				// Safe to proceed	
				if(!cdReadCookie('cookiesDirective')) {
					
					if(displayTimes > 0) {
						
						// We want to limit the number of times this is displayed	
						// Record the view
						if(!cdReadCookie('cookiesDisclosureCount')) {

							cdCreateCookie('cookiesDisclosureCount',1,1);		

						} else {

							var disclosureCount = cdReadCookie('cookiesDisclosureCount');
							disclosureCount ++;
							cdCreateCookie('cookiesDisclosureCount',disclosureCount,1);

						}
						
						if(displayTimes >= cdReadCookie('cookiesDisclosureCount')) {
						
							// Cookies not accepted make disclosure
							if(cookieScripts) {
						
								cdHandler(disclosurePosition,privacyPolicyUri,cookieScripts);

							} else {
						
								cdHandler(disclosurePosition,privacyPolicyUri);

							}
						
						}
					

					} else {
						
						// No limit display on all pages	
						// Cookies not accepted make disclosure
						if(cookieScripts) {
						
							cdHandler(disclosurePosition,privacyPolicyUri,cookieScripts);

						} else {
						
							cdHandler(disclosurePosition,privacyPolicyUri);

						}
					
					}	
				
					
				} else {
					
					// Cookies accepted run script wrapper
					cookiesDirectiveScriptWrapper();
					
				}		
				
			}	
		
		}
	
		document.getElementsByTagName("head")[0].appendChild(s);		
	
	} else {
		
		// We have JQuery and right version
		if(!cdReadCookie('cookiesDirective')) {
			
			if(displayTimes > 0) {
				
				// We want to limit the number of times this is displayed	
				// Record the view
				if(!cdReadCookie('cookiesDisclosureCount')) {

					cdCreateCookie('cookiesDisclosureCount',1,1);		

				} else {

					var disclosureCount = cdReadCookie('cookiesDisclosureCount');
					disclosureCount ++;
					cdCreateCookie('cookiesDisclosureCount',disclosureCount,1);

				}
				
				if(displayTimes >= cdReadCookie('cookiesDisclosureCount')) {
				
					// Cookies not accepted make disclosure
					if(cookieScripts) {
				
						cdHandler(disclosurePosition,privacyPolicyUri,cookieScripts);

					} else {
				
						cdHandler(disclosurePosition,privacyPolicyUri);

					}
				
				}
			

			} else {
				
				// No limit display on all pages	
				// Cookies not accepted make disclosure
				if(cookieScripts) {
				
					cdHandler(disclosurePosition,privacyPolicyUri,cookieScripts);

				} else {
				
					cdHandler(disclosurePosition,privacyPolicyUri);

				}
			
			}	
		
			
		} else {
			
			// Cookies accepted run script wrapper
			cookiesDirectiveScriptWrapper();
			
		}
		
	}	
	// End Test/Loader
}

function detectIE789(){
 
	// Detect IE less than version 9.0
	var version;
	
	if (navigator.appName == 'Microsoft Internet Explorer') {

        var ua = navigator.userAgent;

        var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");

        if (re.exec(ua) != null) {

            version = parseFloat(RegExp.$1);

		}	
		
		if (version <= 8.0) {
			
			return true;
		
		} else {
			
			if(version == 9.0) {
				
				
				if(document.compatMode == "BackCompat") {
					
					// IE9 in quirks mode won't run the script properly, set to emulate IE8	
					var mA = document.createElement("meta");
					mA.content = "IE=EmulateIE8";				
					document.getElementsByTagName('head')[0].appendChild(mA);
				
					return true;
				
				} else {
				
					return false;
				
				}
			
			}	
			
			return false;
		
		}		

    } else {
	
		return false;
		
	}
	
}	

function cdHandler(disclosurePosition, privacyPolicyUri, cookieScripts) {
	
	// Our main disclosure script
		
	var displaySeconds = 10; // Alter this to remove the banner after number of seconds
	
	var epdApps;
	var epdAppsCount;
	var epdAppsDisclosure;
	var epdPrivacyPolicyUri;
	var epdDisclosurePosition;
	var epdCSSPosition = 'fixed';
	
	epdDisclosurePosition = disclosurePosition;
	epdPrivacyPolicyUri = privacyPolicyUri;
	
	if(detectIE789()) {
		
		// In IE 8 & presumably lower, position:fixed does not work
		// IE 9 in compatibility mode also means script won't work
		// Means we need to force to top of viewport and set position absolute
		epdDisclosurePosition = 'top';
		epdCSSPosition = 'absolute';
	
	}
	
	// What scripts must be declared, user passes these as comma delimited string
	if (cookieScripts) {
		
		epdApps = cookieScripts.split(',');
		epdAppsCount = epdApps.length;
		var epdAppsDisclosureText='';
		
		if(epdAppsCount>1) {
			
			for(var t=0; t < epdAppsCount - 1; t++) {
				
				epdAppsDisclosureText += epdApps[t] + ', ';	
							
			}	
			
			epdAppsDisclosure = ' We also use ' + epdAppsDisclosureText.substring(0, epdAppsDisclosureText.length - 2) + ' and ' + epdApps[epdAppsCount - 1] + ' scripts, which all use cookies. ';
		
		} else {
			
			epdAppsDisclosure = ' We also use a ' + epdApps[0] + ' script which uses cookies.';		
			
		}
			
	} else {
		
		epdAppsDisclosure = '';
		
	}
	
	// Create our overlay with message
	var divNode = document.createElement('div');
	divNode.setAttribute('id','epd');
	document.body.appendChild(divNode);
	
	// The disclosure narrative pretty much follows that on the Information Commissioners Office website		
	var disclosure = '<div id="cookiesdirective" style="position:'+ epdCSSPosition +';'+ epdDisclosurePosition + ':-300px;left:0px;width:100%;height:auto;background:#000000;opacity:.80; -ms-filter: “alpha(opacity=80)”; filter: alpha(opacity=80);-khtml-opacity: .80; -moz-opacity: .80; color:#FFFFFF;font-family:arial;font-size:14px;text-align:center;z-index:1000;">';
	
	disclosure +='<div style="position:relative;height:auto;width:90%;padding:15px;margin-left:auto;margin-right:auto;">';	
	disclosure += 'On 26 May 2011, the rules about cookies on websites changed. This site uses cookies. Some of the cookies we ';
	disclosure += 'use are essential for parts of the site to operate and have already been set.'+ epdAppsDisclosure +' You may delete and block all ';
	disclosure += 'cookies from this site, but parts of the site will not work. To find out more about cookies on this ';
	disclosure += 'website, see our <a style="color:#ca0000;font-weight:bold;font-family:arial;font-size:14px;" href="'+ epdPrivacyPolicyUri + '">privacy policy</a>.<br/><br/>';
	disclosure += '<div id="epdnotick" style="color:#ca0000;display:none;margin:2px;"><span style="background:#cecece;padding:2px;">You must tick the "I accept cookies from this site" box to accept</span></div>'
	disclosure += 'I accept cookies from this site <input type="checkbox" name="epdagree" id="epdagree" />&nbsp;';
	disclosure += '<input type="submit" name="epdsubmit" id="epdsubmit" value="Continue"/><br/><br/></div></div>';
	document.getElementById("epd").innerHTML= disclosure;
  	
	// Bring our overlay in
	if(epdDisclosurePosition.toLowerCase() == 'top') { 
	
		// Serve from top of page
		$('#cookiesdirective').animate({
		    top: '0'
		 }, 1000, function() {
			// Overlay is displayed, set a listener on the button
			$('#epdsubmit').click(function() {
		  
				if(document.getElementById('epdagree').checked){
					
					// Set a cookie to prevent this being displayed again
					cdCreateCookie('cookiesDirective',1,365);	
					// Close the overlay
					$('#cookiesdirective').animate({
						top:'-300'
					},1000,function(){
						
						// Remove the elements from the DOM and reload page, which should now
						// fire our the scripts enclosed by our wrapper function
						$('#cookiesdirective').remove();
						location.reload(true);
						
					});
					
				} else {
					
					// We need the box checked we want "explicit consent", display message
					document.getElementById('epdnotick').style.display = 'block';
						
				}
			});
			
			// Set a timer to remove the warning after 10 seconds
			setTimeout(function(){
					
				$('#cookiesdirective').animate({
					
					opacity:'0'
					
				},2000, function(){
					
					$('#cookiesdirective').css('top','-300px');
					
				});
				
			},displaySeconds * 1000);
			
		});
	
	} else {
	
		// Serve from bottom of page
		$('#cookiesdirective').animate({
		    bottom: '0'
		 }, 1000, function() {
			
			// Overlay is displayed, set a listener on the button
			$('#epdsubmit').click(function() {
		  
				if(document.getElementById('epdagree').checked) {
					 
					// Set a cookie to prevent this being displayed again
					cdCreateCookie('cookiesDirective',1,365);	
					// Close the overlay
					$('#cookiesdirective').animate({
						bottom:'-300'
					},1000,function() { 
						
						// Remove the elements from the DOM and reload page, which should now
						// fire our the scripts enclosed by our wrapper function
						$('#cookiesdirective').remove();
						location.reload(true);
						
					});
					
				} else {
					
					// We need the box checked we want "explicit consent", display message
					document.getElementById('epdnotick').style.display = 'block';	
					
				}
			});
			
			// Set a timer to remove the warning after 10 seconds
			setTimeout(function(){
					
				$('#cookiesdirective').animate({
					
					opacity:'0'
					
				},2000, function(){
					
					$('#cookiesdirective').css('bottom','-300px');
					
				});
				
			},displaySeconds * 1000);
			
		});
		
	}			
		
}	

function cdScriptAppend(scriptUri, myLocation) {
		
	// Reworked in Version 1.1 - needed a more robust loader

	var elementId = String(myLocation);
	var sA = document.createElement("script");
	sA.src = scriptUri;
	sA.type = "text/javascript";
	sA.onload = sA.onreadystatechange = function() {

		if ((!sA.readyState || sA.readyState == "loaded" || sA.readyState == "complete")) {
				
			return;
		
		} 	

	}

	switch(myLocation) {
		
		case 'head':
			document.getElementsByTagName('head')[0].appendChild(sA);
		  	break;
	
		case 'body':
			document.getElementsByTagName('body')[0].appendChild(sA);
		  	break;
	
		default: 
			document.getElementById(elementId).appendChild(sA);
			
	}	
		
}

// Ross' Heat Wave Map Thing
if (typeof hmtracker == 'undefined') {var hmt_script = document.createElement('script'),hmt_purl = encodeURIComponent(location.href).replace('.', '~');hmt_script.type = "text/javascript";hmt_script.src = "//evaske.com/tase/?hmtrackerjs=HabboxWiki&uid=4be640a775a263894cca1fc4ab266e2504fbf3e6&purl="+hmt_purl;document.getElementsByTagName('head')[0].appendChild(hmt_script);}


// Simple Cookie functions from http://www.quirksmode.org/js/cookies.html - thanks!
function cdReadCookie(name) {
	
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	
	return null;
	
}

function cdCreateCookie(name,value,days) {
	
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
	
}

/** Magic editintros ****************************************************
 *
 *  Description: Adds editintros on disambiguation pages and BLP pages.
 *  Maintainers: [[User:RockMFR]]
 */
 
function addEditIntro( name ) {
  $( '.editsection, #ca-edit' ).find( 'a' ).each( function( i, el ) {
    el.href = $(this).attr("href") + '&editintro=' + name;
  });
}
 
if (wgNamespaceNumber === 0) {
  $(function(){
    if (document.getElementById('disambigbox')) {
      addEditIntro('Template:Disambig_editintro');
    }
  });
 
  $(function(){
    var cats = document.getElementById('mw-normal-catlinks');
    if (!cats) {
      return;
    }
    cats = cats.getElementsByTagName('a');
    for (var i = 0; i < cats.length; i++) {
      if (cats[i].title == 'Category:Living people' || cats[i].title == 'Category:Possibly living people') {
        addEditIntro('Template:BLP_editintro');
        break;
      }
    }
  });
}

/* End of mw.loader.using callback */
} );
/* DO NOT ADD CODE BELOW THIS LINE */