This repository has been archived by the owner on Jul 5, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
connect.html
561 lines (517 loc) · 19.7 KB
/
connect.html
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
<!DOCTYPE html>
<html lang="en">
<head>
<!--
Copyright (c) 2013-2017 Antoine Martin <antoine@devloop.org.uk>
Copyright (c) 2014 Joshua Higgins <josh@kxes.net>
Licensed under MPL 2.0
-->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="css/signin.css" rel="stylesheet">
<title>Xpra HTML5 Client</title>
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
<link rel="icon" type="image/png" href="favicon.png">
<script type="text/javascript" src="js/lib/jquery.js"></script>
<script type="text/javascript" src="js/Utilities.js"></script>
<script type="text/javascript" src="js/MediaSourceUtil.js"></script>
<script type="text/javascript" src="js/lib/aurora/aurora.js"></script>
<!--
<script type="text/javascript" src="js/lib/aurora/mp3.js"></script>
<script type="text/javascript" src="js/lib/aurora/flac.js"></script>
<script type="text/javascript" src="js/lib/aurora/aac.js"></script>
-->
</head>
<body>
<div class="container">
<form class="form-signin" action="./index.html">
<img src="icons/xpra-logo.png" alt="xpra logo">
<h2 class="form-signin-heading">Xpra HTML5 Client</h2>
<div id="alert-disconnect" class="alert alert-info" role="alert" style="display:none;">
<p>You were disconnected for the following reason:</p>
<p><span id="disconnect-reason"></span></p>
</div>
<div class="form-group form-inline">
<label class="sr-only" for="server">Server</label>
<input title="Server" type="text" class="form-control" id="server" placeholder="Server" maxlength="256">
<label class="sr-only" for="port">Port</label>
<input title="Port" type="text" class="form-control" id="port" placeholder="Port" size="5" maxlength="5">
<br>
<label class="sr-only" for="username">Username</label>
<input title="Username" type="text" class="form-control" id="username" placeholder="Username" size="16" maxlength="256">
<label class="sr-only" for="password">Password</label>
<input title="Password" type="password" class="form-control" id="password" placeholder="Password" size="16" maxlength="256">
<br>
<div class="password-warning-box">
<input type="checkbox" id="insecure"> <span>Insecure plain-text passwords</span>
</div>
<div class="panel-group">
<ul class="list-style-none action">
<li><input type="radio" name="action" class="radiobox" value="connect" id="action_connect" checked="checked"> Connect</li>
<li><input type="radio" name="action" class="radiobox" value="start" id="action_start" checked="checked"> Start Command:
<input title="command" type="text" class="form-control command" id="start_command" placeholder="Command" size="16" maxlength="256">
</li>
<li><input type="radio" name="action" class="radiobox" value="start-desktop" id="action_start_desktop" checked="checked"> Start Desktop:
<input title="desktop command" type="text" class="form-control command" id="start_desktop_command" placeholder="Desktop Command" size="16" maxlength="256">
</li>
<li><input type="radio" name="action" class="radiobox" value="shadow" id="action_shadow" checked="checked"> Shadow</li>
</ul>
</div>
</div>
<div class="form-group">
<a class="btn btn-lg btn-success" role="button" onclick="doConnect();">Connect</a>
</div>
<div class="panel-group" role="tablist">
<div class="panel panel-default">
<div id="expandopts" class="panel-heading" role="tab">
<h4 class="panel-title">Advanced options</h4>
</div>
<div id="hiddenopts" class="panel-collapse collapse in" role="tabpanel" style="display:none;">
<ul class="list-group">
<li class="list-group-item">
<select id="encoding">
<option value="auto">Automatic</option>
<option value="jpeg">JPEG</option>
<option value="png">PNG</option>
<option value="rgb">Raw RGB</option>
</select>
Encoding
</li>
<li class="list-group-item">
<select id="keyboard_layout">
<option value="us">English USA</option>
<option value="gb">United Kingdom</option>
<option value="fr">France</option>
<option value="de">Germany</option>
<option value="ad">Andorra</option>
<option value="af">Afghanistan</option>
<option value="ara">Arabic</option>
<option value="al">Albania</option>
<option value="am">Armenia</option>
<option value="az">Azerbaijan</option>
<option value="by">Belarus</option>
<option value="be">Belgium</option>
<option value="bd">Bangladesh</option>
<option value="in">India</option>
<option value="ba">Bosnia</option>
<option value="br">Brazil</option>
<option value="bg">Bulgaria</option>
<option value="ma">Morocco</option>
<option value="mm">Myanmar</option>
<option value="ca">Canada</option>
<option value="cd">Congo,</option>
<option value="cn">China</option>
<option value="hr">Croatia</option>
<option value="cz">Czechia</option>
<option value="dk">Denmark</option>
<option value="nl">Netherlands</option>
<option value="bt">Bhutan</option>
<option value="ee">Estonia</option>
<option value="ir">Iran</option>
<option value="iq">Iraq</option>
<option value="fo">Faroe</option>
<option value="fi">Finland</option>
<option value="fr">France</option>
<option value="gh">Ghana</option>
<option value="gn">Guinea</option>
<option value="ge">Georgia</option>
<option value="gr">Greece</option>
<option value="hu">Hungary</option>
<option value="is">Iceland</option>
<option value="il">Israel</option>
<option value="it">Italy</option>
<option value="jp">Japan</option>
<option value="kg">Kyrgyzstan</option>
<option value="kh">Cambodia</option>
<option value="kz">Kazakhstan</option>
<option value="la">Laos</option>
<option value="latam">Latin</option>
<option value="lt">Lithuania</option>
<option value="lv">Latvia</option>
<option value="mao">Maori</option>
<option value="me">Montenegro</option>
<option value="mk">Macedonia</option>
<option value="mt">Malta</option>
<option value="mn">Mongolia</option>
<option value="no">Norway</option>
<option value="pl">Poland</option>
<option value="pt">Portugal</option>
<option value="ro">Romania</option>
<option value="ru">Russia</option>
<option value="rs">Serbia</option>
<option value="si">Slovenia</option>
<option value="sk">Slovakia</option>
<option value="es">Spain</option>
<option value="se">Sweden</option>
<option value="ch">Switzerland</option>
<option value="sy">Syria</option>
<option value="tj">Tajikistan</option>
<option value="lk">Sri</option>
<option value="th">Thailand</option>
<option value="tr">Turkey</option>
<option value="tw">Taiwan</option>
<option value="ua">Ukraine</option>
<option value="gb">United</option>
<option value="uz">Uzbekistan</option>
<option value="vn">Vietnam</option>
<option value="kr">Korea,</option>
<option value="jp">Japan</option>
<option value="ie">Ireland</option>
<option value="pk">Pakistan</option>
<option value="mv">Maldives</option>
<option value="za">South</option>
<option value="epo">Esperanto</option>
<option value="np">Nepal</option>
<option value="ng">Nigeria</option>
<option value="et">Ethiopia</option>
<option value="sn">Senegal</option>
<option value="brai">Braille</option>
<option value="tm">Turkmenistan</option>
<option value="ml">Mali</option>
<option value="tz">Tanzania</option>
</select>
Keyboard Layout
</li>
<li class="list-group-item clipboard">
<input type="checkbox" id="clipboard"> <span>Clipboard sharing</span>
</li>
<li class="list-group-item printing">
<input type="checkbox" id="printing"> <span>Printing</span>
</li>
<li class="list-group-item file_transfer">
<input type="checkbox" id="file_transfer"> <span>File transfers</span>
</li>
<li class="list-group-item sound">
<input type="checkbox" id="sound"> <span>Audio forwarding, codec: </span>
<select id="audio_codec">
</select>
<input type="hidden" id="ignore_audio_blacklist" value="" />
</li>
<li class="list-group-item exit_with_children">
<input type="checkbox" id="exit_with_children"> <span>Terminate server when command exits</span>
</li>
<li class="list-group-item exit_with_client">
<input type="checkbox" id="exit_with_client"> <span>Terminate server when client disconnects</span>
</li>
<li class="list-group-item">
<input type="checkbox" id="sharing"> <span>Share session</span>
</li>
<li class="list-group-item">
<input type="checkbox" id="steal"> <span>Steal session from existing client</span>
</li>
<li class="list-group-item">
<input type="checkbox" id="reconnect"> <span>Re-connect automatically to the session</span>
</li>
<li class="list-group-item">
<input type="checkbox" id="swap_keys"> <span>Swap command and control key</span>
</li>
<li class="list-group-item">
<input type="checkbox" id="video"> <span>Video (experimental) <input type="checkbox" id="mediasource_video"> Native decoding</span>
</li>
<li class="list-group-item">
<input type="checkbox" id="debug"> <span>Debugging</span>
</li>
</ul>
</div>
</div>
</div>
</form>
</div> <!-- /container -->
<script type="text/javascript">
/**
* Adds window.location.getParameter to those browsers that don't have it:
*
* See:
* http://stackoverflow.com/a/8812157/428751
*/
if (!window.location.getParameter ) {
window.location.getParameter = function(key) {
function parseParams() {
var params = {},
e,
a = /\+/g, // Regex for replacing addition symbol with a space
r = /([^&=]+)=?([^&]*)/g,
d = function (s) { return decodeURIComponent(s.replace(a, " ")); },
q = window.location.search.substring(1);
while (e = r.exec(q))
params[d(e[1])] = d(e[2]);
return params;
}
if (!this.queryStringParams)
this.queryStringParams = parseParams();
return this.queryStringParams[key];
};
}
function getparam(prop) {
var value = window.location.getParameter(prop);
if (value === undefined && typeof(Storage) !== undefined) {
value = sessionStorage.getItem(prop);
}
return value;
}
function getboolparam(prop, default_value) {
var v = getparam(prop);
if(v===null) {
return default_value;
}
return ["true", "on", "1"].indexOf(String(v).toLowerCase())>=0;
}
function encodeData(s) {
return encodeURIComponent(s);
}
function doConnect() {
// url to client
var url = "/index.html";
function add_prop(prop, value) {
if (typeof(Storage) !== "undefined") {
if (value===null || value==="undefined") {
sessionStorage.removeItem(prop);
}
else {
sessionStorage.setItem(prop, value);
}
} else {
if (value===null || value==="undefined") {
value = "";
}
url = url + "&"+prop+"="+encodeData(""+value);
}
}
add_prop("submit", true);
var val_props = ["server", "port", "username", "password", "encoding", "keyboard_layout", "audio_codec"];
for (var i = 0; i < val_props.length; i++) {
var prop = val_props[i];
var value = document.getElementById(prop).value;
if (value.length>0) {
add_prop(prop, value);
}
}
var start = null;
if (document.getElementById("action_connect").checked) {
add_prop("action", "connect");
}
else if (document.getElementById("action_start").checked) {
add_prop("action", "start");
start = document.getElementById("start_command").value;
}
else if (document.getElementById("action_start_desktop").checked) {
add_prop("action", "start-desktop");
start = document.getElementById("start_desktop_command").value;
}
else if (document.getElementById("action_shadow").checked) {
add_prop("action", "shadow");
}
if(start) {
add_prop("start", start);
}
var bool_props = ["clipboard", "printing", "file_transfer",
"sound", "ignore_audio_blacklist",
"exit_with_children", "exit_with_client",
"sharing", "steal", "reconnect", "swap_keys",
"video", "mediasource_video",
"debug", "insecure"];
for (var i = 0; i < bool_props.length; i++) {
var prop = bool_props[i];
add_prop(prop, document.getElementById(prop).checked);
}
window.location = url;
}
$(document).ready(function() {
var ssl = document.location.protocol=="https:";
var disconnect_reason = getparam("disconnect") || null;
if(disconnect_reason) {
document.getElementById("alert-disconnect").style.display = "block";
document.getElementById("disconnect-reason").innerHTML = disconnect_reason;
}
//Populate the form:
var url = window.location.href;
var link = document.createElement('a');
link.setAttribute('href', url);
document.getElementById("server").value = getparam("server") || link.hostname;
document.getElementById("port").value = getparam("port") || link.port;
document.getElementById("username").value = getparam("username") || "";
if (getboolparam("insecure", false)) {
document.getElementById("password").value = getparam("password") || "";
}
if(ssl) {
$('div.password-warning-box').hide();
}
else {
$('input#password').prop("disabled", true);
var insecure_input = document.getElementById("insecure");
insecure_input.onchange = function() {
$('input#password').prop("disabled", !insecure_input.checked && typeof(Storage)==="undefined");
};
}
var action = getparam("action") || "";
if(action=="shadow") {
document.getElementById("action_shadow").checked = true;
}
else if(action=="start-desktop") {
document.getElementById("action_start_desktop").checked = true;
}
else if(action=="start") {
document.getElementById("action_start").checked = true;
}
else {
document.getElementById("action_connect").checked = true;
}
function set_exit_actions(disabled) {
var opacity = disabled ? 0.6 : 1;
$('input#exit_with_children').prop("disabled", disabled);
$('input#exit_with_client').prop("disabled", disabled);
$('li.exit_with_children span').css("opacity", opacity);
$('li.exit_with_client span').css("opacity", opacity);
if (disabled) {
$('input#exit_with_children').prop("checked", false);
$('input#exit_with_client').prop("checked", false);
}
}
$(document).on('click', '[name="action"]', function() {
var action = $(this).val();
set_exit_actions(action=="connect");
});
set_exit_actions(action=="connect" || action=="")
$('input:radio[value="'+action+'"]').click();
var encoding = getparam("encoding") || "auto";
document.getElementById('encoding').value = encoding;
var keyboard_layout = Utilities.getKeyboardLayout();
document.getElementById('keyboard_layout').value = keyboard_layout;
try {
var req = new XMLHttpRequest()
req.open('GET', "/favicon.png?echo-headers", true);
req.onload = function (e) {
if (req.readyState === 4) {
if (req.status === 200) {
var headers = Utilities.ParseResponseHeaders(req.getAllResponseHeaders());
console.debug("headers:", headers);
var lang = headers["Echo-Accept-Language"];
//ie: lang = "en-gb,en-us;q=0.8,en;q=0.6"
if (lang) {
//just the first option:
console.debug("accept-language:", lang);
lang = lang.split(",")[0]; //ie: lang="en-gb"
console.debug("first language:", lang);
var locale = lang.split("-")[1];
if (locale) {
locale = locale.toLowerCase();
console.debug("request locale:", locale);
if (locale!=keyboard_layout) {
keyboard_layout = locale;
document.getElementById('keyboard_layout').value = keyboard_layout;
}
}
}
//
} else {
console.error(req.statusText);
}
}
};
req.send(null);
}
catch (e) {
console.warn("Warning: failed to get HTTP header probe:", e);
}
var audio_codec = getparam("audio_codec") || "";
var audio_codec_select = document.getElementById("audio_codec");
var ignore_audio_blacklist = getparam("ignore_audio_blacklist");
if(ignore_audio_blacklist) {
$('input#ignore_audio_blacklist').prop("value", true);
}
var codecs_supported = [];
if(getboolparam("mediasource", true)) {
mediasource_codecs = MediaSourceUtil.getMediaSourceAudioCodecs(ignore_audio_blacklist);
for (var codec_option in mediasource_codecs) {
codecs_supported["mediasource:"+codec_option] = MediaSourceConstants.CODEC_DESCRIPTION[codec_option];
}
}
if(getboolparam("aurora", true)) {
var aurora_codecs = MediaSourceUtil.getAuroraAudioCodecs();
for (var codec_option in aurora_codecs) {
if(codec_option in codecs_supported) {
//we already have native MediaSource support!
continue;
}
codecs_supported["aurora:"+codec_option] = "legacy: "+MediaSourceConstants.CODEC_DESCRIPTION[codec_option];
}
}
if(getboolparam("http-stream", true)) {
var stream_codecs = ["mp3"];
for (var i in stream_codecs) {
var codec_option = stream_codecs[i];
console.log("stream codecs=", stream_codecs, "codec=", codec_option);
codecs_supported["http-stream:"+codec_option] = "http stream: "+MediaSourceConstants.CODEC_DESCRIPTION[codec_option];
}
}
var best_codec = audio_codec;
if(!best_codec) {
var best_distance = MediaSourceConstants.PREFERRED_CODEC_ORDER.length;
for (var codec_option in codecs_supported) {
var cs = codec_option.split(":")[1];
var distance = MediaSourceConstants.PREFERRED_CODEC_ORDER.indexOf(cs);
if(distance>=0 && distance<best_distance) {
best_codec = codec_option;
best_distance = distance;
}
}
}
for (var codec_option in codecs_supported) {
var option = document.createElement("option");
option.value = codec_option;
var description = MediaSourceConstants.CODEC_DESCRIPTION[codec_option] || codecs_supported[codec_option];
option.textContent = description;
option.selected = (codec_option==best_codec);
audio_codec_select.add(option);
}
if(!codecs_supported) {
$('input#sound').prop("disabled", true);
}
else {
//enable sound checkbox if the codec is changed:
audio_codec_select.onchange = function() {
document.getElementById("sound").checked = true;
};
}
var sound = getboolparam("sound");
$('input#sound').prop("checked", sound && codecs_supported.length>0);
var video = document.getElementById("video");
function toggle_mediasource_video() {
$('#mediasource_video').prop("disabled", !video.checked);
}
video.onchange = toggle_mediasource_video;
toggle_mediasource_video();
var bool_props = ["clipboard", "printing", "file_transfer",
"exit_with_children", "exit_with_client",
"sharing", "steal", "reconnect", "swap_keys",
"video", "mediasource_video",
"debug", "insecure"];
var default_on = ["steal", "clipboard", "printing", "file_transfer", "reconnect", "exit_with_children", "exit_with_client"];
if (Utilities.isMacOS()) {
default_on.push("swap_keys");
}
for (var i = 0; i < bool_props.length; i++) {
var prop = bool_props[i];
var def = default_on.indexOf(prop)>=0;
document.getElementById(prop).checked = getboolparam(prop, def);
}
$('input#password').prop("disabled", !insecure_input.checked && typeof(Storage)==="undefined");
$("#expandopts").click(function() {
$("#hiddenopts").slideToggle();
});
//delete session params:
try {
sessionStorage.clear();
}
catch (e) {
//ignore
}
});
</script>
</body>
</html>