aboutsummaryrefslogtreecommitdiffstats
path: root/lib/prompts.js
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2011-03-23 20:18:23 +0100
committerMatěj Cepl <mcepl@redhat.com>2011-03-23 20:18:23 +0100
commit2e5993bc9bd0d468f4e9d12dd39e0548ba9adda1 (patch)
treef31a0d612efbfa5beb78e4718768c55c650f14d8 /lib/prompts.js
parentc662ccddab2cbcc6d13f49a21c04a6aea808f457 (diff)
downloadbugzilla-triage-2e5993bc9bd0d468f4e9d12dd39e0548ba9adda1.tar.gz
Fix indentation and else for Mozilla coding guidelines.
Diffstat (limited to 'lib/prompts.js')
-rw-r--r--lib/prompts.js130
1 files changed, 67 insertions, 63 deletions
diff --git a/lib/prompts.js b/lib/prompts.js
index ed9b3e5..7cfd3d1 100644
--- a/lib/prompts.js
+++ b/lib/prompts.js
@@ -15,9 +15,9 @@ var promptTitle = "Bugzilla Triage Script";
* @return none
*/
exports.alert = function alert(msg) {
- var prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"]
- .getService(Ci.nsIPromptService);
- prompts.alert(null, promptTitle, msg);
+ var prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"]
+ .getService(Ci.nsIPromptService);
+ prompts.alert(null, promptTitle, msg);
};
/**
@@ -26,19 +26,20 @@ exports.alert = function alert(msg) {
* @return String with the password
*/
exports.prompt = function prompt(prompt, defaultValue) {
- var stringValue = {
- value: defaultValue ? defaultValue : ""
- };
+ var stringValue = {
+ value: defaultValue ? defaultValue : ""
+ };
- var prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"]
- .getService(Ci.nsIPromptService);
- var result = prompts.prompt(null, promptTitle, prompt,
- stringValue, null, {});
- if (result) {
- return stringValue.value;
- } else {
- return null;
- }
+ var prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"]
+ .getService(Ci.nsIPromptService);
+ var result = prompts.prompt(null, promptTitle, prompt,
+ stringValue, null, {});
+ if (result) {
+ return stringValue.value;
+ }
+ else {
+ return null;
+ }
};
/**
@@ -47,27 +48,28 @@ exports.prompt = function prompt(prompt, defaultValue) {
* @return String with the password
*/
exports.promptPassword = function promptPassword(prompt) {
- if (!prompt) { // either undefined or null
- prompt = "Enter password:";
- }
- var prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"]
- .getService(Ci.nsIPromptService);
- var password = {
- value : ""
- }; // default the password to pass
- var check = {
- value : true
- }; // default the checkbox to true
- 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.
- // The checkbox is not displayed.
- if (result) {
- return password.value ? password.value : null;
- } else {
- return null;
- }
+ if (!prompt) { // either undefined or null
+ prompt = "Enter password:";
+ }
+ var prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"]
+ .getService(Ci.nsIPromptService);
+ var password = {
+ value : ""
+ }; // default the password to pass
+ var check = {
+ value : true
+ }; // default the checkbox to true
+ 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.
+ // The checkbox is not displayed.
+ if (result) {
+ return password.value ? password.value : null;
+ }
+ else {
+ return null;
+ }
};
/**
@@ -75,21 +77,23 @@ exports.promptPassword = function promptPassword(prompt) {
* https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsIPromptService
*/
exports.promptYesNoCancel = function promptOKNoCancel(prompt) {
- if (!prompt) { // either undefined or null
- throw new Error("Prompt is required!");
- }
- var prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"]
- .getService(Ci.nsIPromptService);
+ if (!prompt) { // either undefined or null
+ throw new Error("Prompt is required!");
+ }
+ 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;
- }
+ 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;
+ }
};
/**
@@ -97,18 +101,18 @@ exports.promptYesNoCancel = function promptOKNoCancel(prompt) {
* documentation is https://developer.mozilla.org/en/NsIFilePicker
*/
exports.promptFileOpenPicker = function promptFilePicker (win) {
- var window = require("window-utils").activeWindow;
- var fp = Cc["@mozilla.org/filepicker;1"]
- .createInstance(Ci.nsIFilePicker);
- fp.init(window, "JSON File Open", Ci.nsIFilePicker.modeOpen);
- fp.appendFilter("JSON files", "*.json");
- fp.appendFilters(Ci.nsIFilePicker.filterAll);
- fp.filterIndex = 0;
- var res = fp.show();
+ var window = require("window-utils").activeWindow;
+ var fp = Cc["@mozilla.org/filepicker;1"]
+ .createInstance(Ci.nsIFilePicker);
+ fp.init(window, "JSON File Open", Ci.nsIFilePicker.modeOpen);
+ fp.appendFilter("JSON files", "*.json");
+ fp.appendFilters(Ci.nsIFilePicker.filterAll);
+ fp.filterIndex = 0;
+ var res = fp.show();
- if (res === Ci.nsIFilePicker.returnOK ||
- res === Ci.nsIFilePicker.returnReplace ) {
- return fp.file.path;
- }
- return null;
+ if (res === Ci.nsIFilePicker.returnOK ||
+ res === Ci.nsIFilePicker.returnReplace ) {
+ return fp.file.path;
+ }
+ return null;
};