User:KonstantinaG07/common.js

$( document ).ready( function { mw.util.addPortletLink( 'p-personal', mw.util.getUrl('Special:NewPagesFeed'), 'Page Curation', 'pt-pagecuration', 'View Special:New Pages using the Page Curation tool', null, '#pt-preferences' ); }); importScript('User:Jackmcbarn/editProtectedHelper.js'); // Linkback: User:Jackmcbarn/editProtectedHelper.js

importScript('User:GoldenRing/wordcount.js'); importScript('User:Lupin/recent2.js'); importScript( 'User:MusikAnimal/responseHelper.js' ); // Backlink: User:MusikAnimal/responseHelper.js importScript( 'User:Technical_13/Scripts/OneClickArchiver.js' ); // Backlink: User:Technical_13/Scripts/OneClickArchiver importScript( 'User:Enterprisey/orcp-helper.js' ); // Backlink: User:Enterprisey/orcp-helper.js importScript( 'User:Andy M. Wang/pageswap.js' ); // Backlink: User:Andy M. Wang/pageswap importScript( 'User:Enterprisey/delsort.js' ); // Backlink: User:Enterprisey/delsort.js

(function ($) { // Wrap with anonymous function   function stubTagTab {        var $h, $hb, $newa,            // A list of subpages of WikiProject Stub sorting/Stub types/ that are relevant to this            a = ['General', 'Architecture', 'Commerce', 'Culture', 'Education', 'Geography', 'Government, law, and politics',                 'History', 'Leisure', 'Military and weaponry', 'Organizations', 'People',                 'Religion, mythology, faiths, and beliefs', 'Science', 'Sports', 'Technology', 'Transport',                 'Miscellaneous'];        $h = $("  ", { "color": "#000000", "background-color": "#fff8f8" });       for (var i = 0; i < a.length; i++) {            $newa = $("");            $newa.click(function (e) { e.preventDefault; stubTagMenu($(this).text); });           $newa.text(a[i]);            $h.append($newa);            if ((i + 1) < a.length) {                $h.append(" &bull; ");            }        }        $("#contentSub").append($h);

$hb = $(" ", {                  "color": "#000000",                  "background-color": "#fffff8"              }); $hb.attr("id", "stubtagmenu"); $("#contentSub").append($hb); }

function stubTagMenuRender(data) { var $parseData = $(data.parse.text["*"]); $parseData.find("a").each(function {            var link = $(this).attr("href"),                index = link.indexOf("Template:");            if (index === -1) {                $(this).attr({ "href": null, "title": null });               $(this).css({ "color": "#000000", "text-decoration": "none" });           } else {                $(this).attr("href", mw.config.get("wgServer") + mw.config.get("wgScript") + "?title=" + encodeURIComponent(mw.config.get("wgPageName")) + "&action=edit&autoaddstubtag=" + encodeURIComponent(link.slice(index + 9)));           }        }); $("#stubtagmenu").html($parseData); }

function stubTagMenuFail { $("#stubtagmenu").html("Failed to load stub tags."); }

function stubTagMenu(stubType) { // Add loading message $("#stubtagmenu").html("Loading stub tags, please wait...");

// Fetch the relevant subpage of the WikiProject $.ajax({           url: mw.config.get("wgServer") + mw.config.get("wgScriptPath") + '/api.php?action=parse&prop=text&text=' + encodeURIComponent('\{\{Wikipedia:WikiProject Stub sorting/Stub types/' + stubType + '}}') + '&format=json',            dataType: "json",            success: stubTagMenuRender,            error: stubTagMenuFail        }); }

$(function {        if ((mw.config.get("wgNamespaceNumber") === 0 ||             mw.config.get("wgPageName") === "Wikipedia:Sandbox") && mw.config.get("wgAction") === "view" && $("#ca-edit").length !== 0) {           var portletLink = mw.util.addPortletLink('p-cactions', '#', 'Stub', 'ca-stubtag', 'Add a stub tag to this page', '');            $(portletLink).click(function (e) { e.preventDefault; stubTagTab; });       }        if (location.href.indexOf("&autoaddstubtag=") !== -1 && $("#wpTextbox1").length !== 0) {            var x = decodeURIComponent(location.href.split("&autoaddstubtag=")[1]);            if (x.indexOf("-stub") === -1 && x !== "Stub") {                x += "-stub";            }            $("#wpTextbox1").val($("#wpTextbox1").val + "\n{" + "{" + x + "}}"); // add to the end of the article            $("#wpSummary").val("Tagging with {" + "{" + x + "}}  (StubTagTab)");            $("#wpPreview").trigger("click");        }    }); } (jQuery)); // End wrap with anonymous function function rollbackEverythingWKMR(editSummary) {	if(editSummary === null)	{		return false;	}	var userName = mw.config.get("wgRelevantUserName");	var titleRegex = /title=([^&]+)/;	mw.loader.using( 'mediawiki.api' ).done( function {		var api = new mw.Api; $("a[href*='action=rollback']").each(function(ind, el)		{			var params = {};			if( editSummary != '' )			{				params.summary = editSummary;			}			api.rollback( titleRegex.exec(el.href)[1], userName, params).done( function {				$(el).after("reverted"); $(el).remove; } );		} );	} );	return false; } $(document).ready(function {	if(mw.config.get("wgCanonicalSpecialPageName") == "Contributions" && $("span.mw-rollback-link").length > 0) {		mw.loader.using("mediawiki.util").done( function 		{			mw.util.addPortletLink('p-cactions', '#', "rollback all", "ca-rollbackeverything", "rollback all edits displayed here");			$("#ca-rollbackeverything").click( function(event) {				event.preventDefault; mw.loader.load( [ 'mediawiki.api' ] ); //start loading, while the user is in the prompt return rollbackEverythingWKMR(prompt("Enter an edit summary, or leave blank to use the default (or hit Cancel to cancel the rollback entirely)")); });		});	} }); mw.loader.using( ['mediawiki.util', 'mediawiki.api', 'jquery.ui'], function { if(mw.config.get('wgPageName').indexOf('Wikipedia:Arbitration/Requests/Case') != -1 &&	  mw.config.get('wgTitle').indexOf('Proposed decision') != -1) { $(document).ready( function {			mw.util.addPortletLink( 'p-cactions', '#', 'ACImplNotes', 'ca-makeACNotes', 'Generate notes' );		} ); ACImplNotes = {}; ACImplNotes.parse_item = function(section_text){ // locate title var section_header_re = /^={3,}\s*([^=]*)?\s*={3,}$/m; var res = section_header_re.exec(section_text); var title = ""; if(res === null){ return null; }			else { title = res[1]; }			var number_re = /^[^=]*?(\d[\w\.]*)\)/m;			res = number_re.exec(section_text);			var number = "";			if(res === null){				return null;			}			else {				number = res[1];			}			var support_loc = section_text.indexOf('Support:');			var oppose_loc = section_text.indexOf('Oppose:');			var abstain_loc = section_text.indexOf('Abstain:');			if(support_loc == -1 || oppose_loc == -1 || abstain_loc == -1){				return null;			}			var support_txt = section_text.substring(support_loc, oppose_loc);			var oppose_txt = section_text.substring(oppose_loc, abstain_loc);			var abstain_txt = section_text.substring(abstain_loc);			var vote_re = /^:#[^:*#].*?\w.*$/mg;			cnt = function(arr){ if(arr === null) return 0; else return arr.length; };			var result = { title: title, number:number,			        support: cnt(support_txt.match(vote_re)),			         oppose:  cnt(oppose_txt.match(vote_re)),			          abstain: cnt(abstain_txt.match(vote_re))}; if(result.title == "Template" && result.support === 0 && result.oppose === 0 && result.abstain === 0) { return null; }			return result; };		ACImplNotes.generate_proposal = function(data){ if(data === null) return ""; return "{" + "{ACImplNotes/Proposal |name= " + data.title + "|number= " + data.number + "|support= " + data.support + "|oppose= " + data.oppose + "|abstain= " + data.abstain + "|notes= }}\n"; };		ACImplNotes.parse_sections = function(sections_txt){ var section_header_re = /^={3,}\s*([^=]*)?\s*={3,}$/mg; var ret = ""; var parse_result = section_header_re.exec(sections_txt); if(parse_result === null){ alert("Can't find section headers."); return ""; }			var first_pos = parse_result.index; while((parse_result = section_header_re.exec(sections_txt)) !== null){ ret += ACImplNotes.generate_proposal(ACImplNotes.parse_item(sections_txt.substring(first_pos, parse_result.index))); first_pos = parse_result.index; }			ret += ACImplNotes.generate_proposal(ACImplNotes.parse_item(sections_txt.substring(first_pos))); return ret; };		ACImplNotes.do_generate = function(page_text){ var principles_re = /=\s*Proposed principles\s*=/; var fof_re = /=\s*Proposed findings of fact\s*=/; var remedies_re = /=\s*Proposed remedies\s*=/; var enforcement_re = /=\s*Proposed enforcement\s*=/; var principles_pos = page_text.search(principles_re); var fof_pos = page_text.search(fof_re); var remedies_pos = page_text.search(remedies_re); var enforcement_pos = page_text.search(enforcement_re); if(principles_pos == -1 || fof_pos == -1 || remedies_pos == -1) { alert("Cannot parse page"); return ""; }			var result = "{" + "{ACImplNotes\n|updated= " + "\n|principles=\n"; result += ACImplNotes.parse_sections(page_text.substring(principles_pos, fof_pos)); result += "|findings=\n"; result += ACImplNotes.parse_sections(page_text.substring(fof_pos, remedies_pos)); result += "|remedies=\n"; result += ACImplNotes.parse_sections(page_text.substring(remedies_pos, enforcement_pos)); result += "|enforcement=\n{" + "{ACImplNotes/Proposal |name=Enforcement of restrictions|number=0 |support=0 |oppose=0 |abstain=0 |pass=pass|notes=Passes by default }}\n"; result += "{" + "{ACImplNotes/Proposal |name=Appeals and modifications|number=0 |support=0 |oppose=0 |abstain=0 |pass=pass|notes=Passes by default }}\n}}"; return result; };		ACImplNotes.onclick = function { var api = new mw.Api; var params = { 'action':'query', 'prop':'revisions', 'titles':mw.config.get('wgPageName'), 'rvprop':'content' };			api.get(params).done(function(data){				var pageid = mw.config.get('wgArticleId').toString;				var wikitext = data['query']['pages'][pageid]['revisions'][0]['*'];				$( "#ACImplNotes-generated" ).html(' ' + ACImplNotes.do_generate(wikitext) +' ');				$( "#ACImplNotes-generated" ).show.dialog( { title: "Implementation notes", width:1000 } );				});			return false; };		$(document).on('click', '#ca-makeACNotes', ACImplNotes.onclick); $('#Implementation_notes').after(' [Generate implementation notes]'); $(document).on('click', '#makeimplnotes_link', ACImplNotes.onclick); $('#bodyContent').before(' '+		' '); } }); importScript('User:Ucucha/duplinks.js'); // User:Ucucha/duplinks importScript( 'User:Evad37/MoveToDraft.js' ); // Backlink: User:Evad37/MoveToDraft mw.util.addPortletLink('p-navigation', mw.config.get( 'wgServer' ) + '/wiki/Special:EmailUser/Oversight', "Request suppression");