diff options
Diffstat (limited to 'examples/hybridshell/index.html')
-rw-r--r-- | examples/hybridshell/index.html | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/examples/hybridshell/index.html b/examples/hybridshell/index.html new file mode 100644 index 0000000..23a765c --- /dev/null +++ b/examples/hybridshell/index.html @@ -0,0 +1,82 @@ +<!DOCTYPE html> +<html> + <head> + <title>QML/HTML Hybrid Shell</title> + <style type="text/css"> + html, body { + margin:0; + padding:0; + width:100%; + height:100%; + } + #layout { + height:100%; + width:92%; + margin: 0 auto; + } + #output { + width:100%; + margin-top:1%; + height: 94%; + display: block; + border-radius: 5px; + border-style: solid; + border-color: #666666; + background-image: -webkit-linear-gradient(left top,#dddddd, #ffffff) + } + #input { + width:100%; + height: 3%; + margin-top:1%; + margin-bottom:1%; + display: block; + background-color: #dddddd; + border-radius: 3px; + border-style: solid; + border-color: #dddddd; + background-image: -webkit-linear-gradient(left,#eeeeee, #cccccc) + } + </style> + <script type="text/javascript" src="qrc:///qwebchannel/webchannel.js"></script> + <script type="text/javascript"> + function out(line) + { + document.querySelector("#output").value += line + "\r\n"; + } + function send() + { + var input = document.querySelector("#input"); + var text = input.value; + out("> " + text); + input.value = ""; + navigator.webChannel.exec(text); + } + + function handleKey(code) + { + switch (code) { + case 13: + send(); + break; + } + } + + window.onload = function() { + out("Starting..."); + + var baseUrl = (/[?&]webChannelBaseUrl=([A-Za-z0-9\-:/\.]+)/.exec(location.search)[1]); + new QWebChannel(baseUrl, function(webChannel) { + window.navigator.webChannel = webChannel; + out("Ready"); + webChannel.subscribe("stdout", out); + }); + } + </script> + </head> + <body> + <div id="layout"> + <textarea readonly id="output" ></textarea> + <input type="text" id="input" onkeyup="handleKey(event.keyCode)"></input> + </div> + </body> +</html> |