User:Kameejl/format.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
Documentation for this user script can be added at User:Kameejl/format. |
function getParamValue(paramName, h){
if (typeof h == 'undefined' ) { h = document.location.href; }
var cmdRe=RegExp('[&?]'+paramName+'=([^&]*)');
var m=cmdRe.exec(h);
if (m) {
try {
return decodeURI(m[1]);
} catch (someError) {}
}
return null;
}
addOnloadHook(function () {
var summary=getParamValue('autosummary');
if(navigator.appName=="Microsoft Internet Explorer"){
tag1="</A>"
tag2="<SMALL>"
}
else{
tag1="</a>"
tag2="<small>"
};
/*
Written by Jonathan Snook, http://www.snook.ca/jonathan
Add-ons by Robert Nyman, http://www.robertnyman.com
*/
function getElementByClassName(oElm, strTagName, strClassName){
var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
var arrReturnElements = new Array();
strClassName = strClassName.replace(/\-/g, "\\-");
var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
var oElement;
for(var i=0; i<arrElements.length; i++){
oElement = arrElements[i];
if(oRegExp.test(oElement.className)){
arrReturnElements.push(oElement);
}
}
return (arrReturnElements)
}
function ppp(text, capitalize){
var text;
var capitalize;
if(capitalize!="yes"){
capitalize="no";
}
if(getElementByClassName(document,"*","infobox vcard")[0]){
//alert('start');
var patat=getElementByClassName(document,"*","infobox vcard")[0];
var aeroplanedeluxe;
for(var i=0;i<patat.getElementsByTagName("th").length;i++){
for(var qq=0;qq<patat.getElementsByTagName("th")[i].innerHTML.length-text.length+1;qq++){
if(patat.getElementsByTagName("th")[i].innerHTML.substr(qq,text.length)==text){
aeroplanedeluxe=i-1;
}
}
}
if(aeroplanedeluxe>0){
var aeroplane=patat.getElementsByTagName("td")[aeroplanedeluxe].innerHTML;
var aeroplanedelux=aeroplane;
var aeroplanedeluxor=aeroplanedelux.indexOf(",");
while (aeroplanedeluxor!=-1){
aeroplanedelux=aeroplanedelux.replace(",","<br />");
aeroplanedelux=aeroplanedelux.replace(",<br />","<br />");
aeroplanedelux=aeroplanedelux.replace(", <br />","<br />");
aeroplanedelux=aeroplanedelux.replace(",<br>","<br />");
aeroplanedelux=aeroplanedelux.replace(", <br>","<br />");
aeroplanedelux=aeroplanedelux.replace(",<br/>","<br />");
aeroplanedelux=aeroplanedelux.replace(", <br/>","<br />");
aeroplanedelux=aeroplanedelux.replace(",</br>","<br />");
aeroplanedelux=aeroplanedelux.replace(", </br>","<br />");
aeroplanedelux=aeroplanedelux.replace(",<BR />","<br />");
aeroplanedelux=aeroplanedelux.replace(", <BR />","<br />");
aeroplanedelux=aeroplanedelux.replace(",<BR>","<br />");
aeroplanedelux=aeroplanedelux.replace(", <BR>","<br />");
aeroplanedelux=aeroplanedelux.replace(",<BR/>","<br />");
aeroplanedelux=aeroplanedelux.replace(", <BR/>","<br />");
aeroplanedelux=aeroplanedelux.replace(",</BR>","<br />");
aeroplanedelux=aeroplanedelux.replace(", </BR>","<br />");
aeroplanedeluxor=aeroplanedelux.indexOf(",");
}
var peer=aeroplanedelux;
if(capitalize=="yes"){
var temp=new Array();
var temppart=new Array();
temp=aeroplanedelux.split('">');
peer="";
for(var z=0;z<temp.length;z++){
temppart=temp[z].split(tag1);
if(temppart[0]=="IDM"
|| temppart[0]=="NWOBHM"
|| temppart[0]=="R&B"
|| temppart[0]=="Hi-NRG"
|| temppart[0]=="New Wave"
|| temppart[0]=="see below"
|| temppart[0]=="various"
|| temppart[0]=="more info"
|| temppart[0]=="various others"){
temp[z]=temppart[0]+"</A>"+temppart[1]
}
else{
temp[z]=temppart[0].substr(0,1).toUpperCase()+temppart[0].substr(1).toLowerCase()+"</A>"+temppart[1]
};
if(z!=temp.length-1){
peer=peer+temp[z]+"\">"
}
else{
peer=peer+temp[temp.length-1]
};
}
if(text=="Years active"){
var tempcomment=new Array();
var tempcommentpart=new Array();
tempcomment=aeroplanedelux.split(tag2);
// alert("2|"+tempcomment[0]+"|"+tempcomment[1])
var vlees=tempcomment[0].indexOf("-");
var taart=tempcomment[0].indexOf(" - ");
var groente=tempcomment[0].indexOf(" – ");
var aardappels=tempcomment[0].indexOf(" – ");
while (vlees!=-1){
tempcomment[0]=tempcomment[0].replace("-","–");
vlees=tempcomment[0].indexOf("-");
}
while (taart!=-1){
tempcomment[0]=tempcomment[0].replace(" - ","–");
taart=tempcomment[0].indexOf(" - ");
}
while (groente!=-1){
tempcomment[0]=tempcomment[0].replace(" – ","–");
groente=tempcomment[0].indexOf(" – ");
}
while (aardappels!=-1){
tempcomment[0]=tempcomment[0].replace(" – ","–");
aardappels=tempcomment[0].indexOf(" – ");
}
if(tempcomment.length>1){
var koek=tempcomment[1].indexOf("<br />");
while (koek!=-1){
tempcomment[1]=tempcomment[1].replace("<br />",", ");
koek=tempcomment[1].indexOf("<br />");
}
peer = tempcomment[0] + "<small>" + tempcomment[1];
}
else{
peer = tempcomment[0]
};
}
}
patat.getElementsByTagName("td")[aeroplanedeluxe].innerHTML=peer;
}
else{
return
};
}
};
//importScript('User:Kameejl/formatmai.js');
//importScript('User:Kameejl/cheesecakegalore.js');
ppp('Associated acts','no');
ppp('Genres','yes');
ppp('Years active','yes');
ppp('Labels','no');
ppp('Occupations','yes');
ppp('Instruments','yes');
ppp('Influences','no');
ppp('Also known as','no');
if (document.editform && summary) { document.editform.wpSummary.value=summary; }
});