Populate the form with url data directly

pull/83/head
Sheng 2019-08-18 15:58:59 +08:00
parent 0a44b1fdf3
commit f54eba8cfe
2 changed files with 11 additions and 7 deletions

View File

@ -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,

View File

@ -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>