diff options
author | Matěj Cepl <mcepl@redhat.com> | 2011-04-28 13:28:55 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@redhat.com> | 2011-04-28 18:26:14 +0200 |
commit | 32af48e442a960b8c3f199f5ffad28a34590fcda (patch) | |
tree | c291cb97627bd2cfb65167347261d5ef8f521bfd /data/lib/util.js | |
parent | 2382ba19afc84e9b747a7981ebf72aaa704f08b6 (diff) | |
download | bugzilla-triage-32af48e442a960b8c3f199f5ffad28a34590fcda.tar.gz |
Reformatting to MoFo coding style
Diffstat (limited to 'data/lib/util.js')
-rw-r--r-- | data/lib/util.js | 149 |
1 files changed, 86 insertions, 63 deletions
diff --git a/data/lib/util.js b/data/lib/util.js index 0e3dac4..77e7bfa 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, <license undeclared> - * - * 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, <license undeclared> + * + * 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); } @@ -70,7 +74,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) { @@ -82,8 +88,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) { @@ -94,14 +101,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 <br> 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 <br> + * element before. * @return none */ function createDeadLink (id, text, parent, callback, params, before, covered, accesskey) { @@ -152,13 +167,13 @@ function createDeadLink (id, text, parent, callback, params, before, covered, ac } /* - * From <a> element diggs out just plain email address - * Note that bugzilla.gnome.org doesn't have mailto: url but + * From <a> 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 = ""; @@ -178,7 +193,7 @@ function parseMailto(aElement) { /** * format date to be in ISO format (just day part) - * + * * @param date * @return string with the formatted date */ @@ -194,9 +209,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) { @@ -208,12 +225,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 && @@ -224,9 +241,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) { @@ -246,9 +265,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) { @@ -264,9 +285,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) { @@ -286,14 +309,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(); @@ -311,8 +336,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) { @@ -328,11 +354,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; |