Show checkbox and radiobox state in hint label.
authorDaniel Carl <danielcarl@gmx.de>
Fri, 10 Jan 2014 00:13:25 +0000 (01:13 +0100)
committerDaniel Carl <danielcarl@gmx.de>
Fri, 10 Jan 2014 00:13:25 +0000 (01:13 +0100)
src/hints.js
src/js2h.sh

index 48b98e2..4d6faee 100644 (file)
@@ -56,12 +56,20 @@ var VbHint = (function(){
             this.e.classList.add(hClass);
 
             /* create the label with the hint number */
-            this.label.innerText = this.num;
+            var text = [];
+            if (this.e instanceof HTMLInputElement) {
+                var type = this.e.type;
+                if (type === "checkbox") {
+                    text.push(this.e.checked ? "☑" : "☐");
+                } else if (type === "radio") {
+                    text.push(this.e.checked ? "⊙" : "○");
+                }
+            }
             if (this.showText && this.text) {
-                /* use \x20 instead of ' ' to keep this space during */
-                /* js2h.sh processing */
-                this.label.innerText += ":\x20" + this.text.substr(0, 20);
+                text.push(this.text.substr(0, 20));
             }
+            /* use \x20 instead of ' ' to keep this space during js2h.sh processing */
+            this.label.innerText = this.num + (text.length ? ":\x20" + text.join("\x20") : "");
         };
     }
 
index 90ed16a..be92ac4 100755 (executable)
@@ -7,6 +7,7 @@ cat $1 | \
     -e 's|[ ]\{2,\}| |g' \
     -e "s|[ ]\{0,\}\([-!?<>:=(){};+\&\"',\|]\)[ ]\{0,\}|\1|g" \
     -e 's|"+"||g' \
+    -e 's|\\x20| |g' \
     -e 's|\\|\\\\|g' \
     -e 's|"|\\"|g'
 echo '"'