From 95cd12fa8e8c42c84985c4a500d0ee430ca287ed Mon Sep 17 00:00:00 2001 From: lwch Date: Thu, 14 Oct 2021 14:55:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=BB=8E=E6=80=BB=E8=A7=88?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E8=BF=9E=E6=8E=A5=E5=88=B0=E7=BB=88=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- html/dashboard/js/terminal.js | 12 ++++++++++-- html/js/common.js | 4 ++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/html/dashboard/js/terminal.js b/html/dashboard/js/terminal.js index 2db0985..1d0ac09 100644 --- a/html/dashboard/js/terminal.js +++ b/html/dashboard/js/terminal.js @@ -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($(``)); }); + cb(); }); }, connect: function() { diff --git a/html/js/common.js b/html/js/common.js index 4b0bb48..54feee1 100644 --- a/html/js/common.js +++ b/html/js/common.js @@ -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'])