Statistics
| Branch: | Tag: | Revision:

one / src / sunstone / public / vendor / noVNC / vnc_auto.html @ 5fcb9de8

History | View | Annotate | Download (4.08 KB)

1
<!DOCTYPE html>
2
<html>
3
    <!-- 
4
    noVNC Example: Automatically connect on page load.
5
    Copyright (C) 2011 Joel Martin
6
    Licensed under LGPL-3 (see LICENSE.txt)
7

8
    Connect parameters are provided in query string:
9
        http://example.com/?host=HOST&port=PORT&encrypt=1&true_color=1
10
    -->
11
    <head>
12
        <title>noVNC</title>
13
        <meta http-equiv="X-UA-Compatible" content="chrome=1">
14
        <link rel="stylesheet" href="include/plain.css" title="plain">
15
        <!--
16
        <script type='text/javascript' 
17
            src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
18
        -->
19
        <script src="include/vnc.js"></script>
20
    </head>
21

    
22
    <body style="margin: 0px;">
23
        <div id="VNC_screen">
24
            <div id="VNC_status_bar" class="VNC_status_bar" style="margin-top: 0px;">
25
                <table border=0 width="100%"><tr>
26
                    <td><div id="VNC_status">Loading</div></td>
27
                    <td width="1%"><div id="VNC_buttons">
28
                        <input type=button value="Send CtrlAltDel"
29
                            id="sendCtrlAltDelButton">
30
                            </div></td>
31
                </tr></table>
32
            </div>
33
            <canvas id="VNC_canvas" width="640px" height="20px">
34
                Canvas not supported.
35
            </canvas>
36
        </div>
37

    
38
        <script>
39
        /*jslint white: false */
40
        /*global window, $, Util, RFB, */
41
        "use strict";
42

43
        var rfb;
44

45
        function setPassword() {
46
            rfb.sendPassword($D('password_input').value);
47
            return false;
48
        }
49
        function sendCtrlAltDel() {
50
            rfb.sendCtrlAltDel();
51
            return false;
52
        }
53
        function updateState(rfb, state, oldstate, msg) {
54
            var s, sb, cad, klass;
55
            s = $D('VNC_status');
56
            sb = $D('VNC_status_bar');
57
            cad = $D('sendCtrlAltDelButton');
58
            switch (state) {
59
                case 'failed':
60
                case 'fatal':
61
                    klass = "VNC_status_error";
62
                    break;
63
                case 'normal':
64
                    klass = "VNC_status_normal";
65
                    break;
66
                case 'disconnected':
67
                case 'loaded':
68
                    klass = "VNC_status_normal";
69
                    break;
70
                case 'password':
71
                    msg = '<form onsubmit="return setPassword();"';
72
                    msg += '  style="margin-bottom: 0px">';
73
                    msg += 'Password Required: ';
74
                    msg += '<input type=password size=10 id="password_input" class="VNC_status">';
75
                    msg += '<\/form>';
76
                    klass = "VNC_status_warn";
77
                    break;
78
                default:
79
                    klass = "VNC_status_warn";
80
            }
81

82
            if (state === "normal") { cad.disabled = false; }
83
            else                    { cad.disabled = true; }
84

85
            if (typeof(msg) !== 'undefined') {
86
                sb.setAttribute("class", klass);
87
                s.innerHTML = msg;
88
            }
89
        }
90

91
        window.onload = function () {
92
            var host, port, password;
93

94
            $D('sendCtrlAltDelButton').onclick = sendCtrlAltDel;
95

96
            host = WebUtil.getQueryVar('host', null);
97
            port = WebUtil.getQueryVar('port', null);
98
            password = WebUtil.getQueryVar('password', '');
99
            if ((!host) || (!port)) {
100
                updateState('failed',
101
                    "Must specify host and port in URL");
102
                return;
103
            }
104

105
            rfb = new RFB({'target':       $D('VNC_canvas'),
106
                           'encrypt':      WebUtil.getQueryVar('encrypt', false),
107
                           'true_color':   WebUtil.getQueryVar('true_color', true),
108
                           'local_cursor': WebUtil.getQueryVar('cursor', true),
109
                           'shared':       WebUtil.getQueryVar('shared', true),
110
                           'updateState':  updateState});
111
            rfb.connect(host, port, password);
112
        };
113
        </script>
114

    
115
    </body>
116
</html>
117