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.js33
1 files changed, 30 insertions, 3 deletions
diff --git a/data/lib/util.js b/data/lib/util.js
index 92b9436..b128d48 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").elements["id"];
+ if (bugNoElem) {
+ return bugNoElem.value;
+ } else {
+ return null;
+ }
}
/**
@@ -210,6 +214,29 @@ function getISODate(dateStr) {
}
/**
+ * 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.
*
@@ -220,7 +247,7 @@ function getISODate(dateStr) {
* @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);