]>
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> | |
7c81747b JM |
10 | <link rel="stylesheet" href="include/plain.css" TITLE="plain"> |
11 | <link rel="Alternate StyleSheet" href="include/black.css" TITLE="Black"> | |
a93c9555 JM |
12 | <!-- |
13 | <script type='text/javascript' | |
14 | src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script> | |
15 | --> | |
16 | <script src="include/vnc.js"></script> | |
91308399 JM |
17 | </head> |
18 | ||
63708ff5 | 19 | <body style="margin: 0px;"> |
91308399 | 20 | <div id="VNC_screen"> |
63708ff5 JM |
21 | <div id="VNC_status_bar" class="VNC_status_bar" style="margin-top: 0px;"> |
22 | <table border=0 width=100%><tr> | |
23 | <td><div id="VNC_status">Loading</div></td> | |
24 | <td width=10%><div id="VNC_buttons"> | |
25 | <input type=button value="Send CtrlAltDel" | |
160fabf6 | 26 | id="sendCtrlAltDelButton" |
63708ff5 JM |
27 | onclick="sendCtrlAltDel();"></div></td> |
28 | </tr></table> | |
29 | </div> | |
91308399 JM |
30 | <canvas id="VNC_canvas" width="640px" height="20px"> |
31 | Canvas not supported. | |
32 | </canvas> | |
33 | </div> | |
34 | </body> | |
35 | ||
91308399 JM |
36 | <script> |
37 | function setPassword() { | |
63708ff5 | 38 | RFB.sendPassword($('password_input').value); |
91308399 JM |
39 | return false; |
40 | } | |
63708ff5 JM |
41 | function sendCtrlAltDel() { |
42 | RFB.sendCtrlAltDel(); | |
43 | } | |
91308399 | 44 | function updateState(state, msg) { |
63708ff5 | 45 | var s, sb, klass, html; |
91308399 | 46 | s = $('VNC_status'); |
63708ff5 | 47 | sb = $('VNC_status_bar'); |
160fabf6 | 48 | cad = $('sendCtrlAltDelButton'); |
91308399 | 49 | switch (state) { |
f00b1e37 JM |
50 | case 'failed': |
51 | case 'fatal': | |
52 | klass = "VNC_status_error"; | |
53 | break; | |
54 | case 'normal': | |
55 | klass = "VNC_status_normal"; | |
56 | break; | |
57 | case 'disconnected': | |
58 | case 'loaded': | |
59 | klass = "VNC_status_normal"; | |
60 | break; | |
61 | case 'password': | |
62 | msg = '<form onsubmit="return setPassword();"'; | |
63 | msg += ' style="margin-bottom: 0px">'; | |
64 | msg += 'Password Required: '; | |
65 | msg += '<input type=password size=10 id="password_input" class="VNC_status">'; | |
66 | msg += '</form>'; | |
67 | // Fall through | |
68 | default: | |
69 | klass = "VNC_status_warn"; | |
91308399 JM |
70 | } |
71 | ||
160fabf6 JM |
72 | if (state === "normal") { cad.disabled = false; } |
73 | else { cad.disabled = true; } | |
74 | ||
91308399 | 75 | if (typeof(msg) !== 'undefined') { |
63708ff5 | 76 | sb.setAttribute("class", klass); |
91308399 JM |
77 | s.innerHTML = msg; |
78 | } | |
91308399 JM |
79 | } |
80 | ||
81 | window.onload = function () { | |
82 | var host, port, password, encrypt; | |
83 | ||
84 | url = document.location.href; | |
85 | host = (url.match(/host=([A-Za-z0-9.\-]*)/) || ['',''])[1]; | |
86 | port = (url.match(/port=([0-9]*)/) || ['',''])[1]; | |
87 | password = (url.match(/password=([^&#]*)/) || ['',''])[1]; | |
88 | encrypt = (url.match(/encrypt=([A-Za-z0-9]*)/) || ['',1])[1]; | |
89 | true_color = (url.match(/true_color=([A-Za-z0-9]*)/) || ['',1])[1]; | |
90 | if ((!host) || (!port)) { | |
91 | updateState('failed', | |
92 | "Must specify host and port in URL"); | |
93 | return; | |
94 | } | |
95 | ||
96 | RFB.setUpdateState(updateState); | |
97 | RFB.load(); | |
98 | RFB.connect(host, port, password, encrypt, true_color); | |
99 | } | |
100 | </script> | |
101 | </html> | |
102 |