aboutsummaryrefslogtreecommitdiffstats
path: root/bugzillaBugTriage.js
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
commit711287ac937e0ad86a091e874ca54928b8187975 (patch)
tree05640ba230a8e55c2f4e6d4727834587fb3d2459 /bugzillaBugTriage.js
parent6d43ba9655e3a7e14eb627cbb37deff60f761b63 (diff)
downloadbugzilla-triage-711287ac937e0ad86a091e874ca54928b8187975.tar.gz
Make the script working again, even with unfinished serialization.
Diffstat (limited to 'bugzillaBugTriage.js')
-rw-r--r--bugzillaBugTriage.js72
1 files changed, 55 insertions, 17 deletions
diff --git a/bugzillaBugTriage.js b/bugzillaBugTriage.js
index 28ae84b..e8c49e0 100644
--- a/bugzillaBugTriage.js
+++ b/bugzillaBugTriage.js
@@ -261,6 +261,7 @@ 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);
@@ -496,15 +497,7 @@ BzPage.prototype.getOptionValue = function (id) {
*/
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
+ elements: [],
name: form.name,
method: form.method,
acceptCharset: form.acceptCharset,
@@ -512,27 +505,59 @@ BzPage.prototype.serializeForm = function (form) {
enctype: form.enctype,
autocomplete: form.getAttribute("autocomplete")
};
-
/**
* @param o control to be serialized
* @return String with the serialized control
*/
function serializeControl(element) {
- // notImplemented
+ var val = element.value;
+ console.log("serializeControl val = " + val);
+ console.log("typeof val = " + typeof val);
+ console.log("val.toSource() = " + val.toSource());
+ if (val == null) {
+ return null;
+ } else if (val instanceof Array) {
+ return val.map(function (x) {
+ return {name: element.name, value: x.value};
+ });
+ } else if (val instanceof String) {
+ return {name: element.name, value: val};
+ } else { // assume HTMLCollection
+ return Array.map(val,function (x) {
+ return {name: element.name, value: x.value};
+ });
+ }
+
+ }
+
+ /**
+ *
+ */
+ function arr2str(arr) {
+ var outStr = "";
+ arr.forEach(function (el) {
+ if (el instanceof Array) {
+ //
+ }
+ });
}
- serialForm = Array.map(form.elements,serializeControl);
+ serialForm = Array.filter(form.elements,function (el) {
+ return !el.disabled && el.name &&
+ (el.checked || /select|textarea/i.test(el.nodeName) ||
+ /text|hidden|password|search/i.test(el.type));
+ }).map(serializeControl);
return serialForm;
-}
+};
-BzPage.prototype.submitCallback(evt) {
+BzPage.prototype.submitCallback = function(evt) {
if (jetpack.__parent__.navigator.onLine) {
options.oldSubmit();
} else {
var serForm = this.serializeForm(this.dok.forms.namedItem("changeform"));
myStorage.forms[this.bugNo] = serForm; // FIXME
}
-}
+};
/**
*
@@ -540,18 +565,31 @@ BzPage.prototype.submitCallback(evt) {
* Yes, this is corrent, this is NOT method of bzPage!
*/
function onlineCallback() {
- function deserializeAndSend(x) {
+ function deserializeAndSend(formData) {
// FIXME notImplemented
// is it enough to just
// run XMLHTTPRequest? Probably yes, this is just a form
// and this is just a HTTP request :)
+ // 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
+ var req = new XMLHTTPRequest();
+ req.open("POST",formData.action);
+ // where to get the real form ... should we just download the page with another
+ // XMLHTTPRequest ... but we just need to emulate, what would happen if...
return success;
}
if (myStorage.forms.length > 0) {
myStorage.forms.forEach(function (x) {
if (deserializeAndSend(x)) {
- del x; // can I do it?
+ //del x; // can I do it?
}
});
}