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'])