From 3fe9f14f10381242a193d91f7dc8ea0307091f8e Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Fri, 25 Mar 2011 01:17:49 +0100 Subject: Working on cutting down lines from bug-page-mod.js --- data/lib/util.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'data/lib/util.js') diff --git a/data/lib/util.js b/data/lib/util.js index f336a7f..6cbb493 100644 --- a/data/lib/util.js +++ b/data/lib/util.js @@ -124,14 +124,18 @@ function createDeadLink (id, text, parent, callback, params, before, covered, ac }, false); } + locParent.appendChild(newAElem); + if ((before === "br") || (before === true)) { locParent.appendChild(document.createElement("br")); } else if (before === "dash") { locParent.appendChild(document.createTextNode("\u00A0-\u00A0")); } - - locParent.appendChild(newAElem); + else if (before === "parens") { + locParent.appendChild(document.createTextNode(")")); + locParent.insertBefore(document.createTextNode("("), newAElem); + } } /* -- cgit From 470e0d853724feb51a991e9e8b867e366c8519ae Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Fri, 25 Mar 2011 16:23:51 +0100 Subject: Cut out general bugzilla functions to a special module. --- data/lib/util.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'data/lib/util.js') diff --git a/data/lib/util.js b/data/lib/util.js index 6cbb493..611d353 100644 --- a/data/lib/util.js +++ b/data/lib/util.js @@ -80,6 +80,19 @@ function getBugNoFromURL(url) { } } +/** + * Send mouse click to the specified element + * + * @param String ID of the element to send mouseclick to + * @return None + */ +function clickMouse (targetID) { + var localEvent = document.createEvent("MouseEvents"); + localEvent.initMouseEvent("click", true, true, document.defaultView, 0, 0, + 0, 0, 0, false, false, false, false, 0, null); + document.getElementById(targetID).dispatchEvent(localEvent); +} + /** * Create a A element leadink nowhere, but with listener running a callback on the click * -- cgit From 461f09665a6a9be7700237f6b458b65ca38061d5 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Thu, 31 Mar 2011 00:35:44 +0200 Subject: Fix order of covering elements in createDeadLink. --- data/lib/util.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'data/lib/util.js') diff --git a/data/lib/util.js b/data/lib/util.js index 611d353..6256171 100644 --- a/data/lib/util.js +++ b/data/lib/util.js @@ -140,10 +140,10 @@ function createDeadLink (id, text, parent, callback, params, before, covered, ac locParent.appendChild(newAElem); if ((before === "br") || (before === true)) { - locParent.appendChild(document.createElement("br")); + locParent.insertBefore(document.createElement("br"), newAElem); } else if (before === "dash") { - locParent.appendChild(document.createTextNode("\u00A0-\u00A0")); + locParent.insertBefore(document.createTextNode("\u00A0-\u00A0"), newAElem); } else if (before === "parens") { locParent.appendChild(document.createTextNode(")")); -- cgit From 50c6825e5d1aecca1edc75b305e28fce86e12b36 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Tue, 19 Apr 2011 00:19:53 +0200 Subject: Working on analysis of bug-page-mod module. * Add some notes * remove getBugNumber and replaced with my getBugNo. --- data/lib/util.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'data/lib/util.js') diff --git a/data/lib/util.js b/data/lib/util.js index 6256171..40a782f 100644 --- a/data/lib/util.js +++ b/data/lib/util.js @@ -64,8 +64,12 @@ function parseXMLfromString (inStuff) { * Get a bug no */ function getBugNo() { - console.log("bugNo = " + document.forms.namedItem('changeform').getElementsByName("id")[0].value); - return document.forms.namedItem('changeform').getElementsByName("id")[0].value; + var bugNoElem = document.forms.namedItem('changeform').getElementsByName("id")[0]; + if (bugNoElem) { + return bugNoElem.value; + } else { + return null; + } } /** -- cgit From 197e98076352809946aabc2c8f042374f2af549e Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Thu, 21 Apr 2011 15:59:49 +0200 Subject: Add better logging support. https://bugzilla.mozilla.org/show_bug.cgi?id=582760 is still unfixed. --- data/lib/util.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'data/lib/util.js') diff --git a/data/lib/util.js b/data/lib/util.js index 40a782f..fa111aa 100644 --- a/data/lib/util.js +++ b/data/lib/util.js @@ -355,3 +355,9 @@ var NotLoggedinException = function NotLoggedinException (message) { NotLoggedinException.prototype.toString = function () { return this.name + ': "' + this.message + '"'; }; + +console.myDebug = function myDebug(str) { + if (debugFlag) { + console.log(str); + } +}; -- cgit From 9a2e436b841d7c0d9d162b1d386a4316c7feb62e Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Thu, 21 Apr 2011 16:26:10 +0200 Subject: debugFlag must be in util.js as well. --- data/lib/util.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'data/lib/util.js') diff --git a/data/lib/util.js b/data/lib/util.js index fa111aa..5b628cf 100644 --- a/data/lib/util.js +++ b/data/lib/util.js @@ -356,6 +356,9 @@ NotLoggedinException.prototype.toString = function () { return this.name + ': "' + this.message + '"'; }; +// Are we debugging? +var debugFlag = false; + console.myDebug = function myDebug(str) { if (debugFlag) { console.log(str); -- cgit From ca6d6953457b0176f9aed372367cb2645e575f3e Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Thu, 21 Apr 2011 23:58:00 +0200 Subject: Fix nvidia. What to do when nvidia chipset is using VESA drivers or something similar. Driver names are not 100% proxy for the card type. --- data/lib/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'data/lib/util.js') diff --git a/data/lib/util.js b/data/lib/util.js index 5b628cf..b145d25 100644 --- a/data/lib/util.js +++ b/data/lib/util.js @@ -357,7 +357,7 @@ NotLoggedinException.prototype.toString = function () { }; // Are we debugging? -var debugFlag = false; +var debugFlag = true; console.myDebug = function myDebug(str) { if (debugFlag) { -- cgit From 738734fc32b9d0c52b89208c708fd6a6f3cc0531 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Fri, 22 Apr 2011 04:05:34 +0200 Subject: Make the categories work only for Xorg bugs. --- data/lib/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'data/lib/util.js') diff --git a/data/lib/util.js b/data/lib/util.js index b145d25..c2989d2 100644 --- a/data/lib/util.js +++ b/data/lib/util.js @@ -284,7 +284,7 @@ function filterByRegexp(list, chosingMark) { return chosenPair[0].addr; } else { - return ""; + return null; } } -- cgit From cb82da27fc37ebe74aa9678506e72eb1a7308ca3 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Thu, 28 Apr 2011 00:39:52 +0200 Subject: Use self.on and self.postMessage instead of global on and postMessage. The reason is https://bugzilla.mozilla.org/show_bug.cgi?id=635748 and effort to save the world from global variables in content scripts. --- data/lib/util.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'data/lib/util.js') diff --git a/data/lib/util.js b/data/lib/util.js index c2989d2..4a46403 100644 --- a/data/lib/util.js +++ b/data/lib/util.js @@ -333,7 +333,7 @@ function removeDuplicates (arr) { // ============================================ /** * object to pack messaging. Use as in - postMessage(new Message("GetPassword", { + self.postMessage(new Message("GetPassword", { login: login, hostname: location.hostname })); @@ -344,7 +344,7 @@ function Message(cmd, data) { } function log(msg) { - postMessage(new Message("LogMessage", msg)); + self.postMessage(new Message("LogMessage", msg)); } var NotLoggedinException = function NotLoggedinException (message) { -- cgit From 55d9a312fbba91f1bcf5e3f3291b7bece8abb178 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Thu, 28 Apr 2011 13:28:55 +0200 Subject: Reformatting to MoFo coding style --- data/lib/util.js | 149 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 86 insertions(+), 63 deletions(-) (limited to 'data/lib/util.js') diff --git a/data/lib/util.js b/data/lib/util.js index 4a46403..be674bc 100644 --- a/data/lib/util.js +++ b/data/lib/util.js @@ -7,16 +7,17 @@ /** * parse URL to get its parts. - * + * * @param url * @return object with all parsed parts of URL as properties - * - * Originally from http://james.padolsey.com/javascript/parsing-urls-with-the-dom/ - * Copyright February 19th, 2009, James Padolsey, - * - * This function creates a new anchor element and uses location - * properties (inherent) to get the desired URL data. Some String - * operations are used (to normalize results across browsers). + * + * Originally from + * http://james.padolsey.com/javascript/parsing-urls-with-the-dom/ Copyright + * February 19th, 2009, James Padolsey, + * + * This function creates a new anchor element and uses location properties + * (inherent) to get the desired URL data. Some String operations are used (to + * normalize results across browsers). */ function parseURL(url) { var a = document.createElement('a'); @@ -47,16 +48,19 @@ function parseURL(url) { } /** - * parse XML object out of string working around various bugs in Gecko implementation - * see https://developer.mozilla.org/en/E4X for more information - * - * @param inStr String with unparsed XML string + * parse XML object out of string working around various bugs in Gecko + * implementation see https://developer.mozilla.org/en/E4X for more information + * + * @param inStr + * String with unparsed XML string * @return XML object */ function parseXMLfromString (inStuff) { - // if (typeof inStuff !== 'string') In future we should recognize this.response + // if (typeof inStuff !== 'string') In future we should recognize + // this.response // and get just .text property out of it. TODO - var respStr = inStuff.replace(/^<\?xml\s+version\s*=\s*(["'])[^\1]+\1[^?]*\?>/, ""); // bug 336551 + var respStr = inStuff.replace(/^<\?xml\s+version\s*=\s*(["'])[^\1]+\1[^?]*\?>/, ""); // bug + // 336551 return new XML(respStr); } @@ -74,7 +78,9 @@ function getBugNo() { /** * Get a bug no from URL ... fails with aliases - * @param url String with URL to be analyzed + * + * @param url + * String with URL to be analyzed * @return String with the bug ID */ function getBugNoFromURL(url) { @@ -86,8 +92,9 @@ function getBugNoFromURL(url) { /** * Send mouse click to the specified element - * - * @param String ID of the element to send mouseclick to + * + * @param String + * ID of the element to send mouseclick to * @return None */ function clickMouse (targetID) { @@ -98,14 +105,22 @@ function clickMouse (targetID) { } /** - * Create a A element leadink nowhere, but with listener running a callback on the click - * - * @param id String with a id to be added to the element - * @param text String with a string to be added as a textContent of the element - * @param parent Node which is a parent of the object - * @param callback Function to be called after clicking on the link - * @param params Array with parameters of the callback - * @param Boolean before if there should be a
element before. + * Create a A element leadink nowhere, but with listener running a callback on + * the click + * + * @param id + * String with a id to be added to the element + * @param text + * String with a string to be added as a textContent of the element + * @param parent + * Node which is a parent of the object + * @param callback + * Function to be called after clicking on the link + * @param params + * Array with parameters of the callback + * @param Boolean + * before if there should be a
+ * element before. * @return none */ function createDeadLink (id, text, parent, callback, params, before, covered, accesskey) { @@ -156,13 +171,13 @@ function createDeadLink (id, text, parent, callback, params, before, covered, ac } /* - * From element diggs out just plain email address - * Note that bugzilla.gnome.org doesn't have mailto: url but + * From element diggs out just plain email address Note that + * bugzilla.gnome.org doesn't have mailto: url but * https://bugzilla.gnome.org/page.cgi?id=describeuser.html&login=mcepl%40redhat.com - * - * @param aElement Element with href attribute or something else - * @return String with the address or null - * + * + * @param aElement Element with href attribute or something else @return String + * with the address or null + * */ function parseMailto(aElement) { var emailStr = "", hrefStr = ""; @@ -182,7 +197,7 @@ function parseMailto(aElement) { /** * format date to be in ISO format (just day part) - * + * * @param date * @return string with the formatted date */ @@ -198,9 +213,11 @@ 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 + * + * @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. */ function isInList(mbr, list) { @@ -212,12 +229,12 @@ function isInList(mbr, list) { /** * Make sure value returned is Array - * + * * @param Array/String * @return Array - * - * If something else than Array or String is passed to the function - * the result will be untouched actual argument of the call. + * + * If something else than Array or String is passed to the function the result + * will be untouched actual argument of the call. */ function valToArray(val) { var isArr = val && @@ -228,9 +245,11 @@ function valToArray(val) { /** * Merges two comma separated string as a list and returns new string - * - * @param str String with old values - * @param value String/Array with other values + * + * @param str + * String with old values + * @param value + * String/Array with other values * @return String with merged lists */ function addCSVValue(str, value) { @@ -250,9 +269,11 @@ function addCSVValue(str, value) { /** * Treats comma separated string as a list and removes one item from it - * - * @param str String treated as a list - * @param value String with the value to be removed from str + * + * @param str + * String treated as a list + * @param value + * String with the value to be removed from str * @return String with the resulting list comma separated */ function removeCSVValue(str, value) { @@ -268,9 +289,11 @@ function removeCSVValue(str, value) { /** * select element of the array where regexp in the first element matches second * parameter of this function - * - * @param list Array with regexps and return values - * @param chosingMark String by which the element of array is to be matched + * + * @param list + * Array with regexps and return values + * @param chosingMark + * String by which the element of array is to be matched * @return Object chosen element */ function filterByRegexp(list, chosingMark) { @@ -290,14 +313,16 @@ function filterByRegexp(list, chosingMark) { /** * remove elements from the page based on their IDs - * - * @param doc Document object - * @param target String/Array with ID(s) - * @param remove Boolean indicating whether the node should be - * actually removed or just hidden. - * @return none - * TODO remove parameter could be replaced by function which would - * do actual activity. + * + * @param doc + * Document object + * @param target + * String/Array with ID(s) + * @param remove + * Boolean indicating whether the node should be actually removed or + * just hidden. + * @return none TODO remove parameter could be replaced by function which would + * do actual activity. */ function killNodes(doc, target, remove) { target = target.trim(); @@ -315,8 +340,9 @@ function killNodes(doc, target, remove) { /** * Remove duplicate elements from array - * - * @param arr Array which needs to be cleaned up + * + * @param arr + * Array which needs to be cleaned up * @return cleaned up array */ function removeDuplicates (arr) { @@ -332,11 +358,8 @@ function removeDuplicates (arr) { // ============================================ /** - * object to pack messaging. Use as in - self.postMessage(new Message("GetPassword", { - login: login, - hostname: location.hostname - })); + * object to pack messaging. Use as in self.postMessage(new + * Message("GetPassword", { login: login, hostname: location.hostname })); */ function Message(cmd, data) { this.cmd = cmd; -- cgit From 272ab432ddc4562237c7235f8e0ab8a11bad3d3d Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Fri, 29 Apr 2011 01:22:18 +0200 Subject: All XML-RPC calls are rewritten as JSON-RPC ones. * also MakeJSONRPCall is a functional call now * reorganization for dealing with the history. --- data/lib/util.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'data/lib/util.js') diff --git a/data/lib/util.js b/data/lib/util.js index be674bc..064887c 100644 --- a/data/lib/util.js +++ b/data/lib/util.js @@ -68,12 +68,8 @@ function parseXMLfromString (inStuff) { * Get a bug no */ function getBugNo() { - var bugNoElem = document.forms.namedItem('changeform').getElementsByName("id")[0]; - if (bugNoElem) { - return bugNoElem.value; - } else { - return null; - } + console.log("bugNo = " + document.getElementsByName("id")[0].value); + return document.getElementsByName("id")[0].value; } /** -- cgit From 4fea7aeaf6dc6f3687662882782658ed4b31e7e3 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Wed, 4 May 2011 17:50:28 +0200 Subject: Make filterByRegexp more tolerant to different configurations. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * filterByRegexp shouldn’t crash when list is undefined * also be more tolerant for nonexistent some RH-specific functions Fixes #91. --- data/lib/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'data/lib/util.js') diff --git a/data/lib/util.js b/data/lib/util.js index 064887c..dc927b6 100644 --- a/data/lib/util.js +++ b/data/lib/util.js @@ -294,7 +294,7 @@ function removeCSVValue(str, value) { */ function filterByRegexp(list, chosingMark) { var chosenPair = []; - if (list.length > 0) { + if (list && list.length > 0) { chosenPair = list.filter(function (pair) { return new RegExp(pair.regexp, "i").test(chosingMark); }); -- cgit From da49b6460ae02a1a1f0e86aef8f541798730a18f Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Thu, 5 May 2011 12:27:10 +0200 Subject: Make my console.myDebug configurable via about:config preference. That is the Boolean variable bugzilla-triage.setting.debug --- data/lib/util.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'data/lib/util.js') diff --git a/data/lib/util.js b/data/lib/util.js index dc927b6..11cf3bc 100644 --- a/data/lib/util.js +++ b/data/lib/util.js @@ -375,11 +375,10 @@ NotLoggedinException.prototype.toString = function () { return this.name + ': "' + this.message + '"'; }; -// Are we debugging? -var debugFlag = true; - console.myDebug = function myDebug(str) { - if (debugFlag) { - console.log(str); + if (typeof config !== "undefined") { + if (config.debuggingVerbose) { + console.log(str); + } } }; -- cgit From 8e501abd49e5aeac70a84ceef96a72b5078df221 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Sat, 7 May 2011 00:53:06 +0200 Subject: Another massive cleanup and simplification of tweak scripts. bugs on bugzilla.mozilla.org now work as well, although the history is still not shown inline, which remains for 1.1. Fixes #88 --- data/lib/util.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'data/lib/util.js') diff --git a/data/lib/util.js b/data/lib/util.js index 11cf3bc..1c3e607 100644 --- a/data/lib/util.js +++ b/data/lib/util.js @@ -160,6 +160,9 @@ function createDeadLink (id, text, parent, callback, params, before, covered, ac else if (before === "dash") { locParent.insertBefore(document.createTextNode("\u00A0-\u00A0"), newAElem); } + else if (before === "pipe") { + locParent.insertBefore(document.createTextNode("\u00A0|\u00A0"), newAElem); + } else if (before === "parens") { locParent.appendChild(document.createTextNode(")")); locParent.insertBefore(document.createTextNode("("), newAElem); -- cgit From 83fd7fd92e5b21a177bc16cc7318792cf63a343b Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Fri, 13 May 2011 12:20:05 +0200 Subject: Really Eclipseize formatting. --- data/lib/util.js | 66 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) (limited to 'data/lib/util.js') diff --git a/data/lib/util.js b/data/lib/util.js index 1c3e607..92b9436 100644 --- a/data/lib/util.js +++ b/data/lib/util.js @@ -1,5 +1,5 @@ -/*global console: false */ -/*jslint onevar: false */ +/* global console: false */ +/* jslint onevar: false */ // Released under the MIT/X11 license // http://www.opensource.org/licenses/mit-license.php "use strict"; @@ -7,14 +7,14 @@ /** * parse URL to get its parts. - * + * * @param url * @return object with all parsed parts of URL as properties - * + * * Originally from * http://james.padolsey.com/javascript/parsing-urls-with-the-dom/ Copyright * February 19th, 2009, James Padolsey, - * + * * This function creates a new anchor element and uses location properties * (inherent) to get the desired URL data. Some String operations are used (to * normalize results across browsers). @@ -30,8 +30,8 @@ function parseURL(url) { query: a.search, params: (function(){ var ret = {}, - seg = a.search.replace(/^\?/,'').split('&'), - len = seg.length, i = 0, s; + seg = a.search.replace(/^\?/,'').split('&'), + len = seg.length, i = 0, s; for (;i/, ""); // bug - // 336551 + // 336551 return new XML(respStr); } @@ -74,7 +74,7 @@ function getBugNo() { /** * Get a bug no from URL ... fails with aliases - * + * * @param url * String with URL to be analyzed * @return String with the bug ID @@ -88,7 +88,7 @@ function getBugNoFromURL(url) { /** * Send mouse click to the specified element - * + * * @param String * ID of the element to send mouseclick to * @return None @@ -103,7 +103,7 @@ function clickMouse (targetID) { /** * Create a A element leadink nowhere, but with listener running a callback on * the click - * + * * @param id * String with a id to be added to the element * @param text @@ -173,10 +173,10 @@ function createDeadLink (id, text, parent, callback, params, before, covered, ac * From element diggs out just plain email address Note that * bugzilla.gnome.org doesn't have mailto: url but * https://bugzilla.gnome.org/page.cgi?id=describeuser.html&login=mcepl%40redhat.com - * + * * @param aElement Element with href attribute or something else @return String * with the address or null - * + * */ function parseMailto(aElement) { var emailStr = "", hrefStr = ""; @@ -196,7 +196,7 @@ function parseMailto(aElement) { /** * format date to be in ISO format (just day part) - * + * * @param date * @return string with the formatted date */ @@ -206,13 +206,13 @@ function getISODate(dateStr) { } var date = new Date(dateStr); return date.getFullYear() + '-' + pad(date.getMonth() + 1) + '-' + - pad(date.getDate()); + pad(date.getDate()); } /** * 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 @@ -228,23 +228,23 @@ function isInList(mbr, list) { /** * Make sure value returned is Array - * + * * @param Array/String * @return Array - * + * * If something else than Array or String is passed to the function the result * will be untouched actual argument of the call. */ function valToArray(val) { var isArr = val && - val.constructor && - val.constructor.name === "Array"; + val.constructor && + val.constructor.name === "Array"; return isArr ? val : [val]; } /** * Merges two comma separated string as a list and returns new string - * + * * @param str * String with old values * @param value @@ -268,7 +268,7 @@ function addCSVValue(str, value) { /** * Treats comma separated string as a list and removes one item from it - * + * * @param str * String treated as a list * @param value @@ -288,7 +288,7 @@ function removeCSVValue(str, value) { /** * select element of the array where regexp in the first element matches second * parameter of this function - * + * * @param list * Array with regexps and return values * @param chosingMark @@ -312,7 +312,7 @@ function filterByRegexp(list, chosingMark) { /** * remove elements from the page based on their IDs - * + * * @param doc * Document object * @param target @@ -339,19 +339,19 @@ function killNodes(doc, target, remove) { /** * Remove duplicate elements from array - * + * * @param arr * Array which needs to be cleaned up * @return cleaned up array */ function removeDuplicates (arr) { for (var i = 0; i < arr.length; i++) { - for (var j = i + 1; j < arr.length; j++) { - if (arr[i] == arr[j]) { - arr.splice (j, 1); + for (var j = i + 1; j < arr.length; j++) { + if (arr[i] == arr[j]) { + arr.splice (j, 1); + } } } - } return arr; } @@ -361,12 +361,12 @@ function removeDuplicates (arr) { * Message("GetPassword", { login: login, hostname: location.hostname })); */ function Message(cmd, data) { - this.cmd = cmd; - this.data = data; + this.cmd = cmd; + this.data = data; } function log(msg) { - self.postMessage(new Message("LogMessage", msg)); + self.postMessage(new Message("LogMessage", msg)); } var NotLoggedinException = function NotLoggedinException (message) { -- cgit From 7509c91794f93a5b4445239429c2b918f771b543 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Tue, 19 Apr 2011 00:19:53 +0200 Subject: Working on analysis of bug-page-mod module. * Add some notes * remove getBugNumber and replaced with my getBugNo. --- data/lib/util.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'data/lib/util.js') diff --git a/data/lib/util.js b/data/lib/util.js index 92b9436..02cda2d 100644 --- a/data/lib/util.js +++ b/data/lib/util.js @@ -68,8 +68,12 @@ function parseXMLfromString (inStuff) { * Get a bug no */ function getBugNo() { - console.log("bugNo = " + document.getElementsByName("id")[0].value); - return document.getElementsByName("id")[0].value; + var bugNoElem = document.forms.namedItem('changeform').getElementsByName("id")[0]; + if (bugNoElem) { + return bugNoElem.value; + } else { + return null; + } } /** -- cgit From ffa6d74ddbf28c7fb7be1ad473847807d0301eac Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Sat, 4 Jun 2011 02:30:57 +0200 Subject: Moving ahead ... storing the progress for future. --- data/lib/util.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'data/lib/util.js') diff --git a/data/lib/util.js b/data/lib/util.js index 02cda2d..f30ddd5 100644 --- a/data/lib/util.js +++ b/data/lib/util.js @@ -68,7 +68,7 @@ function parseXMLfromString (inStuff) { * Get a bug no */ function getBugNo() { - var bugNoElem = document.forms.namedItem('changeform').getElementsByName("id")[0]; + var bugNoElem = document.forms.namedItem("changeform").elements["id"]; if (bugNoElem) { return bugNoElem.value; } else { @@ -213,6 +213,29 @@ function getISODate(dateStr) { pad(date.getDate()); } +/** + * format Date object as ISO-8601 formatted date string + * + * @param d Date + * @return String with date formatted + * @url https://developer.mozilla.org/en/JavaScript/Reference\ + /Global_Objects/Date#Example.3a_ISO_8601_formatted_dates + * outputs something like 2009-09-28T19:03:12Z + */ +function ISODateString(d) { + function pad(n) { + return n<10 ? '0'+n : n + } + + return d.getUTCFullYear()+'-' + + pad(d.getUTCMonth()+1)+'-' + + pad(d.getUTCDate())+'T' + + pad(d.getUTCHours())+':' + + pad(d.getUTCMinutes())+':' + + pad(d.getUTCSeconds())+'Z'; +} + + /** * Check whether an item is member of the list. Idea is just to make long if * commands slightly more readable. -- cgit From 75848ce166959a4e38c5191522b15e35706d3202 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Mon, 6 Jun 2011 16:14:52 +0200 Subject: Make check link working again. --- data/lib/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'data/lib/util.js') diff --git a/data/lib/util.js b/data/lib/util.js index f30ddd5..b128d48 100644 --- a/data/lib/util.js +++ b/data/lib/util.js @@ -247,7 +247,7 @@ function ISODateString(d) { * @return position of the string in the list, or -1 if none found. */ function isInList(mbr, list) { - if (!list) { + if (!Array.isArray(list)) { return false; } return (list.indexOf(mbr) !== -1); -- cgit