M
Matìj Cepl
Hi,
I wrote a jetpack (http://bit.ly/rhbzjetpack) for working at the Red Hat
Bugzilla. I am playing with the idea, whether it wouldn't be possible to
add offline capability to my bugzilla processing (there is no Internet
connection in the Prague metro ). Would it be possible to catch
"submit" event with addEventListener, and if we are offline, store the
request (somehow) to the local storage (jetpack.simple.storage or DOM
Storage or ???), and when switching online (or restarting Firefox when
online) pushing these requests (somehow) to the bugzilla.
Of course the foundation of this would be something like this:
------------------------------------------------------------------------
var win = jetpack.tabs.focused.contentWindow;
function newsubmit(event) {
var target = event ? event.target : this;
// do anything you like here
console.log('Submitting form to ' + target.action);
// call real submit function
if ( navigator.online ) {
this._submit();
} else {
reqQueue.push( <something> ); // HOW?
}
}
function submitQueue() {
reqQueue.forEach( submitItem ); // HOW?
}
// in the initialization part of the jetpack
win.addEventListener( "submit", newsubmit, false);
// 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;
win.addEventListener("online", submitQueue, false);
------------------------------------------------------------------------
Now the question is how to store the request in some form somewhere, and
when it is restored, how to submit it.
Any ideas? URLs for some related articles?
Thanks a lot for any suggestions,
Matìj
--
http://www.ceplovi.cz/matej/, Jabber: mcepl<at>ceplovi.cz
GPG Finger: 89EF 4BC6 288A BF43 1BAB 25C3 E09F EF25 D964 84AC
I didn't attend the funeral, but I sent a nice letter saying
I approved of it.
-- Mark Twain
I wrote a jetpack (http://bit.ly/rhbzjetpack) for working at the Red Hat
Bugzilla. I am playing with the idea, whether it wouldn't be possible to
add offline capability to my bugzilla processing (there is no Internet
connection in the Prague metro ). Would it be possible to catch
"submit" event with addEventListener, and if we are offline, store the
request (somehow) to the local storage (jetpack.simple.storage or DOM
Storage or ???), and when switching online (or restarting Firefox when
online) pushing these requests (somehow) to the bugzilla.
Of course the foundation of this would be something like this:
------------------------------------------------------------------------
var win = jetpack.tabs.focused.contentWindow;
function newsubmit(event) {
var target = event ? event.target : this;
// do anything you like here
console.log('Submitting form to ' + target.action);
// call real submit function
if ( navigator.online ) {
this._submit();
} else {
reqQueue.push( <something> ); // HOW?
}
}
function submitQueue() {
reqQueue.forEach( submitItem ); // HOW?
}
// in the initialization part of the jetpack
win.addEventListener( "submit", newsubmit, false);
// 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;
win.addEventListener("online", submitQueue, false);
------------------------------------------------------------------------
Now the question is how to store the request in some form somewhere, and
when it is restored, how to submit it.
Any ideas? URLs for some related articles?
Thanks a lot for any suggestions,
Matìj
--
http://www.ceplovi.cz/matej/, Jabber: mcepl<at>ceplovi.cz
GPG Finger: 89EF 4BC6 288A BF43 1BAB 25C3 E09F EF25 D964 84AC
I didn't attend the funeral, but I sent a nice letter saying
I approved of it.
-- Mark Twain