User:Zhaladshar/common.js

/** * Ajax sysop * @see https://meta.wikimedia.org/wiki/Ajax_sysop * @update-token */ var ajax_sysop_config = { disable_patrol:true }; mw.loader.load('//tools-static.wmflabs.org/meta/scripts/pathoschild.ajaxsysop.js');

/** * TemplateScript adds configurable templates and scripts to the sidebar, and adds an example regex editor. * @see https://meta.wikimedia.org/wiki/TemplateScript * @update-token */ // $.ajax('//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js', { dataType:'script', cache:true }).then(function {	pathoschild.TemplateScript.add([ // scripts {			name: 'standardization and cleanup', scriptUrl: 'User:Pathoschild/standardise.js', script: function(editor) { standardize(editor); }		},		{			name: 'remove linebreaks', // remove inter-paragraph linebreaks script: function(editor) { editor .escape(/\{\{[^}]+\}\}/g) .replace(/([^\n]+)\n([^\n]+)/g,'$1 $2',10) // remove newline characters in paragraphs (note: + is lazy and there is no backtracking) .replace(/(=+.+?=+) *([^\n]+)/g,'$1\n$2') // place linebreak between headings and text .unescape; }		},		{			name: 'cleanup HTML chars', script: function(editor) { editor .replace(/ *&mdash; *| *-- */ig,'—') // convert HTML em-dash to actual character .replace(/ *– */ig,'–') // convert HTML en-dash to actual character .replace(/_([^_\n]+)_/ig,'\'\'$1\'\''); // convert strings to italics (note: + is lazy and there is no backtracking) }		},

// templates { name:'header', template:'', position:'before' }, { name:'process header', template:'', position:'before' }, { name:'author', template:'' },

{ name:'featured talk', template:'' }, { name:'textinfo', template:'' }, { name:'featured', template:'Featured text (see the protection policy)', forActions:'protect' }, { name:'standardised', template:'Standardised', forActions:'move' }, { name:'disambiguated', template:'disambiguation', forActions:'move' }, { name:'no disambig', template:'no need for disambiguation', forActions:'move' }, { name:'Copyvio discussion', template:'Possible copyright violation', forActions:'delete' }, { name:'Proposed', template:'Proposed deletion', forActions:'delete' }, { name:'G1 no meaningful content', template:'Criteria for speedy deletion G1 ("No meaningful content or history.")', forActions:'delete' }, { name:'G2 recreation', template:'Criteria for speedy deletion G2 ("Reposted content previously deleted...")', forActions:'delete' }, { name:'G3 banned user', template:'Criteria for speedy deletion G3 ("content created and edited solely by a banned user after they were banned...")', forActions:'delete' }, { name:'G4 redundant', template:'Criteria for speedy deletion G4 ("Two versions of the same text on different pages...")', forActions:'delete' }, { name:'G5 beyond scope', template:'Criteria for speedy deletion G5 ("...clearly lies outside the scope of Wikisource...")', forActions:'delete' }, { name:'G6 copyvio', template:'Criteria for speedy deletion G6 ("...clear and proven copyright violation...")', forActions:'delete' }, { name:'G6 re-copyvio', template:'Criteria for speedy deletion G6 ("...content previously deleted as a copyright violation...")', forActions:'delete' }, { name:'G6 copyvio author', template:'Criteria for speedy deletion G6 ("...author pages for authors whose works are all copyrighted...")', forActions:'delete' }, { name:'G7 author\'s request', template:'Criteria for speedy deletion G7 ("Deletion per request of the author...")', forActions:'delete' }, { name:'A1 transwikied', template:'Criteria for speedy deletion A1 ("Articles transwikied to another project...")', forActions:'delete' }, { name:'A1 transwikied (commons)', template:'Criteria for speedy deletion A1 ("...images uploaded to the Wikimedia commons with the original contributor noted...")', forActions:'delete' }, { name:'A2 non-notable', template:'Criteria for speedy deletion A2 ("...not significantly peer-reviewed or previously published in a significant edition or forum.")', forActions:'delete' }, { name:'A3 no authorship info', template:'Criteria for speedy deletion A3 ("Works without authorship information...")', forActions:'delete' }, { name:'M1 trivial', template:'Criteria for speedy deletion M1 ("...deletion as part of a page move or history merge, as long as the action requiring the deletion is uncontroversial.")', forActions:'delete' }, { name:'M2 redirect (new)', template:'Criteria for speedy deletion M2 ("Unneeded redirects from page titles created within the last week...")', forActions:'delete' }, { name:'M2 redirect (old)', template:'Criteria for speedy deletion M2 ("...[unneeded] redirects tagged with "new title" for at least two months.")', forActions:'delete' }, { name:'M2 redirect (broken)', template:'Criteria for speedy deletion M2 ("...Redirects to inexistant pages...)"', forActions:'delete' }, { name:'M3 redirect (article to other ns)', template:'Criteria for speedy deletion M3 ("Internamespace redirects from the article namespace to any other namespace.")', forActions:'delete' }, { name:'M4 talk page', template:'Criteria for speedy deletion M4 ("Unneeded talk: a discussion page for deleted or inexistant content.")', forActions:'delete' } ]); }); //

