User:Ruud10K/Spellchecker.js

/*"Spellchecker.js" by Ruudvan10000 and Quarenon*/ /*Highlights common spelling mistakes and americanisms*/ $(document).ready(function {

var body = $('#bodyContent').get(0);

/** * */ highlight_text(body, 'honor'); highlight_text(body, 'alot'); highlight_text(body, 'traveling'); highlight_text(body, 'traveled'); highlight_text(body, 'leveling'); highlight_text(body, 'leveled'); highlight_text(body, 'recomended'); highlight_text(body, 'extremly'); highlight_text(body, 'have'nt'); highlight_text(body, 'behavoir'); highlight_text(body, 'grater'); highlight_text(body, 'dialog'); highlight_text(body, 'expectedt'); highlight_text(body, 'southwest'); highlight_text(body, 'southeast'); highlight_text(body, 'southeastern'); highlight_text(body, 'southwestern'); highlight_text(body, 'northwest'); highlight_text(body, 'northeast'); highlight_text(body, 'analyze'); highlight_text(body, 'center'); highlight_text(body, 'color'); highlight_text(body, 'armor'); highlight_text(body, 'flavor'); highlight_text(body, 'neighbor'); highlight_text(body, 'rumor'); highlight_text(body, 'labor'); highlight_text(body, 'meter'); highlight_text(body, 'theater'); highlight_text(body, 'defense'); highlight_text(body, 'offense'); highlight_text(body, 'offencive'); highlight_text(body, 'defencive'); highlight_text(body, 'atack'); highlight_text(body, 'organize'); highlight_text(body, 'standardize'); highlight_text(body, 'realize'); highlight_text(body, 'paralyse'); highlight_text(body, 'advertize'); highlight_text(body, 'analog'); highlight_text(body, 'absense'); highlight_text(body, 'acceptible'); highlight_text(body, 'accomadate'); highlight_text(body, 'acheive'); highlight_text(body, 'acheivement'); highlight_text(body, 'artic'); highlight_text(body, 'arguement'); highlight_text(body, 'becuase'); highlight_text(body, 'gray'); highlight_text(body, 'Pl0x'); highlight_text(body, 'acknowlege'); highlight_text(body, 'definate'); function highlight_text(node, search, replace) {	if (node.nodeType == 3) {		var value = node.nodeValue; var matches = value.match(search); if (matches != null) {			var node_parent_node = node.parentNode; var old_node = node; // old_node_list = node.parentNode.childNodes; for (match = 0; match < matches.length; match++) {				var position; if (after_match != null && length != null) position = after_match.search(search) + before_match.length + length; else position = value.search(search); var length = matches[match].toString.length; var before_match = value.substring(0, position); var after_match = value.substring(position + length); var span = document.createElement('span'); span.style.backgroundColor = 'yellow'; /** Apply CSS style to the highlighted element. */				span.style.color = 'black'; span.appendChild(document.createTextNode(matches[match].toString)); var new_node = document.createDocumentFragment; new_node.appendChild(document.createTextNode(before_match)); new_node.appendChild(span); new_node.appendChild(document.createTextNode(after_match));

node_parent_node.replaceChild(new_node, old_node); break; }		}	}	else {		var children = [], child = node.firstChild; while (child) {			children[children.length] = child; child = child.nextSibling; }		for (var child = 0; child < children.length; child++) highlight_text(children[child], search); } }

});