summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org/madore/damlengine/TodoElement.java11
-rw-r--r--org/madore/damlengine/TodoSmileyElement.java75
2 files changed, 86 insertions, 0 deletions
diff --git a/org/madore/damlengine/TodoElement.java b/org/madore/damlengine/TodoElement.java
index 60b80c2..8db448c 100644
--- a/org/madore/damlengine/TodoElement.java
+++ b/org/madore/damlengine/TodoElement.java
@@ -43,6 +43,17 @@ public abstract class TodoElement extends TodoItem {
damlFactories.put("email-dot", new TodoEmailAtOrDotElement.Factory(TodoEmailAtOrDotElement.Type.DOT));
damlFactories.put("extra-style", new TodoExtraStyleOrScriptElement.Factory(TodoStyleOrScript.Type.STYLE));
damlFactories.put("extra-script", new TodoExtraStyleOrScriptElement.Factory(TodoStyleOrScript.Type.SCRIPT));
+ damlFactories.put("smiley-smile", new TodoSmileyElement.Factory(TodoSmileyElement.Type.SMILE));
+ damlFactories.put("smiley-wink", new TodoSmileyElement.Factory(TodoSmileyElement.Type.WINK));
+ damlFactories.put("smiley-surprised", new TodoSmileyElement.Factory(TodoSmileyElement.Type.SURPRISED));
+ damlFactories.put("smiley-sad", new TodoSmileyElement.Factory(TodoSmileyElement.Type.SAD));
+ damlFactories.put("smiley-cool", new TodoSmileyElement.Factory(TodoSmileyElement.Type.COOL));
+ damlFactories.put("smiley-biggrin", new TodoSmileyElement.Factory(TodoSmileyElement.Type.BIGGRIN));
+ damlFactories.put("smiley-confused", new TodoSmileyElement.Factory(TodoSmileyElement.Type.CONFUSED));
+ damlFactories.put("smiley-crazy", new TodoSmileyElement.Factory(TodoSmileyElement.Type.CRAZY));
+ damlFactories.put("smiley-neutral", new TodoSmileyElement.Factory(TodoSmileyElement.Type.NEUTRAL));
+ damlFactories.put("smiley-twisted", new TodoSmileyElement.Factory(TodoSmileyElement.Type.TWISTED));
+ damlFactories.put("smiley-cry", new TodoSmileyElement.Factory(TodoSmileyElement.Type.CRY));
}
protected final Element node;
diff --git a/org/madore/damlengine/TodoSmileyElement.java b/org/madore/damlengine/TodoSmileyElement.java
new file mode 100644
index 0000000..20eec1c
--- /dev/null
+++ b/org/madore/damlengine/TodoSmileyElement.java
@@ -0,0 +1,75 @@
+package org.madore.damlengine;
+
+import java.util.regex.Pattern;
+import org.w3c.dom.*;
+
+public final class TodoSmileyElement extends TodoDefaultElement {
+
+ public enum Type {
+ SMILE("smile", ":-)", "Smile", "Sourire"),
+ WINK("wink", ";-)", "Wink", "Clin d'\u0153il"),
+ SURPRISED("surprised", ":-o", "Surprised", "Surpris"),
+ SAD("sad", ":-(", "Sad", "Triste"),
+ COOL("cool", "8-)", "Cool", "Cool"),
+ BIGGRIN("biggrin", ":-D", "Big grin", "Grand sourire"),
+ CONFUSED("confused", ":-S", "Confused", "Troubl\u00e9"),
+ CRAZY("crazy", "%-)", "Crazy", "Fou"),
+ NEUTRAL("neutral", ":-|", "Non-grin", "Sans sourire"),
+ TWISTED("twisted", "8->", "Twisted", "Tordu"),
+ CRY("cry", "\u00A6-(", "Crying", "Pleure");
+ final String emotion;
+ final String altText;
+ final String enName;
+ final String frName;
+ Type(String emotion, String altText,
+ String enName, String frName) {
+ this.emotion = emotion;
+ this.altText = altText;
+ this.enName = enName;
+ this.frName = frName;
+ }
+ }
+
+ public static class Factory extends TodoElement.Factory {
+ final Type t;
+ public Factory(Type t) {
+ super();
+ this.t = t;
+ }
+ @Override
+ public TodoSmileyElement newItem(Element node,
+ Context ctx,
+ TodoItem caller) {
+ return new TodoSmileyElement(t, node, ctx, caller);
+ }
+ }
+
+ final Type t;
+
+ public TodoSmileyElement(Type t,
+ Element node,
+ Context ctx,
+ TodoItem caller) {
+ super(node, ctx, caller);
+ this.t = t;
+ }
+
+ @Override
+ public void handleNodeOnly() {
+ String lang = LangHelper.getLangRec(node);
+ Element img = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "img");
+ img.setAttributeNS(null, "src",
+ (ctx.uriToTop==null?"":ctx.uriToTop)+"images/smileys/"+t.emotion+".png");
+ img.setAttributeNS(null, "class",
+ "smiley");
+ img.setAttributeNS(null, "alt", t.altText);
+ img.setAttributeNS(null, "height", "15");
+ img.setAttributeNS(null, "width", "15");
+ if ( lang != null && lang.equals("en") )
+ img.setAttributeNS(null, "title", t.enName);
+ else if ( lang != null && lang.equals("fr") )
+ img.setAttributeNS(null, "title", t.frName);
+ node.getParentNode().replaceChild(img, node);
+ }
+
+}