diff options
author | obscuren <geffobscura@gmail.com> | 2014-04-29 05:24:42 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-04-29 05:24:42 +0800 |
commit | 922974c760278b6d49cb6f286b663d60f77d5248 (patch) | |
tree | 58b04982be7dfd134103e350da7cc8b0a8fbd2eb /ethereal/assets/muted | |
parent | c0de11955b3a15e6122e3ec9b68623515d311962 (diff) | |
download | go-tangerine-922974c760278b6d49cb6f286b663d60f77d5248.tar go-tangerine-922974c760278b6d49cb6f286b663d60f77d5248.tar.gz go-tangerine-922974c760278b6d49cb6f286b663d60f77d5248.tar.bz2 go-tangerine-922974c760278b6d49cb6f286b663d60f77d5248.tar.lz go-tangerine-922974c760278b6d49cb6f286b663d60f77d5248.tar.xz go-tangerine-922974c760278b6d49cb6f286b663d60f77d5248.tar.zst go-tangerine-922974c760278b6d49cb6f286b663d60f77d5248.zip |
Added muted
Diffstat (limited to 'ethereal/assets/muted')
-rw-r--r-- | ethereal/assets/muted/debugger.html | 2 | ||||
-rw-r--r-- | ethereal/assets/muted/index.html | 46 | ||||
-rw-r--r-- | ethereal/assets/muted/muted.js | 61 |
3 files changed, 106 insertions, 3 deletions
diff --git a/ethereal/assets/muted/debugger.html b/ethereal/assets/muted/debugger.html index 077c59bcf..b7552f030 100644 --- a/ethereal/assets/muted/debugger.html +++ b/ethereal/assets/muted/debugger.html @@ -4,7 +4,7 @@ <style type="text/css"> html, body { margin: 0; padding: 0; - min-height: 100%; + min-height: 100%; } #debugger { diff --git a/ethereal/assets/muted/index.html b/ethereal/assets/muted/index.html index c750d780b..14949b5ac 100644 --- a/ethereal/assets/muted/index.html +++ b/ethereal/assets/muted/index.html @@ -7,20 +7,63 @@ <script src="lib/codemirror.js"></script> <script src="lib/matchbrackets.js"></script> <script src="lib/go.js"></script> +<script src="muted.js"></script> <style type="text/css"> html, body { margin: 0; padding: 0; + min-height: 100%; + } + + #debugger { + height: 30%; + font-family: "Monaco"; + border-top: 5px solid grey; + } + #debugger .line { + overflow: none; + } + #debugger .col1, #debugger .col2 { + float: left; + padding: 3px; + } + #debugger .col1 { + width: 10px; + padding-left: 10px + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + } + #debugger .col2 { + width: 90%; + } + .prompt { + color: "#5089D4"; } .CodeMirror { - height: 100%; + height: 70%; + font-size: 14pt; } </style> </head> <body> <textarea id="editor"></textarea> + +<div id="debugger"> + <div class="line"> + <div class="col1 prompt"> + > + </div> + <div class="col2" contenteditable> + </div> + </div> +</div> + <script> var textArea = document.querySelector("#editor") var editor = CodeMirror.fromTextArea(textArea, { @@ -33,6 +76,5 @@ indentWithTabs: true, }); </script> - </body> </html> diff --git a/ethereal/assets/muted/muted.js b/ethereal/assets/muted/muted.js new file mode 100644 index 000000000..72e858d7a --- /dev/null +++ b/ethereal/assets/muted/muted.js @@ -0,0 +1,61 @@ +// Helper function for generating pseudo callbacks and sending data to the QML part of the application +function postData(data, cb) { + data._seed = Math.floor(Math.random() * 1000000) + if(cb) { + Muted._callbacks[data._seed] = cb; + } + + if(data.args === undefined) { + data.args = []; + } + + navigator.qt.postMessage(JSON.stringify(data)); +} + +window.Muted = { + prototype: Object(), +} + +window.Muted._callbacks = {} +window.Muted._onCallbacks = {} + +function debug(/**/) { + console.log("hello world") + + var args = arguments; + var msg = "" + for(var i = 0; i < args.length; i++){ + if(typeof args[i] == "object") { + msg += " " + JSON.stringify(args[i]) + } else { + msg += args[i] + } + } + + document.querySelector("#debugger").innerHTML += "<div class='line'><div class='col1'></div><div class='col2'>"+msg+"</div></div>"; +} +console.log = function() { + var args = [] + for(var i = 0; i < arguments.length; i++) { + args.push(arguments[i]); + } + postData({call:"log", args:args}) +} + +navigator.qt.onmessage = function(ev) { + var data = JSON.parse(ev.data) + + if(data._event !== undefined) { + Muted.trigger(data._event, data.data); + } else { + if(data._seed) { + var cb = Muted._callbacks[data._seed]; + if(cb) { + // Call the callback + cb(data.data); + // Remove the "trigger" callback + delete Muted._callbacks[ev._seed]; + } + } + } +} |