User:TheV1ct0ri0u5/global.js

/**********/ /* Toolbar */ /**********/

/* Main */ $(function {	$('' );

/* More */

/* My Tools */ $('#my-tools-menu').prepend(   ' Edit Count' +    ' Recent Changes' +    ' User Block Log');

/******************************************/ /* Special:ListUsers Powerusers check box */ /******************************************/ if (wgCanonicalSpecialPageName == "Listusers") { $("fieldset.lu_fieldset tr:last-child").prepend('  Powerusers '); };

/*************/ /* AJAX Stuff */ /*************/

/* Anchored Rollback */ /* $('.mw-rollback-link a').click(function(e) { e.preventDefault;  $.get($(this).attr('href'));  $(this).text('rollbacked').css({'color':'grey','text-decoration':'line-through'}).removeAttr('href title'); }); }) (this.jQuery, this.mediaWiki); //
 * Anchored Rollback
 * @description Perform rollbacks without changing location
 * @author Ozuzanna
 * (function($, mw) {

/* AJAX Patrol */ /** * jQuery Ajax Patrol Links * * @author Grunny * */ function ajaxPatrolLinks { if( !$( '.patrollink' ).length ) return; $( '.patrollink' ).click( function ( e ) {		e.preventDefault;		var	$patrolLink = $( this ).children( 'a' ),			$url = $patrolLink.attr( 'href' );		$patrolLink.html('');		$.get( $url, $patrolLink.removeAttr( 'href' ).css( 'color', 'grey' ).text( 'Marked as patrolled' ));	} ); } $( ajaxPatrolLinks );

/* AjaxRC */ */ /* * ADVANCED AJAX AUTO-REFRESHING ARTICLES * * Original by pcj of Wowpedia * Maintenance, cleanup, style and bug fixes by: *  Grunny (http://c.wikia.com/wiki/User:Grunny) *  Kangaroopower (http://c.wikia.com/wiki/User:Kangaroopower) *  Cqm (http://c.wikia.com/wiki/User:Cqm) */ /*jshint browser:true, camelcase:true, curly:true, eqeqeq:true, immed:true, jquery:true, latedef:true, newcap:true, noarg:true, noempty:true, nonew:true, quotmark:single, trailing:true, undef:true, unused:true, onevar:true */ /*global mediaWiki:true, Wikia:true */ ( function ( window, $, mw, Wikia ) {	'use strict';	var config = mw.config.get( [ 'stylepath', 'wgAction', 'wgCanonicalSpecialPageName', 'wgPageName' ] ),		// use common file as it's very likely to be already cached by user		// used in oasis sidebar loading, preview modal, etc.		ajaxIndicator = window.ajaxIndicator || config.stylepath + '/common/images/ajax.gif',		ajaxTimer,		refreshText = typeof window.AjaxRCRefreshText === 'string' ? window.AjaxRCRefreshText : 'AJAX',		refreshHover = typeof window.AjaxRCRefreshHoverText === 'string' ? window.AjaxRCRefreshHoverText : 'Enable auto-refreshing page loads',		ajRefresh = window.ajaxRefresh || 60000,		ajPages = window.ajaxPages || [ 'Special:RecentChanges' ],		RecentChangesLocal,		// don't load on these values of wgAction		// @todo check if markpatrolled should be here		disallowActions = [			'delete',			'edit',			'protect',			'revisiondelete'		];	function storage( setTo ) {		if ( localStorage.getItem( 'AjaxRC-refresh' ) === null ) {			localStorage.setItem( 'AjaxRC-refresh', true );		}		if ( setTo === false ) { localStorage.setItem( 'AjaxRC-refresh', false ); } else if ( setTo === true ) { localStorage.setItem( 'AjaxRC-refresh', true ); }		return JSON.parse( localStorage.getItem( 'AjaxRC-refresh' ) ); }	/**	 * Main function to start the Auto-refresh process */	function preloadAJAXRL { // monobook var $appTo = $( '.firstHeading' ).length ? $( '.firstHeading' ) : // most oasis pages ( $( '#WikiaPageHeader' ).length ? $( '#WikiaPageHeader' ) :				// most oasis special pages				( $( '#AdminDashboardHeader' ).length ? $( '#AdminDashboardHeader > h1' ) : false ) ), $checkbox = $( ' ' ) .css( { 'font-size': 'xx-small', 'line-height': '100%', 'margin-left': '5px' } ) .append(					$( ' ' )						.css( { 'border-bottom': '1px dotted', 'cursor': 'help' } )						.attr( 'title', refreshHover ).text( refreshText + ':' ),					$( '' ).css( { 'margin-bottom': 0 } ),					$( ' ' ).css( 'display', 'none' ).append( $( ' ' ).css( { 'vertical-align': 'baseline', 'float': 'none', 'border': 0 } ) .attr( 'src', ajaxIndicator ).attr( 'alt', 'Refreshing page' ) )				),			$throbber; // fallback for pages with profile masthead if ( $appTo === false ) { $( '#WikiaArticle' ).prepend( $checkbox ); } else { $appTo.append( $checkbox ); }		$throbber = $appTo.find( '#ajaxLoadProgress' ); $( document ).ajaxSend( function ( event, xhr, settings ) {			if ( location.href === settings.url ) {				$throbber.show;			}		} ).ajaxComplete ( function ( event, xhr, settings ) {			var $collapsibleElements = $( '#mw-content-text' ).find( '.mw-collapsible' ),				ajCallAgain = window.ajaxCallAgain || [],				i;			if ( location.href === settings.url ) {				$throbber.hide;				if ( $collapsibleElements.length ) {					$collapsibleElements.makeCollapsible;				}				if ( config.wgCanonicalSpecialPageName === 'Recentchanges' ) {					mw.special.recentchanges.init;					if ( $( '.mw-recentchanges-table' ).find( '.WikiaDropdown' ).length ) {						RecentChangesLocal.init;					}				}				if ( config.wgCanonicalSpecialPageName === 'WikiActivity' ) {					window.WikiActivity.init;				}				for ( i = 0; i < ajCallAgain.length; i++ ) {					ajCallAgain[i];				}			}		} ); $( '#ajaxToggle' ).click( toggleAjaxReload ); $( '#ajaxToggle' ).attr( 'checked', storage ); if ( storage ) { loadPageData; }	}	/**	 * Turn refresh on and off by toggling the checkbox */	function toggleAjaxReload { if ( $( '#ajaxToggle' ).prop( 'checked' ) === true ) { storage( true ); loadPageData; } else { storage( false ); clearTimeout( ajaxTimer ); }	}	/**	 * Does the actual refresh */	function loadPageData { var $temp = $( ' ' ); $temp.load( location.href + ' #mw-content-text', function {			var $newContent = $temp.children( '#mw-content-text' );			if ( $newContent.length ) {				$( '#mw-content-text' ).replaceWith( $newContent );			}			ajaxTimer = setTimeout( loadPageData, ajRefresh );		} ); $temp.remove; }	/**	 * Load the script on specific pages * and only on certain values for wgAction (see disallowActions above) */	$( function {		if ( $.inArray( config.wgPageName, ajPages ) !== -1 && $( '#ajaxToggle' ).length === 0 && $.inArray( config.wgAction, disallowActions ) === -1 ) {			preloadAJAXRL;		}	} ); /**	 * Temp Hack: copy the RC filter JS since it can't be accessed * @source  */	RecentChangesLocal = { init: function { this.$table = $( '.mw-recentchanges-table' ); this.$dropdown = this.$table.find( '.WikiaDropdown' ); this.$submit = this.$table.find('input[type="submit"]'); this.$submit.on( 'click.RecentChangesDropdown', $.proxy( this.saveFilters, this ) ); this.$submit.removeAttr( 'disabled' ); //FF clean this.dropdown = new Wikia.MultiSelectDropdown( this.$dropdown ); this.dropdown.on( 'change', $.proxy( this.onChange, this ) ); },		saveFilters: function( event ) { var self = this; event.preventDefault; self.dropdown.disable; self.$submit.attr( 'disabled', 'disabled' ); if ( self.dropdown.getSelectedValues.length === 0 ) { self.dropdown.doSelectAll( true ); }			$.nirvana.sendRequest( {				controller: 'RecentChangesController',				method: 'saveFilters',				data: {					filters: self.dropdown.getSelectedValues				},				type: 'POST',				format: 'json',				callback: function ( data ) {					window.location.reload;				}			} ); }	}; }( this, jQuery, mediaWiki, Wikia ) ); /*

/* AJAX Rename */ /** * Ajax Page Rename * Allows the user to quickly rename a page without having to load Special:MovePage * http://community.wikia.com/wiki/User:Cörey */     var currentName = mw.config.get("wgPageName"), token = mw.user.tokens.get("editToken"); $(".WikiaMenuElement li:last").after('<a href="#" id="ajax-rename">Ajax Rename</a></li>'); $('#ajax-rename').click(function {	 	renamePage;	  }); function renamePage { var newName = prompt('What would you like to rename the page to?', ''), moveReason = prompt('Reason: ', 'Renaming page'); if (newName === null) { return; }	 	if (moveReason === null) { return; }	 	new mw.Api.post({	  		action: 'move',	  		from: currentName,	  		to: newName,	  		movesubpages: ,	  		movetalk: ,	  		reason: moveReason,	  		token: token	  	}).done(function(ajaxrename) {	  		if (!ajaxrename.error) {	  			alert(currentName + ' has been renamed to ' + newName);	  			location.reload(true);	  		} else {	  			alert('Unable to rename page. ' + ajaxrename.error.code);	 		}	  	}).fail(function {	  		alert('Unable to rename page.');	  	}); }	}) (this.jQuery, this.mediaWiki); //
 * (function($, mw) {

/* AJAX Undo */ /** * Ajax Undo links * * Adds an Ajax undo link next to the normal undo link on page histories * and on diff pages * * @author Grunny * @version 0.2 * */ jQuery(document).ready( function ( $ ) {	"use strict";	function createUndoLink( diffUndoUrl ) {		var $ajaxUndoLink = $( '<a />' ).text( 'AJAX Undo' ).attr( 'href', '#' ).click( function { var	$ajaxUndoLinkob = $( this ), undoIdRegex = /&undo=([^&]*)/, undoId = undoIdRegex.exec( diffUndoUrl )[1], editToken, etUrl = wgServer + wgScriptPath + '/api.php?action=query&prop=info|revisions&intoken=edit&titles=' + encodeURIComponent( wgPageName ) + '&format=json'; $ajaxUndoLinkob.html( ' <img src="http://images2.wikia.nocookie.net/dev/images/8/82/Facebook_throbber.gif" style="vertical-align: baseline;" border="0" alt="Undoing..." />' ); $.getJSON( etUrl, function ( data ) {				editToken = data.query.pages[wgArticleId].edittoken;				$.ajax( { url: wgScriptPath + '/api.php?', data: 'action=edit&format=json&title=' + encodeURIComponent( wgPageName ) + '&undo=' + encodeURIComponent( undoId ) + '&bot=1&token=' + encodeURIComponent( editToken ), dataType: 'json', type: 'POST', success: function ( data ) { if ( data.edit && data.edit.result === 'Success' ) { $ajaxUndoLinkob.text( '(undone)' ); } else if ( data.error && data.error.code === 'undofailure' ) { $ajaxUndoLinkob.text( '(error)' ); alert( data.error.info ); } else { $ajaxUndoLinkob.text( '(error)' ); alert( 'Error: Unknown result from API.' ); }					},					error: function { $ajaxUndoLinkob.text( '(error)' ); }				} );			} );		} );		return $ajaxUndoLink;	}	if ( $( '.mw-history-undo > a' ).length && wgAction === 'history' ) {		$( '.mw-history-undo > a' ).each( function { var	diffUndoUrl = $( this ).attr( 'href' ), $ajaxUndoLink = createUndoLink( diffUndoUrl ); $( this ).parent.after( ' | ', $ajaxUndoLink ); } );	} else if ( $( 'table.diff' ).length && typeof $.getUrlVar( 'diff' ) !== 'undefined' ) {		var	$diffUndoLink = $( 'table.diff' ).find( '.diff-ntitle > #mw-diff-ntitle1 a:last' ),			diffUndoUrl = $diffUndoLink.attr( 'href' ),			$ajaxDiffUndoLink = createUndoLink( diffUndoUrl );		$diffUndoLink.parent.append( ' (', $ajaxDiffUndoLink, ')' );	} } ); //

/*********/ /* Other */ /*********/

/* FindAndReplace */ //__NOWYSIWYG__ <input type="button" value="' + lng.farbuttontext + '" id="find-and-replace">  <input type="button" value="' + lng.farselbuttontext + '" id="find-and-replace-selected"> <p style="font-size: 120%">' + lng.selectedtext + ' <textarea id="texteselectionne" readonly="" style="width: 100%; height: 80px;"> <a href="javascript:void(0)" id="far-undo">' + lng.undoedits + '</a><acronym title="' + lng.undoinfo + '" style="border: none;" class="icone-aide"><img src="http://img2.wikia.nocookie.net/__cb20141207003419/harrypotter/fr/images/thumb/6/6c/Icone-aide.png/12px-Icone-aide.png" alt="Icone-aide" class="lzyPlcHld lzyTrns lzyLoaded" data-image-key="Icone-aide.png" data-image-name="Icone-aide.png" data-src="http://img2.wikia.nocookie.net/__cb20141207003419/harrypotter/fr/images/thumb/6/6c/Icone-aide.png/12px-Icone-aide.png" width="12" height="12">   ');    $(window).resize(function { $('#findfielddiv').height($(window).height - 250 - $('.module_content').height); });   $(window).trigger('resize');    $('#find-and-replace').click(function  { var searchfor = '', searchexp, $textarea = $('#wpTextbox1'), replacewith = $('#replace_with').val.replace(/\r/gi, ''), text = $textarea.val.replace(/\r/gi, ''), flagg = 'g', flagi = 'i', enableregex = 0; if ($('#globl').prop('checked') === false) { flagg = ''; }       if ($('#case_sen').prop('checked') === true) { flagi = ''; }       if ($('#regex_search').prop('checked') === true) { enableregex = 1; }       var flags = flagg + flagi + 'm'; if(enableregex === 1) { searchfor = $('#find_this').val; } else { searchfor = $('#find_this').val.replace(/\r/gi, '').replace(/([.*+?^=!:${}|\[\]\/\\])/g,'\\$1'); }       searchexp = new RegExp(searchfor, flags); var rcount = 0; var matched = text.match(searchexp); if (matched !== null) { rcount = matched.length; }       text = text.replace(searchexp, replacewith); $textarea.val(text); $('#far-found').text( rcount + ' ' + lng.farfound ); });   function getSelectedText {        var texte = "";        if (window.getSelection) {            texte = window.getSelection.toString;        } else if (document.selection && document.selection.type != "Control") {            texte = document.selection.createRange.text;        }        if(texte === "") {            texte = selectedText;        }        return texte;    }    $('#wpTextbox1').bind('mouseup keyup mouseleave', function{ selectedText = getSelectedText; debuta = contengut.selectionStart; fin = contengut.selectionEnd; $('#texteselectionne').text(selectedText); });   $('#find-and-replace-selected').click(function  { if(selectedText === "") { alert(lng.noselected); }       var searchfor = '', searchexp, searchexp2, letexte, selectedText2, $textarea = $('#wpTextbox1'), replacewith = $('#replace_with').val.replace(/\r/gi, ''), text = $textarea.val.replace(/\r/gi, ''), flagg = 'g', flagi = 'i', enableregex = 0;

if ($('#globl').prop('checked') === false) { flagg = ''; }       if ($('#case_sen').prop('checked') === true) { flagi = ''; }       var flags = flagg + flagi + 'm'; if(enableregex === 1) { searchfor = $('#find_this').val; } else { searchfor = $('#find_this').val.replace(/\r/gi, '').replace(/([.*+?^=!:${}|\[\]\/\\])/g,'\\$1'); }       searchexp = new RegExp(searchfor, flags); selectedText2 = selectedText.replace(/\r/gi, '').replace(/([.*+?^=!:${}|\[\]\/\\])/g,'\\$1'); searchexp2 = new RegExp(selectedText2, 'im'); var rcount = 0; var matched = selectedText.match(searchexp); if (matched !== null) { rcount = matched.length; }       letexte = selectedText.replace(searchexp, replacewith); text = text.substring(0, debuta) + letexte + text.substring(fin); $textarea.val(text); $('#far-found').text( rcount + ' ' + lng.farfound ); selectedText = letexte; $('#texteselectionne').text(selectedText); });   function getOldContent {        $("#wpTextbox1").val($("#wpTextbox1").text);    }    $('a#far-undo').click(function  { if (confirm(lng.undomsg)) getOldContent; });   $(".far-module h3").click(function  { var $header = $(this); var $content = $header.next; var $visible = $content.is(":visible"); $header.find('span').text(lng.far + " (" + ($visible ? lng.expand : lng.collapse) + ")"); $header.find(".chevron").addClass($visible ? "expand" : "collapse").removeClass($visible ? "collapse" : "expand"); $content.stop.slideToggle(500); });   $(window).bind("beforeunload", function{ $.storage.set("FindAndReplace", {sh: $("#findfielddiv").is(":visible")}); }); }); // //

