支持从总览页面连接到终端

This commit is contained in:
lwch
2021-10-14 14:55:48 +08:00
parent 93b583dd83
commit 95cd12fa8e
2 changed files with 14 additions and 2 deletions
+10 -2
View File
@@ -1,9 +1,16 @@
var page = {
init: function() {
page.load();
page.load(function() {
var name = arg('name');
if (name != null) {
$('#terms').find(`option:contains(${name})`).prop('selected', true);
page.connect();
}
});
$('#connect').click(page.connect);
},
load: function() {
load: function(cb) {
if (!cb) cb = function(){};
$.get('/api/tunnels', function(ret) {
$('#terms').empty();
$.each(ret, function(_, tunnel) {
@@ -12,6 +19,7 @@ var page = {
}
$('#terms').append($(`<option value="${tunnel.port}">${tunnel.name}</option>`));
});
cb();
});
},
connect: function() {
+4
View File
@@ -1,3 +1,7 @@
function arg(key) {
var url = new URL(location.href);
return decodeURIComponent(url.searchParams.get(key));
}
var humanize = {
bytes: function(n) {
return humanize.humanate_bytes(n, 1024, ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'])