Benutzer:Rooooo/monobook.js

aus Wikipedia, der freien Enzyklopädie
Zur Navigation springen Zur Suche springen

Hinweis: Leere nach dem Veröffentlichen den Browser-Cache, um die Änderungen sehen zu können.

  • Firefox/Safari: Umschalttaste drücken und gleichzeitig Aktualisieren anklicken oder entweder Strg+F5 oder Strg+R (⌘+R auf dem Mac) drücken
  • Google Chrome: Umschalttaste+Strg+R (⌘+Umschalttaste+R auf dem Mac) drücken
  • Edge: Strg+F5 drücken oder Strg drücken und gleichzeitig Aktualisieren anklicken
$( function() {
   $('#p-cactions, #p-personal').appendTo('#globalWrapper');
});

/* <nowiki> */

var charinsert = {
  "Vorlagen":[
    [ [ "{{Benutzer:Rooooo/V}}" ], [ "{{ers:Benutzer:Cy Phex/Hinweis}}" ], [ "{{ers:Vorlage:Unterseite}}" ]]
  ],
};
 
$(function() {
$(function() {
  var box;
  function loadCommonsTools() {
    function selectSubset() {
      var pp = box.getElementsByTagName("p");
      for (var i=0; i<pp.length; ++i) {
        pp[i].style["display"] = "none";
      }
      //show/create current subset
      var id = sel.options[sel.selectedIndex].value;
      var p = document.getElementById(id);
      if(!p) {
        p = document.createElement('p');
        p.setAttribute("id", id);
        p.setAttribute("class", "mwEdittoolsLanguage");
        createTokens(p, charinsert[id.substr("mwEdittools--".length)]);
        box.appendChild(p);
      }
      p.style["display"] = "inline";
    }
 
    function createTokens(paragraph, outerArr) {
      var buttons;
 
      function insertInner(elem) {
        var a = false, ins;
        switch(typeof(elem)) {
          case("string"): {
            ins = function() {
              insertTags(elem, "", "");
              return false;
            };
            a = document.createElement("a");
            a.setAttribute("title", elem);
            a.appendChild(document.createTextNode(elem));
          } break;
          case("array"):
          case("object"): {
            ins = function() {
              insertTags(elem[0], elem[1] || "", elem[2] || "");
              return false;
            };
            a = document.createElement("a");
            a.setAttribute("title", elem[3] || (elem[0] + (elem[2] || "…") + (elem[1] || "")));
            a.appendChild(document.createTextNode(elem[0] + (elem[1] || "")));
          }; break;
        }
        if(a !== false) {
          a.onclick = ins;
          a.setAttribute("href", "#");
          a.setAttribute("class", "mwEdittoolsButton");
          buttons.appendChild(document.createTextNode(" "));
          buttons.appendChild(a);
        }
      }
 
      function insertOuter(innerArr) {
        switch(typeof(innerArr)) {
          case("object"):
          case("array"):
            var obj = false;
            if(typeof(innerArr["class"]) === "string") {
              obj = true;
              paragraph.setAttribute("class", innerArr["class"]);
            }
            if(typeof(innerArr["lang"]) === "string") {
              obj = true;
              paragraph.setAttribute("lang", innerArr["lang"]);
            }
            if(typeof(innerArr["direction"]) === "string") {
              obj = true;
              paragraph.style.direction = innerArr["direction"];
            }
            if(typeof(innerArr["font-family"]) === "string") {
              obj = true;
              paragraph.style.fontFamily = innerArr["font-family"];
            }
            if(typeof(innerArr["font-size"]) === "string") {
              obj = true;
              paragraph.style.fontSize = innerArr["font-size"];
            }
            if(obj) {
              return false;
            }
            buttons = document.createElement("span");
            buttons.setAttribute("class", "mwEdittoolsButtons");
            for(var i = 0; i<innerArr.length; ++i) {
              insertInner(innerArr[i]);
            }
            paragraph.appendChild(buttons);
            return true;
          default:
            return false;
        }
      }
 
      if(outerArr.length == 0) { return; }
      for(var i=0; i<outerArr.length-1; ++i) {
        if(insertOuter(outerArr[i])) {
          var s = document.createElement("span");
          s.appendChild(document.createTextNode("\xA0\xA0•\xA0 "));
          s.style["font-weight"] = "bold";
          paragraph.appendChild(s);
        }
      }
      insertOuter(outerArr[outerArr.length-1]);
    }
 
    //create drop-down select
    var sel = document.createElement("select");
    for(var id in charinsert) {
      var op = document.createElement("option");
      op.setAttribute("value", "mwEdittools--" + id);
      op.appendChild(document.createTextNode(id));
      sel.appendChild(op);
    }
    sel.setAttribute("title", "Zeichensatz auswählen");
    sel.onchange = sel.onkeyup = selectSubset;
    box.appendChild(sel);
    box.appendChild(document.createTextNode(" "));
    selectSubset();
    return false;
  }
 
  //get div#mw-editTools
  box = document.getElementById('mw-editTools');
  if(!box) { return; }
 
  box = box.appendChild(document.createElement("div"));
  box.setAttribute("id", "specialchars");
 
  loadCommonsTools();
})
});
/* </nowiki> */