1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2024-12-24 23:25:24 +00:00

console layout rearranged. fix indentation. add translate tags

This commit is contained in:
catborise 2020-01-23 15:45:41 +03:00
parent d95b5a4017
commit 34394c2b5e
3 changed files with 350 additions and 376 deletions

View file

@ -53,6 +53,7 @@
</head> </head>
<body> <body>
<div id='main_container' class="container">
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation"> <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container"> <div class="container">
<div class="navbar-header"> <div class="navbar-header">
@ -90,7 +91,7 @@
</div> </div>
</div> </div>
</nav> </nav>
<div id='main_container' class="container">
{% block content %}{% endblock %} {% block content %}{% endblock %}
</div> </div>
<script src="{% static "js/jquery.js" %}"></script> <script src="{% static "js/jquery.js" %}"></script>

View file

@ -26,7 +26,6 @@
{% load i18n %} {% load i18n %}
{% load staticfiles %} {% load staticfiles %}
{% block head %} {% block head %}
<title>WebVirtCloud - Spice Client - Full</title> <title>WebVirtCloud - Spice Client - Full</title>
<script src="{% static "js/spice-html5/spicearraybuffer.js" %}"></script> <script src="{% static "js/spice-html5/spicearraybuffer.js" %}"></script>
<script src="{% static "js/spice-html5/enums.js" %}"></script> <script src="{% static "js/spice-html5/enums.js" %}"></script>
@ -58,29 +57,28 @@
<script src="{% static "js/spice-html5/resize.js" %}"></script> <script src="{% static "js/spice-html5/resize.js" %}"></script>
<script src="{% static "js/spice-html5/filexfer.js" %}"></script> <script src="{% static "js/spice-html5/filexfer.js" %}"></script>
<link rel="stylesheet" type="text/css" href="{% static "js/spice-html5/spice.css" %}" /> <link rel="stylesheet" type="text/css" href="{% static "js/spice-html5/spice.css" %}" />
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<div id="login" hidden> <div id="login" hidden>
<span class="logo">SPICE</span> <span class="logo">SPICE</span>
<label for="host">Host:</label> <input type='text' id='host' value='{{ ws_host }}'> <!-- localhost --> <label for="host">{% trans 'Host' %}:</label> <input type='text' id='host' value='{{ ws_host }}'> <!-- localhost -->
<label for="port">Port:</label> <input type='text' id='port' value='{{ ws_port }}'> <label for="port">{% trans 'Port' %}:</label> <input type='text' id='port' value='{{ ws_port }}'>
<label for="password">Password:</label> <input type='password' id='password' value='{{ console_passwd }}'> <label for="password">{% trans 'Password' %}:</label> <input type='password' id='password' value='{{ console_passwd }}'>
<label for="show_console">Show console </label><input type="checkbox" id="show_console" value="1" onchange="toggle_console()" checked> <label for="show_console">{% trans 'Show console' %}</label><input type="checkbox" id="show_console" value="1" onchange="toggle_console()" checked>
<button id="connectButton" onclick="connect();">Start</button> <button id="connectButton" onclick="connect();">{% trans 'Start' %}</button>
</div> </div>
<div id="spice-area"> <div id="spice-area">
<div id="spice-screen" class="spice-screen"></div> <div id="spice-screen" class="spice-screen"></div>
</div>
<div id="message-div" class="spice-message"></div> <div id="message-div" class="spice-message"></div>
</div>
<div id="debug-div"> <div id="debug-div">
<!-- If DUMPXXX is turned on, dumped images will go here --> <!-- If DUMPXXX is turned on, dumped images will go here -->
</div> </div>
{% endblock %} {% endblock %}
{% block foot %} {% block foot %}
@ -89,13 +87,11 @@
var host = null, port = null; var host = null, port = null;
var sc; var sc;
function spice_error(e) function spice_error(e) {
{
disconnect(); disconnect();
} }
function connect() function connect() {
{
var host, port, password, scheme = "ws://", uri; var host, port, password, scheme = "ws://", uri;
host = document.getElementById("host").value; host = document.getElementById("host").value;
@ -105,7 +101,6 @@
} }
password = document.getElementById("password").value; password = document.getElementById("password").value;
if ((!host) || (!port)) { if ((!host) || (!port)) {
console.log("must set host and port"); console.log("must set host and port");
return; return;
@ -120,8 +115,7 @@
document.getElementById('connectButton').innerHTML = "Stop"; document.getElementById('connectButton').innerHTML = "Stop";
document.getElementById('connectButton').onclick = disconnect; document.getElementById('connectButton').onclick = disconnect;
try try {
{
sc = new SpiceMainConn({uri: uri, screen_id: "spice-screen", dump_id: "debug-div", sc = new SpiceMainConn({uri: uri, screen_id: "spice-screen", dump_id: "debug-div",
message_id: "message-div", password: password, onerror: spice_error, onagent: agent_connected }); message_id: "message-div", password: password, onerror: spice_error, onagent: agent_connected });
} }
@ -130,20 +124,16 @@
alert(e.toString()); alert(e.toString());
disconnect(); disconnect();
} }
} }
function disconnect() function disconnect() {
{
console.log(">> disconnect"); console.log(">> disconnect");
if (sc) { if (sc) {
sc.stop(); sc.stop();
} }
document.getElementById('connectButton').innerHTML = "Start"; document.getElementById('connectButton').innerHTML = "Start";
document.getElementById('connectButton').onclick = connect; document.getElementById('connectButton').onclick = connect;
if (window.File && window.FileReader && window.FileList && window.Blob) if (window.File && window.FileReader && window.FileList && window.Blob) {
{
var spice_xfer_area = document.getElementById('spice-xfer-area'); var spice_xfer_area = document.getElementById('spice-xfer-area');
document.getElementById('spice-area').removeChild(spice_xfer_area); document.getElementById('spice-area').removeChild(spice_xfer_area);
document.getElementById('spice-area').removeEventListener('dragover', handle_file_dragover, false); document.getElementById('spice-area').removeEventListener('dragover', handle_file_dragover, false);
@ -152,38 +142,32 @@
console.log("<< disconnect"); console.log("<< disconnect");
} }
function agent_connected(sc) function agent_connected(sc) {
{
window.addEventListener('resize', handle_resize); window.addEventListener('resize', handle_resize);
window.spice_connection = this; window.spice_connection = this;
resize_helper(this); resize_helper(this);
if (window.File && window.FileReader && window.FileList && window.Blob) if (window.File && window.FileReader && window.FileList && window.Blob) {
{
var spice_xfer_area = document.createElement("div"); var spice_xfer_area = document.createElement("div");
spice_xfer_area.setAttribute('id', 'spice-xfer-area'); spice_xfer_area.setAttribute('id', 'spice-xfer-area');
document.getElementById('spice-area').appendChild(spice_xfer_area); document.getElementById('spice-area').appendChild(spice_xfer_area);
document.getElementById('spice-area').addEventListener('dragover', handle_file_dragover, false); document.getElementById('spice-area').addEventListener('dragover', handle_file_dragover, false);
document.getElementById('spice-area').addEventListener('drop', handle_file_drop, false); document.getElementById('spice-area').addEventListener('drop', handle_file_drop, false);
} }
else else {
{
console.log("File API is not supported"); console.log("File API is not supported");
} }
} }
function toggle_console() function toggle_console() {
{
var checkbox = document.getElementById('show_console'); var checkbox = document.getElementById('show_console');
var m = document.getElementById('message-div'); var m = document.getElementById('message-div');
if (checkbox.checked) if (checkbox.checked) {
{
m.style.display = 'block'; m.style.display = 'block';
} }
else else {
{
m.style.display = 'none'; m.style.display = 'none';
} }

View file

@ -62,13 +62,11 @@
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<div id="spice-area"> <div id="spice-area">
<div id="spice-screen" class="spice-screen"></div> <div id="spice-screen" class="spice-screen"></div>
</div>
<div id="message-div" class="spice-message"></div> <div id="message-div" class="spice-message"></div>
</div>
<div id="debug-div"> <div id="debug-div">
<!-- If DUMPXXX is turned on, dumped images will go here --> <!-- If DUMPXXX is turned on, dumped images will go here -->
@ -93,8 +91,7 @@
return match ? decodeURIComponent(match[1].replace(/\+/g, ' ')) : defvalue; return match ? decodeURIComponent(match[1].replace(/\+/g, ' ')) : defvalue;
} }
function spice_error(e) function spice_error(e) {
{
console.log(e); console.log(e);
disconnect(); disconnect();
if (e.message !== undefined) { if (e.message !== undefined) {
@ -105,8 +102,7 @@
} }
} }
function connect() function connect() {
{
var host, port, password, scheme = "ws://", uri; var host, port, password, scheme = "ws://", uri;
console.log('>> connect'); console.log('>> connect');
// By default, use the host and port of server that served this file // By default, use the host and port of server that served this file
@ -159,17 +155,14 @@
uri += path[0] == '/' ? path : ('/' + path); uri += path[0] == '/' ? path : ('/' + path);
} }
try try {
{
sc = new SpiceMainConn({uri: uri, screen_id: "spice-screen", dump_id: "debug-div", sc = new SpiceMainConn({uri: uri, screen_id: "spice-screen", dump_id: "debug-div",
message_id: "message-div", password: password, onerror: spice_error, onagent: agent_connected }); message_id: "message-div", password: password, onerror: spice_error, onagent: agent_connected });
} }
catch (e) catch (e) {
{
alert(e.toString()); alert(e.toString());
disconnect(); disconnect();
} }
console.log('<< connect') console.log('<< connect')
} }
@ -179,8 +172,7 @@
if (sc) { if (sc) {
sc.stop(); sc.stop();
} }
if (window.File && window.FileReader && window.FileList && window.Blob) if (window.File && window.FileReader && window.FileList && window.Blob) {
{
var spice_xfer_area = document.getElementById('spice-xfer-area'); var spice_xfer_area = document.getElementById('spice-xfer-area');
document.getElementById('spice-area').removeChild(spice_xfer_area); document.getElementById('spice-area').removeChild(spice_xfer_area);
document.getElementById('spice-area').removeEventListener('dragover', handle_file_dragover, false); document.getElementById('spice-area').removeEventListener('dragover', handle_file_dragover, false);
@ -189,23 +181,20 @@
console.log("<< disconnect"); console.log("<< disconnect");
} }
function agent_connected(sc) function agent_connected(sc) {
{
window.addEventListener('resize', handle_resize); window.addEventListener('resize', handle_resize);
window.spice_connection = this; window.spice_connection = this;
resize_helper(this); resize_helper(this);
if (window.File && window.FileReader && window.FileList && window.Blob) if (window.File && window.FileReader && window.FileList && window.Blob) {
{
var spice_xfer_area = document.createElement("div"); var spice_xfer_area = document.createElement("div");
spice_xfer_area.setAttribute('id', 'spice-xfer-area'); spice_xfer_area.setAttribute('id', 'spice-xfer-area');
document.getElementById('spice-area').appendChild(spice_xfer_area); document.getElementById('spice-area').appendChild(spice_xfer_area);
document.getElementById('spice-area').addEventListener('dragover', handle_file_dragover, false); document.getElementById('spice-area').addEventListener('dragover', handle_file_dragover, false);
document.getElementById('spice-area').addEventListener('drop', handle_file_drop, false); document.getElementById('spice-area').addEventListener('drop', handle_file_drop, false);
} }
else else {
{
console.log("File API is not supported"); console.log("File API is not supported");
} }
} }