From 5333869aac2dbd71c91727dbca6aee1a46b3cdb1 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Wed, 13 Jan 2010 00:21:23 +0100 Subject: Starting to work on the offline capabilities. --- bugzillaBugTriage.js | 21 +++++++ offline-submit/collect-inputs.js | 45 +++++++++++++++ offline-submit/http-requests.txt | 28 ++++++++++ offline-submit/john-resig-offline-app-stub.js | 43 +++++++++++++++ offline-submit/post-data.txt | 79 +++++++++++++++++++++++++++ 5 files changed, 216 insertions(+) create mode 100644 offline-submit/collect-inputs.js create mode 100644 offline-submit/http-requests.txt create mode 100644 offline-submit/john-resig-offline-app-stub.js create mode 100644 offline-submit/post-data.txt diff --git a/bugzillaBugTriage.js b/bugzillaBugTriage.js index 06af057..041ed05 100644 --- a/bugzillaBugTriage.js +++ b/bugzillaBugTriage.js @@ -1670,6 +1670,27 @@ var callback = function (doc) { var curPage = new BzPage(doc); }; +/* FIXME + - 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(); +} + +// 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; + */ + var options = {}; options.matches = [ "https://bugzilla.redhat.com/show_bug.cgi" diff --git a/offline-submit/collect-inputs.js b/offline-submit/collect-inputs.js new file mode 100644 index 0000000..d6a2b47 --- /dev/null +++ b/offline-submit/collect-inputs.js @@ -0,0 +1,45 @@ +bzPage.prototype.collectInputs = function (form) { + +// form.elements array of all controls ... no, forEach though +// INPUT, SELECT, TEXTAREA, and BUTTON +// each interesting control of them have NAME and VALUE +// You can access a particular element by using either an index or the element name or id. +// +// https://developer.mozilla.org/en/DOM/form +// form.elements.querySelectorAll("*[name]") + + var x=this.dok.getElementById("myForm"); +for (var i=0;i"); +} + +} + +// INTERESTING: http://www.quirksmode.org/js/forms.html + +// Example onsubmit handler + +function checkscript() { + if (some value is/is not something) { + // something is wrong + alert('alert user of problem'); + return false; + } + else if (another value is/is not something) { + // something else is wrong + alert('alert user of problem'); + return false; + } + + // If the script makes it to here, everything is OK, + // so you can submit the form + + return true; +} + +// with XPCNativeWrappers you cannot use document.formname.inputname.value +var form = document.forms.namedItem("gs"); +var input = form.elements.namedItem("q"); +var q = input.value; diff --git a/offline-submit/http-requests.txt b/offline-submit/http-requests.txt new file mode 100644 index 0000000..7800182 --- /dev/null +++ b/offline-submit/http-requests.txt @@ -0,0 +1,28 @@ +00:03:23.973 4.726 2246 4222 POST 200 text/html https://bugzilla.redhat.com/process_bug.cgi +00:03:28.208 0.149 577 (2635) GET (Cache) text/css https://bugzilla.redhat.com/skins/standard/global.css +00:03:28.215 0.169 583 (1100) GET (Cache) text/css https://bugzilla.redhat.com/skins/standard/yui/calendar.css +00:03:28.221 0.173 579 (442) GET (Cache) text/css https://bugzilla.redhat.com/skins/standard/show_bug.css +00:03:28.237 0.192 583 (1728) GET (Cache) text/css https://bugzilla.redhat.com/skins/contrib/RedHat/global.css +00:03:28.243 0.197 589 (103) GET (Cache) text/css https://bugzilla.redhat.com/skins/contrib/RedHat/yui/calendar.css +00:03:28.250 0.209 585 (100) GET (Cache) text/css https://bugzilla.redhat.com/skins/contrib/RedHat/show_bug.css +00:03:28.257 0.227 575 (100) GET (Cache) text/css https://bugzilla.redhat.com/skins/custom/global.css +00:03:28.264 0.236 581 (103) GET (Cache) text/css https://bugzilla.redhat.com/skins/custom/yui/calendar.css +00:03:28.273 0.234 577 (100) GET (Cache) text/css https://bugzilla.redhat.com/skins/custom/show_bug.css +00:03:28.280 0.293 550 (493) GET (Cache) application/x-javascript https://bugzilla.redhat.com/js/cookies.js +00:03:28.508 0.220 581 (1568) GET (Cache) text/css https://bugzilla.redhat.com/skins/contrib/Dusk/global.css +00:03:28.513 1.086 587 477 GET 404 text/html https://bugzilla.redhat.com/skins/contrib/Dusk/yui/calendar.css +00:03:28.520 1.091 583 473 GET 404 text/html https://bugzilla.redhat.com/skins/contrib/Dusk/show_bug.css +00:03:28.574 0.222 547 (2033) GET (Cache) application/x-javascript https://bugzilla.redhat.com/js/util.js +00:03:28.582 0.234 548 (3746) GET (Cache) application/x-javascript https://bugzilla.redhat.com/js/field.js +00:03:28.589 0.252 562 (9752) GET (Cache) application/x-javascript https://bugzilla.redhat.com/js/yui/yahoo-dom-event.js +00:03:28.598 0.272 555 (12147) GET (Cache) application/x-javascript https://bugzilla.redhat.com/js/yui/calendar.js +00:03:28.606 0.283 554 (4985) GET (Cache) application/x-javascript https://bugzilla.redhat.com/js/productform.js +00:03:28.633 0.276 550 (5467) GET (Cache) application/x-javascript https://bugzilla.redhat.com/js/rpc-min.js +00:03:28.641 0.284 551 (1047) GET (Cache) application/x-javascript https://bugzilla.redhat.com/js/show_bug.js +00:03:29.557 0.077 427 (14643) GET (Cache) text/plain http://mcepl.fedorapeople.org/scripts/BugZappers_data.json +00:03:29.564 0.071 422 (11352) GET (Cache) text/plain http://mcepl.fedorapeople.org/scripts/drm_pciids.json +00:03:32.916 0.168 566 11698 GET 200 application/vnd.google.safebrowsing-chunk http://safebrowsing-cache.google.com/safebrowsing/rd/goog-malware-shavar_s_25761-25920.25761-25796.25797-25920: +00:03:34.383 0.275 561 20882 GET 200 application/vnd.google.safebrowsing-chunk http://safebrowsing-cache.google.com/safebrowsing/rd/goog-malware-shavar_a_16771-16780.16771,16773-16780.: +00:03:34.691 0.080 566 7154 GET 200 application/vnd.google.safebrowsing-chunk http://safebrowsing-cache.google.com/safebrowsing/rd/goog-malware-shavar_a_16781-16800.16781-16791.16792-16800: +00:03:34.810 0.084 564 3875 GET 200 application/vnd.google.safebrowsing-chunk http://safebrowsing-cache.google.com/safebrowsing/rd/goog-phish-shavar_s_52481-52640.52481-52528.52529-52640: +00:03:35.195 0.111 564 15346 GET 200 application/vnd.google.safebrowsing-chunk http://safebrowsing-cache.google.com/safebrowsing/rd/goog-phish-shavar_a_78641-78720.78641-78718.78719-78720: diff --git a/offline-submit/john-resig-offline-app-stub.js b/offline-submit/john-resig-offline-app-stub.js new file mode 100644 index 0000000..b9d6160 --- /dev/null +++ b/offline-submit/john-resig-offline-app-stub.js @@ -0,0 +1,43 @@ +// stub for the offline application in pseudocode +// from http://ejohn.org/blog/offline-events/ + +function saveData( item ){ + if ( navigator.onLine ) { + saveToServer( item ); + } else { + toSave.push( item ); + } +} + +function loadData( item ){ + if ( navigator.onLine ) { + return loadFromServer( item ); + } else { + var result = loadFromQueue( item ); + if ( !result ) { + displayError(); + toLoad.push( item ); + } + return result; + } +} + +setInterval(function(){ + if ( navigator.onLine ) { + var item = predictNextItemToBeLoaded(); + loadData( item ); + } +}, 5000); + +window.ononline = function(){ + toSave.forEach( saveData ); + toLoad.forEach( loadData ); +}; + +window.onload = function(){ + document.getElementById("myform").onsubmit = function(){ + saveData( this ); + return false; + }; +}; + diff --git a/offline-submit/post-data.txt b/offline-submit/post-data.txt new file mode 100644 index 0000000..85a8e0a --- /dev/null +++ b/offline-submit/post-data.txt @@ -0,0 +1,79 @@ +delta_ts=2009-12-09+19%3A42%3A04&longdesclength=6&id=544623&token=1260958169-c8aa4a3bf3735866fc1e8a398d5c878c&short_desc=%5Babrt%5D+crash+detected+in+compiz-0.8.2-20.fc12+%230++in+__longjmp+%28%29+from+%2Flib64%2Fld-linux-x86-64.so.2&newalias=__longjmp&product=Fedora&component=compiz&version=12&rep_platform=x86_64&op_sys=Linux&priority=low&bug_severity=medium&assigned_to=adel.gadllah%40gmail.com&qa_contact=extras-qa%40fedoraproject.org&bug_file_loc=&status_whiteboard=abrt_hash%3A9d6ed64860473c6d40b0b90137f67f48417a51e7&keywords=&dependson=&blocked=&newcc=&cf_fixed_in=&cf_cust_facing=---&cf_issuetracker=&cf_internal_whiteboard=&cf_devel_whiteboard=&cf_qa_whiteboard=&cf_release_notes=&cf_build_id=&cf_targetrelease=---&defined_cf_partner=&defined_cf_verified=&cf_clone_of=&defined_cf_conditional_nak=&cf_environment=&flag_type-65=X&flag_type-67=X&flag_type-16=X&requestee_type-16=&flag_type-66=X&defined_bit-41=1&defined_bit-68=1&defined_bit-31=1&defined_bit-58=1&defined_bit-50=1&defined_bit-83=1&defined_bit-21=1&defined_bit-32=1&defined_bit-15=1&defined_bit-12=1&defined_bit-161=1&defined_bit-44=1&defined_bit-22=1&defined_bit-11=1&defined_bit-48=1&defined_bit-10=1&defined_bit-93=1&estimated_time=0.0&work_time=0&remaining_time=0.0&deadline=&external_id=0&external_bug_id=&comment=&needinfo_role=&needinfo_from=&bug_status=NEW&resolution=NOTABUG&dup_id=&defined_isprivate_2522533=1&defined_isprivate_2521233=1&defined_isprivate_2520112=1&defined_isprivate_2519826=1&defined_isprivate_2518162=1&defined_isprivate_2518161=1 + +which is + +delta_ts 2009-12-09 19:42:04 +longdesclength 6 +id 544623 +token 1260958169-c8aa4a3bf3735866fc1e8a398d5c878c +short_desc [abrt] crash detected in compiz-0.8.2-20.fc12 #0 in __longjmp () from /lib64/ld-linux-x86-64.so.2 +newalias __longjmp +product Fedora +component compiz +version 12 +rep_platform x86_64 +op_sys Linux +priority low +bug_severity medium +assigned_to adel.gadllah@gmail.com +qa_contact extras-qa@fedoraproject.org +bug_file_loc +status_whiteboard abrt_hash:9d6ed64860473c6d40b0b90137f67f48417a51e7 +keywords +dependson +blocked +newcc +cf_fixed_in +cf_cust_facing --- +cf_issuetracker +cf_internal_whiteboard +cf_devel_whiteboard +cf_qa_whiteboard +cf_release_notes +cf_build_id +cf_targetrelease --- +defined_cf_partner +defined_cf_verified +cf_clone_of +defined_cf_conditional_nak +cf_environment +flag_type-65 X +flag_type-67 X +flag_type-16 X +requestee_type-16 +flag_type-66 X +defined_bit-41 1 +defined_bit-68 1 +defined_bit-31 1 +defined_bit-58 1 +defined_bit-50 1 +defined_bit-83 1 +defined_bit-21 1 +defined_bit-32 1 +defined_bit-15 1 +defined_bit-12 1 +defined_bit-161 1 +defined_bit-44 1 +defined_bit-22 1 +defined_bit-11 1 +defined_bit-48 1 +defined_bit-10 1 +defined_bit-93 1 +estimated_time 0.0 +work_time 0 +remaining_time 0.0 +deadline +external_id 0 +external_bug_id +comment +needinfo_role +needinfo_from +bug_status NEW +resolution NOTABUG +dup_id +defined_isprivate_2522533 1 +defined_isprivate_2521233 1 +defined_isprivate_2520112 1 +defined_isprivate_2519826 1 +defined_isprivate_2518162 1 +defined_isprivate_2518161 1 -- cgit