diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libbugzilla.js | 178 | ||||
-rw-r--r-- | lib/logger.js | 131 | ||||
-rw-r--r-- | lib/main.js | 154 | ||||
-rw-r--r-- | lib/passwords.js | 1 | ||||
-rw-r--r-- | lib/prompts.js | 3 | ||||
-rw-r--r-- | lib/util.js | 14 | ||||
-rw-r--r-- | lib/xmlrpc.js | 1 |
7 files changed, 294 insertions, 188 deletions
diff --git a/lib/libbugzilla.js b/lib/libbugzilla.js index 14fd675..6d556a4 100644 --- a/lib/libbugzilla.js +++ b/lib/libbugzilla.js @@ -1,4 +1,3 @@ -/*jslint rhino: true, forin: true, onevar: false, browser: true, evil: true, laxbreak: true, undef: true, nomen: true, eqeqeq: false, bitwise: true, maxerr: 1000, immed: false, white: false, plusplus: false, regexp: false, undef: false */ // Released under the MIT/X11 license // http://www.opensource.org/licenses/mit-license.php // @@ -7,17 +6,23 @@ var preferences = require("preferences-service"); var prompts = require("prompts"); var clipboard = require("clipboard"); var tabs = require("tabs"); -//var logger = require("logger"); +var logger = require("logger"); var passUtils = require("passwords"); var Request = require("request").Request; var selfMod = require("self"); var urlMod = require("url"); +var dataUtils = require("utils/data"); +var xrpc = require("xmlrpc"); +var panelMod = require("panel"); var JSONURLDefault = "https://fedorahosted.org/released"+ "/bugzilla-triage-scripts/Config_data.json"; var BTSPrefNS = "bugzilla-triage.setting."; var BTSPassRealm = "BTSXMLRPCPass"; +var passwords = {}; // hash of passwords indexed by a hostname +var config = exports.config = {}; + function Message(cmd, data) { console.log("Message: cmd = " + cmd + ", data = " + data); this.cmd = cmd; @@ -46,13 +51,9 @@ function parseXMLfromString (inStuff) { * 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. * - * somewhere in RPC functions which need it, we should have - * if (isNAN(parseInt(bugNo, 10))) { - * getRealBugNo(bugNo, location, callback); - * } - * Or not + * This is a slow variant for bugs other than actual window */ -function getRealBugNo(bugNo, location, callback) { +function getRealBugNoSlow(bugNo, location, callback) { console.log("We have to deal with bug aliased as " + this.bugNo); // https://bugzilla.redhat.com/show_bug.cgi?ctype=xml&id=serialWacom Request({ @@ -72,22 +73,21 @@ function getRealBugNo(bugNo, location, callback) { }).get(); } -exports.getPassword = function getPassword(login, domain, callback) { +function getPassword(login, domain) { var passPrompt = "Enter your Bugzilla password for fixing MIME attachment types"; var switchPrompt = "Do you want to switch off features requiring password completely"; var prefName = BTSPrefNS+"withoutPassowrd"; - var domain = window.location.protocol + "//" + window.location.hostname; var pass = passUtils.getPassword(login, domain, BTSPassRealm); var retObject = { - password: null, - withoutPass: false + password: null, // password string or null if no password provided + withoutPass: false // whether user doesn't want to use password at all }; // pass === null means no appropriate password in the storage if (!preferences.get(prefName,false) && (pass === null)) { - passwordText = prompts.promptPassword(passPrompt); + var passwordText = prompts.promptPassword(passPrompt); if (passwordText && passwordText.length > 0) { passUtils.setLogin(login, passwordText, domain, BTSPassRealm); @@ -102,8 +102,8 @@ exports.getPassword = function getPassword(login, domain, callback) { } else { retObject.password = pass; } - callback(new Message("RetPassword", retObject)); -}; + return retObject; +} exports.changeJSONURL = function changeJSONURL() { var prfNm = BTSPrefNS+"JSONURL"; @@ -121,18 +121,21 @@ exports.changeJSONURL = function changeJSONURL() { * libbz.getInstalledPackages(msg.data, function (pkgsMsg) { worker.postMessage(pkgsMsg); + + locationLoginObj: { + location: window.location.href, + login: getLogin() + } */ -exports.getInstalledPackages = function getInstalledPackages(location, config, callback) { +exports.getInstalledPackages = function getInstalledPackages(locationLoginObj, callback) { var installedPackages = {}; var enabledPackages = []; + var location = locationLoginObj.location; if (typeof location == "string") { location = new urlMod.URL(location); } - console.log("location = " + location); - console.log("typeof location = " + typeof location); - // Collect enabled packages per hostname (plus default ones) if (config.gJSONData && ("commentPackages" in config.gJSONData)) { if ("enabledPackages" in config.gJSONData.configData) { @@ -172,30 +175,117 @@ exports.getInstalledPackages = function getInstalledPackages(location, config, c } } + if (config.gJSONData.commentStrings && + "sentUpstreamString" in config.gJSONData.commentStrings) { + config.constantData.commentStrings = {}; + config.constantData.commentStrings.sentUpstreamString = + config.gJSONData.commentStrings["sentUpstreamString"]; + } + + var locURL = new urlMod.URL(locationLoginObj.location); + var passDomain = locURL.scheme + "://" + locURL.host; + var passwObj = getPassword(locationLoginObj.login, passDomain); + // In order to avoid sending whole password to the content script, + // we are sending just these two Booleans. + config.constantData.passwordState = { + passAvailable: (passwObj.password !== null), + withoutPass: passwObj.withoutPass + }; + callback(new Message("CreateButtons", { instPkgs: installedPackages, constData: config.constantData, + config: config.configData, kNodes: config.gJSONData.configData.killNodes })); }; -exports.getClipboard = function getClipboard(command, cb) { - cb(new Message("RetClipboard", { - text: clipboard.get(), - cmd: command - })); +exports.getClipboard = function getClipboard(cb) { + cb(clipboard.get()); +}; + +exports.setClipboard = function setClipboard(stuff) { + clipboard.set(stuff, "text"); +}; + +exports.getURL = function getURL(url, callback) { + Request({ + url: url, + onComplete: function(response) { + if (response.status == 200) { + callback(response.text); + } + } + }).get(); +}; + +exports.openStringInNewPanel = function openStringInNewPanel(inHTMLStr) { + openURLInNewPanel("data:text/html;charset=utf-8," + + inHTMLStr); }; -exports.openURLinNewTab = function openURLinNewTab(urlStr) { +var openURLInNewPanel = exports.openURLInNewPanel = function openURLInNewPanel(url) { + var panel = panelMod.Panel({ + contentURL: url, + width: 640, + height: 640 + }); + panel.show(); +}; + +var openURLInNewTab = exports.openURLInNewTab = function openURLInNewTab(url) { + tabs.open({ + url: url, + inBackground: true, + onReady: function(t) { + t.activate(); + } + }); +}; + +exports.createUpstreamBug = function createUpstreamBug(urlStr, subject, comment) { tabs.open({ url: urlStr, inBackground: true, onReady: function (t) { + var otherElems = t.contentDocument.forms.namedItem("Create").elements; + // Summary + otherElems.namedItem("short_desc").value = subject; + // Comment + otherElems.namedItem("comment").value = collectComments(); t.activate(); } }); }; +// 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); + var passwObj = getPassword(login, urlObj.schema + "://" + urlObj.host); + if (!passwObj.password) { + return null; // TODO this should happen, only when user presses Escape in password prompt + } + + var msg = new xrpc.XMLRPCMessage(method); + params.forEach(function (par) { + msg.addParameter(par); + }); + msg.addParameter(login); + msg.addParameter(passwObj.password); + + Request({ + url: url, + onComplete: function(response) { + if (response.status == 200) { + var resp = parseXMLfromString(response.text); + callback(resp.toXMLString()); + } + }, + content: msg.xml(), + contentType: "text/xml" + }).post(); +}; + exports.initialize = function initialize(config, callback) { var prefName = BTSPrefNS+"JSONURL"; var urlStr = ""; @@ -229,56 +319,52 @@ exports.initialize = function initialize(config, callback) { url: url, onComplete: function(response) { if (response.status == 200) { - config.gJSONData.constantData[title] = response.json; + config.constantData[title] = response.json; } } }).get(); }); } - // config.logger = new logger.Logger(JSON.parse(self.data.load("bugzillalabelAbbreviations.json"))); - - config.matches = config.gJSONData.configData.matches; - config.skipMatches = config.matches.map(function(x) { + config.configData = {}; + config.configData.matches = config.gJSONData.configData.matches; + config.configData.skipMatches = config.configData.matches.map(function(x) { return x.replace("show_bug.cgi.*","((process|post)_bug|attachment)\.cgi$"); }); - config.objConstructor = {}; - // var bzType = config.gJSONData.configData.objectStyle; - // if (bzType === "RH") { - // config.objConstructor = require("rhbzpage").RHBugzillaPage; - // } else if (bzType === "MoFo") { - // } - // config.objConstructor = require("mozillabzpage").MozillaBugzilla; - - // callback(config); - config.constantData = {}; - // TODO this is important and missing if ("constantData" in config.gJSONData) { config.constantData = config.gJSONData.constantData; config.constantData.queryUpstreamBug = JSON.parse( selfMod.data.load("queryUpstreamBug.json")); config.constantData.XMLRPCData = JSON.parse( selfMod.data.load("XMLRPCdata.json")); + config.constantData.bugzillaLabelNames = + JSON.parse(selfMod.data.load("bugzillalabelNames.json")); + config.constantData.newUpstreamBug = + JSON.parse(selfMod.data.load("newUpstreamBug.json")); + config.constantData.ProfessionalProducts = + JSON.parse(selfMod.data.load("professionalProducts.json")); } if ("CCmaintainer" in config.constantData) { - config.defBugzillaMaintainerArr = config.constantData.CCmaintainer; + config.configData.defBugzillaMaintainerArr = config.constantData.CCmaintainer; } if ("suspiciousComponents" in config.gJSONData.configData) { - config.suspiciousComponents = config.gJSONData.configData.suspiciousComponents; + config.configData.suspiciousComponents = + config.gJSONData.configData.suspiciousComponents; } if ("XorgLogAnalysis" in config.gJSONData.configData) { - config.xorglogAnalysis = config.gJSONData.configData.XorgLogAnalysis; + config.configData.xorglogAnalysis = + config.gJSONData.configData.XorgLogAnalysis; } if ("submitsLogging" in config.gJSONData.configData && config.gJSONData.configData.submitsLogging) { - // config.log = config.logger; - // FIXME this.setUpLogging(); + logger.initialize(JSON.parse(selfMod.data.load( + "bugzillalabelAbbreviations.json"))); } } callback(); diff --git a/lib/logger.js b/lib/logger.js index 659faac..08ef87a 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -9,61 +9,47 @@ var prompts = require("prompts"); var apiUtils = require("api-utils"); var xrpc = require("xmlrpc"); var myStorage = require("simple-storage"); +var libbz = require("libbugzilla"); -exports.addLogRecord = function addLogRecord(rec) { - if (myStorage.storage.logs[rec.key]) { - myStorage.storage.logs[rec.key].comment += "<br/>\n" + comment; - } else { - myStorage.storage.logs[rec.key] = rec; - } -}; - -exports.generateTimeSheet = function generateTimeSheet() { - ; // FIXME -}; +var EmptyLogsColor = "rgb(0, 255, 0)"; +var FullLogsColor = "rgb(0, 40, 103)"; -exports.clearTimeSheet = function clearTimeSheet() { - ; // FIXME -}; - -exports.importTimeSheet = function importTimeSheet() { - ; /* FIXME - jsonPaths = prompts.promptFileOpenPicker(that.win); - that.log.importOtherStore(jsonPaths, clearLogAElem); - */ -}; - -var Logger = exports.Logger = function Logger(abbsMap) { - this.EmptyLogsColor = rgb(0, 255, 0); - this.FullLogsColor = rgb(0, 40, 103); +var abbsMap = {}; +exports.initialize = function initialize(aMap) { if (!myStorage.storage.logs) { myStorage.storage.logs = {}; } + abbsMap = aMap; +}; - this.abbsMap = abbsMap; +exports.addLogRecord = function addLogRecord(rec) { + if (myStorage.storage.logs[rec.key]) { + myStorage.storage.logs[rec.key].comment += "<br/>\n" + comment; + } else { + myStorage.storage.logs[rec.key] = rec; + } }; -Logger.prototype.size = function size() { +function storeSize() { var size = 0, key; for (key in myStorage.storage.logs) { size++; } return size; -}; +} -Logger.prototype.isEmpty = function isEmpty() { - return (this.size() === 0); -}; +function isEmpty() { + return (storeSize() === 0); +} -Logger.prototype.clearStore = function clearStore(clearLink) { +exports.clearTimeSheet = function clearTimeSheet() { myStorage.storage.logs = {}; - var size = this.size(); - clearLink.style.color = this.EmptyLogsColor; - clearLink.style.fontWeight = "normal"; + var size = storeSize(); }; -Logger.prototype.importOtherStore = function importOtherStore (filename, clearLink) { +exports.importTimeSheet = function importTimeSheet() { + var filename = prompts.promptFileOpenPicker(); if (fileMod.exists(filename)) { var otherTS = JSON.parse(fileMod.read(filename)); if (otherTS.logs) { @@ -76,32 +62,42 @@ Logger.prototype.importOtherStore = function importOtherStore (filename, clearLi } else { console.error("File " + filename + " doesn't exist!"); } - if (this.size() > 0) { - clearLink.style.color = this.FullLogsColor; - clearLink.style.fontWeight = "bolder"; - } }; -Logger.prototype.getBugzillaAbbr = function(url) { +function getBugzillaAbbr(url) { // for https://bugzilla.redhat.com/show_bug.cgi?id=579123 get RH // for https://bugzilla.mozilla.org/show_bug.cgi?id=579123 get MoFo - var abbr = this.abbsMap[urlMod.URL(url).host]; - return abbr; -}; + return abbsMap[urlMod.URL(url).host]; +} + +exports.generateTimeSheet = function generateTimeSheet() { + var docHTML = timeSheetRecordsPrinter(myStorage.storage.logs); + libbz.openURLInNewTab("data:text/html;charset=utf-8," + docHTML); +}; -Logger.prototype.timeSheetRecordsPrinter = function(body, records) { - var that = this; +function timeSheetRecordsPrinter(records) { var commentBugRE = new RegExp("[bB]ug\\s+([0-9]+)","g"); // sort the records into temporary array var tmpArr = []; + var outStr = '<!DOCTYPE html PUBLIC "-//IETF//DTD HTML 2.0//EN">' + + "<html><head>\n"+ + "<meta http-equiv='Content-type' content='text/html;charset=utf-8'/>\n"+ + "<title>Status report</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.sort(function(a, b) { - return a[0] > b[0] ? 1 : -1; + if (a[0] > b[0]) { + return 1; + } else if (a[0] < b[0]) { + return -1; + } else { + return 0; + } }); var currentDay = ""; @@ -110,47 +106,24 @@ Logger.prototype.timeSheetRecordsPrinter = function(body, records) { var x = rec[1]; var dayStr = utilMod.getISODate(x.date); var host = urlMod.URL(x.url).host; - var BZName = that.getBugzillaAbbr(x.url); + var BZName = getBugzillaAbbr(x.url); var bugNo = utilMod.getBugNo(x.url); if (dayStr != currentDay) { currentDay = dayStr; - body.innerHTML += "<hr/><p><strong>" + currentDay - + "</strong></p>"; + 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>"); - body.innerHTML += "<p><em><a href='" + outStr += "<p><em><a href='" + x.url + "'>Bug " + BZName + "/" + bugNo + ": " + x.title + "</a>" - + " </em>\n<br/>" + comment + "</p>"; - }); - }; - -/** - * - */ -Logger.prototype.createBlankPage = function (ttl, bodyBuildCB) { - var title = ttl || "Yet another untitled page"; - var that = this; - - var logTab = tabs.open({ - url: "about:blank", - inBackground: true, - onOpen: function (tab) { - var otherDoc = tab.contentDocument; - otherDoc.title = title; - otherDoc.body.innerHTML = "<h1>" + title + "</h1>"; - bodyBuildCB.call(that, otherDoc.body); - tabs.activeTab = tab; - } + + " </em>\n<br/>" + comment + "</p>\n"; }); -}; - -Logger.prototype.generateTimeSheet = function(body) { - var doc = body.ownerDocument; - this.timeSheetRecordsPrinter(body, myStorage.storage.logs); -}; + outStr += "</body></html>"; + return outStr; +} diff --git a/lib/main.js b/lib/main.js index bf34514..b553f6f 100644 --- a/lib/main.js +++ b/lib/main.js @@ -1,4 +1,3 @@ -/*jslint rhino: true, forin: true, onevar: false, browser: true, evil: true, laxbreak: true, undef: true, nomen: true, eqeqeq: false, bitwise: true, maxerr: 1000, immed: false, white: false, plusplus: false, regexp: false, undef: false */ // Released under the MIT/X11 license // http://www.opensource.org/licenses/mit-license.php // @@ -13,13 +12,11 @@ "use strict"; var browser = require("tab-browser"); var self = require("self"); -var Request = require("request").Request; var pageMod = require("page-mod"); var libbz = require("libbugzilla"); var tabs = require("tabs"); var logger = require("logger"); - -var config = {}; +var Message = require("util").Message; function isOurPage(window, matchingURLs) { var url = window.location.href; @@ -46,70 +43,93 @@ function skipThisPage(doc) { } var messageHandler = exports.messageHandler = function messageHandler(worker, msg) { - console.log("messageHandler: msg = " + msg.toSource()); switch (msg.cmd) { - case "LogMessage": - console.log(msg.data); - break; - case "ExecCmd": - libbz.executeCommand(msg.data); - break; - case "AddLogRecord": - logger.addLogRecord(msg.data); - break; - case "GenerateTS": - logger.generateTimeSheet(); - break; - case "ClearTS": - logger.clearTimeSheet(); - break; - case "ImportTS": - logger.importTimeSheet(); - break; - case "GetInstalledPackages": - // send message with packages back - console.log("msg = " + msg.toSource()); - libbz.getInstalledPackages(msg.data, config, function (pkgsMsg) { - worker.postMessage(pkgsMsg); - }); - break; - case "GetClipboard": - libbz.getClipboard(msg.data, function (clipboard) { - worker.postMessage(clipboard); - }); - break; - case "ChangeJSONURL": - libbz.changeJSONURL(); - break; - case "OpenURLinNewTab": - libbz.openURLinNewTab(msg.data); - break; - case "testReady": - // we ignore it here, interesting only in unit test - break; - default: - console.error(msg.toSource()); + case "LogMessage": + console.log(msg.data); + break; + case "ExecCmd": + libbz.executeCommand(msg.data); + break; + case "AddLogRecord": + logger.addLogRecord(msg.data); + break; + case "GenerateTS": + logger.generateTimeSheet(); + break; + case "ClearTS": + logger.clearTimeSheet(); + break; + case "ImportTS": + logger.importTimeSheet(); + break; + case "GetInstalledPackages": + // send message with packages back + libbz.getInstalledPackages(msg.data, function (pkgsMsg) { + worker.postMessage(pkgsMsg); + }); + break; + case "GetClipboard": + libbz.getClipboard(function (clipboard) { + worker.postMessage(new Message(msg.data, clipboard)); + }); + break; + case "SetClipboard": + libbz.setClipboard(msg.data); + break; + case "ChangeJSONURL": + libbz.changeJSONURL(); + break; + case "OpenURLinPanel": + libbz.openURLInNewPanel(msg.data); + break; + case "OpenURLinTab": + libbz.openURLInNewTab(msg.data); + break; + case "OpenStringInPanel": + libbz.openStringInNewPanel(msg.data); + 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)); + }); + break; + case "GetURL": + 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); + break; + case "testReady": + // we ignore it here, interesting only in unit test + break; + default: + console.error(msg.toSource()); } }; -var contentScriptLibraries = { - "bugzilla.redhat.com": [ - self.data.url("util.js"), - self.data.url("color.js"), - self.data.url("bzpage.js") -// self.data.url("rhbzpage.js") - ] -}; +var contentScriptLibraries = [ + self.data.url("lib/jumpNextBug.js"), + self.data.url("lib/util.js"), + self.data.url("lib/color.js"), + self.data.url("lib/logging-front.js"), + self.data.url("lib/rhbzpage.js"), + self.data.url("lib/bzpage.js") +]; -libbz.initialize(config, function () { +libbz.initialize(libbz.config, function () { pageMod.PageMod({ include: [ - "https://bugzilla.redhat.com/show_bug.cgi?id=*" + "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["bugzilla.redhat.com"], + contentScriptFile: contentScriptLibraries, onAttach: function onAttach(worker, msg) { - console.log("worker: " + worker); worker.on('message', function (msg) { messageHandler(worker, msg); }); @@ -117,4 +137,20 @@ libbz.initialize(config, function () { }); }); -tabs.open("https://bugzilla.redhat.com/show_bug.cgi?id=673153"); +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" + ], + contentScriptWhen: 'ready', + contentScriptFile: self.data.url("lib/skip-bug.js") +}); + +// tabs.open("https://bugzilla.redhat.com/show_bug.cgi?id=679515"); diff --git a/lib/passwords.js b/lib/passwords.js index cc9c16b..af76f47 100644 --- a/lib/passwords.js +++ b/lib/passwords.js @@ -1,4 +1,3 @@ -/*jslint forin: true, rhino: true, onevar: false, browser: true, evil: true, laxbreak: true, undef: true, nomen: true, eqeqeq: true, bitwise: true, maxerr: 1000, immed: false, white: false, plusplus: false, regexp: false, undef: false */ // Released under the MIT/X11 license // http://www.opensource.org/licenses/mit-license.php "use strict"; diff --git a/lib/prompts.js b/lib/prompts.js index d4a5293..ed9b3e5 100644 --- a/lib/prompts.js +++ b/lib/prompts.js @@ -97,9 +97,10 @@ exports.promptYesNoCancel = function promptOKNoCancel(prompt) { * documentation is https://developer.mozilla.org/en/NsIFilePicker */ exports.promptFileOpenPicker = function promptFilePicker (win) { + var window = require("window-utils").activeWindow; var fp = Cc["@mozilla.org/filepicker;1"] .createInstance(Ci.nsIFilePicker); - fp.init(win, "JSON File Open", Ci.nsIFilePicker.modeOpen); + fp.init(window, "JSON File Open", Ci.nsIFilePicker.modeOpen); fp.appendFilter("JSON files", "*.json"); fp.appendFilters(Ci.nsIFilePicker.filterAll); fp.filterIndex = 0; diff --git a/lib/util.js b/lib/util.js index 8556951..089e31c 100644 --- a/lib/util.js +++ b/lib/util.js @@ -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 = []; @@ -63,3 +63,15 @@ exports.getISODate = function getISODate(dateStr) { 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 + })); + */ +exports.Message = function Message(cmd, data) { + this.cmd = cmd; + this.data = data; +}; diff --git a/lib/xmlrpc.js b/lib/xmlrpc.js index e883d91..0b84c07 100644 --- a/lib/xmlrpc.js +++ b/lib/xmlrpc.js @@ -1,4 +1,3 @@ -/*jslint rhino: true, forin: true, onevar: false, browser: true */ /*global exports: false */ "use strict"; // Modification of Matěj Cepl released under the MIT/X11 license |