User:Stelercus/global.js

/* VDA */ importScriptPage('User:Ajraddatz/VDA.js', 'community')

/* Forum:Hyper Editing! script */ importScriptURI("http://en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js&action=raw&ctype=text/javascript");

/** * autowelcome.js * * Automatically insert the welcome notice code when editing a new user talk page. * * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ // if (wgCanonicalNamespace == 'User_talk' && wgAction == 'edit' && wgArticleId === 0 && wgTitle.split('.').length != 4 && wgTitle.indexOf('/') == -1) { $(document).ready(function {		$('#wpTextbox1').val((typeof(window.autoWelcomeText) == 'undefined') ? '&mdash;~' : window.autoWelcomeText);		$('#wpSummary,#wpSummaryEnhanced').val((typeof(window.autoWelcomeSummary) == 'undefined') ? 'Welcome!' : window.autoWelcomeSummary);	}); } //

/*	Documentation: Comments in Local Time 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 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 = ' am'; if (hour > 11) ampm = ' 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'] + ' '; }			else {				difference = new Date(time.valueOf - today.valueOf); difference_word = language['from now']; if (days_ago >= -7) last = language['this'] + ' '; }			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 + ' ' + pluralize(language['month'], difference.getMonth, language['months']); descriptive_difference.push(months_ago); }			if (difference.getDate > 0) {				var new_days_ago = difference.getDate + ' ' + pluralize(language['day'], difference.getDate, language['days']); descriptive_difference.push(new_days_ago); }			descriptive_difference = ' (' + descriptive_difference.join(', ') + ' ' + 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 + ' ' + month_name + ' ' + year; break; case 'mdy': formatted_date = month_name + ' ' + day + ', ' + year; break; default: formatted_date = year + '-' + month + '-' + add_leading_zero(day); }		var date = formatted_date + ', ' + last + day_of_the_week + descriptive_difference; }	var time = hour + ':' + minute + ampm; if (LocalComments.timeFirst) var return_date = time + ', ' + date + ' (UTC' + utc_offset + ')'; else var return_date = date + ', ' + time + ' (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 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); } } });

/* */ /** * editreport.js * * Create Edit Report links in the "User Masthead" area in Monaco. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ $(document).ready(function {	if (wgCanonicalNamespace == 'User' || wgCanonicalNamespace == 'User_talk') {		var $li = $(' ').addClass('color1').append($('').attr('href', 'http://rstools.ath.cx/editreport.php?username=' + encodeURIComponent(wgTitle.split('/')[0])).text('Edit Report'));		var id = (skin == 'monaco') ? '#user_masthead_tabs' : '#p-tb ul';		$(id).append($li);	} }); /* */

//Mass rollback function //Written by John254 //Adapted from User:Mr.Z-man/rollbackSummary.js //Instructions: Selecting the "rollback all" tab when viewing a user's contributions history //will open all rollback links displayed there. (Use with caution) // Adapted to work for Monaco // Original source: http://en.wikipedia.org/wiki/User:John254/mass_rollback.js $(document).ready(function {	var hasRollback = getElementsByClassName(document, "span", "mw-rollback-link");	if (hasRollback[0] && wgCanonicalSpecialPageName && wgCanonicalSpecialPageName == 'Contributions') {		// Add icon		appendCSS('#ca-rollbackall {background:url(http://img24.imageshack.us/img24/271/1248654995arrowcircledo.png) center left no-repeat;padding-left: 19px;} body.masthead-special #page_bar {height: auto !important;}');		var portlet = (skin == 'monobook') ? 'p-cactions' : 'page_bar';		addPortletLink(portlet, 'javascript:rollbackEverything;', 'Rollback all', 'ca-rollbackall', 'Rollback all edits displayed here.');	} }); function rollbackEverything { for (var i in document.links) { if (document.links[i].href.indexOf('action=rollback') != -1) { window.open(document.links[i].href); }   	} }

