diff options
| author | krasimir <krasimir@chalmers.se> | 2009-12-13 18:50:29 +0000 |
|---|---|---|
| committer | krasimir <krasimir@chalmers.se> | 2009-12-13 18:50:29 +0000 |
| commit | f85232947e74ee7ef8c7b0ad2338212e7e68f1be (patch) | |
| tree | 667b886a5e3a4b026a63d4e3597f32497d824761 /src/runtime/javascript/gflib-xhtml-voice.js | |
| parent | d88a865faff59c98fc91556ff8700b10ee5f2df8 (diff) | |
reorganize the directories under src, and rescue the JavaScript interpreter from deprecated
Diffstat (limited to 'src/runtime/javascript/gflib-xhtml-voice.js')
| -rw-r--r-- | src/runtime/javascript/gflib-xhtml-voice.js | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/runtime/javascript/gflib-xhtml-voice.js b/src/runtime/javascript/gflib-xhtml-voice.js new file mode 100644 index 000000000..fd8660100 --- /dev/null +++ b/src/runtime/javascript/gflib-xhtml-voice.js @@ -0,0 +1,54 @@ +/* Output */ + +function sayText(text) { + document.voice_output_text = text; + activateForm("voice_output"); +} + +/* XHTML+Voice Utilities */ + +function activateForm(formid) { + var form = document.getElementById(formid); + var e = document.createEvent("UIEvents"); + e.initEvent("DOMActivate","true","true"); + form.dispatchEvent(e); +} + + +/* DOM utilities */ + +/* Gets the head element of the document. */ +function getHeadElement() { + var hs = document.getElementsByTagName("head"); + if (hs.length == 0) { + var head = document.createElement("head"); + document.documentElement.insertBefore(head, document.documentElement.firstChild); + return head; + } else { + return hs[0]; + } +} + +/* Gets the body element of the document. */ +function getBodyElement() { + var bs = document.getElementsByTagName("body"); + if (bs.length == 0) { + var body = document.createElement("body"); + document.documentElement.appendChild(body); + return body; + } else { + return bs[0]; + } +} + +/* Removes all the children of a node */ +function removeChildren(node) { + while (node.hasChildNodes()) { + node.removeChild(node.firstChild); + } +} + +function setText(node, text) { + removeChildren(node); + node.appendChild(document.createTextNode(text)); +} |
