User:Jgjake2/global.js

/* var full = window.location.host; var parts = full.split('.'); var sub = parts[0] + '.' + parts[1]; if(sub == 'ru.elderscrolls') { var set_wikiSubDomain = 'ru.elderscrolls'; importScriptPage('User:Jgjake2/js/Wikia/Popups.js', 'deadisland'); } ( function ( $, mw ) {	var nsNr = mw.config.get( 'wgNamespaceNumber' );	var theText = 'Add CSS';	if ( nsNr < 0 || window.CustomCSSButtonsLoaded || $( '#jgjake2-add-custom-css-btn' ).length ) {		return;	}	window.CustomCSSButtonsLoaded = true; // prevent duplicate running (but not dupe buttons from outside this code)	$( addPurgeButton );	var cssAdded = false;	function addStyle(css, id){		if(css) {			var doc = typeof document !== "undefined" ? document : window.document;			if(doc && doc.head) {				var style = doc.createElement('style');				if(id) style.id = id;				try {					style.innerHTML = css + "";				} catch (x) {					style.innerText = css + "";				}				style.type = 'text/css';				return doc.head.appendChild(style);			}		}	};	function disableButton($link){		$link = $link || $('#jgjake2-add-custom-css-btn');		$link.css({'pointer-events': 'none', 'cursor': 'default'}).addClass('disabled'); $link.parent.css({'pointer-events': 'none', 'cursor': 'default', 'background': 'gray'}); }	function addCSS { if(cssAdded) return; cssAdded = true; if(!$('#jgjake2-add-custom-css-btn').hasClass('disabled') && $('#jgjake2-custom-css').length == 0){ //addStyle('@import url(http://fonts.wikijs.org/UprisingSprites);\r\n', 'jgjake2-custom-css'); addStyle('@import url("http://starwars.wikia.com/load.php?mode=articles&articles=MediaWiki:SWU_Super_Walkthrough_Equipment.css&only=styles");\r\n@import url("http://starwars.wikia.com/load.php?mode=articles&articles=MediaWiki%3ASWU_Super_Walkthrough_Fonts.css&only=styles");\r\n', 'jgjake2-custom-css'); }		disableButton; }	function addOasisPurgeButton { var selector; switch (nsNr) { case 500: case 502: selector = $( '#WikiaUserPagesHeader' ); break; case 2: case 3: selector = $( '.UserProfileActionButton' ); if ( selector.length ) break; default: selector = $( '#WikiaPageHeader' ); }		selector.find('.wikia-menu-button').first.find('ul') .append(''+ theText + ''); }	function addPurgeButton { switch( mw.config.get( 'skin' ) ) { case 'uncyclopedia': /* monobook clone, pass to monobook */ case 'wowwiki': /* monobook clone, pass to monobook */ case 'lostbook': /* monobook clone, pass to monobook */ case 'monobook': $('#p-cactions > .pBody > ul').append(''+ theText + ''); break; case 'oasis': case 'wikia': addOasisPurgeButton; break; }		$( '#jgjake2-add-custom-css-btn' ).click( addCSS ); }	} ( jQuery, mediaWiki ) );

