User:ValentinCurls/global.js

/*$(function killTheHorrorThatIsTheNewFileInfoPageAndReturnItToWhatIsWasWithinWhatIsPossible {	function kill(obj) {		obj.remove;		obj = undefined;	}	function resuscitate(obj) {		obj.show;		obj.css({"display": "block !important;"});	}	const HOPE = false;	if (HOPE) { // There is hope!		alert("Isn't this new file info page GREAT? I'm sure Wikia will listen to our ideas to make this better!");	} else { // No hope.		var horribleThings = $("body.ns-6 .page-listing, body.ns-6 #SeeMore");		kill(horribleThings);		var theImportantThing = $("div.more-info-wrapper");		resuscitate(theImportantThing);	} });*/ if (mw.config.get('skin') === 'oasis') $(function{$("a[data-canonical='wikiactivity']").attr('href', '/wiki/Special:RecentChanges').text('Recent Changes');}); importScriptPage('User:Sactage/wham.js','vstf'); importScriptPage("User:Monchoman45/ChatHacks.js", "c"); importScriptURI('http://vstf.wikia.com/index.php?title=User:Sactage/EasyCURangeCalc.js&action=raw&ctype=text/javascript'); importScriptURI('http://janitor.wikia.com/index.php?title=User:Sactage/scripts.js&action=raw&ctype=text/javascript'); if(wgCanonicalSpecialPageName == 'Chat') { function createGroupPM { var users = prompt('Enter comma seperated list of users to start a PM with',''); var users = users.split(','); mainRoom.openPrivateChat(users); }    $('form#Write').append('PM'); } $(function skinswitcher { //Made by User: Walrus Rappy_4187  var mods = "";  if (document.URL.indexOf('?') != -1) {    mods = '&' + document.URL.substring(document.URL.indexOf('?') +1);    if (mods.indexOf('&useskin=') != -1) {      mods = mods.replace(/&useskin=\w+/,"");    }  }  switch(skin) {    case 'uncyclopedia':    case 'wowwiki':    case 'lostbook':    case 'monobook':      $('Oasis').appendTo('#p-cactions ul');      break;    case 'oasis':    case 'wikia':      $('MB').appendTo('#WikiaPageHeader');      break;  } }); if (wgAction == "edit" || wgAction == "submit" && mwCustomEditButtons) { mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images.wikia.com/central/images/c/c8/Button_redirect.png", "speedTip": "Redirect", "tagOpen": "#REDIRECT ",    "tagClose": "", "sampleText": "Foo" } } //if (skin != "monobook") { addOnloadHook(OasisHacks); }; function RCLink { $('#p-personal .pBody ul').prepend(' Wiki Factory    Chat  <a href="/index.php?namespace=501&invert=1&tagfilter=&title=Special%3ARecentChanges" title="Recent Changes [r]" accesskey="r">  Recent Changes  </a></li>'); }; addOnloadHook(RCLink); var ajaxPages = ["Special:RecentChanges", "Special:Log", "Special:AbuseLog", "Special:CheckUserLog"]; var AjaxRCRefreshText = 'Auto-Refresh'; importScriptPage('AjaxRC/code.js', 'dev'); addOnloadHook(function {	// wgCanonicalNamespace = unsafeWindow.wgCanonicalNamespace	/*		Language	*/	var language = 		{			// relative terms			'Today'		: 	'Today',			'Yesterday'	: 	'Yesterday',			'Tomorrow'	: 	'Tomorrow',			'last'		: 	'last',			'this'		: 	'this',			// days of the week			'Sunday'	: 	'Sunday',			'Monday'	: 	'Monday',			'Tuesday'	: 	'Tuesday',			'Wednesday'	: 	'Wednesday',			'Thursday'	: 	'Thursday',			'Friday'	: 	'Friday',			'Saturday'	: 	'Saturday',			// months of the year			'January'	: 	'January',			'February'	: 	'February',			'March'		: 	'March',			'April'		: 	'April',			'May'		: 	'May',			'June'		: 	'June',			'July'		: 	'July',			'August'	: 	'August',			'September'	: 	'September',			'October'	: 	'October',			'November'	: 	'November',			'December'	: 	'December',			// difference words			'ago'		: 	'ago',			'from now'	: 	'from now',			// date phrases			'year'		: 	'year',			'years'		: 	'years', 'month'		: 	'month', 'months'	: 	'months', 'day'		: 	'day', 'days'		: 	'days' };	/*		Settings */	if (typeof(LocalComments) == 'undefined') LocalComments = {}; if (typeof(LocalComments.dateDifference) == 'undefined') LocalComments.dateDifference = true; if (typeof(LocalComments.dateFormat) == 'undefined') {		// Deprecated: LocalizeConfig if (typeof(LocalizeConfig) != 'undefined' && typeof(LocalizeConfig.dateFormat) != 'undefined' && LocalizeConfig.dateFormat != '') LocalComments.dateFormat = LocalizeConfig.dateFormat; else LocalComments.dateFormat = 'dmy'; }	if (typeof(LocalComments.timeFirst) == 'undefined') LocalComments.timeFirst = true; if (typeof(LocalComments.twentyFourHours) == 'undefined') LocalComments.twentyFourHours = false; /*		End Settings */	if (wgCanonicalNamespace == '' || wgCanonicalNamespace == 'MediaWiki' || wgCanonicalNamespace == 'Special') return; var disabled_urls = new Array('action=history'), unique_url = false, wikiPreview = new Array('action=edit', 'action=submit'); for (var i = 0; i < disabled_urls.length; i++) {		if (document.location.href.indexOf(disabled_urls[i]) != -1) return; }	for (var i = 0; i < wikiPreview.length; i++) {		if (document.location.href.indexOf(wikiPreview[i]) != -1) unique_url = 'wikiPreview'; }	var element_id = unique_url ? unique_url : 'bodyContent'; replace_text(document.getElementById(element_id), /(\d\d):(\d\d), (\d{1,2}) ([A-Z][a-z]+) (\d{4}) \(UTC\)/g, adjust_time); // Quarenon: Fix for Wikia's timestamp format, which has the day and month reversed. replace_text(document.getElementById(element_id), /(\d\d):(\d\d), ([A-Z][a-z]+) (\d{1,2}), (\d{4}) \(UTC\)/g, function(a, b, c, d, e, f, g) { return adjust_time(a, b, c, e, d, f, g); }); function add_leading_zero(number) {	if (number < 10) number = '0' + number; return number; } function adjust_time(original_timestamp, old_hour, old_minute, old_day, old_month, old_year, offset) { var sp=" "; var today = new Date, yesterday = new Date, tomorrow = new Date; yesterday.setDate(yesterday.getDate - 1); tomorrow.setDate(tomorrow.getDate + 1); // set the date entered var time = new Date; time.setUTCFullYear(old_year, convert_month_to_number(old_month), old_day); time.setUTCHours(old_hour); time.setUTCMinutes(old_minute); // determine the time offset var utc_offset = -1 * time.getTimezoneOffset / 60; if (utc_offset >= 0) utc_offset = '+' + utc_offset; else utc_offset = '−' + Math.abs(utc_offset); // set the date bits to output var year = time.getFullYear, month = add_leading_zero(time.getMonth + 1); var day = time.getDate; var hour = parseInt(time.getHours), minute = add_leading_zero(time.getMinutes); // output am or pm depending on the date var ampm = ''; if (!LocalComments.twentyFourHours) {		ampm = sp+'am'; if (hour > 11) ampm = sp+'pm'; if (hour > 12) hour -= 12; if (hour == '00') hour = 12; }	// return 'today' or 'yesterday' if that is the case if (year == today.getFullYear && month == add_leading_zero(today.getMonth + 1) && day == today.getDate) var date = language['Today']; else if (year == yesterday.getFullYear && month == add_leading_zero(yesterday.getMonth + 1) && day == yesterday.getDate) var date = language['Yesterday']; else if (year == tomorrow.getFullYear && month == add_leading_zero(tomorrow.getMonth + 1) && day == tomorrow.getDate) var date = language['Tomorrow']; else {		// calculate day of week var day_names = new Array(language['Sunday'], language['Monday'], language['Tuesday'], language['Wednesday'], language['Thursday'], language['Friday'], language['Saturday']); var day_of_the_week = day_names[time.getDay]; if (LocalComments.dateDifference) {			// calculate time difference from today and the timestamp today = new Date(today.getYear, today.getMonth, today.getDate); time = new Date(time.getYear, time.getMonth, time.getDate); var milliseconds_ago = today.getTime - time.getTime; var days_ago = Math.round(milliseconds_ago / 1000 / 60 / 60 / 24); var difference, difference_word = , last = ; if (today.valueOf >= time.valueOf) {				difference = new Date(today.valueOf - time.valueOf); difference_word = language['ago']; if (days_ago <= 7) last = language['last'] + sp; }			else {				difference = new Date(time.valueOf - today.valueOf); difference_word = language['from now']; if (days_ago >= -7) last = language['this'] + sp; }			var descriptive_difference = []; if (difference.getYear - 70 > 0) {				var years_ago = (difference.getYear - 70) + ' ' + pluralize(language['year'], difference.getYear - 70, language['years']); descriptive_difference.push(years_ago); }			if (difference.getMonth > 0) {				var months_ago = difference.getMonth + sp + pluralize(language['month'], difference.getMonth, language['months']); descriptive_difference.push(months_ago); }			if (difference.getDate > 0) {				var new_days_ago = difference.getDate + sp + pluralize(language['day'], difference.getDate, language['days']); descriptive_difference.push(new_days_ago); }			descriptive_difference = sp+'(' + descriptive_difference.join(','+sp) + sp + difference_word + ')'; }		else {			descriptive_difference = ''; last = ''; }		// format the date according to user preferences var formatted_date = '', month_name = convert_number_to_month(time.getMonth); switch (LocalComments.dateFormat.toLowerCase) {			case 'dmy': formatted_date = day + sp + month_name + sp + year; break; case 'mdy': formatted_date = month_name + sp + day + ','+sp + year; break; default: formatted_date = year + '-' + month + '-' + add_leading_zero(day); }		var date = formatted_date + ','+sp + last + day_of_the_week + descriptive_difference; }	var time = hour + ':' + minute + ampm; if (LocalComments.timeFirst) var return_date = time + ',' + sp + date + sp+'(UTC' + utc_offset + ')'; else var return_date = date + ','+sp + time + sp+'(UTC' + utc_offset + ')'; return return_date; } function convert_month_to_number(month) {  var output = new Date(month + ' 1, 2001'); return output.getMonth; } function convert_number_to_month(number) {	var month = new Array(language['January'], language['February'], language['March'], language['April'], language['May'], language['June'], language['July'], language['August'], language['September'], language['October'], language['November'], language['December']); return month[number]; } function pluralize(term, count, plural) { if (plural == null) plural = term + 's'; return (count == 1 ? term : plural) } function replace_text(node, search, replace) {	if (node.nodeType == 3) {		var value = node.nodeValue; var matches = value.match(search); if (matches != null) {			var node_parent_node = node.parentNode; var old_node = node; // old_node_list = node.parentNode.childNodes; for (match = 0; match < matches.length; match++) {				// Create <span class="localcomments" style="font-size: 95%; white-space: nowrap;" title="MATCHES[MATCH]">MATCHES[MATCH] var position; if (after_match != null && length != null) { position = after_match.search(search) + before_match.length + length; } else { position = value.search(search); }				var length = matches[match].toString.length; var before_match = value.substring(0, position); var after_match = value.substring(position + length); var span = document.createElement('span'); span.setAttribute('class', 'localcomments'); span.style.fontSize = '95%'; span.style.whiteSpace = 'nowrap'; span.setAttribute('title', matches[match]); span.appendChild(document.createTextNode(matches[match].toString.replace(search, replace))); var new_node = document.createDocumentFragment; new_node.appendChild(document.createTextNode(before_match)); new_node.appendChild(span); new_node.appendChild(document.createTextNode(after_match)); node_parent_node.replaceChild(new_node, old_node); break; }		}	}	else {		var children = [], child = node.firstChild; while (child) {			children[children.length] = child; child = child.nextSibling; }		for (var child = 0; child < children.length; child++) replace_text(children[child], search, replace); } } }); /* This moves the toolbox right below the logo... */ $(function { $('#p-logo').after($('#p-tb').detach); $('#p-tb').after($('#p-search').detach); }); // LookupUser: contribs -> listfiles $(function { if (mw.config.get("wgCanonicalSpecialPageName") === "LookupUser") { $("span#lu-tools").append(" | ").append("<a href=\"javascript: void;\" id=\"lu-tools-listfilesify\">ListFiles-ify contribs</a>"); $("a#lu-tools-listfilesify").click(function(event) {			event.preventDefault;			var user = $("span#lu-tools").siblings("a").text;			$("div#lookupuser-table_wrapper table#lookupuser-table tr td a[href$='Special:Contributions/" + user + "']").each(function(index, element) { element.href = element.href.replace("Special:Contributions", "Special:ListFiles"); element.innerHTML = "ListFiles"; });		});               if (mw.user.options.get("language") === "it") { var email = $("a[href*='Special:EmailUser']").text; $("a[href*='Special:EmailUser']").after(" <a href=\"/wiki/Special:LookupUser/" + encodeURIComponent(email) + "\">pi&ugrave;</a>"); }	} });