// copied and modified from english wiktionary
// http://en.wiktionary.orghttps://dictious.com/de/MediaWiki:Common.js
/*<pre>*/
/**
* Create a new DOM node for the current document.
* Basic usage: var mySpan = newNode('span', "Hello World!")
* Supports attributes and event handlers*: var mySpan = newNode('span', {style:"color: red", focus: function(){alert(this)}, id:"hello"}, "World, Hello!")
* Also allows nesting to create trees: var myPar = newNode('p', newNode('b',{style:"color: blue"},"Hello"), mySpan)
*
* *event handlers, there are some issues with IE6 not registering event handlers on some nodes that are not yet attached to the DOM,
* it may be safer to add event handlers later manually.
**/
window.newNode = function (tagname){
var node = document.createElement(tagname);
for( var i=1;i<arguments.length;i++ ){
if(typeof arguments == 'string'){ //Text
node.appendChild( document.createTextNode(arguments) );
}else if(typeof arguments == 'object'){
if(arguments.nodeName){ //If it is a DOM Node
node.appendChild(arguments);
}else{ //Attributes (hopefully)
for(var j in arguments){
if(j == 'class'){ //Classname different because...
node.className = arguments;
}else if(j == 'style'){ //Style is special
node.style.cssText = arguments;
}else if(typeof arguments == 'function'){ //Basic event handlers
newNode.addEventHandler(node, j, arguments);
}else{
node.setAttribute(j,arguments); //Normal attributes
}
}
}
}
}
node.addEventHandler =
function(eventName, handler)
{ newNode.addEventHandler(this, eventName, handler); };
return node;
}
newNode.addEventHandler = function(node, eventName, handler)
{
try{ node.addEventListener(eventName,handler,false); //W3C
}catch(e){try{ node.attachEvent('on'+eventName,handler,"Language"); //MSIE
}catch(e){ node=handler; }} //Legacy
};
// fügt eine Standardüberschrift auf Diskussionsseiten hinzu, ggf noch eine Unterschrift
// funktioniert nicht in der mobilen Version
(function() {
var ns = mw.config.get("wgNamespaceNumber");
// nicht in namespaces Benutzer, Wiktionary und Modul
if (ns != "3" && ns != "5" && ns != "829" && ns % 2 == 1) {
var ef = document.getElementById("editform");
if (ef) {
ef.onsubmit = function() {headerFunction()};
function headerFunction() {
var tb = document.getElementById("wpTextbox1");
if (tb) {
var txt = tb.value;
var sum = document.getElementById("wpSummary");
var sumtxt = "" || sum.value;
if (txt.indexOf ("==\n") < 0 && sumtxt.length == 0 ) {
tb.value = "== Diskussionsbeitrag ==\n" + tb.value;
}
if (txt.length > 0 && txt.indexOf ("~~" + "~~") < 0 && !(/\d\d:\d\d,/).test(txt)) {
tb.value = tb.value.trim() + " --" + "~~" + "~~\n";
}
}
}
}
}
})();
jQuery(window).ready(function(){
function pagefromplus(title) {
return mw.util.wikiUrlencode(title.replace(/ /g, "+")).replace(/%2B/g, "+");
}
function sortChars(str) {
var r = "";
var arr = ;
for (var i = str.length; i >= 0; i--){
arr.push(str.charAt(i).toLowerCase());
}
arr.sort();
for (var i = 0; i < arr.length; i++){
r += arr;
}
return r;
}
// extract substring
function extractStr(txt,left,right,strip)
{
var i = left.length == 0 ? 0 : txt.indexOf(left);
if (i >= 0) {
var j = right.length == 0 ? txt.length : txt.indexOf(right,i+1);
if (j >= 0) {
if (typeof strip === "undefined") {
return txt.substring(i,j+right.length);
} else {
switch (strip) {
case 'L': return txt.substring(i+left.length,j+right.length);
case 'R': return txt.substring(i,j);
case 'B': return txt.substring(i+left.length,j);
}
}
}
}
return '';
}
// wirklichen server ermitteln (mobile/desktop) site
function getRealServer() {
return window.location.protocol + "//" + window.location.hostname;
}
var ns = mw.config.get("wgNamespaceNumber");
// 14 = Kategorie
if ((ns == 14) && mw.config.get("wgAction") == "view")
{
var form,node;
var title = mw.config.get("wgTitle");
// --------------- Start (größere Schrift) ---------
// größere Schrift für bestimmte Sprachen. Beispiel: Urdu
// aktiv in Kategorie: "Urdu" oder "... (Urdu)" aber nicht in "Übersetzungen (Urdu)"
var bigSize = "Arabisch,Urdu";
var bigSizeA = bigSize.split(',');
var titleLang = title.match(/\((*)\)/); // match == "(Sprache)"; match == "Sprache"
var bed1 = bigSizeA.includes(title);
var bed2 = false;
if (titleLang && titleLang.length > 1) {
bed2 = bigSizeA.includes(titleLang);
}
if (!title.includes("Übersetzungen") && (bed1 || bed2)) {
$("#mw-pages li a").attr( "style", "font-size: 133%");
}
// --------------- Ende (größere Schrift) ---------
if (title.substr(0,23) == "Rückläufige Wörterliste"){
form = newNode(
'form',
{'class':'noprint'},
newNode('label','Liste starten bei Einträgen, die enden auf: ',
newNode('input',{'type':'text','name':'pagefrom','id':'morfegap'})),
newNode('input',{'type':'button','value':'Los'})
);
form.lastChild.onclick = function(){
var pf = document.getElementById("morfegap");
var r = "";
for (var i = pf.value.length-1; i >= 0; i--){
r += pf.value.charAt(i);
}
location.href = getRealServer() + mw.config.get("wgScript")
+"?title="+mw.util.wikiUrlencode(mw.config.get("wgPageName"))
+"&pagefrom="+pagefromplus(r);
};
// Hinweis: Auf Kategorieseiten wird kein div.mw-headingN Wrapper erzeugt
$("#mw-pages h3").attr( "dir", "rtl" ).attr( "style", "margin-right: 1em").wrapInner("<span dir='ltr'></span>");
$("#mw-pages ul").attr( "dir", "rtl" ).attr( "style", "margin-right: 2em");
$("#mw-pages li").wrapInner("<span dir='ltr'></span>");
} else if (title.substr(0,17) == "Anagramm sortiert"){
form = newNode(
'form',
{'class':'noprint'},
newNode('label','Liste starten bei Einträgen, die diese Zeichen enthalten: ',
newNode('input',{'type':'text','name':'pagefrom','id':'morfegap'})),
newNode('input',{'type':'button','value':'Los'})
);
form.lastChild.onclick = function(){
var pf = document.getElementById("morfegap");
var r = sortChars(pf.value);
location.href = getRealServer() + mw.config.get("wgScript")
+"?title="+mw.util.wikiUrlencode(mw.config.get("wgPageName"))
+"&pagefrom="+pagefromplus(r);
};
var lastKey = "";
var nextKey = "";
var lastelement = {};
var aktcolor = "cyan";
var changecolor = false;
// Markierung an Seitengrenze nötig?
$('#mw-pages a').each(function( index, element ) {
if (element.textContent == "vorherige Seite") {
lastKey = extractStr(element.href, "&pageuntil=", "%0A", "B");
}
if (element.textContent == "nächste Seite") {
nextKey = extractStr(element.href, "&pagefrom=", "%0A", "B");
}
});
$("#mw-pages li a").each(function( index, element ) {
// element == this
var thisKey = sortChars(element.textContent);
if (thisKey == lastKey) {
if (changecolor) {
changecolor = false;
if (aktcolor == "cyan") {
aktcolor = "yellow";
} else {
aktcolor = "cyan";
}
}
if (index > 0) {
lastelement.style.backgroundColor = aktcolor;
}
element.style.backgroundColor = aktcolor;
} else if (index == 199 && thisKey == nextKey) {
if (changecolor) {
changecolor = false;
if (aktcolor == "cyan") {
aktcolor = "yellow";
} else {
aktcolor = "cyan";
}
}
element.style.backgroundColor = aktcolor;
} else {
changecolor = true;
lastKey = thisKey;
lastelement = element;
}
});
} else {
form=newNode(
'form',
{'class':'noprint'},
newNode('label','Liste starten bei Einträgen, die beginnen mit: ',
newNode('input',{'type':'text','name':'pagefrom','id':'morfegap'})),
newNode('input',{'type':'button','value':'Los'})
);
form.lastChild.onclick = function(){
var pf=document.getElementById("morfegap");
location.href = getRealServer() + mw.config.get("wgScript")
+"?title="+mw.util.wikiUrlencode(mw.config.get("wgPageName"))
+"&pagefrom="+pagefromplus(pf.value);
};
}
node = document.getElementById("mw-content-text");
node.parentNode.insertBefore(form,node);
$('#morfegap').keypress(function (e) {
if (e.which == 13) {
form.lastChild.onclick();
return false;
}
});
}
});
/*</pre>*/