Zum Inhalt springen

„Benutzer:Pjacobi/monobook.js“ – Versionsunterschied

aus Wikipedia, der freien Enzyklopädie
Inhalt gelöscht Inhalt hinzugefügt
Pjacobi (Diskussion | Beiträge)
Keine Bearbeitungszusammenfassung
Pjacobi (Diskussion | Beiträge)
Keine Bearbeitungszusammenfassung
Zeile 173: Zeile 173:
}
}


window.onload = initExtensions;
aOnloadFunctions[aOnloadFunctions.length] = initExtensions;

Version vom 22. September 2005, 19:03 Uhr

function foo33() {
   window.alert("Huhu!");
}

function from7bit () {
  var input = document.forms ['editform'].elements ['wpTextbox1'];
  input.focus ();
  var start = input.selectionStart;
  var end = input.selectionEnd;
  var str = input.value.substring (start, end);
  str = str.replace (/([aeiou]|,l|,r)\1/g, "$1\u0304")
  str = str.replace (/;S/g, "\u015A")
  str = str.replace (/;s/g, "\u015B")
  str = str.replace (/;([a-zA-Z])/g, "$1\u0307")
  str = str.replace (/\.([a-zA-Z])/g, "$1\u0323")
  str = str.replace (/,([a-zA-Z])/g, "$1\u0325")
  str = str.replace (/_([a-zA-Z])/g, "$1\u0331")
  input.value = input.value.substr (0, start) + str + input.value.substr (end);
  var pos = start + str.length;
  input.selectionStart = pos;
  input.selectionEnd = pos;
}


var lu = new Object;

lu.vowels  = {
        a: "a", aa: "a\u0304", 
        e: "e", ee: "e\u0304", 
        o: "o", oo: "o\u0304", 
        i: "i", ii: "i\u0304", 
        u: "u", uu: "u\u0304",
        ai: "ai", au: "au",
        ".r": "r\u0325", ".R": "r\u0304\u0325",
        ".l": "l\u0325", ".L": "l\u0304\u0325"
};

lu.ivowels  = lu.vowels;

lu.vowels [""] = "";

lu.cons = {
 k: "k", kh: "kh", g: "g", gh: "gh", "\"n": "n\u0307",
 c: "c", ch: "ch", j: "j", jh: "jh", "~n": "\u00F1",
 ".t": "t\u0323", ".th": "t\u0323h", ".d": "d\u0323", ".dh": "d\u0323h", ".n": "n\u0323",
 t: "t", th: "th", d: "d", dh: "dh", n: "n",
 p: "p", ph: "ph", b: "b", bh: "bh", m: "m",
 y: "y", r: "r", l: "l", v: "v", "\"s": "\u015B",
 ".s": "s\u0323", h: "h", q: "q", ".kh": "k\u0331h\u0331", ".g": "g\u0323",
 z: "z", R: "r\u0323", Rh: "r\u0323h", f: "f", L: "l\u0323"
}

lu.lookup = function (c, v, iv) {
    if (c == null) c = "";
    if (v == null) v = "";
    if (iv == null) iv = "";
    if (iv != "") {
        vv = this.ivowels [iv];
        if (vv == null)  vv = "?" + v + "?";
        return vv;
    } else if (v != "") {
        cc = this.cons [c];
        if (cc == null) cc = "?" + c + "?";
        vv = this.vowels [v]
        if (vv == null) vv = "?" + v + "?"
        return cc + vv;
    } else {
        cc = this.cons [c];
        if (cc == null) cc = "?" + c + "?";
        return cc + this.vowels [""];
    }
}

var luh = new Object;

luh.ivowels  = {
        a: "\u0905", aa: "\u0906", 
        e: "\u090F", ee: "\u090F", 
        o: "\u0913", oo: "\u0913", 
        i: "\u0907", ii: "\u0908", 
        u: "\u0909", uu: "\u090A",
        ai: "\u0910", au: "\u0914",
        ".r": "\u090B", ".R": "\u0960",
        ".l": "\u090C", ".L": "\u0961"
};

