User:WOSlinker/hlist-comma.js

function hlist_queryString(p) { var re = RegExp('[&?]' + p + '=([^&]*)'); var matches; if (matches = re.exec(document.location)) { try { return decodeURI(matches[1]); } catch (e) { } }   return null; }

//Add a 'hlist edit' tab if(mw.config.get('wgNamespaceNumber') == 10 && mw.config.get('wgArticleId') != 0) { $( function hlistEditButton {       mw.util.addPortletLink('p-cactions', mw.util.getUrl(null,{action:'edit',hlist:true}), 'hlist', 'p-hlist', 'hlist edit');   } )} if(mw.config.get('wgAction') == 'edit' && hlist_queryString('hlist') == 'true') { $(function qscale {       var myContent = document.getElementById('wpTextbox1').value;        myContent = myContent.replace(/\<\!--\(reduces gap between wrapped lines\)--\>/g,'');

myContent = myContent.replace(/\{\{nowrap begin\}\}\n/g,'\n* '); myContent = myContent.replace(/\{\{nowrap begin\}\}/g,'\n* '); myContent = myContent.replace(/\{\{Nowrap begin\}\}\n/g,'\n* '); myContent = myContent.replace(/\{\{Nowrap begin\}\}/g,'\n* ');

myContent = myContent.replace(/\{\{nowrap\|[ ]*/g,'* '); myContent = myContent.replace(/\}\}\{\{•\}\}[ ]*/g,''); myContent = myContent.replace(/\{\{•\}\}\}\}[ ]*/g,''); myContent = myContent.replace(/\}\}\{\{·\}\}[ ]*/g,''); myContent = myContent.replace(/\{\{·\}\}\}\}[ ]*/g,'');

myContent = myContent.replace(/\{\{•wrap\}\}[ ]*\n/g,'\n* '); myContent = myContent.replace(/\{\{•wrap\}\}[ ]*/g,'\n* '); myContent = myContent.replace(/\{\{•w\}\}[ ]*\n/g,'\n* '); myContent = myContent.replace(/\{\{•w\}\}[ ]*/g,'\n* ');

myContent = myContent.replace(/\{\{·wrap\}\}[ ]*\n/g,'\n* '); myContent = myContent.replace(/\{\{·wrap\}\}\'\'[ ]*/g,'\n* \'\''); myContent = myContent.replace(/\{\{·wrap\}\}[ ]*/g,'\n* '); myContent = myContent.replace(/\{\{·w\}\}[ ]*\n/g,'\n* '); myContent = myContent.replace(/\{\{·w\}\}\'\'[ ]*/g,'\n* \'\''); myContent = myContent.replace(/\{\{·w\}\}[ ]*/g,'\n* '); myContent = myContent.replace(/\{\{·\}\}[ ]*\n/g,'\n* '); myContent = myContent.replace(/\{\{·\}\}[ ]*/g,'\n* '); myContent = myContent.replace(/\{\{,\}\}[ ]*\n/g,'\n* '); myContent = myContent.replace(/\{\{,\}\}[ ]*/g,'\n* ');

myContent = myContent.replace(/\{\{•\}\}[ ]*\n/g,'\n* '); myContent = myContent.replace(/\{\{•\}\}[ ]*/g,'\n* ');

myContent = myContent.replace(/\{\{\*\}\}[ ]*\n/g,'\n* '); myContent = myContent.replace(/\{\{\*\}\}[ ]*/g,'\n* ');

myContent = myContent.replace(/[ ]*\&bull\;[ ]*/g,'\n* ');

myContent = myContent.replace(/\{\{!\}\}[ ]*\n/g,'\n* '); myContent = myContent.replace(/\{\{!\}\}\}\}[ ]*/g,''); myContent = myContent.replace(/\{\{!\}\}[ ]*/g,'\n* '); myContent = myContent.replace(/\{\{!w\}\}[ ]*\n/g,'\n* '); myContent = myContent.replace(/\{\{!w\}\}[ ]*/g,'\n* ');

myContent = myContent.replace(/\&nbsp\;•[ ]*/g,'\n* '); myContent = myContent.replace(/[ ]*•[ ]*/g,'\n* ');

