aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/cookiemanager.js4
-rw-r--r--lib/libbugzilla.js40
-rw-r--r--lib/logger.js82
-rw-r--r--lib/main.js135
-rw-r--r--lib/prompts.js31
-rw-r--r--lib/util.js31
-rw-r--r--lib/xmlrpc.js83
7 files changed, 211 insertions, 195 deletions
diff --git a/lib/cookiemanager.js b/lib/cookiemanager.js
index 087d6ab..b777ab9 100644
--- a/lib/cookiemanager.js
+++ b/lib/cookiemanager.js
@@ -46,10 +46,10 @@ exports.getHostCookies = function getHostCookies(host) {
if (cookie.rawHost == host) {
result.push({
name: cookie.name,
- value: cookie.value,
+ value: cookie.value
});
}
}
return result;
-}
+};
diff --git a/lib/libbugzilla.js b/lib/libbugzilla.js
index 7e2398b..c85d331 100644
--- a/lib/libbugzilla.js
+++ b/lib/libbugzilla.js
@@ -38,23 +38,26 @@ function log(msg) {
}
/**
- * 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);
}
/**
- * In case URL contains alias, not the real bug number, get the real bug no
- * from the XML representation. Sets correct value to this.bugNo.
- *
+ * In case URL contains alias, not the real bug number, get the real bug no from
+ * the XML representation. Sets correct value to this.bugNo.
+ *
* This is a slow variant for bugs other than actual window
*/
function getRealBugNoSlow(bugNo, location, callback) {
@@ -141,14 +144,11 @@ exports.changeJSONURL = function changeJSONURL() {
};
/**
- *
- libbz.getInstalledPackages(msg.data, function (pkgsMsg) {
- worker.postMessage(pkgsMsg);
-
- locationLoginObj: {
- location: window.location.href,
- login: getLogin()
- }
+ *
+ * libbz.getInstalledPackages(msg.data, function (pkgsMsg) {
+ * worker.postMessage(pkgsMsg);
+ *
+ * locationLoginObj: { location: window.location.href, login: getLogin() }
*/
exports.getInstalledPackages = function getInstalledPackages(locationLoginObj, callback) {
var installedPackages = {};
@@ -283,14 +283,16 @@ exports.createUpstreamBug = function createUpstreamBug(urlStr, subject, comment)
});
};
-// Make a XML-RPC call ... most of the business logic should stay in the content script
+// Make a XML-RPC call ... most of the business logic should stay in the content
+// script
exports.makeXMLRPCCall = function makeXMLRPCCall(url, login, method, params, callback) {
var urlObj = urlMod.URL(url);
getPassword(login,
urlObj.schema + "://" + urlObj.host,
function (passwObj) {
if (!passwObj.password) {
- // TODO this should happen, only when user presses Escape in password prompt
+ // TODO this should happen, only when user presses Escape in password
+ // prompt
return null;
}
diff --git a/lib/logger.js b/lib/logger.js
index ce96f69..ed9ac47 100644
--- a/lib/logger.js
+++ b/lib/logger.js
@@ -24,8 +24,10 @@ exports.initialize = function initialize(aMap) {
};
exports.addLogRecord = function addLogRecord(rec) {
- if (myStorage.storage.logs[rec.key] && myStorage.storage.logs[rec.key].comment) {
- myStorage.storage.logs[rec.key].comment += "<br/>\n" + rec.comment;
+ if (myStorage.storage.logs[rec.key]
+ && myStorage.storage.logs[rec.key].comment) {
+ myStorage.storage.logs[rec.key].comment += "<br/>\n"
+ + rec.comment;
}
else {
myStorage.storage.logs[rec.key] = rec;
@@ -54,7 +56,7 @@ exports.importTimeSheet = function importTimeSheet() {
if (fileMod.exists(filename)) {
var otherTS = JSON.parse(fileMod.read(filename));
if (otherTS.logs) {
- for (var rec in otherTS.logs) {
+ for ( var rec in otherTS.logs) {
myStorage.storage.logs[rec] = otherTS.logs[rec];
}
}
@@ -74,27 +76,30 @@ function getBugzillaAbbr(url) {
}
exports.generateTimeSheet = function generateTimeSheet() {
- var docHTML = timeSheetRecordsPrinter(myStorage.storage.logs, new Date());
- libbz.openURLInNewTab("data:text/html;charset=utf-8," + docHTML);
-};
+ var docHTML = timeSheetRecordsPrinter(myStorage.storage.logs,
+ new Date());
+ libbz.openURLInNewTab("data:text/html;charset=utf-8,"
+ + docHTML);
+};
-var timeSheetRecordsPrinter = exports.timeSheetRecordsPrinter =
- function timeSheetRecordsPrinter(records, date) {
- var commentBugRE = new RegExp("[bB]ug\\s+([0-9]+)","g");
+var timeSheetRecordsPrinter = exports.timeSheetRecordsPrinter = function timeSheetRecordsPrinter(
+ records, date) {
+ var commentBugRE = new RegExp("[bB]ug\\s+([0-9]+)", "g");
// sort the records into temporary array
var tmpArr = [];
- var dateStr = date.getFullYear() + "-" +
- xrpc.leadingZero(date.getMonth()+1) + "-" +
- xrpc.leadingZero(date.getDate());
- var outStr = '<!DOCTYPE html>' +
- "<html><head>\n"+
- "<meta charset='utf-8'/>\n"+
- "<title>TimeSheet-"+ dateStr + "</title>\n</head>\n<body>\n" +
- "<h1>TimeSheet</h1>\n";
+ var dateStr = date.getFullYear() + "-"
+ + xrpc.leadingZero(date.getMonth() + 1) + "-"
+ + xrpc.leadingZero(date.getDate());
+ var outStr = '<!DOCTYPE html>' + "<html><head>\n"
+ + "<meta charset='utf-8'/>\n" + "<title>TimeSheet-"
+ + dateStr + "</title>\n</head>\n<body>\n"
+ + "<h1>TimeSheet</h1>\n";
- for (var i in records) {
+ for ( var i in records) {
if (records.hasOwnProperty(i)) {
- tmpArr.push( [ i, records[i] ]);
+ tmpArr.push([
+ i, records[i]
+ ]);
}
}
tmpArr.sort(function(a, b) {
@@ -112,27 +117,24 @@ var timeSheetRecordsPrinter = exports.timeSheetRecordsPrinter =
var currentDay = "";
// now print the array
tmpArr.forEach(function(rec) {
- var x = rec[1];
- var dayStr = utilMod.getISODate(x.date);
- var host = urlMod.URL(x.url).host;
- var BZName = getBugzillaAbbr(x.url);
- var bugNo = utilMod.getBugNo(x.url);
- if (dayStr != currentDay) {
- currentDay = dayStr;
- outStr += "<hr/><p><strong>" + currentDay
- + "</strong></p>\n";
- }
- // replace "bug ####" with a hyperlink to the current bugzilla
- var comment = x.comment.replace(commentBugRE,
- "<a href='http://"+host+"/show_bug.cgi?id=$1'>$&</a>");
- outStr += "<p><em><a href='"
- + x.url
- + "'>Bug "
- + BZName + "/" + bugNo + ": "
- + x.title
- + "</a>"
- + " </em>\n<br/>" + comment + "</p>\n";
+ var x = rec[1];
+ var dayStr = utilMod.getISODate(x.date);
+ var host = urlMod.URL(x.url).host;
+ var BZName = getBugzillaAbbr(x.url);
+ var bugNo = utilMod.getBugNo(x.url);
+ if (dayStr != currentDay) {
+ currentDay = dayStr;
+ outStr += "<hr/><p><strong>" + currentDay
+ + "</strong></p>\n";
+ }
+ // replace "bug ####" with a hyperlink to the current bugzilla
+ var comment = x.comment.replace(commentBugRE,
+ "<a href='http://" + host
+ + "/show_bug.cgi?id=$1'>$&</a>");
+ outStr += "<p><em><a href='" + x.url + "'>Bug " + BZName
+ + "/" + bugNo + ": " + x.title + "</a>"
+ + " </em>\n<br/>" + comment + "</p>\n";
});
outStr += "</body></html>";
return outStr;
-}
+};
diff --git a/lib/main.js b/lib/main.js
index 849da68..f3e9458 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -23,13 +23,13 @@ function isOurPage(window, matchingURLs) {
var url = window.location.href;
// like ["regexp-url1", "regexp-url2"]
- return matchingURLs.some(function (element,i,a) {
+ return matchingURLs.some(function(element, i, a) {
return new RegExp(element).test(url);
});
}
/**
- *
+ *
*/
function skipThisPage(doc) {
var stemURL = "https://HOSTNAME/show_bug.cgi?id=";
@@ -39,20 +39,21 @@ function skipThisPage(doc) {
var hostname = doc.location.hostname;
if (REArr) {
var bugNo = REArr[1];
- doc.location = stemURL.replace("HOSTNAME",hostname) + bugNo;
+ doc.location = stemURL.replace("HOSTNAME", hostname) + bugNo;
}
}
-var messageHandler = exports.messageHandler = function messageHandler(worker, msg) {
+var messageHandler = exports.messageHandler = function messageHandler(
+ worker, msg) {
switch (msg.cmd) {
case "LogMessage":
console.log(msg.data);
break;
case "ExecCmd":
- libbz.executeCommand(msg.data);
+ libbz.executeCommand(msg.data);
break;
case "AddLogRecord":
- logger.addLogRecord(msg.data);
+ logger.addLogRecord(msg.data);
break;
case "GenerateTS":
logger.generateTimeSheet();
@@ -65,12 +66,12 @@ var messageHandler = exports.messageHandler = function messageHandler(worker, ms
break;
case "GetInstalledPackages":
// send message with packages back
- libbz.getInstalledPackages(msg.data, function (pkgsMsg) {
+ libbz.getInstalledPackages(msg.data, function(pkgsMsg) {
worker.postMessage(pkgsMsg);
});
break;
case "GetClipboard":
- libbz.getClipboard(function (clipboard) {
+ libbz.getClipboard(function(clipboard) {
worker.postMessage(new Message(msg.data, clipboard));
});
break;
@@ -91,18 +92,23 @@ var messageHandler = exports.messageHandler = function messageHandler(worker, ms
break;
case "MakeXMLRPCall":
// url, login, method, params, callback
- libbz.makeXMLRPCCall(msg.data.url, msg.data.login, msg.data.method,
- msg.data.params, function(ret) {
- worker.postMessage(new Message(msg.data.callRPC, ret));
- });
+ libbz
+ .makeXMLRPCCall(msg.data.url, msg.data.login,
+ msg.data.method, msg.data.params, function(ret) {
+ worker.postMessage(new Message(msg.data.callRPC,
+ ret));
+ });
break;
case "GetURL":
- libbz.getURL(msg.data.url, function(stuff) {
- worker.postMessage(new Message(msg.data.backMessage, stuff));
- });
+ libbz.getURL(msg.data.url,
+ function(stuff) {
+ worker.postMessage(new Message(msg.data.backMessage,
+ stuff));
+ });
break;
case "OpenBugUpstream":
- libbz.createUpstreamBug(msg.data.url, msg.data.subject, msg.data.comment);
+ libbz.createUpstreamBug(msg.data.url, msg.data.subject,
+ msg.data.comment);
break;
case "testReady":
// we ignore it here, interesting only in unit test
@@ -113,36 +119,36 @@ var messageHandler = exports.messageHandler = function messageHandler(worker, ms
};
var contentScriptLibraries = [
- self.data.url('lib/urltest.js'),
- self.data.url("lib/util.js"),
- self.data.url("lib/jumpNextBug.js"),
- self.data.url("lib/queries.js"),
- self.data.url("lib/preprocessDuplicates.js"),
- self.data.url("lib/viewSource.js"),
- self.data.url("lib/color.js"),
- self.data.url("lib/addNewLinks.js"),
- self.data.url("lib/bugzillaDOMFunctions.js"),
- self.data.url("lib/xorgBugCategories.js"),
- self.data.url("lib/otherButtons.js"),
- self.data.url("lib/makeBacktraceAttachment.js"),
- self.data.url("lib/fixingAttMIME.js"),
- self.data.url("lib/logging-front.js"),
- self.data.url('lib/bug-page-mod.js'),
- self.data.url("lib/rhbzpage.js"),
- self.data.url("lib/bzpage.js")
+ self.data.url('lib/urltest.js'),
+ self.data.url("lib/util.js"),
+ self.data.url("lib/jumpNextBug.js"),
+ self.data.url("lib/queries.js"),
+ self.data.url("lib/preprocessDuplicates.js"),
+ self.data.url("lib/viewSource.js"),
+ self.data.url("lib/color.js"),
+ self.data.url("lib/addNewLinks.js"),
+ self.data.url("lib/bugzillaDOMFunctions.js"),
+ self.data.url("lib/xorgBugCategories.js"),
+ self.data.url("lib/otherButtons.js"),
+ self.data.url("lib/makeBacktraceAttachment.js"),
+ self.data.url("lib/fixingAttMIME.js"),
+ self.data.url("lib/logging-front.js"),
+ self.data.url('lib/bug-page-mod.js'),
+ self.data.url("lib/rhbzpage.js"),
+ self.data.url("lib/bzpage.js")
];
-libbz.initialize(libbz.config, function () {
+libbz.initialize(libbz.config, function() {
pageMod.PageMod({
- include: [
- "https://bugzilla.redhat.com/show_bug.cgi?id=*",
- "https://bugzilla.mozilla.org/show_bug.cgi?id=*",
- "https://bugzilla.gnome.org/show_bug.cgi?id=*"
+ include : [
+ "https://bugzilla.redhat.com/show_bug.cgi?id=*",
+ "https://bugzilla.mozilla.org/show_bug.cgi?id=*",
+ "https://bugzilla.gnome.org/show_bug.cgi?id=*"
],
- contentScriptWhen: 'ready',
- contentScriptFile: contentScriptLibraries,
- onAttach: function onAttach(worker, msg) {
- worker.on('message', function (msg) {
+ contentScriptWhen : 'ready',
+ contentScriptFile : contentScriptLibraries,
+ onAttach : function onAttach(worker, msg) {
+ worker.on('message', function(msg) {
messageHandler(worker, msg);
});
}
@@ -150,34 +156,37 @@ libbz.initialize(libbz.config, function () {
});
pageMod.PageMod({
- include: [
- "https://bugzilla.redhat.com/process_bug.cgi",
- "https://bugzilla.redhat.com/post_bug.cgi",
- "https://bugzilla.redhat.com/attachment.cgi",
- "https://bugzilla.mozilla.org/process_bug.cgi",
- "https://bugzilla.mozilla.org/post_bug.cgi",
- "https://bugzilla.mozilla.org/attachment.cgi",
- "https://bugzilla.gnome.org/process_bug.cgi",
- "https://bugzilla.gnome.org/post_bug.cgi",
- "https://bugzilla.gnome.org/attachment.cgi"
+ include : [
+ "https://bugzilla.redhat.com/process_bug.cgi",
+ "https://bugzilla.redhat.com/post_bug.cgi",
+ "https://bugzilla.redhat.com/attachment.cgi",
+ "https://bugzilla.mozilla.org/process_bug.cgi",
+ "https://bugzilla.mozilla.org/post_bug.cgi",
+ "https://bugzilla.mozilla.org/attachment.cgi",
+ "https://bugzilla.gnome.org/process_bug.cgi",
+ "https://bugzilla.gnome.org/post_bug.cgi",
+ "https://bugzilla.gnome.org/attachment.cgi"
],
- contentScriptWhen: 'ready',
- contentScriptFile: self.data.url("lib/skip-bug.js")
+ contentScriptWhen : 'ready',
+ contentScriptFile : self.data.url("lib/skip-bug.js")
});
-
// Allow toggling of CC event displays using a context menu entry
contextMenu.Item({
- label: "Toggle CC History",
- contentScriptFile: [self.data.url('lib/urltest.js'),
- self.data.url('lib/cc-context.js')]
+ label : "Toggle CC History",
+ contentScriptFile : [
+ self.data.url('lib/urltest.js'),
+ self.data.url('lib/cc-context.js')
+ ]
});
contextMenu.Item({
- label: "Copy Check-in Comment",
- contentScriptFile: [self.data.url('lib/urltest.js'),
- self.data.url('lib/checkin-context.js')],
- onMessage: function (comment) {
- require("clipboard").set(comment);
+ label : "Copy Check-in Comment",
+ contentScriptFile : [
+ self.data.url('lib/urltest.js'),
+ self.data.url('lib/checkin-context.js')
+ ],
+ onMessage : function(comment) {
+ require("clipboard").set(comment);
}
});
diff --git a/lib/prompts.js b/lib/prompts.js
index 7cfd3d1..3f34e0d 100644
--- a/lib/prompts.js
+++ b/lib/prompts.js
@@ -11,23 +11,23 @@ var promptTitle = "Bugzilla Triage Script";
/**
* shows the text in a simple window
- *
+ *
* @return none
*/
exports.alert = function alert(msg) {
var prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"]
- .getService(Ci.nsIPromptService);
+ .getService(Ci.nsIPromptService);
prompts.alert(null, promptTitle, msg);
};
/**
* general prompts for a string method
- *
+ *
* @return String with the password
*/
exports.prompt = function prompt(prompt, defaultValue) {
var stringValue = {
- value: defaultValue ? defaultValue : ""
+ value : defaultValue ? defaultValue : ""
};
var prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"]
@@ -44,7 +44,7 @@ exports.prompt = function prompt(prompt, defaultValue) {
/**
* returns password with a special password
- *
+ *
* @return String with the password
*/
exports.promptPassword = function promptPassword(prompt) {
@@ -59,8 +59,8 @@ exports.promptPassword = function promptPassword(prompt) {
var check = {
value : true
}; // default the checkbox to true
- var result = prompts.promptPassword(null, "Bugzilla Triage Script", prompt,
- password, null, check);
+ var result = prompts.promptPassword(null,
+ "Bugzilla Triage Script", prompt, password, null, check);
// result is true if OK was pressed, false if cancel was pressed.
// password.value is set if OK was pressed.
// The checkbox is not displayed.
@@ -83,8 +83,9 @@ exports.promptYesNoCancel = function promptOKNoCancel(prompt) {
var prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Ci.nsIPromptService);
- var result = prompts.confirmEx(null, "Bugzilla Triage Script", prompt,
- prompts.STD_YES_NO_BUTTONS, null, null, null, null, {});
+ var result = prompts.confirmEx(null, "Bugzilla Triage Script",
+ prompt, prompts.STD_YES_NO_BUTTONS, null, null, null,
+ null, {});
if (result === 0) {
return true;
}
@@ -97,22 +98,22 @@ exports.promptYesNoCancel = function promptOKNoCancel(prompt) {
};
/**
- *
+ *
* documentation is https://developer.mozilla.org/en/NsIFilePicker
*/
-exports.promptFileOpenPicker = function promptFilePicker (win) {
+exports.promptFileOpenPicker = function promptFilePicker(win) {
var window = require("window-utils").activeWindow;
var fp = Cc["@mozilla.org/filepicker;1"]
- .createInstance(Ci.nsIFilePicker);
+ .createInstance(Ci.nsIFilePicker);
fp.init(window, "JSON File Open", Ci.nsIFilePicker.modeOpen);
fp.appendFilter("JSON files", "*.json");
fp.appendFilters(Ci.nsIFilePicker.filterAll);
fp.filterIndex = 0;
var res = fp.show();
- if (res === Ci.nsIFilePicker.returnOK ||
- res === Ci.nsIFilePicker.returnReplace ) {
- return fp.file.path;
+ if (res === Ci.nsIFilePicker.returnOK
+ || res === Ci.nsIFilePicker.returnReplace) {
+ return fp.file.path;
}
return null;
};
diff --git a/lib/util.js b/lib/util.js
index d28f001..008d6fb 100644
--- a/lib/util.js
+++ b/lib/util.js
@@ -11,7 +11,7 @@ var urlMod = require("url");
/**
* get parameters of URL as an object (name, value)
*/
-function getParamsFromURL (url, base) {
+function getParamsFromURL(url, base) {
if (!url || (url.toString().length === 0)) {
throw new Error("Missing URL value!");
}
@@ -23,7 +23,7 @@ function getParamsFromURL (url, base) {
var paramsArr = url.path.split("?");
if (paramsArr.length === 1) {
return {};
- }
+ }
// get convert URL parameters to an Object
var params = {}, s = [];
@@ -35,11 +35,11 @@ function getParamsFromURL (url, base) {
}
/**
- * Get a bug no from URL ... fails with aliases
- * It should theoretically belong to bzpage.js, but we don't have
- * unit tests there yet, so keeping here.
- *
- * @param url String with URL to be analyzed
+ * Get a bug no from URL ... fails with aliases It should theoretically belong
+ * to bzpage.js, but we don't have unit tests there yet, so keeping here.
+ *
+ * @param url
+ * String with URL to be analyzed
* @return String with the bug ID (hopefully number, but not for aliases)
*/
exports.getBugNo = function getBugNo(url) {
@@ -51,7 +51,7 @@ exports.getBugNo = function getBugNo(url) {
/**
* format date to be in ISO format (just day part)
- *
+ *
* @param date
* @return string with the formatted date
*/
@@ -60,18 +60,15 @@ exports.getISODate = function getISODate(dateStr) {
return n < 10 ? '0' + n : n;
}
var date = new Date(dateStr);
- return date.getFullYear() + '-' + pad(date.getMonth() + 1) + '-' +
- pad(date.getDate());
+ 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
- }));
+ * 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;
+ this.cmd = cmd;
+ this.data = data;
};
diff --git a/lib/xmlrpc.js b/lib/xmlrpc.js
index e038c4e..3991b04 100644
--- a/lib/xmlrpc.js
+++ b/lib/xmlrpc.js
@@ -3,41 +3,44 @@
// Modification of Matěj Cepl released under the MIT/X11 license
// http://www.opensource.org/licenses/mit-license.php
/*
- *
+ *
* xmlrpc.js beta version 1 Tool for creating XML-RPC formatted requests in
* JavaScript
- *
+ *
* Copyright 2001 Scott Andrew LePera scott@scottandrew.com
- *
- *
+ *
+ *
* License: You are granted the right to use and/or redistribute this code only
* if this license and the copyright notice are included and you accept that no
* warranty of any kind is made or implied by the author.
- *
+ *
*/
/**
* checks whether parameter is an array
- *
- * @param obj Object
+ *
+ * @param obj
+ * Object
* @return Boolean true if obj is array
- *
+ *
* The problem is that in different contexts, Array is not same, and so obj is
* not an instance of SAME Array.
*/
/**
* pads a single number with a leading zero. Heh.
- *
- * @param n String or Number
+ *
+ * @param n
+ * String or Number
* @return String with leading zero added if necessary
- *
+ *
* If the real parameter is not numerical, it is just returned as it is.
*/
var leadingZero = exports.leadingZero = function leadingZero(n) {
if (isNaN(Number(n))) {
return n;
- };
+ }
+ ;
var s = "0" + n;
if (s.length > 2) {
@@ -46,22 +49,24 @@ var leadingZero = exports.leadingZero = function leadingZero(n) {
return s;
};
-var dateToISO8601 = exports.dateToISO8601 = function dateToISO8601(date) {
+var dateToISO8601 = exports.dateToISO8601 = function dateToISO8601(
+ date) {
// wow I hate working with the Date object
console.log("date = " + date);
var year = date.getYear();
var month = leadingZero(date.getMonth());
var day = leadingZero(date.getDate());
- var time = leadingZero(date.getHours()) +
- ":" + leadingZero(date.getMinutes()) +
- ":" + leadingZero(date.getSeconds());
+ var time = leadingZero(date.getHours()) + ":"
+ + leadingZero(date.getMinutes()) + ":"
+ + leadingZero(date.getSeconds());
var converted = year + month + day + "T" + time;
console.log("date = " + converted);
return converted;
};
-var XMLRPCMessage = exports.XMLRPCMessage = function XMLRPCMessage(methodname) {
+var XMLRPCMessage = exports.XMLRPCMessage = function XMLRPCMessage(
+ methodname) {
this.method = methodname || "system.listMethods";
this.params = [];
return this;
@@ -71,20 +76,19 @@ XMLRPCMessage.prototype.myIsArray = function myIsArray(obj) {
return (typeof obj.sort === 'function');
};
-
-XMLRPCMessage.prototype.setMethod = function (methodName) {
+XMLRPCMessage.prototype.setMethod = function(methodName) {
if (methodName !== undefined) {
this.method = methodName;
}
};
-XMLRPCMessage.prototype.addParameter = function (data) {
+XMLRPCMessage.prototype.addParameter = function(data) {
if (data !== undefined) {
this.params.push(data);
}
};
-XMLRPCMessage.prototype.xml = function () {
+XMLRPCMessage.prototype.xml = function() {
var method = this.method;
@@ -97,11 +101,11 @@ XMLRPCMessage.prototype.xml = function () {
xml += "<params>\n";
// do individual parameters
- this.params.forEach(function (data) {
+ this.params.forEach(function(data) {
xml += "<param>\n";
- xml += "<value>" +
- this.getParamXML(this.dataTypeOf(data),
- data) + "</value>\n";
+ xml += "<value>"
+ + this.getParamXML(this.dataTypeOf(data), data)
+ + "</value>\n";
xml += "</param>\n";
}, this);
xml += "</params>\n";
@@ -110,7 +114,7 @@ XMLRPCMessage.prototype.xml = function () {
return xml; // for now
};
-XMLRPCMessage.prototype.dataTypeOf = function (o) {
+XMLRPCMessage.prototype.dataTypeOf = function(o) {
// identifies the data type
var type = typeof (o);
type = type.toLowerCase();
@@ -138,49 +142,50 @@ XMLRPCMessage.prototype.dataTypeOf = function (o) {
return type;
};
-XMLRPCMessage.prototype.doValueXML = function (type, data) {
+XMLRPCMessage.prototype.doValueXML = function(type, data) {
var xml = "<" + type + ">" + data + "</" + type + ">";
return xml;
};
-XMLRPCMessage.prototype.doBooleanXML = function (data) {
+XMLRPCMessage.prototype.doBooleanXML = function(data) {
var value = (data === true) ? 1 : 0;
var xml = "<boolean>" + value + "</boolean>";
return xml;
};
-XMLRPCMessage.prototype.doDateXML = function (data) {
+XMLRPCMessage.prototype.doDateXML = function(data) {
var xml = "<dateTime.iso8601>";
xml += dateToISO8601(data);
xml += "</dateTime.iso8601>";
return xml;
};
-XMLRPCMessage.prototype.doArrayXML = function (data) {
+XMLRPCMessage.prototype.doArrayXML = function(data) {
var xml = "<array><data>\n";
- for (var i = 0; i < data.length; i++) {
- xml += "<value>" +
- this.getParamXML(this.dataTypeOf(data[i]),
- data[i]) + "</value>\n";
+ for ( var i = 0; i < data.length; i++) {
+ xml += "<value>"
+ + this.getParamXML(this.dataTypeOf(data[i]), data[i])
+ + "</value>\n";
}
xml += "</data></array>\n";
return xml;
};
-XMLRPCMessage.prototype.doStructXML = function (data) {
+XMLRPCMessage.prototype.doStructXML = function(data) {
var xml = "<struct>\n";
- for (var i in data) {
+ for ( var i in data) {
xml += "<member>\n";
xml += "<name>" + i + "</name>\n";
- xml += "<value>" + this.getParamXML(this.dataTypeOf(data[i]),
- data[i]) + "</value>\n";
+ xml += "<value>"
+ + this.getParamXML(this.dataTypeOf(data[i]), data[i])
+ + "</value>\n";
xml += "</member>\n";
}
xml += "</struct>\n";
return xml;
};
-XMLRPCMessage.prototype.getParamXML = function (type, data) {
+XMLRPCMessage.prototype.getParamXML = function(type, data) {
var xml;
switch (type) {
case "date":