From: Argiris K. <be...@us...> - 2005-11-21 12:18:45
|
Update of /cvsroot/magicajax/magicajax/Core/script In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2251/Core/script Modified Files: AjaxCallObject.js Log Message: Replaced RBS_Control_Stores with a single field storing the form's html. Added 'tracing' configuration option, used to monitor the traffic of AjaxCalls. Added a check that does not enable MagicAjax for browsers other than IE and Firefox. Index: AjaxCallObject.js =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/script/AjaxCallObject.js,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** AjaxCallObject.js 20 Nov 2005 08:47:30 -0000 1.11 --- AjaxCallObject.js 21 Nov 2005 12:18:37 -0000 1.12 *************** *** 1,4 **** --- 1,6 ---- __AJAXCboList = new Array(); __bPageIsStored = false; + __PageStateCache = null; + __bTracing = false; __PreviousOnFormSubmit = null; __PreviousPostBack = null; *************** *** 59,63 **** } ! AjaxCallObject.prototype.HookAjaxCall = function(bPageIsStored, bUnloadStoredPage) { __PreviousOnFormSubmit = document.forms[0].onsubmit; --- 61,65 ---- } ! AjaxCallObject.prototype.HookAjaxCall = function(bPageIsStored, bUnloadStoredPage, pageStateCache, bTracing) { __PreviousOnFormSubmit = document.forms[0].onsubmit; *************** *** 71,80 **** __bPageIsStored = bPageIsStored; ! if (typeof(RBS_ControlIDs) != "undefined") ! { ! for (var i=0; i < RBS_ControlIDs.length; i++) ! RBS_Controls_Store[i].setAttribute("ExcludeFromPost", "true"); ! } if ( !bPageIsStored || !bUnloadStoredPage ) --- 73,80 ---- __bPageIsStored = bPageIsStored; + __PageStateCache = pageStateCache; + __bTracing = bTracing; ! __PageStateCache.setAttribute("ExcludeFromPost", "true"); if ( !bPageIsStored || !bUnloadStoredPage ) *************** *** 161,178 **** AjaxCallObject.prototype.OnPageLoad = function() { ! // Restore the html of RenderedByScript controls ! if (typeof(RBS_ControlIDs) != "undefined") { ! for (var i=0; i < RBS_ControlIDs.length; i++) ! { ! var elem = document.all[RBS_ControlIDs[i]]; ! var html = RBS_Controls_Store[i].value; ! if (html != "" && elem != null) ! { ! elem.innerHTML = decodeURIComponent(html.substring(5, html.length)); ! RBS_Controls_Store[i].value = ""; ! } ! } } if (__PreviousOnPageLoad != null) return __PreviousOnPageLoad(); --- 161,172 ---- AjaxCallObject.prototype.OnPageLoad = function() { ! // Restore the html of form ! var html = __PageStateCache.value; ! if (html != "") { ! document.forms[0].innerHTML = decodeURIComponent(html.substr(5)); ! __PageStateCache.value = ""; } + if (__PreviousOnPageLoad != null) return __PreviousOnPageLoad(); *************** *** 181,195 **** AjaxCallObject.prototype.OnPageBeforeUnload = function() { ! // Save the html of RenderedByScript controls, so that it can be restored for the // browser's "Back Button" ! if (typeof(RBS_ControlIDs) != "undefined") ! { ! for (var i=0; i < RBS_ControlIDs.length; i++) ! { ! var elem = document.all[RBS_ControlIDs[i]]; ! if (elem != null) ! RBS_Controls_Store[i].value = "HTML:" + encodeURIComponent(elem.innerHTML); ! } ! } if (__PreviousOnPageBeforeUnload != null) return __PreviousOnPageBeforeUnload(); --- 175,182 ---- AjaxCallObject.prototype.OnPageBeforeUnload = function() { ! // Save the html of the form, so that it can be restored for the // browser's "Back Button" ! __PageStateCache.value = "HTML:" + encodeURIComponent(document.forms[0].innerHTML); ! if (__PreviousOnPageBeforeUnload != null) return __PreviousOnPageBeforeUnload(); *************** *** 280,286 **** } ! if (theData.substring(theData.length-1, theData.length) == "&") ! theData = theData.substring(0, theData.length-1); ! if( this.XmlHttp ) { --- 267,273 ---- } ! if (theData.substr(theData.length-1) == "&") ! theData = theData.substr(0, theData.length-1); ! if( this.XmlHttp ) { *************** *** 294,297 **** --- 281,290 ---- __AJAXCboList.push(oThis); AJAXCbo = new AjaxCallObject(); + + if (__bTracing) + { + this.CreateTracingWindow(); + this.TraceSentData(theData); + } if( this.XmlHttp.readyState == 4 || this.XmlHttp.readyState == 0 ) *************** *** 345,353 **** AjaxCallObject.prototype.OnComplete = function(responseText, responseXml) { ! //alert(responseText); // Checking if the data were fully loaded, without being aborted var flag = "'AJAX_LOADING_OK';\r\n"; ! if (responseText.substring(responseText.length - flag.length, responseText.length) != flag) return false; --- 338,349 ---- AjaxCallObject.prototype.OnComplete = function(responseText, responseXml) { ! if (__bTracing) ! { ! this.TraceReceivedData(responseText); ! } // Checking if the data were fully loaded, without being aborted var flag = "'AJAX_LOADING_OK';\r\n"; ! if (responseText.substr(responseText.length - flag.length) != flag) return false; *************** *** 407,410 **** --- 403,408 ---- } + AjaxCallObject.prototype.TraceWindow = null; + AjaxCallObject.prototype.ClockID = 0; *************** *** 422,425 **** --- 420,457 ---- } + AjaxCallObject.prototype.CreateTracingWindow = function() + { + this.TraceWindow = window.open("","_blank","location=no,resizable=yes,scrollbars=yes"); + } + + AjaxCallObject.prototype.TraceSentData = function(data) + { + this.WriteTrace("<b>Ajax Call invoked at " + new Date().toLocaleTimeString() + "<br>"); + this.WriteTrace("Form Data sent to server (" + data.length + " characters):<br>"); + this.WriteTrace("------------------------------</b><br>"); + + var fields = data.split("&"); + for (var i=0; i < fields.length; i++) + this.WriteTrace(decodeURIComponent(fields[i].split("<").join("<")) + "<br>"); + + this.WriteTrace("<b>------------------------------</b><br>"); + this.WriteTrace("Waiting response from server.....<br>"); + } + + AjaxCallObject.prototype.TraceReceivedData = function(data) + { + this.WriteTrace("<b>Server responsed at " + new Date().toLocaleTimeString() + "<br>"); + this.WriteTrace("Javascript code received from server (" + data.length + " characters):<br>"); + this.WriteTrace("------------------------------</b><br>"); + this.WriteTrace(data.split("<").join("<").split("\r\n").join("<br>")); + this.WriteTrace("<b>------------------------------</b><br>"); + this.TraceWindow.document.close(); + } + + AjaxCallObject.prototype.WriteTrace = function(text) + { + this.TraceWindow.document.write(text); + } + AjaxCallObject.prototype.SetAttributesOfControl = function(clientID, attributes) { *************** *** 439,443 **** { var place = document.getElementById(parentID); ! var child = document.getElementById(elementID); if (place != null && child == null) { --- 471,475 ---- { var place = document.getElementById(parentID); ! var child = (elementID != "") ? document.getElementById(elementID) : null; if (place != null && child == null) { *************** *** 446,451 **** var before = (beforeElemID != null) ? document.getElementById(beforeElemID) : null; place.insertBefore(child, before); } ! this.SetHtmlOfElementScript (html, elementID); } --- 478,485 ---- var before = (beforeElemID != null) ? document.getElementById(beforeElemID) : null; place.insertBefore(child, before); + child.innerHTML = html; } ! else ! this.SetHtmlOfElementScript (html, elementID); } |