diff options
author | Matěj Cepl <mcepl@redhat.com> | 2010-01-13 00:22:47 +0100 |
---|---|---|
committer | Matěj Cepl <mcepl@redhat.com> | 2010-01-13 00:22:47 +0100 |
commit | 84771aca9037cf74eab0aa141f552eb00b4dcdb4 (patch) | |
tree | fbf19ad8aafc8034531724c5b1ec26bc7b0db4ea | |
parent | 52d4973a72930fa25bc30d4d529b12c05fbbfba6 (diff) | |
download | bugzilla-triage-84771aca9037cf74eab0aa141f552eb00b4dcdb4.tar.gz |
Some more attempts to make offline submit functional:
- unified name of myConfig/myStorage to myStorage
- add upstreamButtonAvailable declaration
- don't allow empty elements to be stored (not sure, how good it is)
- some incorrect this changed to that
-rw-r--r-- | bugzillaBugTriage.js | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/bugzillaBugTriage.js b/bugzillaBugTriage.js index 8f5caf4..359285c 100644 --- a/bugzillaBugTriage.js +++ b/bugzillaBugTriage.js @@ -24,7 +24,7 @@ var TriagedDistro = 13; var NumberOfFrames = 7; var XMLRPCurl = "https://bugzilla.redhat.com/xmlrpc.cgi"; var bugURL = "https://bugzilla.redhat.com/show_bug.cgi?id="; -var myConfig = jetpack.storage.simple; +var myStorage = jetpack.storage.simple; var badMIMEArray = ["application/octet-stream","text/x-log","undefined"]; //============================================================== @@ -41,7 +41,7 @@ jetpack.future.import("storage.settings"); // jetpack.settings.open(); //} -var jsonDataURL = myConfig.JSONURL ? myConfig.JSONURL : +var jsonDataURL = myStorage.JSONURL ? myStorage.JSONURL : "http://mcepl.fedorapeople.org/scripts/BugZappers_data.json"; var PCIIDsURL = "http://mcepl.fedorapeople.org/scripts/drm_pciids.json"; var abrtQueryURL = "https://bugzilla.redhat.com/buglist.cgi?"+ @@ -85,6 +85,7 @@ var suspiciousComponents = []; var signatureFedoraString = ""; // TODO we should have an array SpecialFlags instead of multiple Boolean variables var queryButtonAvailable = false; +var upstreamButtonAvailable = false; var chipIDsGroupings = []; var AddrArray = []; var PCI_ID_Array = []; @@ -502,8 +503,6 @@ BzPage.prototype.serializeForm = function (form) { */ function serializeControl(element) { var val = element.value; - console.log("serializeControl val = " + val); - console.log("typeof val = " + typeof val); console.log("val.toSource() = " + val.toSource()); /* FIXME what is element with type="select-one" ??? on HTMLSelectElement we have an attribute 'type' of type DOMString, readonly @@ -511,8 +510,8 @@ BzPage.prototype.serializeForm = function (form) { when the multiple attribute is true and the string "select-one" when false. */ - if (val == null) { - return null; + if ((val == null) || (val == undefined)|| (val == "")) { + return ; } else if (val instanceof Array) { return val.map(function (x) { return genURIElement(element.name,x.value); @@ -528,19 +527,23 @@ BzPage.prototype.serializeForm = function (form) { serialForm.dataOut = Array.filter(form.elements,function (el) { return !el.disabled && el.name && + // FIXME shouldn't I just add && el.value here? (el.checked || /select|textarea/i.test(el.nodeName) || /text|hidden|password|search/i.test(el.type)); }).map(serializeControl).join("&"); return serialForm; }; -BzPage.prototype.submitCallback = function(evt) { +BzPage.prototype.submitCallback = function(evt,that) { + console.log("Submit Callback!"); if (jetpack.__parent__.navigator.onLine) { - var serForm = this.serializeForm(this.dok.forms.namedItem("changeform")); + var serForm = that.serializeForm(jetpack.tabs.focused. + contentWindow.document.forms.namedItem("changeform")); console.log("serForm:\n"+serForm.toSource()); } else { - var serForm = this.serializeForm(this.dok.forms.namedItem("changeform")); - myStorage.forms[this.bugNo] = serForm; + var serForm = that.serializeForm(jetpack.tabs.focused. + contentWindow.document.forms.namedItem("changeform")); + myStorage.forms[that.bugNo] = serForm; evt.stopPropagation(); evt.preventDefault(); } @@ -1235,7 +1238,7 @@ BzPage.prototype.getWholeURL = function(selectValue,bugID) { */ BzPage.prototype.callBack = function(data,textStatus) { if (--this.reqCounter <= 0) { - setTimeout(document.location.reload,1000); + setTimeout(this.dok.location.reload,1000); } }; @@ -1657,13 +1660,12 @@ function BzPage(doc) { querySelector("#header ul.links li:last-of-type"). textContent.split("\n"); this.login = loginArr[loginArr.length-1].trim(); - this.password = ""; // the following is quite awful brutal hack console.log("on __parent__ navigator.online = " + jetpack.__parent__.navigator.onLine); - if (myConfig.BZpassword) { - this.password = myConfig.BZpassword; + if (myStorage.BZpassword) { + this.password = myStorage.BZpassword; } else { var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] .getService(Components.interfaces.nsIPromptService); @@ -1675,7 +1677,7 @@ function BzPage(doc) { // set if OK was pressed. The checkbox is not displayed. if (result) { this.password = password.value; - myConfig.BZpassword = this.password; + myStorage.BZpassword = this.password; jetpack.storage.simple.sync(); } } @@ -1746,7 +1748,8 @@ function BzPage(doc) { abrtButton.textContent = "Abrt bugs"; mainTitle.appendChild(abrtButton); var develWhiteboardElem = this.dok.getElementById("cf_devel_whiteboard"); - var develWhiteboard = develWhiteboardElem ? develWhiteboardElem.value : "btparsed"; + var develWhiteboard = develWhiteboardElem ? develWhiteboardElem. + value : "btparsed"; if (!(this.hasKeyword("Triaged") || (/btparsed/.test(develWhiteboard)))) { var btAttachments = this.attachments.filter(function (att,idx,arr) { @@ -1796,7 +1799,7 @@ function BzPage(doc) { var newURL = jetpack.tabs.focused.contentWindow. prompt("URL for your JSON customization file"); if (newURL) { - myConfig.JSONURL = newURL; + myStorage.JSONURL = newURL; jetpack.storage.simple.sync(); jetpack.tabs.focused.contentWindow.location.reload(); } @@ -1812,7 +1815,9 @@ function BzPage(doc) { // offline-capable submit this.dok.forms.namedItem("changeform"). - addEventListener('submit', this.submitCallback, false); + addEventListener('submit', function (evt) { + that.submitCallback(evt, that)}, + false); } var callback = function (doc) { @@ -1822,5 +1827,5 @@ var callback = function (doc) { var options = {}; options.matches = [ "https://bugzilla.redhat.com/show_bug.cgi" - ]; +]; jetpack.pageMods.add(callback, options); |