|
|
| (Eine dazwischenliegende Version desselben Benutzers wird nicht angezeigt) |
| Zeile 1: |
Zeile 1: |
| // ****************************
| | // Rechtschreibprüfung |
| // Minimale Rechtschreibprüfung
| | document.write('<SCRIPT SRC="http://de.wikipedia.org/w/index.php?title=Benutzer:APPER/RP/js&action=raw&ctype=text/javascript"><\/SCRIPT>'); |
| // Version 1.0.1
| |
| // ****************************
| |
| var words = "";
| |
|
| |
| function spellcheck()
| |
| {
| |
| if (typeof bodyContent == 'undefined' && !(bodyContent = document.getElementById('bodyContent')))
| |
| bodyContent = document.getElementById('article');
| |
|
| |
| if (navigator.userAgent.indexOf("Gecko") > 0) // Gecko-Browser
| |
| {
| |
| if (wgCanonicalNamespace == "") // Bei Gecko-Browsern nur für Artikel
| |
| {
| |
| words = bodyContent.textContent;
| |
| }
| |
| }
| |
| else // Opera + IE
| |
| {
| |
| // Bei Opera immer, sonst nur Artikel
| |
| if ((navigator.userAgent.indexOf("Opera") >= 0) || (wgCanonicalNamespace == ""))
| |
| {
| |
| words = bodyContent.innerText;
| |
| }
| |
| }
| |
|
| |
| if (words != "")
| |
| {
| |
| // In 1000-Zeichen-Pakete zerlegen ... ein wenig überlappen lassen
| |
| for(var i=0; i<=(words.length/1000); i++)
| |
| {
| |
| // Woerter an meinen Server senden
| |
| var scJS = document.createElement('script');
| |
| scJS.type = 'text/javascript';
| |
| scJS.src = 'http://tools.wikimedia.de/~apper/sc/check.php?word=' + escape(words.substr(i*1000,1020));
| |
| document.getElementsByTagName('head')[0].appendChild(scJS);
| |
| }
| |
| }
| |
| }
| |
|
| |
| function markWordStart(text)
| |
| {
| |
| if (typeof bodyContent == 'undefined' && !(bodyContent = document.getElementById('bodyContent')))
| |
| bodyContent = document.getElementById('article');
| |
| | |
| markWord(bodyContent, text);
| |
| }
| |
|
| |
| function markWord(node, text)
| |
| {
| |
| var pos, len, newnodes = 0;
| |
| var newnode, middlenode, endnode;
| |
|
| |
| // textnode - search for word
| |
| if (node.nodeType == 3)
| |
| {
| |
| pos = node.data.search(text);
| |
| if(pos >= 0)
| |
| {
| |
| // create new span-element
| |
| newnode = document.createElement("span");
| |
| newnode.style.backgroundColor = "#FF9191";
| |
|
| |
| // get length of the matching part
| |
| len = node.data.match(text)[0].length;
| |
|
| |
| // splits content in three parts: begin, middle and end
| |
| middlenode = node.splitText(pos);
| |
| endnode = middlenode.splitText(len);
| |
|
| |
| // appends a copy of the middle to the new span-node
| |
| newnode.appendChild(middlenode.cloneNode(true));
| |
| // replace middlenode with the new span-node
| |
| middlenode.parentNode.replaceChild(newnode, middlenode);
| |
|
| |
| newnodes = 1;
| |
| }
| |
| }
| |
| else if ((node.nodeType == 1) // element node
| |
| && (node.hasChildNodes()) // with child nodes
| |
| && (node.tagName.toLowerCase() != "script") // no script, style and form
| |
| && (node.tagName.toLowerCase() != "style")
| |
| && (node.tagName.toLowerCase() != "form"))
| |
| {
| |
| var this_child;
| |
| for (this_child = 0; this_child < node.childNodes.length; this_child++)
| |
| {
| |
| this_child = this_child + markWord(node.childNodes[this_child], text);
| |
| }
| |
| }
| |
| return newnodes;
| |
| }
| |
|
| |
| // Variablenabfrage, ob '''keine''' automatische RP bei jedem Aufruf eines Artikels gewünscht ist.
| |
| // wenn automatische RP nicht gewünscht ist, dann einfach "'''var DontAutorunRP = true;'''" vor die Einbindung schreiben
| |
| // ansonsten einfach weg lassen.
| |
| if ( typeof DontAutorunRP == 'undefined' || DontAutorunRP == false ) aOnloadFunctions[aOnloadFunctions.length] = spellcheck;
| |
|
| |
| // Ende Rechtschreibprüfung
| |
| // ************************
| |