summaryrefslogtreecommitdiff
path: root/examples/hybridshell/qml/hybridshell/index.html
blob: a76f047e4a1255e26fd232b071fadbd1aace132a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<html>
    <head>
        <style>
        #output {
            width:92%; height: 95%; display: block;
            border-radius: 5px;
            border-style: solid;
            border-color: #666666;
            background-image: -webkit-linear-gradient(left top,#dddddd, #ffffff)
        }
        #input {
            width:92%; height: 5%; display: block; background-color: #dddddd;
            border-radius: 3px;
            border-style: solid;
            border-color: #dddddd;
            background-image: -webkit-linear-gradient(left,#eeeeee, #cccccc)
        }
        </style>
        <script>
            document.write('<script src="' + (/[?&]webChannelBaseUrl=([A-Za-z0-9\-:/]+)/.exec(location.search)[1]) + '/webchannel.js/createWebChannel"><' + '/script>');
        </script>
        <script>
        function out(line)
        {
            document.querySelector("#output").value += line + "\r\n";
        }
        window.onload = function() {
            out("Starting...");
            createWebChannel(function(webChannel) {
                window.navigator.webChannel = webChannel;
                out("Ready");
                webChannel.subscribe("stdout", out);
            });
        };

        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;

            }
        }
        </script>
    </head>
    <body marginleft=0 margintop=0 style="width:480px; height: 800px">
        <textarea readonly id="output" ></textarea>
        <input type="text" id="input" onkeyup="handleKey(event.keyCode)"></input>
    </body>
</html>