var popScript    = 'http://en.wikipedia.org/w/index.php?action=raw&ctype=text/javascript&title=MediaWiki:Gadget-popups.js'; var popStyleSheet = 'http://en.wikipedia.org/w/index.php?action=raw&ctype=text/css&title=User:Lupin/navpopdev.css'; if ( window.localCSS ) { popStyleSheet = 'http://localhost:8080/js/navpop.css'; }

function popups_importScriptURI(url) { var s = document.createElement('script'); s.setAttribute('src',url); s.setAttribute('type','text/javascript'); document.getElementsByTagName('head')[0].appendChild(s); return s; }

function popups_importStylesheetURI(url) { return document.createStyleSheet ? document.createStyleSheet(url) : popups_appendCSS('@import "' + url + '";'); }

function popups_appendCSS(text) { var s = document.createElement('style'); s.type = 'text/css'; s.rel = 'stylesheet'; if (s.styleSheet) s.styleSheet.cssText = text //IE else s.appendChild(document.createTextNode(text + '')) //Safari sometimes borks on null document.getElementsByTagName('head')[0].appendChild(s); return s; }

popups_importStylesheetURI(popStyleSheet); popups_importScriptURI(popScript);

/** * rcrollback.js * * Add rollback and undo links to Special:RecentChanges. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** FIXME Also require MW version to be 1.14.x */ if (wgCanonicalSpecialPageName && wgCanonicalSpecialPageName == 'Recentchanges') { $(document).ready(function {		var rollbackLinks = new Array;		// Check if user is in a group with rollback rights.		function userHasRollback {			for (var i in wgUserGroups) {				if (wgUserGroups[i] == 'sysop' || wgUserGroups[i] == 'rollback') {					return true;				}			}			return false;		}		// Return true if the given string is a unique rollback link		function uniqueRollback(str) {			for (var i in rollbackLinks) {				if (rollbackLinks[i] == str) {					return false;				}			}			rollbackLinks.push(str);			return true;		}		// Add a revert links as a child to the given DOM object.		function addRevertLinks(obj, title, user, diffLink) {			var matches = diffLink.match(/diff=([0-9]+)&oldid=([0-9]+)/);			var titleURI = encodeURIComponent(title);			var userURI = encodeURIComponent(user);			var span = document.createElement('span');			span.setAttribute('class', 'rc-revert');			span.setAttribute('className', 'rc-revert'); if (wgVersion.split('.')[1] == '14' && userHasRollback && uniqueRollback(user + '|' + title)) { span.appendChild(document.createTextNode('[')); var rbLink = document.createElement('a'); rbLink.href = '#doRollback'; rbLink.setAttribute('class', 'rc-rollback'); rbLink.setAttribute('className', 'rc-rollback'); rbLink.setAttribute('onclick', 'doRollback(this, "' + titleURI + '", "' + userURI + '"); return false;'); if (rbLink.attachEvent) { rbLink.onclick = function { doRollback(this, titleURI, userURI); return false; };				}				rbLink.setAttribute('title', '"Rollback" reverts edit(s) to this page of the last contributor in one click'); rbLink.appendChild(document.createTextNode('rollback')); span.appendChild(rbLink); span.appendChild(document.createTextNode('] ')); }			span.appendChild(document.createTextNode('('));			var undoLink = document.createElement('a');			undoLink.href = wgScript + '?action=edit&title=' + titleURI + '&undoafter=' + matches[2] + '&undo=' + matches[1];			undoLink.setAttribute('class', 'rc-undo');			undoLink.setAttribute('className', 'rc-undo');			undoLink.setAttribute('title', '"Undo" reverts this edit and opens the edit form in preview mode. Allows adding a reason in the summary');			undoLink.appendChild(document.createTextNode('undo'));			span.appendChild(undoLink);			span.appendChild(document.createTextNode(')')); obj.appendChild(span); obj.insertBefore(document.createTextNode(' '), span); }		var lists = getElementsByClassName(document,'ul','special'); if (lists.length == 0) { // User is using enhanced RC. var bodyDivs = document.getElementById('bodyContent').getElementsByTagName('div'); var groups = null; // Search for the RC container, which is the first div without an id in MW 1.14.0. for (var i = 0; i < bodyDivs.length; i++) { // iterate over days if (bodyDivs[i].id == '') { groups = bodyDivs[i].getElementsByTagName('table'); for (var j = 0; j < groups.length; j++) { // iterate over collapsible tables var items = groups[j].getElementsByTagName('tr'); for (var k = 0; k < items.length; k++) { // iterate over each row var entry = items[k].getElementsByTagName('td')[1]; var links = entry.getElementsByTagName('a'); if (links.length >= 3) { if (links[1].innerHTML == 'diff') { // Nongrouped change var diffLink = links[1].href; } else if (links[2].innerHTML == 'prev') { // Grouped change var diffLink = links[2].href; } else { continue; }								addRevertLinks(entry, links[0].getAttribute('title'), links[3].innerHTML, diffLink); }						}					}				}			}		} else { // User is using standard RC. for (var i = 0; i < lists.length; i++) { // iterate over days var items = lists[i].getElementsByTagName('li'); for (var j = 0; j < items.length; j++) { // iterate over entries var links = items[j].getElementsByTagName('a'); if (links[0].innerHTML == 'diff') { addRevertLinks(items[j], links[2].innerHTML, links[3].innerHTML, links[0].href); }				}			}		}	}); } // Perform a rollback. First, use AJAX to obtain a rollback token, then redirect to the rollback page. function doRollback(link, title, user) {	var span = link.parentNode;	span.innerHTML = '';	var ajax = null;	if (window.XMLHttpRequest) {		ajax = new XMLHttpRequest; 	} else {                                      		ajax = new ActiveXObject("Microsoft.XMLHTTP");	}	ajax.onreadystatechange = function {		if (ajax.readyState === 4) {			if (ajax.status == 200) {				// FIXME Switch to JSON				var revs = ajax.responseXML.getElementsByTagName("rev");				var token = revs[0].getAttribute('rollbacktoken');				if (token) {					document.location.href = wgScript + '?title=' + title + '&action=rollback&from=' + user + '&token=' + encodeURIComponent(token);				} else {					span.innerHTML = '[Rollback error]'; }			} else { span.innerHTML = '[Server error]'; }		}	}	ajax.open('GET', wgScriptPath + '/api.php?action=query&prop=revisions&rvtoken=rollback&format=xml&titles=' + title, true); ajax.send(null); }

/** * Original script: User:Sander_Säde/quickpreview.js * Ported to use jQuery and Monaco for Wikia */ if (skin == 'monaco' && (wgAction == 'edit' || wgAction == 'submit')) { $(document).ready(function {		var attrs = {			tabindex: 6,			accesskey: 'g',			id: 'dlQuickPreview',			title: 'Preview your changes'		};		var $button = $(' ').val('Quick preview').attr(attrs).click(function { $(this).val('Getting preview').attr('disabled', 'disabled'); var f = document.editform; $.ajax({				data: {					'wpMinoredit': f.wpMinoredit.checked,					'wpWatchthis': f.wpWatchthis.checked,					'wpStarttime': f.wpStarttime.value,					'wpEdittime': f.wpEdittime.value,					'wpAutoSummary': f.wpAutoSummary.value,					'wpEditToken': f.wpEditToken.value,					'wpSummary': 'Quick preview',					'wpTextbox1': f.wpTextbox1.value				},				dataType: 'text',				type: 'POST',				url: document.location.href.replace('&action=edit', '&action=submit') + '&wpPreview=true&live=true',				success: function(response) {					$('#wikiPreview').css('display', 'block').html(unescape(response.replace(/&gt;/g, '>').replace(/&lt;/g, '<').replace(/&amp;/g, '&').replace(/&quot;/g, '"')));					$('#dlQuickPreview').val('Quick preview').attr('disabled', null);				}			});		});		var $li = $(' ').append($button);		$('#edit_enhancements_toolbar li').eq(2).after($li);	}); }