Make sure an element is focused
Also fix up the docstrings.
This commit is contained in:
parent
dc842516b0
commit
6e73d17650
1 changed files with 33 additions and 16 deletions
49
cdispass.js
49
cdispass.js
|
@ -86,25 +86,42 @@ function dispass_complete(input, pos, conservative)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function dispass_interactive(I) {
|
function dispass_interactive(with_submit) {
|
||||||
let label = yield I.minibuffer.read($prompt="label:",
|
return function (I) {
|
||||||
$auto_complete=true,
|
if (!I.buffer.focused_element) {
|
||||||
$completer=dispass_complete);
|
I.minibuffer.message("No input selected.");
|
||||||
|
yield co_return(null);
|
||||||
|
}
|
||||||
|
|
||||||
I.minibuffer.input_element.type = "password";
|
let label = yield I.minibuffer.read(
|
||||||
let password = yield I.minibuffer.read(
|
$prompt="label:", $auto_complete=true,
|
||||||
$prompt="password:"
|
$completer=dispass_complete
|
||||||
);
|
);
|
||||||
I.minibuffer.input_element.type = "";
|
|
||||||
|
|
||||||
I.buffer.focused_element.value = (yield dispass(label, password));
|
I.minibuffer.input_element.type = "password";
|
||||||
|
let password = yield I.minibuffer.read(
|
||||||
|
$prompt="password:"
|
||||||
|
);
|
||||||
|
I.minibuffer.input_element.type = "";
|
||||||
|
|
||||||
|
I.buffer.focused_element.value =
|
||||||
|
(yield dispass(label, password));
|
||||||
|
|
||||||
|
if (with_submit)
|
||||||
|
I.buffer.focused_element.form.submit();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
interactive("dispass", "Something", dispass_interactive);
|
interactive("dispass",
|
||||||
interactive("dispass-and-submit", "Something",
|
"Call DisPass to generate a passphrase.\n"
|
||||||
function (I) {
|
+ "\n"
|
||||||
yield dispass_interactive(I);
|
+ "Put the result in the currently focused input.",
|
||||||
I.buffer.focused_element.form.submit();
|
dispass_interactive(false));
|
||||||
});
|
interactive("dispass-and-submit",
|
||||||
|
"Call Dispass to generate a passphrase.\n"
|
||||||
|
+ "\n"
|
||||||
|
+ "Put the result in the currently focused input and"
|
||||||
|
+ " submit the input's form.",
|
||||||
|
dispass_interactive(true));
|
||||||
|
|
||||||
provide("cdispass");
|
provide("cdispass");
|
||||||
|
|
Loading…
Reference in a new issue