MediaWiki:Skin/dateSpecific/CAPSLOCK.js: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
J* (Diskussion | Beiträge) K (hat „MediaWiki:Skin/dateSpecific/CAPSLOCK.JS“ nach „MediaWiki:Skin/dateSpecific/CAPSLOCK.js“ verschoben) |
J* (Diskussion | Beiträge) |
||
Zeile 32: | Zeile 32: | ||
addOnloadHook( function () { | addOnloadHook( function () { | ||
+ | if (window.NO_CAPS_ON_CAPSLOCKDAY) | ||
+ | return; | ||
jQuery("div,span,a,b,i,s,li,p,h1,h2,h3,h4,h5,small,big,td,th,dd") | jQuery("div,span,a,b,i,s,li,p,h1,h2,h3,h4,h5,small,big,td,th,dd") | ||
.contents() | .contents() |
Aktuelle Version vom 28. Juni 2011, 08:59 Uhr
function genCapsTable(arr)
{
var out = {};
for(var i=0; i<arr.length; i++)
{
out[arr[i][0]] = arr[i][1];
out[arr[i][1]] = arr[i][0];
}
return out;
}
function stringCaps (string, table) {
var out = "";
for(var i=0; i<string.length; i++)
{
var char = string[i];
if (char != char.toLowerCase())
out += char.toLowerCase();
else if (char != char.toUpperCase())
out += char.toUpperCase();
else if (table[char] != null)
out += table[char];
else
out += char;
}
return out;
}
var capsTable = genCapsTable(["^°","1!","2\"","3§","4$","5%","6&","7/","8(","9)","0=","ß?","´`",",;",".:","-_","#'","+*"]);
/* das da unten müsste man dann als onloadHook ausführen … */
addOnloadHook( function () {
if (window.NO_CAPS_ON_CAPSLOCKDAY)
return;
jQuery("div,span,a,b,i,s,li,p,h1,h2,h3,h4,h5,small,big,td,th,dd")
.contents()
.filter(function() {
return this.nodeType == 3; // IE-FIX: use the number 3 instead of Node.TEXT_NODE
})
.each( function (x,y) {
if(y != null) y.textContent = stringCaps(y.textContent, capsTable);
});
});