/*
 * Mass Null Edit
 * @description Null edit listed multiple pages. Similar to Ajax Batch Delete.
 * Scripts used to help create:
 * http://dev.wikia.com/wiki/NullEditButton/code.js
 * http://dev.wikia.com/wiki/AjaxBatchDelete/code.js
 * http://dev.wikia.com/wiki/ChatBlockButton/code.js
 * @author Ozuzanna


 * (function($, mw) {

if ($('#t-mne').length) return; if (!Date.now) { Date.now = function { return new Date.getTime; } }

var purgeWorkingCount = 0; var purgeCompleteCount = 0; var FormMNE = '\  \ \     Enter the name of each page you want to null edit on a separate line. Remember to include the namespace too if it is not in main. \      \ Any errors encountered will appear below \ \ ',  delay = window.nullEditDelay || 500, userbtn = window.nullEditUserButton;

//Support for Monobook if (mw.config.get('skin') === 'monobook') { mw.util.addPortletLink('p-tb', '#', 'Mass Null Edit', 't-mne'); } else { $('#my-tools-menu').prepend(' Mass Null Edit'); }

//Optional user drop-down button if (userbtn == true) { $('#AccountNavigation > li > .subnav > li:last-child').after(     $('').append('Mass Null Edit</a>')    ); }

$('#t-mne,#user-mne').click(function {    $.showCustomModal('Mass Null Edit', FormMNE, { id: 'null-edit', width: 500, buttons: [{ message: 'Cancel', handler: function { $('#null-edit').closeModal; }     }, {          message: 'Add category contents', defaultButton: true, handler: function { addCategoryContents; }     }, {          id: 'startButton', message: 'Initiate', defaultButton: true, handler: function { init; }     }]    });

//Autocomplete support for Special:WhatLinksHere if (mw.config.get('wgCanonicalSpecialPageName') === "Whatlinkshere") { $('#mw-whatlinkshere-list a').each(function {            link = $(this).prop("href");             page = $(this).text;             if (page == '← links' || page == 'edit' || link.indexOf("/Thread") != -1 || link.indexOf("/Message_Wall") != -1 ) return;            $('#text-null-edit').append(page+"\n");          }); } });

function init { var txt = document.getElementById('text-null-edit'), pages = txt.value.split('\n'), page = pages[0];

document.getElementById('startButton').setAttribute('disabled','disabled'); if (page === '' ) { document.getElementById('startButton').removeAttribute("disabled"); $.showCustomModal('Finished!', 'Nothing left to do, or next line is blank.', {          id: 'null-edit-complete',           width: 200,           buttons: [{              message: 'Close',              defaultButton: true,              handler: function {                $('#null-edit-complete').closeModal;              }           }]        }); } else { //nullEdit(page); purgePage(page); }     pages = pages.slice(1,pages.length); txt.value = pages.join('\n'); }

function addCategoryContents { var category = prompt('Please enter the category name (no category prefix):'); new mw.Api.get({     action: 'query',      list: 'categorymembers',      cmtitle: "Category:"+category,      cmlimit: 5000      }) .done(function(d) {       if (!d.error) {          var data = d.query;

for (var i in data.categorymembers) { $('#text-null-edit').append(data.categorymembers[i].title+'\n'); }       }        else { $('#text-error-output').append('Failed to get contents of '+ category +' : '+ d.error.code +' '); }     })      .fail(function { $('#text-error-output').append('Failed to get contents of '+ category +'! '); });   } 	var purgeComplete = false;	var _isPurgeComplete = false;	function isPurgeComplete{		if(purgeComplete)			return true;		if(_isPurgeComplete)			return;		_isPurgeComplete = true;		setTimeout(function{ _isPurgeComplete = false; if(purgeCompleteCount > 0 && purgeWorkingCount == 0){ purgeComplete = true; console.log('All Purges Complete'); }		}, 2500);	}

function onPurgeComplete(title, data, textStatus, jqXHR){ purgeWorkingCount--; purgeCompleteCount++; console.log('Purged: "' + title + '" (' + purgeWorkingCount + ' working, ' + purgeCompleteCount + ' Complete)'); isPurgeComplete; }	//purgeWorkingCount purgeCompleteCount function purgePage(title){ purgeWorkingCount++; purgeComplete = false; $.get( '/index.php?title=' + title.replace(/\s/g, '_') + '&action=purge&z=' + Date.now, function (data, textStatus, jqXHR) {			onPurgeComplete(title, data, textStatus, jqXHR);		} ); setTimeout(init,delay); }	/*  function nullEdit(pageNullEdit) { new mw.Api.post({    format: 'json',     action: 'edit',     title: pageNullEdit,     token: mw.user.tokens.get('editToken'),     prependtext: ''     }) .done(function(d) {       if (!d.error) {         console.log('Null edit of '+pageNullEdit+' successful!');       } else {         console.log('Failed to null edit '+pageNullEdit+': '+ d.error.code);	 $('#text-error-output').append('Failed to null edit '+pageNullEdit+': '+d.error.code+' ');       }     }) .fail(function {      console.log('Failed to null edit '+pageNullEdit+'!');       $('#text-error-output').append('Failed to null edit '+pageNullEdit+': unknownerror ');     }); setTimeout(init,delay); } */ }) (this.jQuery, this.mediaWiki);