User:JuhkoDev/buttons.js

//TitleButtons adds action buttons after page title. They are used to respond to vandalism. // addOnloadHook(j_titlebuttons); addOnloadHook(revertlinks); addOnloadHook(topbarlinks); function edit_tt { document.getElementById("editform").wpTextbox1.innerHTML = "" + " --"+"\r\n" + document.getElementById("editform").wpTextbox1.innerHTML; document.getElementById("editform").wpSummary.value = "Added welcome-template (TB)"; document.getElementById("editform").submit; } function edit_test { document.getElementById("editform").wpTextbox1.innerHTML += "\r\n" + " --"+""; document.getElementById("editform").wpSummary.value = "Warning #1 (TB)"; document.getElementById("editform").submit; } function edit_test2 { document.getElementById("editform").wpTextbox1.innerHTML += "\r\n" + " --"+""; document.getElementById("editform").wpSummary.value = "Warning #2 (TB)"; document.getElementById("editform").submit; } function edit_test3 { document.getElementById("editform").wpTextbox1.innerHTML += "\r\n" + " --"+""; document.getElementById("editform").wpSummary.value = "Warning #3 (TB)"; document.getElementById("editform").submit; } function edit_test4 { document.getElementById("editform").wpTextbox1.innerHTML += "\r\n" + " --"+""; document.getElementById("editform").wpSummary.value = "Last warning (TB)"; document.getElementById("editform").submit; } function edit_uwv1 { document.getElementById("editform").wpTextbox1.innerHTML += "\r\n" + " --"+""; document.getElementById("editform").wpSummary.value = "Uw-vandalism1 (TB)"; document.getElementById("editform").submit; } function edit_uwv2 { document.getElementById("editform").wpTextbox1.innerHTML += "\r\n" + " --"+""; document.getElementById("editform").wpSummary.value = "Uw-vandalism2 (TB)"; document.getElementById("editform").submit; } function edit_uwv3 { document.getElementById("editform").wpTextbox1.innerHTML += "\r\n" + " --"+""; document.getElementById("editform").wpSummary.value = "Uw-vandalism3 (TB)"; document.getElementById("editform").submit; } function edit_uwv4 { document.getElementById("editform").wpTextbox1.innerHTML += "\r\n" + " --"+""; document.getElementById("editform").wpSummary.value = "Uw-vandalism4 (TB)"; document.getElementById("editform").submit; } function edit_uwv5 { document.getElementById("editform").wpTextbox1.innerHTML += "\r\n" + " --"+""; document.getElementById("editform").wpSummary.value = "Uw-vandalism5 (TB)"; document.getElementById("editform").submit; }

