webssh

Web based ssh client https://github.com/huashengdun/webssh webssh.huashengdun.org/
git clone http://git.hanabi.in/repos/webssh.git
Log | Files | Refs | README | LICENSE

commit d496b4ff87c91445cad52f7e858c089a15d32b16
parent 18b20de3a4d03024451c0dcce36b67fa5d8f7225
Author: Sheng <webmaster0115@gmail.com>
Date:   Sun, 25 Aug 2019 16:35:19 +0800

Use populate_form rather than restore_items

Diffstat:
Mwebssh/static/js/main.js | 29++++++++++++++++++-----------
1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/webssh/static/js/main.js b/webssh/static/js/main.js @@ -76,16 +76,12 @@ jQuery(function($){ } - function restore_items(names, storage) { + function restore_items(names) { var i, name, value; - if (storage === undefined) { - storage = window.localStorage; - } - for (i=0; i < names.length; i++) { name = names[i]; - value = storage.getItem(name); + value = window.localStorage.getItem(name); if (value) { $('#'+name).val(value); } @@ -93,6 +89,17 @@ jQuery(function($){ } + function populate_form(data) { + var names = form_keys.concat(['passphrase']), + i, name; + + for (i=0; i < names.length; i++) { + name = names[i]; + $('#'+name).val(data.get(name)); + } + } + + function get_object_length(object) { return Object.keys(object).length; } @@ -310,12 +317,12 @@ jQuery(function($){ } - function log_status(text, fill_form) { + function log_status(text, to_populate) { console.log(text); status.html(text.split('\n').join('<br/>')); - if (fill_form && validated_form_data) { - restore_items(fields.concat(['password']), validated_form_data); + if (to_populate && validated_form_data) { + populate_form(validated_form_data); validated_form_data = undefined; } @@ -539,7 +546,7 @@ jQuery(function($){ function wrap_object(opts) { var obj = {}; - obj.getItem = obj.get = function(attr) { + obj.get = function(attr) { return opts[attr] || ''; }; @@ -553,7 +560,7 @@ jQuery(function($){ function clean_data(data) { var i, attr, val; - var attrs = fields.concat(['password', 'privatekey', 'passphrase', 'totp']); + var attrs = form_keys.concat(['privatekey', 'passphrase']); for (i = 0; i < attrs.length; i++) { attr = attrs[i];