1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2024-11-01 20:14:15 +00:00
webvirtcloud/console/templates/console-vnc.html

204 lines
6.9 KiB
HTML
Raw Normal View History

{% extends "console-base.html" %}
2015-02-27 12:25:41 +00:00
{% load i18n %}
{% load staticfiles %}
{% block head %}
<script src="{% static "js/novnc/util.js" %}"></script>
{% endblock %}
{% block navbarmenu %}
<!-- dirty fix for keyboard on iOS devices -->
2018-08-08 08:24:59 +00:00
<li id="showKeyboard"><a href='#'>{% trans "Show Keyboard" %}</a></li>
{% endblock %}
{% block content %}
<div id='noVNC_area'>
2015-02-27 12:25:41 +00:00
<canvas id="noVNC_canvas" width="640px" height="20px">
{% trans "Canvas not supported." %}
</canvas>
</div>
<!-- Note that Google Chrome on Android doesn't respect any of these,
html attributes which attempt to disable text suggestions on the
on-screen keyboard. Let's hope Chrome implements the ime-mode
style for example -->
<!-- TODO: check if this is needed on iOS -->
<textarea id="keyboardinput" autocapitalize="off"
autocorrect="off" autocomplete="off" spellcheck="false"
mozactionhint="Enter" onsubmit="return false;"
style="display: none;">
</textarea>
{% endblock %}
{% block foot %}
2015-02-27 12:25:41 +00:00
<script>
/*jslint white: false */
/*global window, $, Util, RFB, */
"use strict";
// dirty fix for keyboard on iOS devices
var keyboardVisible = false;
var isTouchDevice = false;
isTouchDevice = 'ontouchstart' in document.documentElement;
// Load supporting scripts
Util.load_scripts(["webutil.js", "base64.js", "websock.js", "des.js",
"input.js", "display.js", "jsunzip.js", "rfb.js"]);
var rfb;
function passwordRequired(rfb) {
var modal;
modal = '<div class="modal fade">';
modal += ' <div class="modal-dialog">';
modal += ' <div class="modal-content">';
modal += ' <div class="modal-header">';
modal += ' <h4 class="modal-title">{% trans "Password required" %}</h4>';
modal += ' </div>';
modal += ' <div class="modal-body">';
modal += ' <form id="password_form" onsubmit="return setPassword();">';
modal += ' <div class="form-group">';
modal += ' <label for="password_input">Password</label>';
modal += ' <input type="password" class="form-control" id="password_input" placeholder="Password"/>';
modal += ' </div>';
modal += ' </form>';
modal += ' </div>';
modal += ' <div class="modal-footer">';
modal += ' <button type="button" class="btn btn-primary" data-dismiss="modal" onclick="return setPassword();">{% trans "OK" %}</button>';
modal += ' </div>';
modal += ' </div>';
modal += ' </div>';
modal += '</div>';
$('body').append(modal);
$('div.modal').modal();
2015-02-27 12:25:41 +00:00
}
function setPassword() {
rfb.sendPassword($('#password_input').val());
2015-02-27 12:25:41 +00:00
return false;
}
function sendCtrlAltDel() {
rfb.sendCtrlAltDel();
return false;
}
function sendCtrlAltFN(f) {
var keys_code=[0xFFBE,0xFFBF,0xFFC0,0xFFC1,0xFFC2,0xFFC3,0xFFC4,0xFFC5,0xFFC6,0xFFC7,0xFFC8,0xFFC9];
if (keys_code[f]==undefined) {
return;
}
rfb.sendKey(0xFFE3, 'down');
rfb.sendKey(0xFFE9, 'down');
rfb.sendKey(keys_code[f], 'down');
rfb.sendKey(keys_code[f], 'up');
rfb.sendKey(0xFFE9, 'up');
rfb.sendKey(0xFFE3, 'up');
};
2015-02-27 12:25:41 +00:00
// dirty fix for keyboard on iOS devices
function showKeyboard() {
var kbi, skb, l;
kbi = $D('keyboardinput');
skb = $D('showKeyboard');
l = kbi.value.length;
if (keyboardVisible === false) {
kbi.focus();
try {
kbi.setSelectionRange(l, l);
} // Move the caret to the end
catch (err) {
} // setSelectionRange is undefined in Google Chrome
keyboardVisible = true;
//skb.className = "noVNC_status_button_selected";
} else if (keyboardVisible === true) {
kbi.blur();
//skb.className = "noVNC_status_button";
keyboardVisible = false;
}
}
function updateState(rfb, state, oldstate, msg) {
2015-04-29 05:41:37 +00:00
var s, sb, cad, af, level;
2015-02-27 12:25:41 +00:00
cad = $D('sendCtrlAltDelButton');
2015-04-29 05:41:37 +00:00
af = $D('askFullscreen');
2015-02-27 12:25:41 +00:00
switch (state) {
case 'failed':
level = "danger";
2015-02-27 12:25:41 +00:00
break;
case 'fatal':
level = "danger";
2015-02-27 12:25:41 +00:00
break;
case 'normal':
level = "info";
2015-02-27 12:25:41 +00:00
break;
case 'disconnected':
level = "info";
2015-02-27 12:25:41 +00:00
break;
case 'loaded':
level = "info";
2015-02-27 12:25:41 +00:00
break;
default:
level = "warning";
2015-02-27 12:25:41 +00:00
break;
}
if (typeof(msg) !== 'undefined') {
log_message(msg,level);
2015-02-27 12:25:41 +00:00
}
}
2015-04-29 05:41:37 +00:00
function fullscreen() {
var screen=document.getElementById('main_container');
2015-04-29 05:41:37 +00:00
if(screen.requestFullscreen) {
screen.requestFullscreen();
} else if(screen.mozRequestFullScreen) {
screen.mozRequestFullScreen();
} else if(screen.webkitRequestFullscreen) {
screen.webkitRequestFullscreen();
} else if(screen.msRequestFullscreen) {
screen.msRequestFullscreen();
}
}
2015-02-27 12:25:41 +00:00
window.onscriptsload = function () {
var host, port, password, path, token;
// dirty fix for keyboard on iOS devices
if (isTouchDevice) {
$D('showKeyboard').onclick = showKeyboard;
// Remove the address bar
setTimeout(function () {
window.scrollTo(0, 1);
}, 100);
} else {
$D('showKeyboard').style.display = "none";
}
WebUtil.init_logging(WebUtil.getQueryVar('logging', 'warn'));
document.title = unescape(WebUtil.getQueryVar('title', 'noVNC'));
// By default, use the host and port of server that served this file
host = '{{ ws_host }}';
port = '{{ ws_port }}';
password = '{{ console_passwd }}';
if ((!host) || (!port)) {
updateState('failed',
"Must specify host and port in URL");
return;
}
rfb = new RFB({'target': document.getElementById('noVNC_canvas'),
2015-02-27 12:25:41 +00:00
'encrypt': WebUtil.getQueryVar('encrypt',
(window.location.protocol === "https:")),
'repeaterID': WebUtil.getQueryVar('repeaterID', ''),
'true_color': WebUtil.getQueryVar('true_color', true),
'local_cursor': WebUtil.getQueryVar('cursor', true),
'shared': WebUtil.getQueryVar('shared', true),
'view_only': WebUtil.getQueryVar('view_only', false),
'updateState': updateState,
'onPasswordRequired': passwordRequired});
rfb.connect(host, port, password, path);
};
</script>
{% endblock %}