function y1 { document.location.href = "http://en.wikipedia.org/w/index.php?title="+escape(wgPageName)+"&action=edit&jtb=true&jtb_action=y1"; } function g6 { document.location.href = "http://en.wikipedia.org/w/index.php?title="+escape(wgPageName)+"&action=edit&jtb=true&jtb_action=g6"; } function notab { document.location.href = "http://en.wikipedia.org/w/index.php?title="+escape(wgPageName)+"&action=edit&jtb=true&jtb_action=notab"; } function breaks { document.location.href = "http://en.wikipedia.org/w/index.php?title="+escape(wgPageName)+"&action=edit&jtb=true&jtb_action=breaks"; } function bold { document.location.href = "http://en.wikipedia.org/w/index.php?title="+escape(wgPageName)+"&action=edit&jtb=true&jtb_action=bold"; } function stub { document.location.href = "http://en.wikipedia.org/w/index.php?title="+escape(wgPageName)+"&action=edit&jtb=true&jtb_action=stub&jtb_param="+escape(document.getElementById("stubInput").value); } function tt { document.location.href = "http://en.wikipedia.org/w/index.php?title="+escape(wgPageName)+"&action=edit&jtb=true&jtb_action=tt"; } function test { document.location.href = "http://en.wikipedia.org/w/index.php?title="+escape(wgPageName)+"&action=edit&jtb=true&jtb_action=test"; } function test2 { document.location.href = "http://en.wikipedia.org/w/index.php?title="+escape(wgPageName)+"&action=edit&jtb=true&jtb_action=test2"; } function test3 { document.location.href = "http://en.wikipedia.org/w/index.php?title="+escape(wgPageName)+"&action=edit&jtb=true&jtb_action=test3"; } function test4 { document.location.href = "http://en.wikipedia.org/w/index.php?title="+escape(wgPageName)+"&action=edit&jtb=true&jtb_action=test4"; } function uwv1 { document.location.href = "http://en.wikipedia.org/w/index.php?title="+escape(wgPageName)+"&action=edit&jtb=true&jtb_action=uwv1"; } function uwv2 { document.location.href = "http://en.wikipedia.org/w/index.php?title="+escape(wgPageName)+"&action=edit&jtb=true&jtb_action=uwv2"; } function uwv3 { document.location.href = "http://en.wikipedia.org/w/index.php?title="+escape(wgPageName)+"&action=edit&jtb=true&jtb_action=uwv3"; } function uwv4 { document.location.href = "http://en.wikipedia.org/w/index.php?title="+escape(wgPageName)+"&action=edit&jtb=true&jtb_action=uwv4"; } function uwv5 { document.location.href = "http://en.wikipedia.org/w/index.php?title="+escape(wgPageName)+"&action=edit&jtb=true&jtb_action=uwv5"; } function sendmessage { document.location.href = "http://en.wikipedia.org/w/index.php?title="+escape(wgPageName)+"&action=edit&jtb=true&jtb_action=message&jtb_param="+escape(document.getElementById("message").value); } function j_titlebuttons { var jtbdiv=document.createElement("div"); document.getElementById("firstHeading").appendChild(jtbdiv); if(wgIsArticle==true) { //pikalisäyspainikkeet switch(wgNamespaceNumber) { //Artikkeli case 0: jtbdiv.innerHTML = " Delete:  General:  Stub:  Quick-add: "; break; //Keskustelu käyttäjästä case 3: jtbdiv.innerHTML = " Vandalism: <input type='button' value='UWV-4im' title='UWV-4im' style='font-size:9px;cursor:pointer;' onClick='uwv5;'> Send message: <input type='text' size='100' id='message'><input type='submit' value='OK' style='font-size:10px;cursor:pointer;' title='Jättää kirjoitetun viestin' onClick='sendmessage;'>"; break; } } if((wgAction=="edit") || (wgAction=="submit")) { if(!(wgPageName=="Special:MovePage")) { if(getValue("jtb")=="true") { if(!(wgArticleId==0)) { try {    document.getElementById("editform").style.display="none";    getElementsByClass("mw-undo-success")[0].style.display="none";    document.getElementById("contentSub").style.display="none";    document.getElementById("wikiDiff").style.display="none";  }  catch(err) {  } } var sig="--"+""+""; var param=getValue("jtb_param"); switch(getValue("jtb_action")) { case "y1":  if(document.getElementById("wpTextbox1").innerHTML.toLowerCase.indexOf("{{db-g1") == -1) document.getElementById("wpTextbox1").innerHTML = "{{db-g1}}\n" + document.getElementById("wpTextbox1").innerHTML; document.getElementById("wpSummary").value = "Requested speedy deletion (G1) (TB)"; break; case "g6": if(document.getElementById("wpTextbox1").innerHTML.toLowerCase.indexOf("{{db-g6") == -1) document.getElementById("wpTextbox1").innerHTML = "{{db-g6}}\n" + document.getElementById("wpTextbox1").innerHTML; document.getElementById("wpSummary").value = "Requested speedy deletion (G6) (TB)"; break; case "notab": if(document.getElementById("wpTextbox1").innerHTML.toLowerCase.indexOf("{{notability") == -1) document.getElementById("wpTextbox1").innerHTML = "{{Notability|{{subst:DATE}}}}\n" + document.getElementById("wpTextbox1").innerHTML; document.getElementById("wpSummary").value = "Added {{Notability}} (TB)"; break; case "breaks": while(document.getElementById("wpTextbox1").innerHTML.indexOf("\n\n\n") > -1) { document.getElementById("wpTextbox1").innerHTML = document.getElementById("editform").wpTextbox1.innerHTML.replace("\n\n\n","\n\n"); } document.getElementById("wpSummary").value = "Removing triple line breaks (TB)"; break; case "bold": document.getElementById("editform").wpTextbox1.innerHTML = document.getElementById("editform").wpTextbox1.innerHTML.replace(getrealname(wgTitle),""+getrealname(wgTitle)+""); //Kaksinkertaisen lihavoinnin poisto document.getElementById("editform").wpTextbox1.innerHTML = document.getElementById("editform").wpTextbox1.innerHTML.replace("","'''"); document.getElementById("editform").wpTextbox1.innerHTML = document.getElementById("editform").wpTextbox1.innerHTML.replace("","'''"); document.getElementById("editform").wpSummary.value = "Automatic bolding (TB)"; break; case "stub": if(document.getElementById("wpTextbox1").innerHTML.toLowerCase.indexOf("stub}}") == -1) { if(param=="") { document.getElementById("wpTextbox1").innerHTML += "\n{{stub}}" } else { document.getElementById("wpTextbox1").innerHTML += "\n{{"+unescape(param)+"-stub}}" } document.getElementById("wpSummary").value = "Stub"; } break; case "tt": document.getElementById("wpTextbox1").innerHTML = " "+sig+"\n\n" + document.getElementById("wpTextbox1").innerHTML; document.getElementById("wpSummary").value = "Added Welcome-template (TB)"; break; case "test": document.getElementById("wpTextbox1").innerHTML += "\n "+sig; document.getElementById("wpSummary").value = "Warning #1 (TB)"; break; case "test2": document.getElementById("wpTextbox1").innerHTML += "\n "+sig; document.getElementById("wpSummary").value = "Warning #2 (TB)"; break; case "test3": document.getElementById("wpTextbox1").innerHTML += "\n "+sig; document.getElementById("wpSummary").value = "Warning #3 (TB)"; break; case "test4": document.getElementById("wpTextbox1").innerHTML += "\n "+sig; document.getElementById("wpSummary").value = "Last warning (TB)"; break; case "uwv1": document.getElementById("wpTextbox1").innerHTML += "\n "+sig; document.getElementById("wpSummary").value = "Uw-vandalism1 (TB)"; break; case "uwv2": document.getElementById("wpTextbox1").innerHTML += "\n "+sig; document.getElementById("wpSummary").value = "Uw-vandalism2 (TB)"; break; case "uwv3": document.getElementById("wpTextbox1").innerHTML += "\n "+sig; document.getElementById("wpSummary").value = "Uw-vandalism3 (TB)"; break; case "uwv4": document.getElementById("wpTextbox1").innerHTML += "\n "+sig; document.getElementById("wpSummary").value = "Uw-vandalism4 (TB)"; break; case "uwv4im": document.getElementById("wpTextbox1").innerHTML += "\n{{subst:uw-vandalism4im}} "+sig; document.getElementById("wpSummary").value = "Uw-vandalism4im (TB)"; break; case "message": document.getElementById("wpTextbox1").innerHTML += "\n"+unescape(param); document.getElementById("wpSummary").value = "Quick-added message: "+unescape(param)+" (TB)"; break; case "revert": document.getElementById("wpSummary").value = "Reverted to revision "+getValue("oldid")+" (TB)"; break; } if(!(wgArticleId==0)) submitEditform; } else { jtbdiv.innerHTML = "<input type='button' value='Save' style='font-size:13px; font-weight:bold; cursor:pointer;' onClick='submitEditform;'><input type='button' value='Save as minor' style='font-size:9px; cursor:pointer;' onClick='markAsMinor;'>"+jtbdiv.innerHTML; switch(wgNamespaceNumber) { case 3: jtbdiv.innerHTML += " Quick-add: <input type='button' value='Welcome' style='font-size:9px; cursor:pointer;' onClick='edit_tt;'><input type='button' value='Test' style='font-size:9px; cursor:pointer;' onClick='edit_test;'><input type='button' value='Test2' style='font-size:9px; cursor:pointer;' onClick='edit_test2;'><input type='button' value='Test3' style='font-size:9px; cursor:pointer;' onClick='edit_test3;'><input type='button' value='Test4' style='font-size:9px; cursor:pointer;' onClick='edit_test4;'> Vandalism: <input type='button' value='UWV-1' style='font-size:9px; cursor:pointer;' onClick='edit_uwv1;'><input type='button' value='UWV-2' style='font-size:9px; cursor:pointer;' onClick='edit_uwv2;'><input type='button' value='UWV-3' style='font-size:9px; cursor:pointer;' onClick='edit_uwv3;'><input type='button' value='UWV-4' style='font-size:9px; cursor:pointer;' onClick='edit_uwv4;'><input type='button' value='UWV-4im' style='font-size:9px; cursor:pointer;' onClick='edit_uwv4im;'>"; break; } } } } } function submitEditform {document.getElementById('editform').submit;} function markAsMinor {document.getElementById('wpMinoredit').checked=true; document.getElementById('editform').submit;} function getValue(varname) { // First, we load the URL into a variable var url = window.location.href; if(url.indexOf("?")==-1) return ""; // Next, split the url by the ? var qparts = url.split("?"); // Check that there is a querystring, return "" if not if (qparts.length == 0) {   return ""; } // Then find the querystring, everything after the ? var query = qparts[1]; // Split the query string into variables (separates by &s) var vars = query.split("&"); // Initialize the value with "" as default var value = ""; // Iterate through vars, checking each one for varname for (i=0;i<vars.length;i++) {   // Split the variable by =, which splits name and value var parts = vars[i].split("="); // Check if the correct variable if (parts[0] == varname) {     // Load value into variable value = parts[1]; // End the loop break; } }  // Convert escape code value = unescape(value); // Convert "+"s to " "s value.replace(/\+/g," "); // Return the value return value; } //Artikkelien linkkipalkkiin lisäys function addTab(tabtitle,tablink,tooltip,tabid) { switch(skin) { case "vector": var topbar=document.getElementById("p-views").getElementsByTagName("ul")[0]; break; default: var topbar=getElementsByClass("pBody")[0].getElementsByTagName("ul")[0]; break; } topbar.innerHTML += '<li id="'+tabid+'"><a href="'+tablink+'" title="'+tooltip+'"> '+tabtitle+' </a></li>'; } //Yläpalkkilinkkejä function topbarlinks { //Artikkelin googletus if(wgNamespaceNumber==0) addTab('Google','http://www.google.fi/search?q='+googlestring(wgTitle),'Google-search with article name', 'ca-google'); } function googlestring(txt) { var txt2=txt; while(txt2.indexOf(' ') > -1) { txt2=txt2.replace(' ','+'); } while(txt2.indexOf('_') > -1) { txt2=txt2.replace('_','+'); } return txt2; } //Palautuslinkit function revertlinks { if((!(getValue("oldid")==wgCurRevisionId)) && (!(getValue("oldid")=="")) && (getValue("diff")=="")) { addTab('Revert','/w/index.php?title='+escape(wgPageName)+'&amp;action=edit&amp;oldid='+getValue("oldid")+'&jtb=true&jtb_action=revert','Revert to this revision','ca-revert'); } else if((!(getValue("diff")=="")) && (!(getValue("oldid")=="")) && (!(getValue("diff")==""))) { document.getElementById("mw-diff-ntitle1").innerHTML += " (<a href='"+document.getElementById("mw-diff-ntitle1").getElementsByTagName("a")[2].href+"&jtb=true' title='Quick undo (not same as rollback)'>quick-undo</a>) "; } if(wgAction=="history") { var litags=document.getElementById("pagehistory").getElementsByTagName("li"); var reverturl; for(i = 0; i < litags.length; i++) { if(!(i==0)) { if(i==litags.length-1) {     reverturl=litags[i].getElementsByTagName("a")[1].href+"&action=edit&jtb=true&jtb_action=revert"; }   else {     reverturl=litags[i].getElementsByTagName("a")[2].href+"&action=edit&jtb=true&jtb_action=revert"; }   litags[i].innerHTML += ' (<a href="'+reverturl+'">restore</a>)'; } } undourl=getElementsByClass("mw-history-undo")[0].getElementsByTagName("a")[0].href+"&jtb=true"; litags[0].innerHTML += ' (<a href="'+undourl+'">quick-undo</a>)'; } } function getElementsByClass(searchClass,node,tag) { // Function from http://www.dustindiaz.com/getelementsbyclass/ var classElements = new Array; if ( node == null ) node = document; if ( tag == null ) tag = '*'; var els = node.getElementsByTagName(tag); var elsLen = els.length; var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)"); for (i = 0, j = 0; i < elsLen; i++) { if ( pattern.test(els[i].className) ) { classElements[j] = els[i]; j++; } }  return classElements; } function getrealname(txt) { txt2=txt; if(txt2.indexOf("(")==-1) return txt2; else return txt2.substr(0,txt2.indexOf("(")-1); } //