User:Tinkleheimer/monobook.js

From Simple English Wikipedia, the free encyclopedia

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/***********************************************************************
                         EXTRA EDIT BUTTONS
***********************************************************************/
// Extra edit page buttons [[Wikipedia:Tools/Editing_tools#Misc._Editing_tools]]
 
// This is based on the original code on Wikipedia:Tools/Editing tools
//
// The original code was on the project page and needed to be cut and paste to the user's
// monobook.js page. However, this caused problems with the quote marks. So I have moved 
// it to its own page. 
//
// I do not know a lot about Javascript so please do not ask for a complicated change
//
// See the [[User:MarkS/Extra edit buttons]] for changes log
 
 
function InsertButtonsToToolBar()
{
d = new Date();
todayISO = d.getFullYear()+"-";
if (d.getMonth() > 8) {
  todayISO += (d.getMonth()+1)+"-";
} else {
  todayISO += "0"+(d.getMonth()+1)+"-";
}
if (d.getDate() > 9) {
  todayISO += d.getDate();
} else {
  todayISO += "0"+d.getDate();
}
 
//Strike-Out Button
mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://upload.wikimedia.org/wikipedia/en/c/c9/Button_strike.png",
    "speedTip": "Strike",
    "tagOpen": "<s>",
    "tagClose": "</s>",
    "sampleText": "Strike-through text"}
//Table button
mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://upload.wikimedia.org/wikipedia/en/6/60/Button_insert_table.png",
    "speedTip": "Table",
    "tagOpen": "\n{| border='1' \n|- \n| 1 || 2\n|- \n| 3 || 4",
    "tagClose": "\n|}\n",
    "sampleText": ""}
//Line break button
mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://upload.wikimedia.org/wikipedia/en/1/13/Button_enter.png",
    "speedTip": "Line break",
    "tagOpen": "<br />",
    "tagClose": "",
    "sampleText": ""}
//Gallery
mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://upload.wikimedia.org/wikipedia/en/1/12/Button_gallery.png",
    "speedTip": "Insert a picture gallery",
    "tagOpen": "\n<gallery>\n",
    "tagClose": "\n</gallery>",
    "sampleText": "Image:FileName.jpg|Caption1\\Image:FileName2.jpg|Caption2"}
//Template
mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/e/eb/Button_plantilla.png",
    "speedTip": "T",
    "tagOpen": "{{",
    "tagClose": "}}",
    "sampleText": "template name"}
//Category button
mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/5/5a/Button_category_alt.png",
    "speedTip": "Category",
    "tagOpen": "[[Category:",
    "tagClose": "]]",
    "sampleText": "Category title"}
//Reference link button
mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/7/79/Button_reflink.png",
    "speedTip": "<ref>",
    "tagOpen": "<ref>",
    "tagClose": "</ref>",
    "sampleText": "Insert reference material"}
//Reference button
mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/a/a0/Button_references_alt.png",
    "speedTip": "Reference footer",
    "tagOpen": "==References==\n{{reflist}}",
    "tagClose": "",
    "sampleText": ""}
//ref+cite web
mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/b/b8/Button_Globe.png",
    "speedTip": "Reference footer",
    "tagOpen": "<ref>{{cite web|url=",
    "tagClose": "|title=|publisher=|accessdate="+todayISO+"}}</ref>",
    "sampleText": ""}
//redirect
mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://upload.wikimedia.org/wikipedia/en/c/c8/Button_redirect.png",
    "speedTip": "Redirect",
    "tagOpen": "#REDIRECT [[",
    "tagClose": "]]",
    "sampleText": ""}
//welcome
mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/8/83/Button_biocitas.png",
    "speedTip": "Welcome message",
    "tagOpen": "{{sub" + "st:welcomeg}}~~" + "~~",
    "tagClose": "",
    "sampleText": ""}
