From: Daniel Carl Date: Fri, 10 Jan 2014 00:13:25 +0000 (+0100) Subject: Show checkbox and radiobox state in hint label. X-Git-Url: https://git.owens.tech/assets/static/git.owens.tech/assets/static/git.owens.tech/git?a=commitdiff_plain;h=64459af4aec30337bac038a71ef06222de06153b;p=vimb.git Show checkbox and radiobox state in hint label. --- diff --git a/src/hints.js b/src/hints.js index 48b98e2..4d6faee 100644 --- a/src/hints.js +++ b/src/hints.js @@ -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") : ""); }; } diff --git a/src/js2h.sh b/src/js2h.sh index 90ed16a..be92ac4 100755 --- a/src/js2h.sh +++ b/src/js2h.sh @@ -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 '"'