/** * Add 'soft redirect' to page tabs */ // function addlilink(tabs, url, name, id){ var na = document.createElement('a'); na.href = url; na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); li.id = id; li.appendChild(na); tabs.appendChild(li); return li; }

$(function{	if(document.forms.editform) {		var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];		addlilink(tabs, 'javascript:softRedirect;', 'Soft redirect', 'ca-redirect');	} });

function softRedirect { var txt = document.editform.wpTextbox1; var r = txt.value.replace(new RegExp("[\\S\\s]*#[Rr][Ee][Dd][Ii][Rr][Ee][Cc][Tt][_ ]?(\\[\\^\\*\\]\\])[\\S\\s]*|[\\s\\S]*", "g"), "$1"); if (r==""){ var r = ""+prompt('What page should the redirect point to?')+""; }	txt.value = ""+r+""; var summary = document.editform.wpSummary; summary.value = "Converted to soft redirect"; }

/* hide wikipedia links */ function hideextiw { var i = 0; var k = document.links.length; for (i=0;i<k;i++) { if (document.links[i].className == 'extiw') { document.links[i].className='hiddenextiw'; }   }    var a = document.getElementById('hideshow'); a.onclick = function { showextiw; }; }

/* show wikipedia links */ function showextiw { var i = 0; var k = document.links.length; for (i=0;i<k;i++) { if (document.links[i].className == 'hiddenextiw') { document.links[i].className='extiw'; }   }    var a = document.getElementById('hideshow'); a.onclick = function { hideextiw; }; }

/* add hide tab */ function addthetab { var a = document.createElement('a'); a.setAttribute('href', 'javascript:;'); a.onclick = function { hideextiw; }; a.setAttribute('id', 'hideshow'); a.appendChild(document.createTextNode('hide/show')); var tab = document.createElement('li'); tab.appendChild(a); var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; tabs.appendChild(tab); }

if (window.addEventListener) window.addEventListener("load",addthetab,false); else if (window.attachEvent) window.attachEvent("onload",addthetab);

/* Add soft redirect template */ function addSoftRedirectTemplateLink { if(document.getElementById) { var loc = '' + window.location; if(loc.indexOf("action=edit") > -1 || loc.indexOf("action=submit") > -1) { var toolbar = document.getElementById('toolbar'); var a = document.createElement('a'); a.setAttribute('href',"javascript:insertTags(,,'');"); var img = document.createElement('img'); img.setAttribute('src', "/skins-1.5/common/images/template_button.png"); img.setAttribute('alt', "Soft redirect"); img.setAttribute('title', "Soft redirect"); img.setAttribute('border', "0"); img.setAttribute('height', "22"); img.setAttribute('width', "23"); a.appendChild(img); toolbar.appendChild(a); }   } }

if (window.addEventListener) window.addEventListener("load",addSoftRedirectTemplateLink,false); else if (window.attachEvent) window.attachEvent("onload",addSoftRedirectTemplateLink); //

/* CharInsert specific */ window.charinsertDontMove = false; window.editToolsRecall = true; window.charinsertCustom = { User: '| =  {\{+}}  [\[+|]]  —  “+”  ‽  Æ  æ  Œ  œ  ℩  {\{hws|+|}}  {\{hwe|+|}}    ' }; if(window.updateEditTools) window.updateEditTools;