diff options
author | Matěj Cepl <mcepl@redhat.com> | 2011-02-15 00:37:57 +0100 |
---|---|---|
committer | Matěj Cepl <mcepl@redhat.com> | 2011-02-15 00:37:57 +0100 |
commit | 10dcf8de5c6965832452c538451d6170b3bafb66 (patch) | |
tree | 26a485d017ce2d3ea2032293687827f6c6d3a3e8 | |
parent | 04657077ba12e8f23feaa0c3787b590c44446056 (diff) | |
download | bugzilla-triage-10dcf8de5c6965832452c538451d6170b3bafb66.tar.gz |
Bit of reorganization
Also add an event handler on changes in assigned_to input box
-rw-r--r-- | data/bzpage.js | 26 | ||||
-rw-r--r-- | data/rhbzpage.js | 6 | ||||
-rw-r--r-- | data/util.js | 26 | ||||
-rw-r--r-- | lib/main.js | 3 | ||||
-rw-r--r-- | lib/util.js | 12 | ||||
-rw-r--r-- | tests/test-color.js | 10 | ||||
-rw-r--r-- | tests/test-util.js | 44 |
7 files changed, 73 insertions, 54 deletions
diff --git a/data/bzpage.js b/data/bzpage.js index f99bc21..c71ab51 100644 --- a/data/bzpage.js +++ b/data/bzpage.js @@ -20,32 +20,6 @@ var config = {}; var constantData = {}; // This should be probably eliminated ASAP or // or done by other means. TODO var submitHandlerInstalled = false; // for setUpLogging -// ============================================ -/** - * object to pack messaging. Use as in - postMessage(new Message("GetPassword", { - login: login, - hostname: location.hostname - })); - */ -function Message(cmd, data) { - this.cmd = cmd; - this.data = data; -} - -function log(msg) { - postMessage(new Message("LogMessage", msg)); -} - -var NotLoggedinException = function NotLoggedinException (message) { - this.message = message; - this.name = "NotLoggedinException"; -}; - -NotLoggedinException.prototype.toString = function () { - return this.name + ': "' + this.message + '"'; -}; - /** * central handler processing messages from the main script. */ diff --git a/data/rhbzpage.js b/data/rhbzpage.js index fa511c7..f0347d7 100644 --- a/data/rhbzpage.js +++ b/data/rhbzpage.js @@ -986,4 +986,10 @@ function RHBZinit() { changeAssignee("default"); }, false); } + + // Uncheck "set default assignee" when the assignee is changed by other means + document.getElementById("assigned_to").addEventListener("change", + function() { + document.getElementById("set_default_assignee").checked = false; + }, false); } diff --git a/data/util.js b/data/util.js index 09360a0..6c5e7b0 100644 --- a/data/util.js +++ b/data/util.js @@ -251,3 +251,29 @@ function removeDuplicates (arr) { } return arr; } + +// ============================================ +/** + * object to pack messaging. Use as in + postMessage(new Message("GetPassword", { + login: login, + hostname: location.hostname + })); + */ +function Message(cmd, data) { + this.cmd = cmd; + this.data = data; +} + +function log(msg) { + postMessage(new Message("LogMessage", msg)); +} + +var NotLoggedinException = function NotLoggedinException (message) { + this.message = message; + this.name = "NotLoggedinException"; +}; + +NotLoggedinException.prototype.toString = function () { + return this.name + ': "' + this.message + '"'; +}; diff --git a/lib/main.js b/lib/main.js index be4ff8d..0348842 100644 --- a/lib/main.js +++ b/lib/main.js @@ -16,6 +16,7 @@ var pageMod = require("page-mod"); var libbz = require("libbugzilla"); var tabs = require("tabs"); var logger = require("logger"); +var Message = require("util").Message; function isOurPage(window, matchingURLs) { var url = window.location.href; @@ -115,7 +116,7 @@ var contentScriptLibraries = { "bugzilla.redhat.com": [ self.data.url("util.js"), self.data.url("color.js"), - self.data.url("rhbzpage.js"), + self.data.url("rhbzpage.js"), self.data.url("bzpage.js") ] }; diff --git a/lib/util.js b/lib/util.js index 3532203..089e31c 100644 --- a/lib/util.js +++ b/lib/util.js @@ -63,3 +63,15 @@ exports.getISODate = function getISODate(dateStr) { return date.getFullYear() + '-' + pad(date.getMonth() + 1) + '-' + pad(date.getDate()); }; + +/** + * object to pack messaging. Use as in + postMessage(new Message("GetPassword", { + login: login, + hostname: location.hostname + })); + */ +exports.Message = function Message(cmd, data) { + this.cmd = cmd; + this.data = data; +}; diff --git a/tests/test-color.js b/tests/test-color.js index 7394057..2006fd9 100644 --- a/tests/test-color.js +++ b/tests/test-color.js @@ -1,30 +1,30 @@ /*global exports: false, require: false */ // TODO: add some failing tests as well "use strict"; -var util = require("color"); +//var util = require("color"); // testing Color object -exports.ensureColorNew = function (test) { +var ensureColorNew = function (test) { var col = new util.Color(255, 255, 166); test.assertEqual(col.toString(), "#ffffa6", "creation of new RGB Color object"); }; -exports.ensureColorUpdate = function (test) { +var ensureColorUpdate = function (test) { var col = new util.Color(255, 255, 166); col.update(255, 224, 176); test.assertEqual(col.toString(), "#ffe0b0", "updating Color object"); }; -exports.ensureColorHSL = function (test) { +var ensureColorHSL = function (test) { var col = new util.Color(255, 224, 176); test.assertEqual(col.hsl().toSource(), "[0.10126582278481013, 1, 0.8450980392156863]", "converting to HSL model"); }; -exports.ensureColorLight = function (test) { +var ensureColorLight = function (test) { var col = new util.Color(255, 224, 176); test.assertEqual(col.lightColor().toString(), "#e8dcc9", "getting a light color"); diff --git a/tests/test-util.js b/tests/test-util.js index 9acb54c..d4e4a78 100644 --- a/tests/test-util.js +++ b/tests/test-util.js @@ -6,7 +6,7 @@ var util = require("util"); var urlMod = require("url"); // testing util.heir -exports.ensureHeir = function (test) { +var ensureHeir = function (test) { var fedlimid = {}, naoise = {}; function Father(x) { @@ -51,28 +51,28 @@ exports.ensureHeir = function (test) { }; // testing util.isInList -exports.ensureIsInListTrue = function (test) { +var ensureIsInListTrue = function (test) { test.assert(util.isInList("a", ["a"]), "conversion of a string to an array"); }; -exports.ensureIsInListFalse = function (test) { +var ensureIsInListFalse = function (test) { test.assert(!util.isInList("b", ["a"]), "conversion of a string to an array"); }; -exports.ensureIsInListEmpty = function (test) { +var ensureIsInListEmpty = function (test) { test.assert(!util.isInList("b", []), "conversion of a string to an array"); }; -exports.ensureIsInListNoMember = function (test) { +var ensureIsInListNoMember = function (test) { test.assert(!util.isInList("", ["x"]), "conversion of a string to an array"); }; // testing util.filterByRegexp -exports.ensureFilterByRegexp = function (test) { +var ensureFilterByRegexp = function (test) { var list = [ { "regexp": "test(ing|ed)", @@ -92,7 +92,7 @@ exports.ensureFilterByRegexp = function (test) { "simple testing of filterByRegexp with non-string return value"); }; -exports.ensureFilterByRegexpEmpty = function (test) { +var ensureFilterByRegexpEmpty = function (test) { test.assertRaises(function () { util.filterByRegexp(undefined, "tralala"); }, @@ -101,78 +101,78 @@ exports.ensureFilterByRegexpEmpty = function (test) { }; // testing util.getISODate -exports.ensureGetISODate = function (test) { +var ensureGetISODate = function (test) { test.assertEqual(util.getISODate("Mon May 31 2010 23:29:09 GMT+0200 (CET)"), "2010-05-31", "conversion of a Date to ISO-formatted String"); }; // testing util.valToArray -exports.ensureValToArrayString = function (test) { +var ensureValToArrayString = function (test) { test.assertEqual(JSON.stringify(util.valToArray("a")), JSON.stringify(["a"]), "conversion of a string to an array"); }; -exports.ensureValToArrayEmpty = function (test) { +var ensureValToArrayEmpty = function (test) { test.assertEqual(JSON.stringify(util.valToArray("")), JSON.stringify([""]), "conversion of an empty string to an array"); }; -exports.ensureValToArrayArray = function (test) { +var ensureValToArrayArray = function (test) { test.assertEqual(JSON.stringify(util.valToArray(["a"])), JSON.stringify(["a"]), "non-conversion of an array"); }; // testing util.addCSVValue -exports.ensureCSVAddedToNull = function (test) { +var ensureCSVAddedToNull = function (test) { test.assertEqual(util.addCSVValue("", "b"), "b", "adding a string to empty string"); }; -exports.ensureCSVAddedNull = function (test) { +var ensureCSVAddedNull = function (test) { test.assertEqual(util.addCSVValue("a", ""), "a", "adding nothing to a string"); }; -exports.ensureCSVAddedString = function (test) { +var ensureCSVAddedString = function (test) { test.assertEqual(util.addCSVValue("a", "b"), "a, b", "adding one string to another one"); }; -exports.ensureCSVAddedArray = function (test) { +var ensureCSVAddedArray = function (test) { test.assertEqual(util.addCSVValue("a", ["b", "c"]), "a, b, c", "adding array to a string"); }; -exports.ensureCSVAddedArray2Array = function (test) { +var ensureCSVAddedArray2Array = function (test) { test.assertEqual(util.addCSVValue("a, b", ["c", "d"]), "a, b, c, d", "adding one array to another"); }; // testing util.removeCSVValue -exports.ensureCSVRemoveSimple = function (test) { +var ensureCSVRemoveSimple = function (test) { test.assertEqual(util.removeCSVValue("a, b", "b"), "a", "removing one string from an array"); }; // also checking a tolerancy against different ways of writing arrays -exports.ensureCSVRemoveNonMember = function (test) { +var ensureCSVRemoveNonMember = function (test) { test.assertEqual(util.removeCSVValue("a,b", "c"), "a, b", "removing a string from an array of which it isn't a member"); }; -exports.ensureCSVRemoveEmpty = function (test) { +var ensureCSVRemoveEmpty = function (test) { test.assertEqual(util.removeCSVValue("", "c"), "", "removing a string from an empty array"); }; // testing util.getObjectKeys -exports.ensureGetObjectKeys = function (test) { +var ensureGetObjectKeys = function (test) { var testObj = { a: 1, b: 2 @@ -183,7 +183,7 @@ exports.ensureGetObjectKeys = function (test) { }; // testing util.getParamsFromURL -exports.ensureGetParamsFromURL = function (test) { +var ensureGetParamsFromURL = function (test) { test.assertEqual(JSON.stringify(util.getParamsFromURL("https://bugzilla.redhat.com/show_bug.cgi?id=549066")), JSON.stringify({id:"549066"}), "simply compare result of bugzilla show_page URL"); @@ -206,7 +206,7 @@ exports.ensureGetParamsFromURL = function (test) { }; // testing util.getBugNo -exports.ensureGetBugNo = function (test) { +var ensureGetBugNo = function (test) { var bugNo = util.getBugNo("https://bugzilla.redhat.com/show_bug.cgi?id=597141"); test.assertEqual(bugNo, 597141, "getting bug number"); bugNo = util.getBugNo("https://bugzilla.redhat.com/show_bug.cgi?id=serialWacom"); |