summaryrefslogtreecommitdiffstats
path: root/org/madore/damlengine/included.js
diff options
context:
space:
mode:
authorDavid A. Madore <david+git@madore.org>2011-04-27 17:08:48 +0200
committerDavid A. Madore <david+git@madore.org>2011-04-27 17:08:48 +0200
commit0434afe04c64502bc1181793f471c4f6d4409981 (patch)
treed8c67ad97df18b266817e0bd36e9053ea899b1a6 /org/madore/damlengine/included.js
parentdc889c3f777041e72f79ff6cb6c3523632db259d (diff)
downloaddamlengine-0434afe04c64502bc1181793f471c4f6d4409981.tar.gz
damlengine-0434afe04c64502bc1181793f471c4f6d4409981.tar.bz2
damlengine-0434afe04c64502bc1181793f471c4f6d4409981.zip
Add content to style and script elements.
Diffstat (limited to 'org/madore/damlengine/included.js')
-rw-r--r--org/madore/damlengine/included.js56
1 files changed, 56 insertions, 0 deletions
diff --git a/org/madore/damlengine/included.js b/org/madore/damlengine/included.js
new file mode 100644
index 0000000..7aa2a2b
--- /dev/null
+++ b/org/madore/damlengine/included.js
@@ -0,0 +1,56 @@
+var textNodeType;
+function textContent(n) {
+ if ( n.nodeType == textNodeType ) {
+ return n.data;
+ } else {
+ var children = n.childNodes;
+ var t = "";
+ for ( var i=0 ; i<children.length ; i++ ) {
+ t = t.concat(textContent(children.item(i)));
+ }
+ return t;
+ }
+}
+function despam() {
+ // MSIE seems to barf... Deactivate for now
+ if ( (/MSIE *[1-6]\./).test(navigator.userAgent) )
+ return;
+ // Now replace as appropriate.
+ var elts = document.getElementsByTagName("span");
+ for ( var i=0 ; i<elts.length ; i++ ) {
+ var elt = elts.item(i);
+ if ( elt.className == "replace-commercial-at" ) {
+ elt.parentNode.replaceChild(document.createTextNode("@"),elt);
+ i--; // Semi-bugware
+ } else if ( elt.className == "replace-full-stop" ) {
+ elt.parentNode.replaceChild(document.createTextNode("."),elt);
+ i--; // Semi-bugware
+ }
+ }
+ // Merge adjacent text nodes.
+ try {
+ document.normalize(); // Your DOM is BROKEN!
+ } catch (exn) {
+ document.documentElement.normalize();
+ }
+ // Next, process all <a> elements having class="despammed-address".
+ elts = document.getElementsByTagName("a");
+ for ( var i=0 ; i<elts.length ; i++ ) {
+ var elt = elts.item(i);
+ if ( elt.className == "despammed-address" ) {
+ var addr = "mailto:".concat(textContent(elt));
+ elt.setAttribute("href",addr); // (abstract)
+ elt.href = addr; // (semantic)
+ }
+ }
+}
+function onLoad() {
+ // Start with some bugware...
+ try {
+ textNodeType = Node.TEXT_NODE;
+ } catch (exn) { // Your DOM is BROKEN!
+ textNodeType = 3;
+ }
+ // Now despam email adresses.
+ despam();
+}