aboutsummaryrefslogtreecommitdiffstats
path: root/data/lib/util.js
diff options
context:
space:
mode:
Diffstat (limited to 'data/lib/util.js')
-rw-r--r--data/lib/util.js149
1 files changed, 86 insertions, 63 deletions
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, <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);
}
@@ -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 <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) {
@@ -156,13 +171,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 = "";
@@ -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;