aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2010-01-13 00:21:24 +0100
committerMatěj Cepl <mcepl@redhat.com>2010-01-13 00:21:24 +0100
commit6d43ba9655e3a7e14eb627cbb37deff60f761b63 (patch)
tree169380435ce80f1e248bcb80c6cc1dbd60024541
parent875a60dba09cf984e84c1531254d2c11dc0fe1ac (diff)
downloadbugzilla-triage-6d43ba9655e3a7e14eb627cbb37deff60f761b63.tar.gz
A lot of notes and some high-level design
-rw-r--r--bugzillaBugTriage.js100
1 files changed, 99 insertions, 1 deletions
diff --git a/bugzillaBugTriage.js b/bugzillaBugTriage.js
index 041ed05..28ae84b 100644
--- a/bugzillaBugTriage.js
+++ b/bugzillaBugTriage.js
@@ -3,6 +3,33 @@
// Released under the MIT/X11 license
// http://www.opensource.org/licenses/mit-license.php
+/* FIXME
+ - settings to https://wiki.mozilla.org/Labs/Jetpack/JEP/24 instead of
+ jetpack.storage.simple; make conversion from the current system
+ - consider offline status
+ function newsubmit(event) {
+ var target = event ? event.target : this;
+
+ // do anything you like here
+ alert('Submitting form to ' + target.action);
+
+ // call real submit function
+ this._submit();
+
+ - consider
+ https://developer.mozilla.org/en/DOM/document.evaluate and
+ https://developer.mozilla.org/en/Introduction_to_using_XPath_in_JavaScript
+}
+
+// capture the onsubmit event on all forms
+window.addEventListener('submit', newsubmit, true);
+
+// If a script calls someForm.submit(), the onsubmit event does not fire,
+// so we need to redefine the submit method of the HTMLFormElement class.
+HTMLFormElement.prototype._submit = HTMLFormElement.prototype.submit;
+HTMLFormElement.prototype.submit = newsubmit;
+ */
+
"use strict";
jetpack.future.import("pageMods");
jetpack.future.import("storage.simple");
@@ -234,7 +261,6 @@ Color.prototype.hs = function(nStr) {
};
Color.prototype.toString = function() {
- var rH = Number(this.r.toFixed()).toString(16);
var gH = Number(this.g.toFixed()).toString(16);
var bH = Number(this.b.toFixed()).toString(16);
return "#"+this.hs(rH)+this.hs(gH)+this.hs(bH);
@@ -459,6 +485,78 @@ BzPage.prototype.getOptionValue = function (id) {
return this.dok.getElementById(id).value;
};
+/* Offline supporting functions */
+/**
+ *
+ * @todo FIXME this probably makes a closure and a memory leak
+ * name='changeform'
+ * investigate https://developer.mozilla.org/en/How_to_Turn_Off_Form_Autocompletion
+ *
+ * <form method="post" action="process_bug.cgi" autocomplete="off">
+ */
+BzPage.prototype.serializeForm = function (form) {
+ var serialForm = {
+ elements: [], // it is probably better to get already processed
+ // application/x-www-form-urlencoded
+ // see http://htmlhelp.com/reference/html40/forms/form.html for details
+ // and also https://developer.mozilla.org/en/AJAX/Getting_Started
+ // what's?
+ // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference\
+ // /Global_Functions/encodeURI & co.
+ // this seems to be also interesting
+ // https://developer.mozilla.org/en/Code_snippets/Post_data_to_window
+ name: form.name,
+ method: form.method,
+ acceptCharset: form.acceptCharset,
+ action: form.action, // TODO shouldn't we get a non-relative URL?
+ enctype: form.enctype,
+ autocomplete: form.getAttribute("autocomplete")
+ };
+
+ /**
+ * @param o control to be serialized
+ * @return String with the serialized control
+ */
+ function serializeControl(element) {
+ // notImplemented
+ }
+
+ serialForm = Array.map(form.elements,serializeControl);
+ return serialForm;
+}
+
+BzPage.prototype.submitCallback(evt) {
+ if (jetpack.__parent__.navigator.onLine) {
+ options.oldSubmit();
+ } else {
+ var serForm = this.serializeForm(this.dok.forms.namedItem("changeform"));
+ myStorage.forms[this.bugNo] = serForm; // FIXME
+ }
+}
+
+/**
+ *
+ *
+ * Yes, this is corrent, this is NOT method of bzPage!
+ */
+function onlineCallback() {
+ function deserializeAndSend(x) {
+ // FIXME notImplemented
+ // is it enough to just
+ // run XMLHTTPRequest? Probably yes, this is just a form
+ // and this is just a HTTP request :)
+ return success;
+ }
+
+ if (myStorage.forms.length > 0) {
+ myStorage.forms.forEach(function (x) {
+ if (deserializeAndSend(x)) {
+ del x; // can I do it?
+ }
+ });
+ }
+}
+
/* Bugzilla functions.*/
/**