summaryrefslogtreecommitdiffstats
path: root/org/madore/damlengine/TodoCommentsScript.java
blob: 224d547a72e4adce37f886eafa307fd1bd45a2a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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);
    }
}