]>
git.proxmox.com Git - mirror_novnc.git/blob - include/default_controls.js
2 * noVNC: HTML5 VNC client
3 * Copyright (C) 2010 Joel Martin
4 * Licensed under LGPL-3 (see LICENSE.LGPL-3)
6 * See README.md for usage and integration instructions.
9 /*global console, $, RFB, Canvas, VNC_uri_prefix, Element, Fx */
13 var pre
= (typeof VNC_uri_prefix
!== "undefined") ?
14 VNC_uri_prefix
: "include/";
15 document
.write("<script src='" + pre
+ "mootools.js'><\/script>");
19 var DefaultControls
= {
21 load: function(target
) {
24 /* Handle state updates */
25 RFB
.setUpdateState(DefaultControls
.updateState
);
26 RFB
.setClipboardReceive(DefaultControls
.clipReceive
);
28 /* Populate the 'target' DOM element with default controls */
29 if (!target
) { target
= 'vnc'; }
32 html
+= '<div id="VNC_controls">';
34 html
+= ' <li>Host: <input id="VNC_host"></li>';
35 html
+= ' <li>Port: <input id="VNC_port"></li>';
36 html
+= ' <li>Password: <input id="VNC_password"';
37 html
+= ' type="password"></li>';
38 html
+= ' <li>Encrypt: <input id="VNC_encrypt"';
39 html
+= ' type="checkbox"></li>';
40 html
+= ' <li>True Color: <input id="VNC_true_color"';
41 html
+= ' type="checkbox" checked></li>';
42 html
+= ' <li><input id="VNC_connect_button" type="button"';
43 html
+= ' value="Loading" disabled></li>';
46 html
+= '<div id="VNC_screen">';
47 html
+= ' <div id="VNC_status_bar" class="VNC_status_bar" style="margin-top: 0px;">';
48 html
+= ' <table border=0 width=100%><tr>';
49 html
+= ' <td><div id="VNC_status">Loading</div></td>';
50 html
+= ' <td width=10%><div id="VNC_buttons">';
51 html
+= ' <input type=button value="Send CtrlAltDel"';
52 html
+= ' id="sendCtrlAltDelButton"';
53 html
+= ' onclick="DefaultControls.sendCtrlAltDel();"></div></td>';
54 html
+= ' </tr></table>';
56 html
+= ' <canvas id="VNC_canvas" width="640px" height="20px">';
57 html
+= ' Canvas not supported.';
61 html
+= '<div id="VNC_clipboard">';
62 html
+= ' VNC Clipboard:';
63 html
+= ' <input id="VNC_clipboard_clear_button"';
64 html
+= ' type="button" value="Clear"';
65 html
+= ' onclick="DefaultControls.clipClear();">';
67 html
+= ' <textarea id="VNC_clipboard_text" cols=80 rows=5';
68 html
+= ' onfocus="DefaultControls.clipFocus();"';
69 html
+= ' onblur="DefaultControls.clipBlur();"';
70 html
+= ' onchange="DefaultControls.clipSend();"></textarea>';
72 $(target
).innerHTML
= html
;
74 /* Populate the controls if defaults are provided in the URL */
75 url
= document
.location
.href
;
76 $('VNC_host').value
= (url
.match(/host=([A-Za-z0-9.\-]*)/) ||
78 $('VNC_port').value
= (url
.match(/port=([0-9]*)/) ||
80 $('VNC_password').value
= (url
.match(/password=([^&#]*)/) ||
82 $('VNC_encrypt').checked
= (url
.match(/encrypt=([A-Za-z0-9]*)/) ||
85 $('VNC_screen').onmousemove = function () {
86 // Unfocus clipboard when over the VNC area
87 if (! Canvas
.focused
) {
88 $('VNC_clipboard_text').blur();
93 sendCtrlAltDel: function() {
97 updateState: function(state
, msg
) {
100 sb
= $('VNC_status_bar');
101 c
= $('VNC_connect_button');
102 cad
= $('sendCtrlAltDelButton');
107 klass
= "VNC_status_error";
110 c
.value
= "Disconnect";
111 c
.onclick
= DefaultControls
.disconnect
;
113 cad
.disabled
= false;
114 klass
= "VNC_status_normal";
118 c
.onclick
= DefaultControls
.connect
;
122 klass
= "VNC_status_normal";
127 klass
= "VNC_status_warn";
131 if (typeof(msg
) !== 'undefined') {
132 s
.setAttribute("class", klass
);
133 sb
.setAttribute("class", klass
);
139 connect: function() {
140 var host
, port
, password
, encrypt
, true_color
;
141 host
= $('VNC_host').value
;
142 port
= $('VNC_port').value
;
143 password
= $('VNC_password').value
;
144 encrypt
= $('VNC_encrypt').checked
;
145 true_color
= $('VNC_true_color').checked
;
146 if ((!host
) || (!port
)) {
147 throw("Must set host and port");
150 RFB
.connect(host
, port
, password
, encrypt
, true_color
);
153 disconnect: function() {
157 clipFocus: function() {
158 Canvas
.focused
= false;
161 clipBlur: function() {
162 Canvas
.focused
= true;
165 clipClear: function() {
166 $('VNC_clipboard_text').value
= "";
167 RFB
.clipboardPasteFrom("");
170 clipReceive: function(text
) {
171 console
.log(">> DefaultControls.clipReceive: " + text
.substr(0,40) + "...");
172 $('VNC_clipboard_text').value
= text
;
173 console
.log("<< DefaultControls.clipReceive");
176 clipSend: function() {
177 var text
= $('VNC_clipboard_text').value
;
178 console
.log(">> DefaultControls.clipSend: " + text
.substr(0,40) + "...");
179 RFB
.clipboardPasteFrom(text
);
180 console
.log("<< DefaultControls.clipSend");