aboutsummaryrefslogtreecommitdiffstats
path: root/lib/util.js
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2010-06-21 17:44:25 +0200
committerMatěj Cepl <mcepl@redhat.com>2010-06-21 17:44:25 +0200
commitb5da15622a8ee84cac5c8489c72610bd24b09c29 (patch)
treeea39f899db898780e05b5d2fe7f4cc55e09ba754 /lib/util.js
parenta0756d1dbd9e8bbb37293b8b756f6aee1e205d65 (diff)
downloadbugzilla-triage-b5da15622a8ee84cac5c8489c72610bd24b09c29.tar.gz
Skipping over process pages && system notification.
Diffstat (limited to 'lib/util.js')
-rw-r--r--lib/util.js69
1 files changed, 51 insertions, 18 deletions
diff --git a/lib/util.js b/lib/util.js
index 4cb158a..b832ac0 100644
--- a/lib/util.js
+++ b/lib/util.js
@@ -1,4 +1,4 @@
-/*global exports: false, require: false, Cc: false, Ci: false */
+/*global exports: false, require: false, Cc: false, Ci: false, console: false */
/*jslint onevar: false */
// Released under the MIT/X11 license
// http://www.opensource.org/licenses/mit-license.php
@@ -49,6 +49,39 @@ exports.getBugNo = function getBugNo(url) {
};
/**
+ * Show a system notification with the given message
+ *
+ * @param String or Object with a message to be shown in a default
+ * notification or object with properties title, icon, and body
+ * @return None
+ */
+exports.notification = function notification(msg) {
+ var body = msg;
+ var title = "Bugzilla Notification";
+ var icon = null;
+
+ if (typeof(msg) === "object") {
+ body = msg.body;
+ }
+ if ("title" in msg) {
+ title = msg.title;
+ }
+ if ("icon" in msg) {
+ icon = msg.icon;
+ }
+ try {
+ var classObj = Cc["@mozilla.org/alerts-service;1"];
+ var alertService = classObj.getService(Ci.nsIAlertsService);
+
+ alertService.showAlertNotification(icon, title, body);
+ return true;
+ } catch (e) {
+ console.error("Unable to display notification:", msg);
+ return false;
+ }
+};
+
+/**
* format date to be in ISO format (just day part)
*
* @param date
@@ -64,6 +97,21 @@ exports.getISODate = function getISODate(dateStr) {
};
/**
+ * Check whether an item is member of the list. Idea is just to make long if
+ * commands slightly more readable.
+ *
+ * @param mbr string to be searched in the list
+ * @param list list
+ * @return position of the string in the list, or -1 if none found.
+ */
+var isInList = exports.isInList = function isInList(mbr, list) {
+ if (!list) {
+ return false;
+ }
+ return (list.indexOf(mbr) !== -1);
+};
+
+/**
* Make sure value returned is Array
*
* @param Array/String
@@ -128,9 +176,9 @@ exports.removeCSVValue = function removeCSVValue(str, value) {
*/
var filterByRegexp = exports.filterByRegexp =
function filterByRegexp(list, chosingMark) {
- let chosenPair = [];
+ var chosenPair = [];
if (list.length > 0) {
- chosenPair = list.filter(function(pair) {
+ chosenPair = list.filter(function (pair) {
return new RegExp(pair.regexp, "i").test(chosingMark);
});
}
@@ -142,21 +190,6 @@ var filterByRegexp = exports.filterByRegexp =
};
/**
- * Check whether an item is member of the list. Idea is just to make long if
- * commands slightly more readable.
- *
- * @param mbr string to be searched in the list
- * @param list list
- * @return position of the string in the list, or -1 if none found.
- */
-var isInList = exports.isInList = function isInList(mbr, list) {
- if (!list) {
- return false;
- }
- return (list.indexOf(mbr) !== -1);
-};
-
-/**
* returns password with a special password
*
* @return String with the password