MCPcopy Create free account
hub / github.com/violentmonkey/violentmonkey / showConfirmation

Function showConfirmation

src/common/ui/index.js:79–95  ·  view source on GitHub ↗
(text, { ok, cancel, input = false } = {})

Source from the content-addressed store, hash-verified

77 * `input` is string: <?string> i.e. string on Ok, null otherwise;
78 */
79export function showConfirmation(text, { ok, cancel, input = false } = {}) {
80 return new Promise(resolve => {
81 const hasInput = input !== false;
82 const onCancel = () => resolve(hasInput ? null : false);
83 const onOk = val => resolve(!hasInput || val);
84 showMessage({
85 input,
86 text,
87 buttons: [
88 ok !== false && { text: i18n('buttonOK'), onClick: onOk, ...ok },
89 cancel !== false && { text: i18n('buttonCancel'), onClick: onCancel, ...cancel },
90 ].filter(Boolean),
91 onBackdropClick: onCancel,
92 onDismiss: onCancel, // Esc key
93 });
94 });
95}
96
97/** @returns {?number} Number of lines + 1 if the last line is not empty */
98export function calcRows(val) {

Callers 1

confirmPopStateFunction · 0.90

Calls 2

showMessageFunction · 0.85
filterMethod · 0.80

Tested by

no test coverage detected