User:Gamaliel/monobook.js

importScript('User:AzaToth/twinkle.js'); importScript('User:Shubinator/DYKcheck.js'); //DYKcheck tool

//Creates link that when clicked on at an article's talk page it auto-opens article talk page for editing, //pastes in MiszaBot archiving parameters and fills out the edit summary. All you have to do is adjust //those parameters to your liking and click Save. importScript('User:Allstarecho/autoarchive.js');

//importScript( 'User:Mr. Stradivarius/gadgets/SignpostTagger.js' ); // Linkback: User:Mr. Stradivarius/gadgets/SignpostTagger.js

// //============================================================ // en: ADD SOME EXTRA BUTTONS TO THE EDITPANEL // de: FÜGE NEUE BUTTON IN DIE WERKZEUGLEISTE //============================================================ // Vorschläge für neue Buttons werden gerne entgegengenommen // Die Reihenfolge und Anzahl der Buttons ist über die (alphabetische) Variable XEBOrder wählbar.

if (typeof XEBOrder == 'undefined') // can be modified XEBOrder="Z,A,B,D,C,D1,F,U,S,I1,I2,J1,E,Q,W,X,K,L,M,H,O,R,T";

if (XEBOrder == 'all') XEBOrder="Z,A,B,D,C,D1,F,U,S,I1,I2,J1,E,G,Q,W,X,K,L,M,H,O,R,T,V,FS,J2,N,P,P1,R1,R2,R3,R4,T1,Y1,Y2,AI";

//fills the variable mwCustomEditButtons (s. function in /wikibits.js), with buttons for the Toolbar function addCustomButton(imageFile, speedTip, tagOpen, tagClose, sampleText){ mwCustomEditButtons.push({ "imageFile": imageFile,  "speedTip": speedTip,  "tagOpen": tagOpen,  "tagClose": tagClose,  "sampleText": sampleText}); }

var Isrc='http://upload.wikimedia.org/wikipedia/commons/';

var BDict={ 'A':['e/e9/Button_headline2.png','Secondary headline','\n===','===','Secondary headline'], 'B':['1/13/Button_enter.png','Line break',' ',,], 'C':['5/5f/Button_center.png','Center',' \n','\n<\/div>','Centred text'], 'D':['e/ea/Button_align_left.png','Left-Align',' \n','\n<\/div>','Left-aligned text'], 'D1':['a/a5/Button_align_right.png','Right-Align',' \n','\n<\/div>','Right-aligned text'], 'E':['0/04/Button_array.png','Table','\n{| class="wikitable" \n|- \n| 1 || 2\n|- \n| 3 || 4','\n|}\n',''], 'F':['1/1e/Button_font_color.png','Insert coloured text','Coloured text<\/span>','ColourName'], 'FS':['1/1b/Button_miss_signature.png','Unsigned post',,,'user name or IP'], 'G':, 'H':['7/74/Button_comment.png','Comment',"",'Comment'], 'I1':['6/6a/Button_sup_letter.png','Superscript',' ','<\/sup>','Superscript text'], 'I2':['a/aa/Button_sub_letter.png','Subscript',' ','<\/sub>','Subscript text'], 'J1':['5/58/Button_small.png','Small',' ','<\/small>','Small Text'], 'J2':['5/56/Button_big.png','Big text',' ','<\/big>','Big text'], 'K':['b/b4/Button_category03.png','Category',"",'Category name'], 'L':['8/8e/Button_shifting.png','Insert tab(s)',':','',':'], 'M':['f/fd/Button_blockquote.png','Insert block of quoted text','\n','\n<\/blockquote>','Block quote'], 'N':['4/4b/Button_nbsp.png','nonbreaking space',' ',,], 'O':['2/23/Button_code.png','Insert code',' ','<\/code>','Code'], 'P':['3/3c/Button_pre.png','Pre formatted Text',' ','<\/pre>','Pre formatted text'], 'P1':['9/93/Button_sub_link.png','Insert link to sub-page','','/Sub_Page','Page'], 'Q':['d/d3/Button_definition_list.png','Insert definition list','\n; ','\n: Item 1\n: Item 2','Definition'], 'R':['7/79/Button_reflink.png','Insert a reference',' ','Reference material'], 'R3':['2/28/Button_reflink_advanced_3.gif','No reference material',,'"/>',], 'R4':['9/9a/Button_references.png','Reference footer',"\n==Notes==\n\n\n \n ",,], 'S':['c/c9/Button_strike.png','Strikeout',' ','<\/s>','Struck out text'], 'T':['e/eb/Button_plantilla.png','Template','','Template name'], 'T1':['3/30/Tt_icon.png','Teletype text','','<\/tt>','Teletype Text'], 'U':['f/fd/Button_underline.png','Underlined'," ","<\/u>",'Underlined text'], 'V':['c/c8/Button_redirect.png','Redirect',"#REDIRECT ","",'Article Name'], 'W':['8/88/Btn_toolbar_enum.png','Numbering',"\n# ","\n# Element 2\n# Element 3",'Element 1'], 'X':['1/11/Btn_toolbar_liste.png','List',"\n* ","\n* Element B\n* Element C",'Element A'], 'Y1':['c/ce/Button_no_include.png','No Include'," ","<\/noinclude>",'Text'], 'Y2':['7/79/Button_include.png','Include only'," ","<\/includeonly>",'Text'], 'Z':['3/35/Button_substitute.png','Substitute',"",'Template'], 'AI': }

