]>
Commit | Line | Data |
---|---|---|
91308399 JM |
1 | <!-- |
2 | noVNC Example: Automatically connect on page load. | |
3 | ||
4 | Connect parameters are provided in query string: | |
5 | http://example.com/?host=HOST&port=PORT&encrypt=1&true_color=1 | |
6 | --> | |
7 | <html> | |
8 | <head> | |
9 | <title>VNC Client</title> | |
10 | <link rel="stylesheet" href="include/plain.css"> | |
11 | </head> | |
12 | ||
63708ff5 | 13 | <body style="margin: 0px;"> |
91308399 | 14 | <div id="VNC_screen"> |
63708ff5 JM |
15 | <div id="VNC_status_bar" class="VNC_status_bar" style="margin-top: 0px;"> |
16 | <table border=0 width=100%><tr> | |
17 | <td><div id="VNC_status">Loading</div></td> | |
18 | <td width=10%><div id="VNC_buttons"> | |
19 | <input type=button value="Send CtrlAltDel" | |
160fabf6 | 20 | id="sendCtrlAltDelButton" |
63708ff5 JM |
21 | onclick="sendCtrlAltDel();"></div></td> |
22 | </tr></table> | |
23 | </div> | |
91308399 JM |
24 | <canvas id="VNC_canvas" width="640px" height="20px"> |
25 | Canvas not supported. | |
26 | </canvas> | |
27 | </div> | |
28 | </body> | |
29 | ||
96a6eaad | 30 | <script src="include/vnc.js"></script> |
91308399 JM |
31 | <script> |
32 | function setPassword() { | |
63708ff5 | 33 | RFB.sendPassword($('password_input').value); |
91308399 JM |
34 | return false; |
35 | } | |
63708ff5 JM |
36 | function sendCtrlAltDel() { |
37 | RFB.sendCtrlAltDel(); | |
38 | } | |
91308399 | 39 | function updateState(state, msg) { |
63708ff5 | 40 | var s, sb, klass, html; |
91308399 | 41 | s = $('VNC_status'); |
63708ff5 | 42 | sb = $('VNC_status_bar'); |
160fabf6 | 43 | cad = $('sendCtrlAltDelButton'); |
91308399 | 44 | switch (state) { |
160fabf6 | 45 | case 'failed': klass = "VNC_status_error"; break; |
91308399 JM |
46 | case 'normal': klass = "VNC_status_normal"; break; |
47 | case 'disconnected': klass = "VNC_status_normal"; break; | |
160fabf6 | 48 | default: klass = "VNC_status_warn"; break; |
91308399 JM |
49 | } |
50 | ||
160fabf6 JM |
51 | if (state === "normal") { cad.disabled = false; } |
52 | else { cad.disabled = true; } | |
53 | ||
91308399 | 54 | if (typeof(msg) !== 'undefined') { |
63708ff5 | 55 | sb.setAttribute("class", klass); |
91308399 JM |
56 | s.innerHTML = msg; |
57 | } | |
58 | if (state === 'password') { | |
59 | html = '<form onsubmit="return setPassword();"'; | |
60 | html += ' style="margin-bottom: 0px">'; | |
61 | html += 'Password Required: '; | |
63708ff5 | 62 | html += '<input type=password size=10 id="password_input" class="VNC_status">'; |
91308399 JM |
63 | html += '</form>'; |
64 | s.innerHTML = html; | |
65 | } | |
66 | } | |
67 | ||
68 | window.onload = function () { | |
69 | var host, port, password, encrypt; | |
70 | ||
71 | url = document.location.href; | |
72 | host = (url.match(/host=([A-Za-z0-9.\-]*)/) || ['',''])[1]; | |
73 | port = (url.match(/port=([0-9]*)/) || ['',''])[1]; | |
74 | password = (url.match(/password=([^&#]*)/) || ['',''])[1]; | |
75 | encrypt = (url.match(/encrypt=([A-Za-z0-9]*)/) || ['',1])[1]; | |
76 | true_color = (url.match(/true_color=([A-Za-z0-9]*)/) || ['',1])[1]; | |
77 | if ((!host) || (!port)) { | |
78 | updateState('failed', | |
79 | "Must specify host and port in URL"); | |
80 | return; | |
81 | } | |
82 | ||
83 | RFB.setUpdateState(updateState); | |
84 | RFB.load(); | |
85 | RFB.connect(host, port, password, encrypt, true_color); | |
86 | } | |
87 | </script> | |
88 | </html> | |
89 |