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 f54eba8cfedac5494fa24159db9733b1c6fc3857
parent 0a44b1fdf30c98d4c9488d1f26e57fa2c7ac70c9
Author: Sheng <webmaster0115@gmail.com>
Date:   Sun, 18 Aug 2019 15:58:59 +0800

Populate the form with url data directly

Diffstat:
Mwebssh/static/js/main.js | 12++++++++----
Mwebssh/templates/index.html | 6+++---
2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/webssh/static/js/main.js b/webssh/static/js/main.js @@ -71,12 +71,16 @@ jQuery(function($){ } - function restore_items(names) { + function restore_items(names, storage) { var i, name, value; + if (storage === undefined) { + storage = window.localStorage; + } + for (i=0; i < names.length; i++) { name = names[i]; - value = window.localStorage.getItem(name); + value = storage.getItem(name); if (value) { $('#'+name).val(value); } @@ -521,7 +525,7 @@ jQuery(function($){ function wrap_object(opts) { var obj = {}; - obj.get = function(attr) { + obj.getItem = obj.get =function(attr) { return opts[attr] || ''; }; @@ -676,8 +680,8 @@ jQuery(function($){ data._origin = event_origin; } + restore_items(fields.concat(['password']), data_wrapped); store_items(fields, data_wrapped); - restore_items(fields); $.ajax({ url: url, diff --git a/webssh/templates/index.html b/webssh/templates/index.html @@ -46,7 +46,7 @@ </div> <div class="col"> <label for="Password">Password</label> - <input class="form-control" type="password" name="password" value=""> + <input class="form-control" type="password" id="password" name="password" value=""> </div> </div> <div class="row"> @@ -56,13 +56,13 @@ </div> <div class="col"> <label for="Passphrase">Passphrase</label> - <input class="form-control" type="password" name="passphrase" value=""> + <input class="form-control" type="password" id="passphrase" name="passphrase" value=""> </div> </div> <div class="row"> <div class="col"> <label for="totp">Totp (time-based one-time password)</label> - <input class="form-control" type="password" name="totp" value=""> + <input class="form-control" type="password" id="totp" name="totp" value=""> </div> <div class="col"> </div>