luh.vowels  = {
        "": "\u094D",
        a: "", aa: "\u093E", 
        e: "\u0947", ee: "\u0947", 
        o: "\u094B", oo: "\u094B", 
        i: "\u093F", ii: "\u0940", 
        u: "\u0941", uu: "\u0942",
        ai: "\u0948", au: "\u094C",
        ".r": "\u0943", ".R": "\u0944",
        ".l": "\u0962", ".L": "\u0963"
};

luh.cons = {
 k: "\u0915", kh: "\u0916", g: "\u0917", gh: "\u0918", "\"n": "\u0919",
 c: "\u091A", ch: "\u091B", j: "\u091C", jh: "\u091D", "~n": "\u091E",
 ".t": "\u091F", ".th": "\u0920", ".d": "\u0921", ".dh": "\u0922", ".n": "\u0923",
 t: "\u0924", th: "\u0925", d: "\u0926", dh: "\u0927", n: "\u0928",
 p: "\u092A", ph: "\u092B", b: "\u092C", bh: "\u092D", m: "\u092E",
 y: "\u092F", r: "\u0930", l: "\u0932", v: "\u0935", "\"s": "\u0938",
 ".s": "\u0937", h: "\u0939", q: "\u0958", ".kh": "\u0959", ".g": "\u095A",
 z: "\u095B", R: "\u095C", Rh: "\u095D", f: "\u095E", L: "\u0933"
}

luh.lookup = lu.lookup

function replaceindic (obj) {
  var input = document.forms ['editform'].elements ['wpTextbox1'];
  input.focus ();
  var start = input.selectionStart;
  var end = input.selectionEnd;
  var str = input.value.substring (start, end);
  kmatch = 
    "(kh|k|hg|g|ch|c|jh|j|th|t|dh|d|ph|p|bh|b|n|m|y|r|R|l|L|v|s|h|z|f" +
    "|\\.kh|\\.th|\\.t|\\.dh|\\.d|\\.n|\\.s|\\.g|\\~n|\\\"n|\\\"s)";
  vmatch = "(ai|au|aa|a|ee|e|ii|i|oo|o|uu|u|\\.r|\\.R|\\.l|\\.L)";
  re = new RegExp (kmatch + vmatch + "?|" + vmatch, "g");
  str = str.replace (
        re,
        function ($0, $1, $2, $3) {
                return obj.lookup ($1, $2, $3)
        }  
  );
  input.value = input.value.substr (0, start) + str + input.value.substr (end);
  var pos = start + str.length;
  input.selectionStart = pos;
  input.selectionEnd = pos;
}


function showprops(obj) {
        var names = "";
        for (var i in lu.ivowels) names += i + "=" + obj.ivowels [i] + "\n";
        for (var i in lu.vowels) names += i + "=" + obj.vowels [i] + "\n";
        for (var i in lu.cons) names += i + "=" + obj.cons [i] + "\n";
        var input = document.forms ['formular'].elements ['eingabe'];
        input.value = names;
}


function initExtensions() {
  for (var i = 0; i != document.links.length; ++i) {
    if (document.links [i].target == "helpwindow") {
        n = document.links [i];
        node1 = n.cloneNode (true);
        node1.href = "javascript:from7bit()";
        node1.firstChild.data = "from7bit";
        node1.target = "";
        n.parentNode.insertBefore (node1, n);
        n.parentNode.insertBefore (document.createTextNode(" | "), n);

        node2 = n.cloneNode (true);
        node2.href = "javascript:replaceindic(lu)";
        node2.firstChild.data = "tex2rom";
        node2.target = "";
        n.parentNode.insertBefore (node2, n);
        n.parentNode.insertBefore (document.createTextNode(" | "), n);

        node3 = n.cloneNode (true);
        node3.href = "javascript:replaceindic(luh)";
        node3.firstChild.data = "tex2dev";
        node3.target = "";
        n.parentNode.insertBefore (node3, n);
        n.parentNode.insertBefore (document.createTextNode(" | "), n);
        break;
    }    
  }
}

aOnloadFunctions[aOnloadFunctions.length] = initExtensions;