Jump to content

User:DESiegel/monobook.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by DESiegel (talk | contribs) at 22:32, 24 April 2007 (CSD helper only). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/* <pre><nowiki> */

if (document.title.indexOf("Confirm delete") != -1) {
     var csdDeleteForm = {
				FillSelect:function(sel, arr){
					if(arr && arr.length>0){
						if(arr.length>1){
							var FirstOpt = new Option("CSD Reasons", "");
							// catches stupid IE error
							if(FirstOpt.innerHTML != "CSD Reasons"){
								FirstOpt.innerHTML = "CSD Reasons";
							}
							sel.appendChild(FirstOpt);
							sel.options[0].style.color = "gray"
						}
						sel.disabled = false;
						for(var i=0;i<arr.length;i++){
							var opt = new Option(arr[i].display, arr[i].value);
							// catches stupid IE error
							if(opt.innerHTML != arr[i].display){
								opt.innerHTML = arr[i].display;
							}
							sel.appendChild(opt);
						}
					}else{
						sel.options[0] = new Option("No Options Available", "");
						// catches stupid IE error
						if(sel.options[0].innerHTML != "No Options Available"){
							sel.options[0].innerHTML = "No Options Available";
						}
						sel.disabled = true;
						return false;
					}
					return true;
				},
				ValueArray:[
					{"value":"[[WP:CSD#G1|CSD G1]]","display":"G1 - Nonsense"},
					{"value":"[[WP:CSD#G2|CSD G2]]","display":"G2 - Test Pages"},
					{"value":"[[WP:CSD#G3|CSD G3]]","display":"G3 - Pure Vandalism"},
					{"value":"[[WP:CSD#G4|CSD G4]]","display":"G4 - Recreated Deleted"},
					{"value":"[[WP:CSD#G5|CSD G5]]","display":"G5 - Banned User"},
					{"value":"[[WP:CSD#G6|CSD G6]]","display":"G6 - Housekeeping"},
					{"value":"[[WP:CSD#G7|CSD G7]]","display":"G7 - Author Request"},
					{"value":"[[WP:CSD#G8|CSD G8]]","display":"G8 - Talk Page"},
					{"value":"[[WP:CSD#G9|CSD G9]]","display":"G9 - Office Actions"},
					{"value":"[[WP:CSD#G10|CSD G10]]","display":"G10 - Attack Pages"},
					{"value":"[[WP:CSD#G11|CSD G11]]","display":"G11 - Advertising"},
					{"value":"[[WP:CSD#G12|CSD G12]]","display":"G12 - Copyright"},
					{"value":"[[WP:CSD#A1|CSD A1]]","display":"A1 - No Context"},
					{"value":"[[WP:CSD#A2|CSD A2]]","display":"A2 - Foreign Language"},
					{"value":"[[WP:CSD#A3|CSD A3]]","display":"A3 - No Content"},
					{"value":"[[WP:CSD#A5|CSD A5]]","display":"A5 - Transwikied"},
					{"value":"[[WP:CSD#A7|CSD A7]]","display":"A7 - Unremarkable"},
					{"value":"[[WP:CSD#R1|CSD R1]]","display":"R1 - Bad Target"},
					{"value":"[[WP:CSD#R2|CSD R2]]","display":"R2 - Crossnamespace"},
					{"value":"[[WP:CSD#R3|CSD R3]]","display":"R3 - Bad Typo"},
					{"value":"[[WP:CSD#I1|CSD I1]]","display":"I1 - Redundant"},
					{"value":"[[WP:CSD#I2|CSD I2]]","display":"I2 - Corrupt/Empty"},
					{"value":"[[WP:CSD#I3|CSD I3]]","display":"I3 - Improper License"},
					{"value":"[[WP:CSD#I4|CSD I4]]","display":"I4 - Lack of License"},
					{"value":"[[WP:CSD#I5|CSD I5]]","display":"I5 - Unused Unfree"},
					{"value":"[[WP:CSD#I6|CSD I6]]","display":"I6 - No Fair Use"},
					{"value":"[[WP:CSD#I7|CSD I7]]","display":"I7 - Invalid Fair Use"},
					{"value":"[[WP:CSD#I8|CSD I8]]","display":"I8 - On Commons"},
					{"value":"[[WP:CSD#G1|CSD C1]]","display":"C1 - Empty"},
					{"value":"[[WP:CSD#C2|CSD C2]]","display":"C2 - Speedy Rename"},
					{"value":"[[WP:CSD#C3|CSD C3]]","display":"C3 - Template"},
					{"value":"[[WP:CSD#U1|CSD U1]]","display":"U1 - User Request"},
					{"value":"[[WP:CSD#U2|CSD U2]]","display":"U2 - No User"},
					{"value":"[[WP:CSD#U3|CSD U3]]","display":"U3 - Fair Use Gallery"},
					{"value":"[[WP:CSD#T1|CSD T1]]","display":"T1 - Divisive"},
					{"value":"[[WP:CSD#P1|CSD P1]]","display":"P1 - Speedy Article"},
					{"value":"[[WP:CSD#P2|CSD P2]]","display":"P2 - Underpopulated"},
				],
				//**************************** attaching function *****************************************
				// got thIS super handi function from http://www.scottandrew.com he is pretty dang smart **
			        //*****************************************************************************************
				addEvent:function(obj, evType, fn, useCapture){
					//alert(obj);
					if (obj.addEventListener){
						obj.addEventListener(evType, fn, useCapture);
						return true;
					} else if (obj.attachEvent){
						var r = obj.attachEvent("on"+evType, fn);
						return r;
					} else {
						alert("Handler could not be attached");
					}
				}
			}
			function addSelectAfter(){
    				var obj = document.getElementById('wpReason');
    			        // create select using included array
				var sel = document.createElement("SELECT");
				csdDeleteForm .FillSelect(sel, csdDeleteForm .ValueArray);
				// name it
				sel.name = "csdOptions";
				sel.id = "csdOptions";
                                sel.style.marginLeft = "10px";
                                csdDeleteForm .addEvent(sel, "change", csdChangeBox, false);
				// check for next sibling and insert before it or at the end
				if(obj.nextSibling){
					obj.parentNode.insertBefore(sel,obj.nextSibling);
				}else{
					obj.parentNode.appendChild(sel);
				}
			}
			try{
				// add one on load
				csdDeleteForm.addEvent(window, "load", addSelectAfter, false);
			}catch(err){}
}

function csdChangeBox() {
                                                         var obj = document.getElementById('wpReason');
                                                         obj.value = document.getElementById('csdOptions').value;
                                                         }

/* </nowiki><pre> */