__AJAXCboList = new Array(); __bPageIsStored = false; __bUnloadStoredPage = false; __bTracing = false; __PreviousOnFormSubmit = null; __PreviousPostBack = null; __PreviousOnPageLoad = null; __PreviousOnPageBeforeUnload = null; __PreviousOnPageUnload = null; __TraceWindows = new Array(); __ClockID = 0; function AjaxCallObject() { this.Init(); } AjaxCallObject.prototype.Init = function() { this.XmlHttp = this.GetHttpObject(); } AjaxCallObject.prototype.GetHttpObject = function() { var xmlhttp; /*@cc_on @if (@_jscript_version >= 5) try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp = false; } } @else xmlhttp = false; @end @*/ if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { try { xmlhttp = new XMLHttpRequest(); } catch (e) { xmlhttp = false; } } return xmlhttp; } AjaxCallObject.prototype.GetAjaxCallType = function(element) { if (element == null) return "none"; var attrib = element.getAttribute("AjaxCall"); if (attrib != null) return attrib.toLowerCase(); if (element.parentNode == null || element.parentNode == document.body) return "none"; else return this.GetAjaxCallType(element.parentNode); } AjaxCallObject.prototype.HookAjaxCall = function(bPageIsStored, bUnloadStoredPage, bTracing) { __PreviousOnFormSubmit = document.forms[0].onsubmit; document.forms[0].onsubmit = this.OnFormSubmit; if (typeof __doPostBack != 'undefined') { __PreviousPostBack = __doPostBack; __doPostBack = this.DoPostBack; } __bPageIsStored = bPageIsStored; __bUnloadStoredPage = bUnloadStoredPage; __bTracing = bTracing; if (typeof(RBS_Controls) != "undefined") { for (var i=0; i < RBS_Controls.length; i++) RBS_Controls_Store[i].setAttribute("ExcludeFromPost", "true"); } if ( !bPageIsStored || !bUnloadStoredPage ) { __PreviousOnPageLoad = window.onload; window.onload = this.OnPageLoad; __PreviousOnPageBeforeUnload = window.onbeforeunload; window.onbeforeunload = this.OnPageBeforeUnload; } __PreviousOnPageUnload = window.onunload; window.onunload = this.OnPageUnload; } AjaxCallObject.prototype.OnFormSubmit = function() { // Empty the cached html of RenderedByScript controls if (typeof(RBS_Controls) != "undefined") { for (var i=0; i < RBS_Controls.length; i++) RBS_Controls_Store[i].value = ""; } var target; if ("activeElement" in document) { // Internet Explorer target = document.activeElement; } else { // Firefox target = arguments[0] ? arguments[0].explicitOriginalTarget : null; } if (__PreviousOnFormSubmit != null) if ( __PreviousOnFormSubmit() == false ) return false; var cbType = AJAXCbo.GetAjaxCallType(target); if (cbType != "none") { AJAXCbo.DoAjaxCall(target.name, "", cbType); return false; } else { AJAXCbo.ClearTracingWindows(); return true; } } // Replaces normal __doPostBack AjaxCallObject.prototype.DoPostBack = function(eventTarget, eventArgument) { // Empty the cached html of RenderedByScript controls if (typeof(RBS_Controls) != "undefined") { for (var i=0; i < RBS_Controls.length; i++) RBS_Controls_Store[i].value = ""; } var target; var elemUniqueID = eventTarget.split("$").join(":"); var ids = elemUniqueID.split(":"); // Checks the unique id and its parents until it finds a target element // i.e. for ajaxPanel_grid:row:field it checks // ajaxPanel_grid_row_field // ajaxPanel_grid_row // ajaxPanel_grid for (var num=ids.length; num > 0; num--) { var elemID = ""; for (var i=0; i < num; i++) elemID += (i==0 ? "" : "_") + ids[i]; target = document.getElementById(elemID); if (target != null) break; } var cbType = AJAXCbo.GetAjaxCallType(target); if (cbType != "none") { AJAXCbo.DoAjaxCall(eventTarget, eventArgument, cbType); } else { if (__PreviousPostBack != null) { __PreviousPostBack(eventTarget, eventArgument); } } } AjaxCallObject.prototype.OnPageLoad = function() { // Restore the html of RenderedByScript controls if (typeof(RBS_Controls) != "undefined") { for (var i=0; i < RBS_Controls.length; i++) { var html = RBS_Controls_Store[i].value; if (html != "") { RBS_Controls[i].innerHTML = html.substring(5, html.length); RBS_Controls_Store[i].value = ""; } } } if (__PreviousOnPageLoad != null) return __PreviousOnPageLoad(); } 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_Controls) != "undefined") { for (var i=0; i < RBS_Controls.length; i++) RBS_Controls_Store[i].value = "HTML:" + RBS_Controls[i].innerHTML; } if (__PreviousOnPageBeforeUnload != null) return __PreviousOnPageBeforeUnload(); } AjaxCallObject.prototype.OnPageUnload = function() { AJAXCbo.ClearTracingWindows(); if ( !__bPageIsStored || !__bUnloadStoredPage ) return; if (document.forms[0]["__AJAX_PAGEKEY"] == null) return; var thePage = document.forms[0].action; var index = thePage.indexOf("?"); if (index != -1) thePage = thePage.substring(0, index); thePage = thePage + "?__AJAX_PAGEUNLOAD=" + encodeURIComponent(document.forms[0]["__AJAX_PAGEKEY"].value); var oThis = AJAXCbo; __AJAXCboList.push(oThis); AJAXCbo = new AjaxCallObject(); if( oThis.XmlHttp ) { oThis.XmlHttp.open('GET', thePage, true); oThis.XmlHttp.onreadystatechange = function(){ }; oThis.XmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); oThis.XmlHttp.send(null); } if (__PreviousOnPageUnload != null) return __PreviousOnPageUnload(); } AjaxCallObject.prototype.DoAjaxCall = function(eventTarget, eventArgument, ajaxCallType) { var theData = ''; var theform = document.forms[0]; var thePage = theform.action; var eName = ''; theData = '__EVENTTARGET=' + this.EncodePostData(eventTarget.split("$").join(":")) + '&'; theData += '__EVENTARGUMENT=' + this.EncodePostData(eventArgument) + '&'; theData += '__AJAXCALL=true&'; if ( ! __bPageIsStored ) theData += '__VIEWSTATE=' + this.EncodePostData(theform.__VIEWSTATE.value) + '&'; for( var i=0; i!!! AjaxCall was aborted !!!"); this.CloseTrace(); } if (waitElement) waitElement.style.visibility = 'hidden'; } AjaxCallObject.prototype.OnError = function(status, statusText, responseText) { if (__bTracing) { this.WriteTrace("!!! Server reported an Error !!!"); this.CloseTrace(); } if (waitElement) waitElement.style.visibility = 'hidden'; document.close(); // for IE document.write(responseText); document.close(); // for Firefox } AjaxCallObject.prototype.ReadyStateChange = function() { if( this.XmlHttp.readyState == 1 ) { this.OnLoading(); } else if( this.XmlHttp.readyState == 2 ) { this.OnLoaded(); } else if( this.XmlHttp.readyState == 3 ) { this.OnInteractive(); } else if( this.XmlHttp.readyState == 4 ) { if( this.XmlHttp.status == 0 ) this.OnAbort(); else if( this.XmlHttp.status == 200 && this.XmlHttp.statusText == "OK" ) this.OnComplete(this.XmlHttp.responseText, this.XmlHttp.responseXML); else this.OnError(this.XmlHttp.status, this.XmlHttp.statusText, this.XmlHttp.responseText); // Remove this AJAXCbo from the list for (var i=0; i < __AJAXCboList.length; i++) if (__AJAXCboList[i] == this) { __AJAXCboList[i].XmlHttp = null; __AJAXCboList.splice(i, 1); break; } } } AjaxCallObject.prototype.TraceWindow = null; AjaxCallObject.prototype.SetIntervalForAjaxCall = function(milliSec) { if (__ClockID != 0) this.ClearIntervalForAjaxCall(); __ClockID = window.setInterval("AJAXCbo.DoAjaxCall('__AJAX_AJAXCALLTIMER','','async')", milliSec); } AjaxCallObject.prototype.ClearIntervalForAjaxCall = function() { window.clearInterval(__ClockID); __ClockID = 0; } AjaxCallObject.prototype.CreateTracingWindow = function() { for (var i=0; i < __TraceWindows.length; i++) { if (__TraceWindows[i].closed) { __TraceWindows.splice(i, 1); i--; } } this.TraceWindow = null; for (var i=0; i < __TraceWindows.length; i++) { if (__TraceWindows[i].TraceFinished) { this.TraceWindow = __TraceWindows[i]; } } if (this.TraceWindow == null) { this.TraceWindow = window.open("","_blank","location=no,resizable=yes,scrollbars=yes"); __TraceWindows.push(this.TraceWindow); } this.TraceWindow.TraceFinished = false; } AjaxCallObject.prototype.ClearTracingWindows = function() { for (var i=0; i < __TraceWindows.length; i++) { __TraceWindows[i].close(); __TraceWindows.splice(i, 1); i--; } } AjaxCallObject.prototype.TraceSentData = function(data) { this.WriteTrace("Ajax Call invoked at " + new Date().toLocaleTimeString() + "
"); if (__bPageIsStored) this.WriteTrace("Page Store Mode: Stored (Session or Cache)
"); else this.WriteTrace("Page Store Mode: NoStore
"); this.WriteTrace("Form Data sent to server (" + data.length + " characters):
"); this.WriteTrace("------------------------------

"); var fields = data.split("&"); for (var i=0; i < fields.length; i++) { var parts = fields[i].split("="); this.WriteTrace("" + parts[0] + "="); this.WriteTrace(this.EncodeTraceData(parts[1]) + "
"); } this.WriteTrace("------------------------------
"); this.WriteTrace("Waiting response from server.....
"); } AjaxCallObject.prototype.TraceReceivedData = function(data) { this.WriteTrace("Server responsed at " + new Date().toLocaleTimeString() + "
"); this.WriteTrace("Javascript code received from server (" + data.length + " characters):
"); this.WriteTrace("------------------------------

"); this.WriteTrace(this.EncodeTraceData(data) + "
"); this.WriteTrace("------------------------------
"); this.CloseTrace(); } AjaxCallObject.prototype.WriteTrace = function(text) { this.TraceWindow.document.write(text); } AjaxCallObject.prototype.CloseTrace = function() { this.TraceWindow.document.close(); this.TraceWindow.TraceFinished = true; } AjaxCallObject.prototype.EncodeTraceData = function(data) { return data.split("<").join("<").split(" ").join(" ").split("\r\n").join("
"); } AjaxCallObject.prototype.EncodePostData = function(data) { return data.split("%").join("%25").split("=").join("%3d").split("&").join("%26").split("+").join("%2b"); } AjaxCallObject.prototype.SetAttributesOfControl = function(clientID, attributes) { var place = document.getElementById(clientID); if (place != null && attributes != "") { var attribs = attributes.split("|"); for (var i=0; i < attribs.length; i++) { var parts = attribs[i].split("="); place.setAttribute(parts[0], parts[1]) } } } AjaxCallObject.prototype.AddElementScript = function(parentID, tagName, elementID, html, beforeElemID) { var place = document.getElementById(parentID); var child = (elementID != "") ? document.getElementById(elementID) : null; if (place != null && child == null) { child = document.createElement(tagName); child.id = elementID; var before = (beforeElemID != null) ? document.getElementById(beforeElemID) : null; place.insertBefore(child, before); child.innerHTML = html; } else this.SetHtmlOfElementScript (html, elementID); } AjaxCallObject.prototype.RemoveElementScript = function(parentID, elementID) { var place = document.getElementById(parentID); var child = document.getElementById(elementID); if (place != null && child != null) place.removeChild(child); } AjaxCallObject.prototype.SetFieldScript = function(fieldName, fieldValue) { var field = document.forms[0][fieldName]; if (field != null) field.value = fieldValue; } AjaxCallObject.prototype.SetFieldIfEmptyScript = function(fieldName, fieldValue) { var field = document.forms[0][fieldName]; if (field != null && field.value == '') field.value = fieldValue; } AjaxCallObject.prototype.SetHtmlOfElementScript = function(html, elementID) { var place = document.getElementById(elementID); if (place != null) place.innerHTML=html; } AjaxCallObject.prototype.SetHtmlOfPage = function(html) { document.close(); // for IE document.write(html); document.close(); // for Firefox } AjaxCallObject.prototype.SetVisibilityOfElement = function(elementID, visible) { var place = document.getElementById(elementID); if (place != null) place.style.display = (visible) ? "" : "none"; } AjaxCallObject.prototype.Alert = function(message) { window.alert(message); } // It's used by AjaxPanel AjaxCallObject.prototype.ExtendedSetHtmlOfElementScript = function(html, elementID) { var store = document.createElement("span"); store.innerHTML = html; var spans = store.getElementsByTagName("span"); for (var i=0; i < spans.length; i++) { var elem = spans[i]; if (elem.getAttribute("name") == "__ajaxmark") { var elemOnPage = document.getElementById(elem.id); if (elemOnPage != null) elem.innerHTML = elemOnPage.innerHTML; } } var place=document.getElementById(elementID); if (place != null) place.innerHTML = store.innerHTML; } var AJAXCbo = new AjaxCallObject(); // wait element CreateWaitElement(); if (window.addEventListener) { window.addEventListener('scroll', MoveWaitElement, false); window.addEventListener('resize', MoveWaitElement, false); } else if (window.attachEvent) { window.attachEvent('onscroll', MoveWaitElement); window.attachEvent('onresize', MoveWaitElement); } var waitElement; var scrollX, scrollY = -1; function MoveWaitElement() { var scrollYT, scrollXT; if (!waitElement) CreateWaitElement(); if (typeof(window.pageYOffset) == "number") { scrollYT = window.pageYOffset; scrollXT = window.pageXOffset; } else if (document.body && document.documentElement && document.documentElement.scrollTop) { scrollYT = document.documentElement.scrollTop; scrollXT = document.body.scrollLeft; } else if (document.body && typeof(document.body.scrollTop) == "number") { scrollYT = document.body.scrollTop; scrollXT = document.body.scrollLeft; } if (scrollX != scrollXT || scrollY != scrollYT) { scrollX = scrollXT; scrollY = scrollYT; var width = document.body.clientWidth; waitElement.style.top = scrollYT + "px"; waitElement.style.right = -scrollXT + "px"; } } function CreateWaitElement() { var elem = document.getElementById('__AjaxCall_Wait'); if (!elem) { elem = document.createElement("div"); elem.id = '__AjaxCall_Wait'; elem.style.position = 'absolute'; elem.style.height = 17; elem.border = "1px"; elem.style.paddingLeft = "3px"; elem.style.paddingRight = "3px"; elem.style.fontSize = "11px"; elem.style.fontFamily="Tahoma"; elem.style.color="#ffffff"; elem.style.backgroundColor="Red"; elem.style.borderColor = "#ffffff"; elem.style.borderSize = "1px"; elem.innerHTML = ' Loading MyIFE Data ... '; elem.style.visibility = 'hidden'; document.body.insertBefore(elem, document.body.firstChild); } waitElement = elem; } // end wait element