ca7d5327e325b074ce65c86f9ef7fea5be47ab25 tdreszer Wed Jul 20 11:13:05 2011 -0700 Initial check-in of not yet comple subtrack configuration module. diff --git src/hg/js/ajax.js src/hg/js/ajax.js index 2fc0083..4079a2f 100644 --- src/hg/js/ajax.js +++ src/hg/js/ajax.js @@ -52,72 +52,72 @@ ajaxWaitCallbackFunction = null; } function ajaxWaitCountDown() { // called whenever an ajax request is done if((req && req.readyState == 4) || (this.readyState == 4)) { // It is only state 4 that means done ajaxWaitCount--; if(ajaxWaitIsDone()) ajaxWaitCallback(); } //warn(req.readyState + " waiters:"+ajaxWaitCount); } -var formToSubmit = null; // multistate: null, {form}, "COMPLETE", "ONCEONLY" -var formSubmitPhase = 0; -function formSubmit() -{ // This will be called as a callback on timeout or ajaxWaitCallback - - if(formToSubmit != null) { - //warn("submitting form:"+$(formToSubmit).attr('name') + ": "+ajaxWaitIsDone()); - var form = formToSubmit; - formToSubmit = "GO"; // Flag to wait no longer - $(form).submit(); - } - waitMaskClear(); // clear any outstanding waitMask. overkill if the form has just been submitted -} -function formSubmitRegister(form) -{ // Registers the form submit to be done by ajaxWaitCallback or timeout - if(formToSubmit != null) // Repeated submission got through, so ignore it - return false; - waitMaskSetup(5000); // Will prevent repeated submissions, I hope. - formToSubmit = form; - //warn("Registering form to submit:"+$(form).attr('name')); - ajaxWaitCallbackRegister(formSubmit); - return false; // Don't submit until ajax is done. -} - -function formSubmitWaiter(e) -{ // Here we will wait for up to 5 seconds before continuing. - if(formToSubmit == null) - return formSubmitRegister(e.target); // register on first time through - - if(formToSubmit == "GO") { // Called again as complete - //warn("formSubmitWaiter(): GO"); - formToSubmit = "STOP"; // Do this only once! - return true; - } - return false; -} - -function formSubmitWaitOnAjax(form) -{ // Most typically, we block a form submit until all ajax has returned - $(form).unbind('submit', formSubmitWaiter ); // prevents multiple bind requests - $(form).bind( 'submit', formSubmitWaiter ); -} +// UNUSED but useful ? +// var formToSubmit = null; // multistate: null, {form}, "COMPLETE", "ONCEONLY" +// function formSubmit() +// { // This will be called as a callback on timeout or ajaxWaitCallback +// +// if(formToSubmit != null) { +// //warn("submitting form:"+$(formToSubmit).attr('name') + ": "+ajaxWaitIsDone()); +// var form = formToSubmit; +// formToSubmit = "GO"; // Flag to wait no longer +// $(form).submit(); +// } +// waitMaskClear(); // clear any outstanding waitMask. overkill if the form has just been submitted +// } +// function formSubmitRegister(form) +// { // Registers the form submit to be done by ajaxWaitCallback or timeout +// if(formToSubmit != null) // Repeated submission got through, so ignore it +// return false; +// waitMaskSetup(5000); // Will prevent repeated submissions, I hope. +// formToSubmit = form; +// //warn("Registering form to submit:"+$(form).attr('name')); +// ajaxWaitCallbackRegister(formSubmit); +// return false; // Don't submit until ajax is done. +// } +// +// function formSubmitWaiter(e) +// { // Here we will wait for up to 5 seconds before continuing. +// if(formToSubmit == null) +// return formSubmitRegister(e.target); // register on first time through +// +// if(formToSubmit == "GO") { // Called again as complete +// //warn("formSubmitWaiter(): GO"); +// formToSubmit = "STOP"; // Do this only once! +// return true; +// } +// return false; +// } +// +// function formSubmitWaitOnAjax(form) +// { // Most typically, we block a form submit until all ajax has returned +// $(form).unbind('submit', formSubmitWaiter ); // prevents multiple bind requests +// $(form).bind( 'submit', formSubmitWaiter ); +// } function loadXMLDoc(url) { // Load XML without a request handler; this is useful if you are sending one-way messages. loadXMLDoc(url, null); } function loadXMLDoc(url, callBack) { // From http://developer.apple.com/internet/webcontent/xmlhttpreq.html //warn("AJAX started: "+url); if(callBack == null) callBack = nullProcessReqChange; req = false; // branch for native XMLHttpRequest object @@ -207,34 +207,35 @@ } } function setAllVars(obj,subtrackName) { // Set all enabled inputs and selects found as children obj with names to cart with ajax // If obj is undefined then obj is document! var names = []; var values = []; if($(obj) == undefined) obj = $('document'); setVarsFromHash(getAllVars(obj,subtrackName)); } -function setCartVarFromObjId(obj) -{ - setCartVar($(obj).attr('id'),$(obj).val()); -} +// Unused but useful +// function setCartVarFromObjId(obj) +// { +// setCartVar($(obj).attr('id'),$(obj).val()); +// } function submitMain() { $('form[name="mainForm"]').submit(); } function setCartVarAndRefresh(name,val) { setCartVar(name,val); var main=$('form[name="mainForm"]') $(main).attr('action',window.location.href); setTimeout("submitMain()",50); // Delay in submit helps ensure that cart var has gotten there first. return false; }