mirror of
https://github.com/huashengdun/webssh.git
synced 2026-08-22 13:46:44 +00:00
Prepare to write unit tests
This commit is contained in:
Vendored
+7
File diff suppressed because one or more lines are too long
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
.xterm.fullscreen{position:fixed;top:0;bottom:0;left:0;right:0;width:auto;height:auto;z-index:255}
|
||||
/*# sourceMappingURL=fullscreen.min.css.map */
|
||||
Vendored
+2
File diff suppressed because one or more lines are too long
Binary file not shown.
|
After Width: | Height: | Size: 5.8 KiB |
Vendored
+7
File diff suppressed because one or more lines are too long
Vendored
+1
@@ -0,0 +1 @@
|
||||
!function(e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("../../xterm")):"function"==typeof define?define(["../../xterm"],e):e(window.Terminal)}(function(e){var t={};return t.toggleFullScreen=function(e,t){var n;n=void 0===t?e.element.classList.contains("fullscreen")?"remove":"add":t?"add":"remove",e.element.classList[n]("fullscreen")},e.prototype.toggleFullscreen=function(e){t.toggleFullScreen(this,e)},t});
|
||||
Vendored
+2
File diff suppressed because one or more lines are too long
@@ -0,0 +1,119 @@
|
||||
jQuery(function($){
|
||||
|
||||
var status = $('#status'),
|
||||
btn = $('.btn-primary'),
|
||||
style = {};
|
||||
|
||||
$('form#connect').submit(function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
var form = $(this),
|
||||
url = form.attr('action'),
|
||||
type = form.attr('type'),
|
||||
data = new FormData(this);
|
||||
|
||||
if (!data.get('hostname') || !data.get('port') || !data.get('username')) {
|
||||
status.text('Hostname, port and username are required.');
|
||||
return;
|
||||
}
|
||||
|
||||
var pk = data.get('privatekey');
|
||||
if (pk && pk.size > 16384) {
|
||||
status.text('Key size exceeds maximum value.');
|
||||
return;
|
||||
}
|
||||
|
||||
status.text('');
|
||||
btn.prop('disabled', true);
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: type,
|
||||
data: data,
|
||||
success: callback,
|
||||
cache: false,
|
||||
contentType: false,
|
||||
processData: false
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function parse_xterm_style() {
|
||||
var text = $('.xterm-helpers style').text();
|
||||
var arr = text.split('xterm-normal-char{width:');
|
||||
style.width = parseInt(arr[1]) + 1;
|
||||
arr = text.split('div{height:');
|
||||
style.height = parseInt(arr[1]);
|
||||
}
|
||||
|
||||
function current_geometry() {
|
||||
if (!style.width || !style.height) {
|
||||
parse_xterm_style();
|
||||
}
|
||||
cols = parseInt(window.innerWidth / style.width);
|
||||
rows = parseInt(window.innerHeight / style.height);
|
||||
return [cols, rows];
|
||||
}
|
||||
|
||||
|
||||
function callback(msg) {
|
||||
// console.log(msg);
|
||||
if (msg.status) {
|
||||
status.text(msg.status);
|
||||
setTimeout(function(){
|
||||
btn.prop('disabled', false);
|
||||
}, 3000);
|
||||
return;
|
||||
}
|
||||
|
||||
var ws_url = window.location.href.replace('http', 'ws'),
|
||||
join = (ws_url[ws_url.length-1] == '/' ? '' : '/'),
|
||||
url = ws_url + join + 'ws?id=' + msg.id,
|
||||
socket = new WebSocket(url),
|
||||
terminal = document.getElementById('#terminal'),
|
||||
geometry = current_geometry();
|
||||
term = new Terminal({
|
||||
cursorBlink: true,
|
||||
cols: geometry[0],
|
||||
rows: geometry[1]
|
||||
});
|
||||
|
||||
console.log(url);
|
||||
term.on('data', function(data) {
|
||||
// console.log(data);
|
||||
socket.send(data);
|
||||
});
|
||||
|
||||
socket.onopen = function(e) {
|
||||
$('.container').hide();
|
||||
term.open(terminal, true);
|
||||
term.toggleFullscreen(true);
|
||||
};
|
||||
|
||||
socket.onmessage = function(msg) {
|
||||
// console.log(msg);
|
||||
term.write(msg.data);
|
||||
};
|
||||
|
||||
socket.onerror = function(e) {
|
||||
console.log(e);
|
||||
};
|
||||
|
||||
socket.onclose = function(e) {
|
||||
console.log(e);
|
||||
term.destroy();
|
||||
$('.container').show();
|
||||
status.text(e.reason);
|
||||
btn.prop('disabled', false);
|
||||
};
|
||||
}
|
||||
|
||||
$(window).resize(function(){
|
||||
if (typeof term != 'undefined') {
|
||||
geometry = current_geometry();
|
||||
term.geometry = geometry;
|
||||
term.resize(geometry[0], geometry[1]);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
Vendored
+5
File diff suppressed because one or more lines are too long
Vendored
+1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user