User:Flyax/monobook.js

From Wiktionary, the free dictionary
Jump to navigation Jump to search

Note: You may have to bypass your browser’s cache to see the changes. In addition, after saving a sitewide CSS file such as MediaWiki:Common.css, it will take 5-10 minutes before the changes take effect, even if you clear your cache.

  • Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh);
  • Konqueror and Chrome: click Reload or press F5;
  • Opera: clear the cache in Tools → Preferences;
  • Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.

This JavaScript is executed for Flyax on every page load, when User:Flyax is using the Monobook skin.


// <nowiki> to prevent interpretation of template syntax

function addLoadEvent(func) {
 if (window.addEventListener) window.addEventListener("load", func, false);
  else if (window.attachEvent) window.attachEvent("onload", func);
 }
window.onload = function() {
 if (window.aOnloadFunctions) {
 for (var _i=0; _i<aOnloadFunctions.length; _i++) {
 aOnloadFunctions[_i]();
      }
    }
 }

function DeluxeBar() {
  if (document.createTextNode) {
        var toolbar = document.getElementById("toolbar"); 
        if (!toolbar) return;
        

        var messages = new Array()
        var images = new Array()
        var commentaires = new Array()
        var a=-1;

        messages[++a] = "===" + "Pronunciation" + "===" + "\\n" + "* " + "{{" + "IPA" + "|//|" + "lang=el" + "}}" + "\\n";
        images[a] = "http://upload.wikimedia.org/wikipedia/commons/f/f2/Button_prononciation.png";
        commentaires[a] = "Pronunciation"

        messages[++a] = "==" + "Greek" + "==" + "\\n" + "\\n" +  "===" + "Noun" + "===" + "\\n" + "{{" + "el" + "-" + "noun" + "||" + "}}" + "\\n" + "\\n" + "# ";
        images[a] = "http://upload.wikimedia.org/wikipedia/commons/3/32/Btn_toolbar_Evalution_Securite_informatique.png";
        commentaires[a] = ""

for (var i=0;i<messages.length;i++) {
                var img = document.createElement("img");
                img.setAttribute("src", images[i]);
                
                var ref = document.createElement("a");
                ref.setAttribute("href", "javascript:insertTags('', \"" + messages[i] + "\", '');" + 
                                 "javascript:changeSummary(\"" + commentaires[i] + "\");" ); 
                ref.appendChild(img); 
                
                toolbar.appendChild(ref);
        }
  }
}

function changeSummary(sampleText) {
        document.editform.wpSummary.value = sampleText;
}

addLoadEvent(DeluxeBar);

function addCustomButton(imageFile, speedTip, tagOpen, tagClose, sampleText)
{
 mwCustomEditButtons[mwCustomEditButtons.length] =
 {"imageFile": imageFile,
  "speedTip": speedTip,
  "tagOpen": tagOpen,
  "tagClose": tagClose,
  "sampleText": sampleText};
}
 
addCustomButton('http://upload.wikimedia.org/wikipedia/commons/3/3d/IPA-stress.png','tonos',"ˈ","",'');
addCustomButton('http://upload.wikimedia.org/wikipedia/commons/a/a7/Button_API_%C9%94.png','o',"ɔ","",'');
addCustomButton('http://upload.wikimedia.org/wikipedia/commons/7/74/Button_API_%C9%9B.png','e',"ɛ","",'');
addCustomButton('http://upload.wikimedia.org/wikipedia/commons/7/7d/IPA-gamma-velar.png','ɣ',"ɣ","",'');
addCustomButton('http://upload.wikimedia.org/wikipedia/commons/2/26/IPA-gamma-palatal.png','ουρανικό γ',"ʝ","",'');
addCustomButton('http://upload.wikimedia.org/wikipedia/commons/e/e2/IPA-g-palatal.png','ουρανικό γκ',"ɟ","",'');
addCustomButton('http://upload.wikimedia.org/wikipedia/commons/1/15/IPA-delta.png','δέλτα',"ð","",'');
addCustomButton('http://upload.wikimedia.org/wikipedia/commons/0/06/IPA-theta.png','θήτα',"θ","",'');
addCustomButton('http://upload.wikimedia.org/wikipedia/commons/1/16/IPA-l-palatal.png','ουρανικό λ',"ʎ","",'');
addCustomButton('http://upload.wikimedia.org/wikipedia/commons/6/6b/IPA-m-labiodental.png','χειλοδοντικό μ',"ɱ","",'');
addCustomButton('http://upload.wikimedia.org/wikipedia/commons/f/ff/Button_API_%CA%81.png','Προφορά r',"ɾ","",'');
addCustomButton('http://upload.wikimedia.org/wikipedia/commons/c/c3/Button_API_%C9%B2.png','ουρανικό ν',"ɲ","",'');
addCustomButton('http://upload.wikimedia.org/wikipedia/commons/c/ca/Button_API_%C5%8B.png','υπερωικό ν',"ŋ","",'');
addCustomButton('http://upload.wikimedia.org/wikipedia/commons/c/c9/C-cantilly.png','ουρανικό χ',"ç","",'');
function marque_tab()
{
 var toolbar = document.getElementById('toolbar');
 if (!toolbar) return false;
 
 var textbox = document.getElementById('wpTextbox1');
 if (!textbox) return false;
 
 if (!document.selection && textbox.selectionStart == null)
 return false;
 
 var image = document.createElement("img");
 image.width = 23;
 image.height = 22;
 toolbar.appendChild(image);
}
 
$(marque_tab);

// </nowiki>