summaryrefslogtreecommitdiffstats
path: root/org/madore/damlengine/TodoStyleOrScript.java
diff options
context:
space:
mode:
authorDavid A. Madore <david+git@madore.org>2010-04-18 21:58:49 +0200
committerDavid A. Madore <david+git@madore.org>2010-04-18 21:58:49 +0200
commit876a83c647bfa499323a14d1cd08a4690eef5a34 (patch)
tree945c604d1f509bedcb35224c60c965a13ebae46d /org/madore/damlengine/TodoStyleOrScript.java
parent99cea43742283d7bc383021ebd52087115448159 (diff)
downloaddamlengine-876a83c647bfa499323a14d1cd08a4690eef5a34.tar.gz
damlengine-876a83c647bfa499323a14d1cd08a4690eef5a34.tar.bz2
damlengine-876a83c647bfa499323a14d1cd08a4690eef5a34.zip
A handful of meta tags, script and style sections.
Diffstat (limited to 'org/madore/damlengine/TodoStyleOrScript.java')
-rw-r--r--org/madore/damlengine/TodoStyleOrScript.java41
1 files changed, 41 insertions, 0 deletions
diff --git a/org/madore/damlengine/TodoStyleOrScript.java b/org/madore/damlengine/TodoStyleOrScript.java
new file mode 100644
index 0000000..7b06955
--- /dev/null
+++ b/org/madore/damlengine/TodoStyleOrScript.java
@@ -0,0 +1,41 @@
+package org.madore.damlengine;
+
+import org.w3c.dom.*;
+
+public class TodoStyleOrScript extends TodoItem {
+
+ public enum Type { STYLE, SCRIPT }
+
+ Type t;
+
+ public TodoStyleOrScript(Type t,
+ Context ctx,
+ TodoItem.Options options) {
+ super(ctx, options);
+ this.t = t;
+ }
+
+ public void handle() {
+ if ( ctx.headNode == null )
+ throw new Error("head node is null when doing style or script");
+ Element node
+ = ctx.doc.createElementNS(DamlEngine.XHTML_NS,
+ (t==Type.SCRIPT)?"script":"style");
+ node.setAttributeNS(null, "type",
+ (t==Type.SCRIPT)?"text/javascript":"text/css");
+ if ( t==Type.SCRIPT )
+ node.setAttributeNS(null, "defer", "defer");
+ ctx.headNode.appendChild(node);
+ ctx.headNode.appendChild(ctx.doc.createTextNode("\n"));
+ node.appendChild(ctx.doc.
+ createTextNode((t==Type.SCRIPT)?"\n// ":"\n/* "));
+ StringBuffer content = (t==Type.SCRIPT)?ctx.scriptContent:ctx.styleContent;
+ node.appendChild(ctx.doc.
+ createCDATASection(((t==Type.SCRIPT)?"\n":" */\n")
+ +content
+ +((t==Type.SCRIPT)?"// ":"/* ")));
+ node.appendChild(ctx.doc.
+ createTextNode((t==Type.SCRIPT)?"\n":" */\n"));
+ }
+
+}