summaryrefslogtreecommitdiffstats
path: root/org/madore/damlengine/TodoCommentsScript.java
diff options
context:
space:
mode:
authorDavid A. Madore <david+git@madore.org>2011-09-01 15:41:38 +0200
committerDavid A. Madore <david+git@madore.org>2011-09-01 15:41:38 +0200
commitacdbedc507679be7b35a0fe10990bfb579bdc9d9 (patch)
treeb955f98af9db183bac200df61c8cdbe44965c510 /org/madore/damlengine/TodoCommentsScript.java
parentced5a5f3fad721da1dab1ab90fa8599078eb4c1e (diff)
downloaddamlengine-acdbedc507679be7b35a0fe10990bfb579bdc9d9.tar.gz
damlengine-acdbedc507679be7b35a0fe10990bfb579bdc9d9.tar.bz2
damlengine-acdbedc507679be7b35a0fe10990bfb579bdc9d9.zip
Add the JavaScript magic element to indicate number of comments.
Diffstat (limited to 'org/madore/damlengine/TodoCommentsScript.java')
-rw-r--r--org/madore/damlengine/TodoCommentsScript.java26
1 files changed, 26 insertions, 0 deletions
diff --git a/org/madore/damlengine/TodoCommentsScript.java b/org/madore/damlengine/TodoCommentsScript.java
new file mode 100644
index 0000000..224d547
--- /dev/null
+++ b/org/madore/damlengine/TodoCommentsScript.java
@@ -0,0 +1,26 @@
+package org.madore.damlengine;
+
+import org.w3c.dom.*;
+
+public final class TodoCommentsScript extends TodoElement {
+
+ public TodoCommentsScript(Element node,
+ Context ctx,
+ TodoItem caller) {
+ super(node, ctx, caller);
+ }
+
+ @Override
+ public void handle() {
+ if ( ctx.gc.commentsJSParam == null ) {
+ node.getParentNode().removeChild(node);
+ return;
+ }
+ Element script = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "script");
+ script.setAttributeNS(null, "type", "text/javascript");
+ script.setAttributeNS(null, "src", "/cgi-bin/numcomments.pl/x.js?"+ctx.gc.commentsJSParam);
+ script.setAttributeNS(null, "defer", "defer");
+ node.appendChild(ctx.doc.createComment(" EMPTY "));
+ node.getParentNode().replaceChild(script, node);
+ }
+}