diff options
Diffstat (limited to 'lib/util.js')
-rw-r--r-- | lib/util.js | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/lib/util.js b/lib/util.js index f582d1d..dd4c4f9 100644 --- a/lib/util.js +++ b/lib/util.js @@ -197,8 +197,8 @@ var filterByRegexp = exports.filterByRegexp = * * @return String with the password */ -var getPassword = exports.getPassword = function getPassword(prompt) { - if (prompt === null) { +exports.getPassword = function getPassword(prompt) { + if (!prompt) { // either undefined or null prompt = "Enter password:"; } var prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"] @@ -209,7 +209,7 @@ var getPassword = exports.getPassword = function getPassword(prompt) { var check = { value : true }; // default the checkbox to true - var result = prompts.promptPassword(null, "Title", prompt, + var result = prompts.promptPassword(null, "Bugzilla Triage Script", prompt, password, null, check); // result is true if OK was pressed, false if cancel was pressed. // password.value is set if OK was pressed. @@ -220,3 +220,26 @@ var getPassword = exports.getPassword = function getPassword(prompt) { return undefined; } }; + +/** + * YES/NO prompt; returns boolean or null (for Cancel) + * https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsIPromptService + */ +exports.promptOKNoCancel = function promptOKNoCancel(prompt) { + if (!prompt) { // either undefined or null + console.error("Prompt is required!"); + return undefined; + } + var prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"] + .getService(Ci.nsIPromptService); + + var result = prompts.confirmEx(null, "Bugzilla Triage Script", prompt, + prompts.STD_YES_NO_BUTTONS, null, null, null, null, {}); + if (result === 0) { + return true; + } else if (result === 1) { + return false; + } else { + return null; + } +};
\ No newline at end of file |