Skip to content

Commit

Permalink
missed from r14412 (again, subclipse messed it up)
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@14413 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Nov 14, 2016
1 parent f673ae8 commit c8a7ed1
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 34 deletions.
104 changes: 74 additions & 30 deletions src/html5/connect.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
<link rel="icon" type="image/png" href="favicon.png">

<script type="text/javascript" src="js/lib/jquery.min.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>
</head>

<body>
Expand Down Expand Up @@ -52,10 +56,10 @@ <h2 class="form-signin-heading">Xpra HTML5 Client</h2>
<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" id="start_command" placeholder="Command" size="16" maxlength="256">
<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" id="start_desktop_command" placeholder="Desktop Command" size="16" maxlength="256">
<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>
Expand Down Expand Up @@ -181,7 +185,9 @@ <h4 class="panel-title">Advanced options</h4>
</li>

<li class="list-group-item sound">
<input type="checkbox" id="sound"> <span>Experimental sound support</span>
<input type="checkbox" id="sound"> <span>Audio forwarding, codec: </span>
<select id="audio_codec">
</select>
</li>
<li class="list-group-item exit_with_children">
<input type="checkbox" id="exit_with_children"> <span>Terminate server when command exits</span>
Expand Down Expand Up @@ -242,6 +248,17 @@ <h4 class="panel-title">Advanced options</h4>
};
}

function getparam(name) {
return window.location.getParameter(name);
}
function getboolparam(name, default_value) {
var v = window.location.getParameter(name);
if(v==null) {
return default_value;
}
return ["true", "on", "1"].indexOf(String(v).toLowerCase())>=0;
}

function encodeData(s) {
return encodeURIComponent(s);
}
Expand All @@ -260,6 +277,13 @@ <h4 class="panel-title">Advanced options</h4>
if (password.length>0)
url += "&password="+encodeData(password);

var sound = document.getElementById("sound").checked;
if(sound) {
var audio_codec = document.getElementById("audio_codec");
if(audio_codec) {
url = url + "&audio_codec="+encodeData(audio_codec.value);
}
}
var start = null;
if (document.getElementById("action_connect").checked) {
//default action
Expand Down Expand Up @@ -307,7 +331,7 @@ <h4 class="panel-title">Advanced options</h4>
var username = window.location.getParameter("username") || "";
document.getElementById("username").value = username;

var action = window.location.getParameter("action") || "";
var action = getparam("action") || "";
if(action=="shadow") {
document.getElementById("action_shadow").checked = true;
}
Expand Down Expand Up @@ -336,46 +360,66 @@ <h4 class="panel-title">Advanced options</h4>
set_exit_actions(action=="connect");
}
$(document).on('click', '[name="action"]', on_action_change);
var action = window.location.getParameter("action") || "connect";
$('input:radio[value='+action+']').click();

var encoding = window.location.getParameter("encoding") || "jpeg";
var encoding = getparam("encoding") || "jpeg";
document.getElementById('encoding').value = encoding;

var keyboard_layout = window.location.getParameter("keyboard_layout");
if (!keyboard_layout) {
//IE:
//navigator.systemLanguage
//navigator.browserLanguage
var v = window.navigator.userLanguage || window.navigator.language;
var keyboard_layout = "";
//ie: v="en_GB";
v = v.split(",")[0];
var l = v.split("-", 2);
if (l.length==1)
l = v.split("_", 2);
if (l.length==1)
//ie: "en"
keyboard_layout = l[0];
else
keyboard_layout = l[1].toLowerCase();
}
var keyboard_layout = Utilities.getKeyboardLayout();
document.getElementById('keyboard_layout').value = keyboard_layout;

var exit_with_children = window.location.getParameter("exit_with_children") || "";
if(exit_with_children=="true") {
var exit_with_children = getboolparam("exit_with_children");
if(exit_with_children) {
$('input#exit_with_children').prop("checked", exit_with_children);
}
var exit_with_client = window.location.getParameter("exit_with_client") || "";
if(exit_with_client=="true") {
var exit_with_client = getparam("exit_with_client");
if(exit_with_client) {
$('input#exit_with_client').prop("checked", exit_with_client);
}

var audio_codec = getparam("audio_codec") || "";
var audio_codec_select = document.getElementById("audio_codec");
var codecs_supported = [];
if(getboolparam("mediasource", true)) {
mediasource_codecs = MediaSourceUtil.getMediaSourceAudioCodecs();
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: "+aurora_codecs[codec_option];
}
}
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 = (audio_codec==codec_option);
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 bool_props = ["exit_with_children", "exit_with_client", "sharing", "normal_fullscreen", "debug", "insecure"];
for (var i = 0; i < bool_props.length; i++) {
var prop = bool_props[i];
var value = window.location.getParameter(prop);
document.getElementById(prop).checked = value;
document.getElementById(prop).checked = getparam(prop);
}

$("#expandopts").click(function() {
Expand Down
11 changes: 9 additions & 2 deletions src/html5/css/signin.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,25 @@ body {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
padding: 10px;
font-size: 16px;
}
.form-signin .form-control.command {
margin-left: 1.6em;
}
.form-signin .form-control:focus {
z-index: 2;
}
.form-signin .panel-group {
padding-top:8px;
}

.form-signin .list-group-item {
padding: 6px 10px;
}

.form-signin .list-style-none {
list-style-type:none;
list-style-type: none;
margin-bottom: 5px;
}
.form-signin .action input {
font-size: 12px;
Expand Down
22 changes: 20 additions & 2 deletions src/html5/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<script type="text/javascript" src="js/Window.js"></script>
<script type="text/javascript" src="js/Notifications.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/Client.js"></script>
</head>

Expand Down Expand Up @@ -85,6 +86,13 @@
function getparam(name) {
return window.location.getParameter(name);
}
function getboolparam(name, default_value) {
var v = window.location.getParameter(name);
if(v==null) {
return default_value;
}
return ["true", "on", "1"].indexOf(String(v).toLowerCase())>=0;
}

function encodeData(s) {
return encodeURIComponent(s);
Expand All @@ -96,6 +104,7 @@
var username = getparam("username") || null;
var password = getparam("password") || null;
var sound = getparam("sound") || null;
var audio_codec = getparam("audio_codec") || null;
var encoding = getparam("encoding") || null;
var action = getparam("action") || "connect";
var submit = getparam("submit") || null;
Expand All @@ -109,8 +118,8 @@
var exit_with_client = getparam("exit_with_client") || "";
var sharing = getparam("sharing") || "";
var normal_fullscreen = getparam("normal_fullscreen") || null;
var debug = getparam("debug") || false;
var insecure = getparam("insecure") || null;
var debug = getboolparam("debug");
var insecure = getboolparam("insecure");

// create the client
var client = new XpraClient('screen');
Expand Down Expand Up @@ -149,6 +158,14 @@
// experimental sound support
if(sound) {
client.audio_enabled = true;
console.log("sound enabled, audio codec string: "+audio_codec);
if(audio_codec && audio_codec.indexOf(":")>0) {
var acparts = audio_codec.split(":");
client.audio_framework = acparts[0];
client.audio_codec = acparts[1];
}
client.audio_mediasource_enabled = getboolparam("mediasource", true);
client.audio_aurora_enabled = getboolparam("aurora", true);
}

// insecure passwords
Expand Down Expand Up @@ -213,6 +230,7 @@
}
}
}
client.init();

// and connect
client.connect(server, port, false);
Expand Down

0 comments on commit c8a7ed1

Please sign in to comment.