//blanked
mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/7/74/Button_comment.png",
    "speedTip": "Comment Out",
    "tagOpen": "<!--",
    "tagClose": "-->",
    "sampleText": ""}
//center
mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/9/9e/Nuvola_apps_designer.png",
    "speedTip": "center",
    "tagOpen": "<center>",
    "tagClose": "</center>",
    "sampleText": ""}
//imdb
mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/e/eb/Nuvola_apps_digikam.png",
    "speedTip": "imdb",
    "tagOpen": "{{imdb|id=",
    "tagClose": "}}",
    "sampleText": ""}
//convert1
mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/3/37/Button_tl_template.png",
    "speedTip": "convert",
    "tagOpen": "{{convert|",
    "tagClose": "|sqkm|sqmi|1|abbr=on|lk=on}}",
    "sampleText": ""}
//convert2
mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/b/b8/Button_Globe.png",
    "speedTip": "m to f",
    "tagOpen": "{{m to ft|num=",
    "tagClose": "|abbr=no|spell=Commonwealth|precision=2|wiki=yes}}",
    "sampleText": ""}
}
 
$( InsertButtonsToToolBar );
 
 
 
 
 
 
/***********************************************************************
                          VANDAL VARNINGS
***********************************************************************/
// BASED ON User:Pilotguy/whackamole.js
// To fight vandalism
// **************
// Warnings
// **************
 
function whackEdit (message, msg2, summary) {
   var f = document.editform ;
   var tbox = document.editform.wpTextbox1 ;
   var a = "" + (window.getSelection ? window.getSelection()
     : document.getSelection ? document.getSelection()
        : document.selection.createRange().text);
   if (msg2 != "") {
     a = prompt ("Article name?\n(Empty+OK for a generic message.)\n(Cancel now aborts.)", a) ;
     if (a == null) return ;
     if (a != null && a != "") {
       message = message.replace(/\|/,"|"+a) ;
       summary += " in [[" + a + "]]" ;
     } else {
       message = msg2 ;
     }
   }
   f.wpTextbox1.value += message + " ~~" + "~~\n" ;
   f.wpSummary.value = summary ;
   f.wpMinoredit.checked=false;
   f.wpWatchthis.checked=false;
   f.wpTextbox1.focus();
   if (f.wpTextbox1.scrollTop || true) f.wpTextbox1.scrollTop = f.wpTextbox1.scrollHeight ;
}
 
function whackWarn1  () {
whackEdit ("{{subst"+":test|}}", "{{subst"+":test}}", "Experimenting");
}
 
function whackTestart  () {
whackEdit ("{{subst"+":testarticle|}}", "{{subst"+":testarticle}}", "Test Article");
}
 
function whackWarn2  () {
whackEdit ("{{subst"+":test2|}}", "{{subst"+":test2}}", "Nonsense edit"); 
}
 
function whackWarn2a  () {
whackEdit ("{{subst"+":test2a|}}", "{{subst"+":test2a}}", "Removing content"); 
}
 
function whackWarn3  () {
whackEdit ("{{subst"+":test3|}}", "{{subst"+":test3}}", "Please stop vandalizing");
}
 
function whackWarn4  () {
whackEdit ("{{subst"+":test4|}}", "{{subst"+":test4}}", "Last chance to stop vandalising");
}
 
function whackOnlyWarning  () {
whackEdit ("{{subst"+":test4im|}}", "{{subst"+":test4im}}", "Last chance to stop vandalising");
}
 
function whackBlocked() {
whackEdit ("{{subst"+":blocked}}", "", "Blocked indef"); 
}
 
function whackBlocked2() {
whackEdit ("{{subst"+":block||}}", "{{subst"+":block}}", "Blocked temp"); 
}
 
function whackFreewarn() {
whackEdit ("{{subst"+":Warning|}}", "{{subst"+":warning}}", "Warning"); 
}
 
function whackSpam   () {
whackEdit ("{{subst"+":spam|}}", "{{subst"+":spam}}", "Don't spam");
}