mirror of https://github.com/huashengdun/webssh
Use populate_form rather than restore_items
parent
18b20de3a4
commit
d496b4ff87
|
@ -76,16 +76,12 @@ jQuery(function($){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function restore_items(names, storage) {
|
function restore_items(names) {
|
||||||
var i, name, value;
|
var i, name, value;
|
||||||
|
|
||||||
if (storage === undefined) {
|
|
||||||
storage = window.localStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i=0; i < names.length; i++) {
|
for (i=0; i < names.length; i++) {
|
||||||
name = names[i];
|
name = names[i];
|
||||||
value = storage.getItem(name);
|
value = window.localStorage.getItem(name);
|
||||||
if (value) {
|
if (value) {
|
||||||
$('#'+name).val(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) {
|
function get_object_length(object) {
|
||||||
return Object.keys(object).length;
|
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);
|
console.log(text);
|
||||||
status.html(text.split('\n').join('<br/>'));
|
status.html(text.split('\n').join('<br/>'));
|
||||||
|
|
||||||
if (fill_form && validated_form_data) {
|
if (to_populate && validated_form_data) {
|
||||||
restore_items(fields.concat(['password']), validated_form_data);
|
populate_form(validated_form_data);
|
||||||
validated_form_data = undefined;
|
validated_form_data = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -539,7 +546,7 @@ jQuery(function($){
|
||||||
function wrap_object(opts) {
|
function wrap_object(opts) {
|
||||||
var obj = {};
|
var obj = {};
|
||||||
|
|
||||||
obj.getItem = obj.get = function(attr) {
|
obj.get = function(attr) {
|
||||||
return opts[attr] || '';
|
return opts[attr] || '';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -553,7 +560,7 @@ jQuery(function($){
|
||||||
|
|
||||||
function clean_data(data) {
|
function clean_data(data) {
|
||||||
var i, attr, val;
|
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++) {
|
for (i = 0; i < attrs.length; i++) {
|
||||||
attr = attrs[i];
|
attr = attrs[i];
|
||||||
|
|
Loading…
Reference in New Issue