mirror of
https://github.com/lwch/natpass.git
synced 2026-10-21 07:26:15 +00:00
支持从总览页面连接到终端
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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'])
|
||||
|
||||
Reference in New Issue
Block a user