XEBOrder=XEBOrder.split(","); for (var b in XEBOrder) { var bc = BDict[XEBOrder[b]]; addCustomButton(Isrc+bc[0],bc[1],bc[2],bc[3],bc[4]) } // // //This function adds a link to the toolbox which, when clicked, displays the size of the page //and the size of the prose. See the talk page for more details. // //To use this function add User:Dr pda/prosesize.js to your monobook.js // function loadXMLDocPassingTemplate(url,handler, page) {   // branch for native XMLHttpRequest object if (window.XMLHttpRequest) { var req = new XMLHttpRequest; }   // branch for IE/Windows ActiveX version else if (window.ActiveXObject) { var req = new ActiveXObject("Microsoft.XMLHTTP"); }  if (req) { req.onreadystatechange = function {handler(req, page)}; req.open("GET", url, true); req.send(""); } } function getWikiText(req, page) { // only if req shows "loaded" if (req.readyState == 4) { // only if "OK" if (req.status == 200) { // ...processing statements go here... response = req.responseXML.documentElement; var rev = response.getElementsByTagName('rev'); if(rev.length > 0){ result = rev[0].getAttribute('size'); if(result > 10240){ result = (result/1024).toFixed(0)+' kB'; }          else{ result = result+' B'; }          wiki_value = document.createElement("li"); wiki_value.id = "wiki-size"; wiki_value.innerHTML = 'Wiki text: '+result; var output = document.getElementById("document-size-stats"); prose_value = document.getElementById("prose-size"); output.insertBefore(wiki_value,prose_value); }	 else{ //alert("There was a problem using the Wikipedia Search to find the wiki text size\nEither the search is not working or the correct article did not appear on the first page of results"); wiki_value = document.createElement("li"); wiki_value.id = "wiki-size"; wiki_value.innerHTML = 'Wiki text: Problem getting wiki text size'; var output = document.getElementById("document-size-stats"); prose_value = document.getElementById("prose-size"); output.insertBefore(wiki_value,prose_value); }       } else { alert("There was a problem retrieving the XML data:\n" +               req.statusText); }   } } function getFileSize(req, page) { // only if req shows "loaded" if (req.readyState == 4) { // only if "OK" if (req.status == 200) { // ...processing statements go here... var fsize = req.responseText.length; window.status = fsize; var total_value = document.createElement("li"); total_value.id = "total-size"; total_value.innerHTML='File size: '+(fsize/1024).toFixed(0)+' kB'; var output = document.getElementById("document-size-stats"); var prose_html_value = document.getElementById("prose-size-html"); output.insertBefore(total_value,prose_html_value); } else { alert("There was a problem retrieving the XML data:\n" +               req.statusText + "\n(" + url + ")"); }   } } function getLength(id){ var textLength = 0; for(var i=0;i<id.childNodes.length; i++){ if(id.childNodes[i].nodeName == '#text'){ textLength += id.childNodes[i].nodeValue.length; } else if(id.childNodes[i].id == 'coordinates' || id.childNodes[i].className.indexOf('emplate') != -1){ //special case for °N, °W and -like templates //Exclude from length, and don't set background yellow id.childNodes[i].style.cssText = 'background-color:white'; } else{ textLength += getLength(id.childNodes[i]); } } return textLength; } function getRefMarkLength(id,html){ var textLength = 0; for(var i=0;i<id.childNodes.length; i++){ if(id.childNodes[i].className == 'reference'){ textLength += (html)? id.childNodes[i].innerHTML.length : getLength(id.childNodes[i]); } } return textLength; } function getDocumentSize{ contentDivName = ''; if(skin == 'vector' || skin == 'monobook' || skin == 'chick' || skin == 'myskin' || skin == 'simple'){ contentDivName = 'bodyContent'; } else if (skin == 'modern'){ contentDivName = 'mw_contentholder'; } else if (skin == 'standard' || skin == 'cologneblue' || skin == 'nostalgia'){ contentDivName = 'article'; } else{ //fallback case; the above covers all currently existing skins contentDivName = 'bodyContent'; } //Same for all skins if previewing page if(mw.config.get('wgAction') == 'submit') contentDivName = 'wikiPreview'; var bodyContent = document.getElementById(contentDivName); if(document.getElementById("document-size-stats")){ //if statistics already exist, turn them off and remove highlighting var output = document.getElementById("document-size-stats"); var oldStyle = output.className; var pList = bodyContent.getElementsByTagName("p"); for(var i=0;i<pList.length; i++){ if(pList[i].parentNode.id == contentDivName || pList[i].parentNode.nodeName == "BLOCKQUOTE") pList[i].style.cssText = oldStyle; }  output.parentNode.removeChild(output); var header = document.getElementById("document-size-header"); header.parentNode.removeChild(header); } else{ var output = document.createElement("ul"); output.id = "document-size-stats"; var prose_html_value = document.createElement("li"); prose_html_value.id = "prose-size-html"; output.appendChild(prose_html_value); var ref_html_value = document.createElement("li"); ref_html_value.id = "ref-size-html"; output.appendChild(ref_html_value); var prose_value = document.createElement("li"); prose_value.id = "prose-size"; output.appendChild(prose_value); output.className = bodyContent.getElementsByTagName("p").item(0).style.cssText; var ref_value = document.createElement("li"); ref_value.id = "ref-size"; output.appendChild(ref_value); var dummy = document.getElementById("siteSub"); dummy.parentNode.insertBefore(output, dummy.nextSibling); var header = document.createElement("span"); header.id = "document-size-header"; header.innerHTML = ' Document statistics: (See here for details.) '; dummy.parentNode.insertBefore(header,output); //File size not well defined for preview mode or section edit if(mw.config.get('wgAction') != 'submit'){ //If browser supports document.fileSize property (IE) if(document.fileSize){ var total_value = document.createElement("li"); total_value.id = "total-size"; total_value.innerHTML='File size: '+(document.fileSize/1024).toFixed(0)+' kB'; output.insertBefore(total_value,prose_html_value); }  else{ loadXMLDocPassingTemplate(location.pathname,getFileSize,'') } } //Get size of images only if browser supports filesize property (IE) var iList = bodyContent.getElementsByTagName("img"); if(iList.length >0 && iList[0].fileSize){ //Get size of images included in document var image_size = 0; var first_magnify = true; for (var i=0;i<iList.length; i++){ var im = iList[i]; if(im.getAttribute("src").indexOf("magnify-clip.png") != -1){ if(first_magnify){ image_size += im.fileSize*1; first_magnify = false; }   }    else{ image_size += im.fileSize*1; }  }   var image_value = document.createElement("li"); image_value.id = "image-size"; image_value.innerHTML='Images: '+(image_size/1024).toFixed(0)+' kB'; output.appendChild(image_value); } //Calculate prose size and size of reference markers ([1] etc) var pList = bodyContent.getElementsByTagName("p"); prose_size = 0; prose_size_html = 0; refmark_size = 0; refmark_size_html = 0; word_count = 0; for(var i=0;i]+)>)/ig,"").split(' ').length para.style.cssText = "background-color:yellow"; } } if((prose_size-refmark_size)>10240){ prose_value.innerHTML='Prose size (text only): '+((prose_size-refmark_size)/1024).toFixed(0)+' kB ('+word_count+' words) "readable prose size"'; } else{ prose_value.innerHTML='Prose size (text only): '+(prose_size-refmark_size)+' B ('+word_count+' words) "readable prose size"'; } if((prose_size_html-refmark_size_html)>10240){ prose_html_value.innerHTML='Prose size (including all HTML code): '+((prose_size_html-refmark_size_html)/1024).toFixed(0)+' kB'; } else{ prose_html_value.innerHTML='Prose size (including all HTML code): '+(prose_size_html-refmark_size_html)+' B'; } //Calculate size of references (i.e. output of ) var rList = bodyContent.getElementsByTagName("ol"); var ref_size = 0; var ref_size_html = 0; for (var i=0; i10240){ ref_value.innerHTML='References (text only): '+((ref_size+refmark_size)/1024).toFixed(0)+' kB'; } else{ ref_value.innerHTML='References (text only): '+(ref_size+refmark_size)+' B'; } if((ref_size_html+refmark_size_html)>10240){ ref_html_value.innerHTML='References (including all HTML code): '+((ref_size_html+refmark_size_html)/1024).toFixed(0)+' kB'; } else{ ref_html_value.innerHTML='References (including all HTML code): '+(ref_size_html+refmark_size_html)+' B'; } //get correct name of article from wikipedia-defined global variables var pageNameUnderscores = mw.config.get('wgPageName'); var pageNameSpaces = pageNameUnderscores.replace(/_/g,' ') //if page is a permalink, diff, etc don't try to search if(!location.pathname.match('/w/index.php')){ //Get revision size from API var searchURL = mw.config.get('wgScriptPath') + '/api.php?action=query&prop=revisions&rvprop=size&format=xml&revids=' + mw.config.get('wgCurRevisionId'); loadXMLDocPassingTemplate(searchURL,getWikiText,pageNameSpaces); } else if(mw.config.get('wgAction') == 'submit'){ //Get size of text in edit box result = document.getElementById('wpTextbox1').value.length; if(result > 10240){ result = (result/1024).toFixed(0)+' kB'; }  else{ result = result+' B'; }  wiki_value = document.createElement("li"); wiki_value.id = "wiki-size"; wiki_value.innerHTML = 'Wiki text: '+result; var output = document.getElementById("document-size-stats"); prose_value = document.getElementById("prose-size"); output.insertBefore(wiki_value,prose_value); } } } addOnloadHook(function {  if(mw.config.get('wgAction') == 'edit' || (mw.config.get('wgAction') == 'submit' && document.getElementById('wikiDiff')) ){    addPortletLink('p-tb', 'javascript:alert("You need to preview the text for the prose size script to work in edit mode.")', 'Page size', 't-page-size', 'Calculate page and prose size', , );    document.getElementById("t-page-size").firstChild.style.cssText = "color:black;"  }  else if(mw.config.get('wgAction') == 'view' || mw.config.get('wgAction') == 'submit' || mw.config.get('wgAction') == 'historysubmit' || mw.config.get('wgAction') == 'purge'){    addPortletLink('p-tb', 'javascript:getDocumentSize', 'Page size', 't-page-size', 'Calculate page and prose size', , );  } }); //

//importScript( 'User:Mr. Stradivarius/gadgets/SignpostTagger.js' ); // Linkback: User:Mr. Stradivarius/gadgets/SignpostTagger.js importScript("User:GregU/dashes.js");