/* WHAM */ //

/* DisplayClock */ // __NOWYSIWYG__

/* View Source */ /** * View Source * * © Peter Coester 2013 Pecoes * * documentation and examples at: * http://dev.wikia.com/wiki/View_Source */

// __NOWYSIWYG__

/* Sine */ //

/* AllPagesHideRedirect */ //

/* PortableCSSPad */ //

/* BackToTopArrow */ //__NOWYSIWYG__

/* Quick Management */ //

/* RevealAnonIP */ /* __NOWYSIWYG__  */

/* ViewRemoved */ //

/* UserRightsRecord */ // ');       } else if (mode === 'users') {            $urr.append('<ul></ul>');        }

for (var key in stuff) { keysOuter.push(key); }       keysOuter.sort;

for (var i = 0; i < keysOuter.length; i++) { keysInner = []; for (var key in stuff[keysOuter[i]]) { keysInner.push(key); }           keysInner.sort;

for (var j = 0; j < keysInner.length; j++) { item = stuff[keysOuter[i]][keysInner[j]]; merge = arrMerge(item);

if (mode === 'rights') { if (j === 0) { $urr.append(                           $(' ', { 'id':'urr-' + keysOuter[i] + '-' + thisidx, 'text':keysOuter[i] }).after( $(' ', {'id':'urr-active'}) )                       );

$('#urr-toc').append(                           $(' ', { 'class':'toclevel-1', 'html':$('<a />', {                                   'href':'#urr-' + keysOuter[i] + '-' + thisidx,                                    'text':keysOuter[i]                                }) })                       );                    }

if (merge) { $('#urr-active').append(                           $(' ').html( $('<a />', {                                   'href':'/wiki/' + keysInner[j].replace(/ /g, '_'),                                    'text':keysInner[j].substring(5)                                }).after(': ') ).append(merge)                       ); }               } else if (mode === 'users') { if (j === 0) { $urr.children('ul').append(                           $(' ', { 'id':'urr-active', 'html':$('<a />', {                                   'href':'/wiki/' + keysOuter[i].replace(/ /g, '_'),                                    'text':keysOuter[i].substring(5)                                }).after(': ') })                       );                    } else if (merge && $('#urr-active').text.slice(-1) === ')') {                        $('#urr-active').append(', ');                    }

if (merge) { $('#urr-active').append(keysInner[j] + ' (' + merge + ')'); }               }            }

$('#urr-active').removeAttr('id'); }

cleanOutput; //easier to clean up a mess than to avoid making one

$('#urr-toc').removeAttr('id'); //for multiple instances on one page }

//One line to call them all getData(start, putResults); }); //