// myContent = myContent.replace(/[ ]*\&bull\;[ ]*\n/g,'\n* '); // myContent = myContent.replace(/[ ]*\&bull\;[ ]*/g,'\n* ');

myContent = myContent.replace(/(\|[ ]*list\d*[ ]*=[ ]*)\/g,'$1'); myContent = myContent.replace(/\n\<\/div\>[ ]*\n/g,'\n');

myContent = myContent.replace(/(\|[ ]*list\d*[ ]*=)[ ]*\[/g,'$1\n* \['); myContent = myContent.replace(/(\|[ ]*list\d*[ ]*=)[ ]*\'/g,'$1\n* \''); myContent = myContent.replace(/(\|[ ]*list\d*[ ]*=)[ ]*\"/g,'$1\n* \"');

myContent = myContent.replace(/\}\} \{\{nowrap\|[ ]*/g,''); myContent = myContent.replace(/\* \{\{nowrap\|/g,'* ');

myContent = myContent.replace(/ · /g,'\n* ');

myContent = myContent.replace(/\n\* \* /g,'\n* '); myContent = myContent.replace(/\n\* [ ]*/g,'\n* '); myContent = myContent.replace(/\n\* \&nbsp\;/g,'\n* '); myContent = myContent.replace(/\n\* \}\} \* /g,'\n* '); myContent = myContent.replace(/\n\*[ ]*\}\}[ ]*\n\* /g,'\n'); myContent = myContent.replace(/\n\*[ ]*\n/g,'\n* ');

myContent = myContent.replace(/\{\{nowrap end\}\}[ ]*/g,''); myContent = myContent.replace(/\{\{Nowrap end\}\}[ ]*/g,'');

// myContent = myContent.replace(/\:\&nbsp\;/g,': '); // myContent = myContent.replace(/\&nbsp\;/g,'');

myContent = myContent.replace(/[ ]*,[ ]*/g,'\n* ');  /*split commas */

if(document.getElementById('wpTextbox1').value != myContent) {

myContent = myContent.replace(/\|\{\{PAGENAME\}\}\]\]/g,']]');

var idx1 = 0; var idx2 = 0; var listclass = "listclass";

if ( myContent.indexOf("avbox Musical artist",idx1)+myContent.indexOf("avbox musical artist",idx1) > 0 ) { if ( myContent.indexOf("| above",idx1)+myContent.indexOf("|above",idx1) > 0 ) { listclass = "bodyclass"; } }

idx1 = myContent.search(/\|[ ]*title[ ]*=/) if( idx1 > 0 ) { idx2 = myContent.indexOf("\n",idx1); } if( idx2 > 0 ) { myContent = myContent.substring(0,idx2+1)+"\|"+listclass+" = hlist"+myContent.substring(idx2,myContent.length); }

idx1 = 0; idx2 = 0; idx1 = myContent.search(/\|[ ]*capital[ ]*=/) if( idx1 > 0 ) { idx2 = myContent.indexOf("\n",idx1); } if( idx2 > 0 ) { myContent = myContent.substring(0,idx2+1)+"\|"+listclass+" = hlist"+myContent.substring(idx2,myContent.length); }

idx1 = 0; idx2 = 0; idx1 = myContent.search(/\|[ ]*template_name[ ]*=/) if( idx1 > 0 ) { idx2 = myContent.indexOf("\n",idx1); } if( idx2 > 0 ) { myContent = myContent.substring(0,idx2+1)+"\| "+listclass+" = hlist"+myContent.substring(idx2,myContent.length); }

idx1 = 0; idx2 = 0; idx1 = myContent.search(/\|[ ]*raw_name[ ]*=/) if( idx1 > 0 ) { idx2 = myContent.indexOf("\n",idx1); } if( idx2 > 0 ) { myContent = myContent.substring(0,idx2+1)+"\| "+listclass+" = hlist"+myContent.substring(idx2,myContent.length); }

document.getElementById('wpTextbox1').value=myContent; document.getElementById('wpSummary').value='use listclass = hlist in navbox as per WP:HLIST'; };   } )}