User:WOSlinker/asscats.js

function asscat_queryString(p) { var re = RegExp('[&?]' + p + '=([^&]*)'); var matches; if (matches = re.exec(document.location)) { try { return decodeURI(matches[1]); } catch (e) { } }   return null; } /* if(mw.config.get('wgNamespaceNumber') == 14 && mw.config.get('wgArticleId') != 0) { $( function asscatIEditButton {       mw.util.addPortletLink('p-cactions', mw.util.getUrl(null,{action:'edit',asscatI:true}), 'asscatI', 'p-asscatI', 'AssCatI this page');   } )} if(mw.config.get('wgNamespaceNumber') == 14 && mw.config.get('wgArticleId') != 0) { $( function asscatCEditButton {       mw.util.addPortletLink('p-cactions', mw.util.getUrl(null,{action:'edit',asscatC:true}), 'asscatC', 'p-asscatC', 'AssCatC this page');   } )}

if(mw.config.get('wgAction') == 'edit' && asscat_queryString('asscatI') == 'true') { $(function asscatIEdit {

var PageName = mw.config.get('wgPageName'); var myContent = document.getElementById('wpTextbox1').value;

var importance = PageName.replace(/Category\:(\w*)\-.*/,'$1'); var topic = PageName.replace(/Category\:(\w*)\-importance_(.*?)_articles/,'$2').replace(/_/g,' ');

//myContent = myContent.replace(/(\{\{Articles by Importance[^\}]*\}\}) *\n/i,'{'+'{'+'Category importance|topic='+topic+'|importance='+importance+'}}\n'); //myContent = myContent.replace(/(\{\{AbI[^\}]*\}\}) *\n/i,'{'+'{'+'Category importance|topic='+topic+'|importance='+importance+'}}\n'); myContent = myContent.replace(/(\{\{CatAutoTOC\}\})/i,'{'+'{'+'Category importance|topic='+topic+'|importance='+importance+'}}\n$1'); if(document.getElementById('wpTextbox1').value == myContent) { myContent = myContent.replace(/(\[\[Category\:)/i,'{'+'{'+'Category importance|topic='+topic+'|importance='+importance+'}}\n$1'); }

if(document.getElementById('wpTextbox1').value != myContent) { document.getElementById('wpTextbox1').value=myContent; document.getElementById('wpSummary').value='add importance templates'; document.getElementById('wpMinoredit').checked = true; };

} )}

if(mw.config.get('wgAction') == 'edit' && asscat_queryString('asscatC') == 'true') { $(function asscatCEdit {

var PageName = mw.config.get('wgPageName'); var myContent = document.getElementById('wpTextbox1').value;

var clas = PageName.replace(/Category\:(\w*)\-.*/,'$1'); var topic = PageName.replace(/Category\:(\w*)\-Class_(.*?)_articles/,'$2').replace(/_/g,' ');

if(clas == PageName) { var clas = 'Unassessed'; var topic = PageName.replace(/Category\:Unassessed_(.*?)_articles/,'$1').replace(/_/g,' '); }

//myContent = myContent.replace(/(\{\{ArticlesByQuality[^\}]*\}\}) *\n/i,'{'+'{'+'Category class|topic='+topic+'|class='+clas+'}}\n'); //myContent = myContent.replace(/(\{\{Articles by Quality[^\}]*\}\}) *\n/i,'{'+'{'+'Category class|topic='+topic+'|class='+clas+'}}\n'); //myContent = myContent.replace(/(\{\{AbQ[^\}]*\}\}) *\n/i,'{'+'{'+'Category class|topic='+topic+'|class='+clas+'}}\n'); myContent = myContent.replace(/(\{\{CatAutoTOC\}\})/i,'{'+'{'+'Category class|topic='+topic+'|class='+clas+'}}\n$1'); if(document.getElementById('wpTextbox1').value == myContent) { myContent = myContent.replace(/(\[\[Category\:)/i,'{'+'{'+'Category class|topic='+topic+'|class='+clas+'}}\n$1'); }

if(document.getElementById('wpTextbox1').value != myContent) { document.getElementById('wpTextbox1').value=myContent; document.getElementById('wpSummary').value='update class templates'; document.getElementById('wpMinoredit').checked = true; };

} )}