diff options
Diffstat (limited to 'data/bzpage.js')
-rw-r--r-- | data/bzpage.js | 90 |
1 files changed, 53 insertions, 37 deletions
diff --git a/data/bzpage.js b/data/bzpage.js index 7538b80..def12a7 100644 --- a/data/bzpage.js +++ b/data/bzpage.js @@ -13,6 +13,22 @@ var BTSPassRealm = "BTSXMLRPCPass"; // ============================================ +/** + * object to pack messaging. Use as in + postMessage(new Message("GetPassword", { + login: login, + hostname: location.hostname + })); + */ +function Message(cmd, data) { + this.cmd = cmd; + this.data = data; +} + +function log(msg) { + postMessage(new Message("LogMessage", msg)); +} + var NotLoggedinException = function NotLoggedinException (message) { this.message = message; this.name = "NotLoggedinException"; @@ -28,7 +44,7 @@ exports.NotLoggedinException = NotLoggedinException; * 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. */ -function getRealBugNo() { +nonTestedFunction getRealBugNo() { console.log("We have to deal with bug aliased as " + this.bugNo); var that = this; // https://bugzilla.redhat.com/show_bug.cgi?ctype=xml&id=serialWacom @@ -51,7 +67,7 @@ function getRealBugNo() { /** * */ -function getInstalledPackages(cfg) { +nonTestedFunction getInstalledPackages(cfg) { var installedPackages = {}; var enabledPackages = []; @@ -89,7 +105,7 @@ function getInstalledPackages(cfg) { * @param cmdLabel String with the name of the command to be executed * @param cmdParams Object with the appropriate parameters for the command */ -function centralCommandDispatch (cmdLabel, cmdParams) { +nonTestedFunction centralCommandDispatch (cmdLabel, cmdParams) { switch (cmdLabel) { case "resolution": case "product": @@ -198,7 +214,7 @@ function centralCommandDispatch (cmdLabel, cmdParams) { * everywhere except of Internet Explorer this should work well, but waiting * impatiently when this bite us. */ -function executeCommand (cmd) { +nonTestedFunction executeCommand (cmd) { var cmdArr = cmd.split("//"); var commentObj = this.packages[cmdArr[0]][cmdArr[1]]; @@ -215,7 +231,7 @@ function executeCommand (cmd) { * Value null clears "Reset Assignee to default for component" checkbox * @return none */ -function changeAssignee (newAssignee) { +nonTestedFunction changeAssignee (newAssignee) { var defAssigneeButton = null; // Previous assignee should know what's going on in his bug this.addToCCList(this.owner); @@ -257,7 +273,7 @@ function changeAssignee (newAssignee) { * If the 'comment_action' scroll down box doesn't exist, this * function will set up new one. */ -function addToCommentsDropdown (pkg, cmd) { +nonTestedFunction addToCommentsDropdown (pkg, cmd) { var select = this.doc.getElementById("comment_action"); if (!select) { var that = this; @@ -299,7 +315,7 @@ function addToCommentsDropdown (pkg, cmd) { * @param Boolean breakBefore if there should be a <br> element before. * @return none */ -function createDeadLink (id, text, parent, callback, params, before, covered, accesskey) { +nonTestedFunction createDeadLink (id, text, parent, callback, params, before, covered, accesskey) { var that = this; params = util.valToArray(params); var locParent = {}; @@ -346,7 +362,7 @@ function createDeadLink (id, text, parent, callback, params, before, covered, ac * @param id String which command to take * @return none */ -function createNewButton (location, after, pkg, id) { +nonTestedFunction createNewButton (location, after, pkg, id) { var that = this; var cmdObj = this.packages[pkg][id]; var newId = id + "_btn"; @@ -398,7 +414,7 @@ function createNewButton (location, after, pkg, id) { /** * */ -function generateButtons () { +nonTestedFunction generateButtons () { var topRowPosition = "topRowPositionID"; var bottomRowPosition = "commit"; @@ -432,7 +448,7 @@ function generateButtons () { } } -function setConfigurationButton () { +nonTestedFunction setConfigurationButton () { var additionalButtons = this.doc.querySelector("#bugzilla-body *.related_actions"); var configurationButtonUI = this.doc.createElement("li"); configurationButtonUI.innerHTML = "\u00A0-\u00A0<a href='' id='configurationButton'>" @@ -464,7 +480,7 @@ function setConfigurationButton () { * @return String with the address or null * */ -function parseMailto(aElement) { +nonTestedFunction parseMailto(aElement) { var emailStr = "", hrefStr = ""; // use url utils if (aElement) { @@ -485,7 +501,7 @@ function parseMailto(aElement) { * * @return string */ -function getReporter () { +nonTestedFunction getReporter () { var reporterElement = this.getOptionTableCell("bz_show_bug_column_2", "Reported"); // RH Bugzilla after upgrade to 3.6.2 moved the information to other column if (!reporterElement) { @@ -496,7 +512,7 @@ function getReporter () { return this.parseMailto(reporterElement); } -function getComponent() { +nonTestedFunction getComponent() { var elem = this.doc.getElementById("component"); if (elem) { return elem.value; @@ -505,7 +521,7 @@ function getComponent() { } -function commentsWalker (fce) { +nonTestedFunction commentsWalker (fce) { var comments = this.doc.getElementById("comments").getElementsByClassName( "bz_comment"); Array.forEach(comments, function(item) { @@ -517,7 +533,7 @@ function commentsWalker (fce) { * Set background color of all comments made by reporter in ReporterColor color * */ -function checkComments () { +nonTestedFunction checkComments () { var that = this; var reporterRE = new RegExp(this.getReporter()); this.commentsWalker(function(x) { @@ -529,7 +545,7 @@ function checkComments () { }); } -function collectComments () { +nonTestedFunction collectComments () { var outStr = ""; this.commentsWalker(function(x) { outStr += x.getElementsByTagName("pre")[0].textContent + "\n"; @@ -548,7 +564,7 @@ function collectComments () { * @return none * */ -function selectOption (id, label, fireEvent) { +nonTestedFunction selectOption (id, label, fireEvent) { if (!fireEvent) { fireEvent = true; } @@ -561,7 +577,7 @@ function selectOption (id, label, fireEvent) { } } -function selectOptionByLabel(id, label, fireEvent) { +nonTestedFunction selectOptionByLabel(id, label, fireEvent) { if (!fireEvent) { fireEvent = true; } @@ -588,7 +604,7 @@ function selectOptionByLabel(id, label, fireEvent) { * @param String ID of the element to send mouseclick to * @return None */ -function clickMouse (targetID) { +nonTestedFunction clickMouse (targetID) { var localEvent = this.doc.createEvent("MouseEvents"); localEvent.initMouseEvent("click", true, true, this.doc.defaultView, 0, 0, 0, 0, 0, false, false, false, false, 0, null); @@ -603,7 +619,7 @@ function clickMouse (targetID) { * * @return none */ -function addStuffToTextBox (id, stuff) { +nonTestedFunction addStuffToTextBox (id, stuff) { var textBox = this.doc.getElementById(id); if (textBox.tagName.toLowerCase() === "textarea") { stuff = textBox.value ? "\n\n" + stuff : stuff; @@ -619,7 +635,7 @@ function addStuffToTextBox (id, stuff) { * @param id String with the id of the element * @param stuff String/Array with keyword(s) to be removed */ -function removeStuffFromTextBox (id, stuff) { +nonTestedFunction removeStuffFromTextBox (id, stuff) { var changedElement = this.getElementById(id); changedElement.value = util.removeCSVValue(changedElement.value,stuff); } @@ -631,7 +647,7 @@ function removeStuffFromTextBox (id, stuff) { * @param str String to be searched for * @return Boolean found? */ -function idContainsWord (id, str) { +nonTestedFunction idContainsWord (id, str) { var kwd = ""; try { kwd = this.doc.getElementById(id).value; @@ -648,7 +664,7 @@ function idContainsWord (id, str) { * @param str String with the keyword * @return Boolean */ -function hasKeyword (str) { +nonTestedFunction hasKeyword (str) { return (this.idContainsWord('keywords', str)); } @@ -656,7 +672,7 @@ function hasKeyword (str) { @return Element with the href attribute containng the information */ -function getOptionTableCell(tableId, label) { +nonTestedFunction getOptionTableCell(tableId, label) { var cleanLabelRE = /^\s*([^.:]*):?\s*$/; label = label.trim().replace(cleanLabelRE,"$1").toLowerCase(); @@ -682,7 +698,7 @@ function getOptionTableCell(tableId, label) { * @todo TODO we may extend this to general setNeedinfo function * with parameter [reporter|assignee|general-email-address] */ -function setNeedinfoReporter () { +nonTestedFunction setNeedinfoReporter () { this.clickMouse("needinfo"); this.selectOption("needinfo_role", "reporter"); } @@ -690,7 +706,7 @@ function setNeedinfoReporter () { /** * */ -function getOwner () { +nonTestedFunction getOwner () { // TODO(maemo) doesn't work on maemo var assigneeAElement = this.getOptionTableCell("bz_show_bug_column_1","Assigned To"); return this.parseMailto(assigneeAElement); @@ -702,7 +718,7 @@ function getOwner () { * * @return String with the maintainer's email address */ -function getDefaultBugzillaMaintainer (component) { +nonTestedFunction getDefaultBugzillaMaintainer (component) { var address = util.filterByRegexp(this.defBugzillaMaintainerArr, component); return address; } @@ -716,7 +732,7 @@ function getDefaultBugzillaMaintainer (component) { * element itself */ -function parseAttachmentLine(inElem) { +nonTestedFunction parseAttachmentLine(inElem) { var MIMEtype = ""; var size = 0; @@ -753,7 +769,7 @@ function parseAttachmentLine(inElem) { * string of MIME type, integer of size in kilobytes, and the whole * element itself */ -function getAttachments () { +nonTestedFunction getAttachments () { var outAtts = []; var atts = this.doc.getElementById("attachment_table") .getElementsByTagName("tr"); @@ -768,7 +784,7 @@ function getAttachments () { * * @return String with the login name of the currently logged-in user */ -function getLogin () { +nonTestedFunction getLogin () { var lastLIElement = this.doc.querySelector("#header ul.links li:last-of-type"); var loginArr = lastLIElement.textContent.split("\n"); var loginStr = loginArr[loginArr.length - 1].trim(); @@ -781,7 +797,7 @@ function getLogin () { * * @return String with the password */ -function getPassword (login) { +nonTestedFunction getPassword (login) { 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"; @@ -810,7 +826,7 @@ function getPassword (login) { /** * */ -function setUpLogging () { +nonTestedFunction setUpLogging () { // Protection against double-call if (this.doc.getElementById("generateTSButton")) { return ; @@ -860,7 +876,7 @@ function setUpLogging () { } } -function getSelectionOrClipboard () { +nonTestedFunction getSelectionOrClipboard () { var text = selection.text; if (!text) { text = clip.get(); @@ -878,7 +894,7 @@ function getSelectionOrClipboard () { * @return None * */ -function queryInNewTab(text, component, product) { +nonTestedFunction queryInNewTab(text, component, product) { var urlStr = "https://bugzilla.redhat.com/buglist.cgi?query_format=advanced"; if (product) { urlStr += "&product=" + product.trim(); @@ -926,7 +942,7 @@ function queryInNewTab(text, component, product) { * Get the text to search for and prepare other things for the real executive * function this.queryInNewTab, and run it. */ -function queryForSelection() { +nonTestedFunction queryForSelection() { var text = this.getSelectionOrClipboard(); if (text) { this.queryInNewTab(text, this.getComponent()); @@ -939,7 +955,7 @@ function queryForSelection() { * @param who String with email address or "self" if the current user * of the bugzilla should be added */ -function addToCCList (who) { +nonTestedFunction addToCCList (who) { if (!who) { return ; } @@ -958,7 +974,7 @@ function addToCCList (who) { * * @return Array with email addresses as Strings. */ -function getCCList () { +nonTestedFunction getCCList () { var CCListSelect = this.doc.getElementById("cc"); var outCCList = []; if (CCListSelect) { |