User:Frietjes/onlyinclude.js

// jQuery(document).ready(function($) {

var myContent = document.getElementsByName('wpTextbox1')[0]; // //

if(mw.config.get('wgNamespaceNumber') != -1 && myContent && mw.config.get('wgUserName') == 'Frietjes') { mw.loader.using(['mediawiki.util']).done( function {	 var portletlink = mw.util.addPortletLink('p-tb', '#', "Onlyinclude", 't-foi');	  $(portletlink).click(function(e) { e.preventDefault; wpOnlyInclude; });	});	mw.loader.using(['mediawiki.util']).done( function {	 var portletlink = mw.util.addPortletLink('p-tb', '#', "Section", 't-sec');	  $(portletlink).click(function(e) { e.preventDefault; wpSection; });	}); } // // function wpOnlyInclude {	myContent.value = myContent.value.replace(/(==[ ]*(?:Final league[ ]*|League[ ]*|)(?:|[Ll]adder|[Ss]tandings|[Tt]able)[ ]*==[=\r\n]*)[\r\n][ ]*[\r\n]*[ ]*[\r\n]*(\{\{#invoke:[Ss]ports table[^\r\n]*[\r\n])((?:\{\{(?:\{\{[^{}]*\}\}|[^{}])*\}\}|[^{}])*\}\})/g, '$1\n $2|show_limit=5\n$3 '); myContent.value = myContent.value.replace(/\|[ ]*show_limit[ ]*=[ 0-9]*[\r\n]((?:\|[ ]*res_col_header[^\r\n]*[\r\n]|)\|[ ]*show_limit[ ]*=)/g, '$1'); myContent.value = myContent.value.replace(/(\{\{(?:\{\{[^{}]*\}\}|[^{}])*)\|[ ]*show_limit[ ]*=[0-9 ]*[\r\n]?((?:\{\{[^{}]*\}\}|[^{}])*\|[ ]*show_limit[ ]*=)/g, '$1$2'); myContent.value = myContent.value.replace(/(\{\{(?:\{\{[^{}]*\}\}|[^{}])*)\|[ ]*section[ ]*=[0-9A-Za-z ]*[\r\n]?((?:\{\{[^{}]*\}\}|[^{}])*\|[ ]*section[ ]*=)/g, '$1$2'); myContent.value = myContent.value.replace(/(=[ ]*)((?:First|Second|Third|Fourth) [Dd]ivision(?: North| South|))([ ]*=[= ]*[\r\n][\t ]*[\r\n]?\{\{[Ii]nfobox(?:[^{}]|\{\{[^{}]*\}\})*\}\}[\t ]*[\r\n][\t ]*[\r\n]?)(\{\{#invoke:[\t ]*[Ss]ports[_ ]+table[^\r\n]*[\r\n])((?:[^{}]|\{\{(?:[^{}]|\{\{[^{}]*\}\})*\}\})*\}\})/g, '$1$2$3 $4|section=$2\n$5 '); myContent.value = myContent.value.replace(/(=[ ]*)([A-Za-z]+ [Dd]ivision|(?:Pool|Group) [A-Z0-9]+|Groupe [^= ]*|District [^=\r\n ]+)([ ]*=[= ]*[\r\n][\t ]*[\r\n]*)(\{\{#invoke:[\t ]*[Ss]ports[_ ]+table[^\r\n]*[\r\n])((?:[^{}]|\{\{(?:[^{}]|\{\{[^{}]*\}\})*\}\})*\}\})/g, '$1$2$3 $4|section=$2\n$5 '); myContent.value = myContent.value.replace(/(=[ ]*)(Play\-*offs?)([ ]*(?:table|)[ ]*=[= ]*[\r\n][\t ]*[\r\n]*)(\{\{#invoke:[\t ]*[Ss]ports[_ ]+table[^\r\n]*[\r\n])((?:[^{}]|\{\{(?:[^{}]|\{\{[^{}]*\}\})*\}\})*\}\})/g, '$1$2$3 $4|section=$2s\n$5 '); myContent.value = myContent.value.replace(/(=[ ]*)(East|West|Central|Final|North|South)([ ]*(?:table|)[ ]*=[= ]*[\r\n][\t ]*[\r\n]*)(\{\{#invoke:[\t ]*[Ss]ports[_ ]+table[^\r\n]*[\r\n])((?:[^{}]|\{\{(?:[^{}]|\{\{[^{}]*\}\})*\}\})*\}\})/g, '$1$2$3 $4|section=$2\n$5 '); myContent.value = myContent.value.replace(/([^>\r\n \t][\r\n]*[\t ]*[\r\n]*[\t ]*)(\{\{#invoke:[\t ]*[Ss]ports[_ ]+table(?:[^{}]|\{\{(?:[^{}]|\{\{[^{}]*\}\})*\}\})*\}\})/g, '$1 $2 ');

} // // function wpSection {	myContent.value = myContent.value.replace(/((?:Pool|Group)[ ]*)([A-Z]+)([ ]*==[=]*[ ]*[\r\n][\r\n]*[\t ]*[\r\n]*[\t ]*)(\{\{#invoke:[\t ]*[Ss]ports[_ ]+table(?:[^{}]|\{\{(?:[^{}]|\{\{[^{}]*\}\})*\}\})*\}\})/g, '$1$2$3$4'); myContent.value = myContent.value.replace(/([^>\r\n \t][\r\n]*[\t ]*[\r\n]*[\t ]*)(\{\{#invoke:[\t ]*[Ss]ports[_ ]+table(?:[^{}]|\{\{(?:[^{}]|\{\{[^{}]*\}\})*\}\})*\}\})/g, '$1 $2 '); } // // }); //