//! ################################################################ //! Copyright (c) 2004-2007 Amazon.com, Inc., and its Affiliates. //! All rights reserved. //! Not to be reused without permission //! $DateTime: 2007/10/29 04:17:48 $ //! ################################################################ function n2DynUpdateInitLibrary() { // Begin library code wrapper. Goes all the way to the bottom of the file if (window.goN2LibMon) { goN2LibMon.beginLoad('dynUpdate', 'n2CoreLibs'); } var nRequestSequenceNumber = 0; var imagePath = goN2Locale.getImageURL('JSF-loading-bar', 'nav2/images/loading-bar.gif'); window.gsN2LoadingMessage = '
' + goN2Locale.getString('loading_13548', 'Loading...') + '
'; window.gsN2TimeoutMessage = goN2Locale.getString('no_addl_info_36017', 'No additional information is available at this time'); window.n2DUExpandParameter=function(p, bEscape) { var sT=''; if (goN2U.isString(p)) { sT = p; } else if (goN2U.isNumber(p)) { sT = p.toString(); } else if (goN2U.isArray(p)) { for (var i=0; i0) sT +=';'; sT += p[i]; } } else if (goN2U.isObject(p) ) { for (var k in p) { if (sT.length >0) sT +=';'; sT += k+':'+p[k]; } } else if (!goN2U.isUndefOrNull(p)) { ; } if (bEscape) { var sE = sT.replace(/\/g, '>'); sE = encodeURIComponent(sE); sE = sE.replace(/\|/g, '%7C'); sE = sE.replace(/\~/g, '%7E'); sE = sE.replace(/\*/g, '%2A'); sE = sE.replace(/\'/g, '%27'); sE = sE.replace(/\(/g, '%28'); sE = sE.replace(/\)/g, '%29'); sE = sE.replace(/\!/g, '%21'); sE = sE.replace(/\_/g, '%5F'); return sE; } return sT; } window.n2HookForm=function(sFormName, oObj, sExecObjectName, sAction, sID, sType, params, sPaneID, sReftag) { sExecObjectName = sExecObjectName ? sExecObjectName : oObj.objectName; if (goN2U.isUndefOrNull(sExecObjectName)) { ; return; } ; oObj.sFormName = sFormName; var eF = document.forms[sFormName]; if (eF) { oObj.oForm = eF; ; var sParams = n2DUExpandParameter(params, false); if (goN2U.bIsSafari) { eF._sDUObjectName = sExecObjectName; eF['onsubmit'] = _n2SafariGenerateSubmit(sAction, sID, sType, sParams, sPaneID); } else { eF['onsubmit'] = new Function (sExecObjectName + "._submitFormUpdate(" + (sAction ? "'"+ sAction+"'," : "null,") + (sID ? "'"+ sID+"'," : "null,") + (sType ? "'"+ sType+"'," : "null,") + (sParams ? "'"+ sParams+"'," : "null,") + (sPaneID ? "'"+ sPaneID+"'," : "null,") + (sReftag ? "'"+ sReftag+"'" : "null") + "); return false;" ); } var method = eF.method; if (method && (method.toLowerCase() == 'post')) { oObj.sRequestMode = 'sdfs'; } else { oObj.sRequestMode = 'xdfs'; } ; } else { ; } } function _n2SafariGenerateSubmit(sAction, sID, sType, sParams, sPaneID, sRefTag) { var fnF = function () { var oDU = eval(this._sDUObjectName); if (oDU) { oDU._submitFormUpdate(sAction, sID, sType, sParams, sPaneID, sRefTag); } return false; } return fnF; } window.n2GetFieldValue=function(eForm, sValue, sComment) { var sVal; if (goN2U.isUndefOrNull(sValue)) return null; if (sValue.indexOf('MAP:')==0) { var sF = sValue.substring(4); var aF = sF.split(','); sVal = ''; for (var i=0; i0) sVal += ';'; var aMap = aF[i].split('='); var re = / /g; aMap[0] = aMap[0].replace(re,''); var eF = eForm[aMap[0]]; if (eF) { if (aMap.length >1) { eF.value = aMap[1]; ; } if (eF.type == "checkbox") { if (eF.checked) { sVal += eF.value; ; } else { ; } } else if (eF.type == "radio") { if (eF.checked) { sVal += eF.value; ; } else { ; } } else if (goN2U.isArray(eF) && goN2U.isDefined(eF.length)) { ; } else if (goN2U.isList(eF)) { if (eF.length > 0 && goN2U.isDefined(eF.item(0).checked)) { var foundVal = false; for (var j=0; j 0 && goN2U.isDefined(eF.item(0).selected)) { var foundVal = false; for (var j=0; j"); return txt; } this.summary = function () { var txt= this.totalRequestsCount + ":"; txt+= this.remoteRequestsCount + ":" + this.cachedHitsCount + ":"; txt+= this.successCount + ":" + this.nTimeoutCount + ":"; txt+= this.successAfterTimeoutCount + ":"; txt+=this.lastTripTime + ":"; txt+= this.minTripTime + ":" + this.maxTripTime + ":"; txt+= this.averageTripTime; return txt; } } window.N2DynamicUpdateCacheManager=function() { var sGlobalNamespace = '_global'; var cache = new Object(); cache[sGlobalNamespace] = new Array(); // global cache if no namespace used this.resetCache = function() { ; cache = new Object(); cache[sGlobalNamespace] = new Array(); }; this.clearCache = function(sNamespace) { ; if (!goN2U.isUndefOrNull(sNamespace)) { if (cache[sNamespace]) cache[sNamespace] = new Array(); } else { cache[sGlobalNamespace] = new Array(); } }; this.put = function(sKey, oValue, sNamespace) { ; var tmpCache; if (!goN2U.isUndefOrNull(sNamespace)) { if (!cache[sNamespace]) cache[sNamespace] = new Array(); tmpCache = cache[sNamespace]; } else { tmpCache = cache[sGlobalNamespace]; } tmpCache[sKey] = oValue; }; this.get = function(sKey, sNamespace) { ; var result = null; if (!goN2U.isUndefOrNull(sNamespace)) { if (cache[sNamespace]) { var tmpCache = cache[sNamespace]; if (tmpCache[sKey]) { result = tmpCache[sKey]; } } } else { var tmpCache = cache[sGlobalNamespace]; if (tmpCache[sKey]) { result = tmpCache[sKey]; } } return result; }; this.remove = function(sKey, sNamespace) { ; var tmpCache; if (!goN2U.isUndefOrNull(sNamespace)) { if (cache[sNamespace]) { tmpCache = cache[sNamespace]; tmpCache[sKey] = null; } } else { tmpCache = cache[sGlobalNamespace]; tmpCache[sKey] = null; } }; this.cacheSize = function(sNamespace) { var size = 0; if (!goN2U.isUndefOrNull(sNamespace)) { if (cache[sNamespace]) { var ct = 0; var c = cache[sNamespace]; for (var i in c) ct++ size = ct; } } else { var c = cache[sGlobalNamespace]; var ct = 0; for (var i in c) ct++; size = ct; } ; return size; }; this.dumpCache = function() { ; for (var i in cache) { ; var j = cache[i]; for (var k in j) { ; } } ; } }; window.N2DynamicUpdateManager=function() { this.className = 'N2DynamicUpdateManager'; this.version = '190'; this.SCRIPTIDPREFIX = "goN2SO_"; this.nScriptID=0; this.nSdfsID=0; this.oXHR = n2XHRFactory(); this.bXHRPRocessing=false; var queue = new N2FifoQueue(20); // circular queue, max 20 requests var requests = new N2DynamicUpdateCacheManager(); var nTimeoutStatus='255'; var nScriptErrStatus = '254'; var nNoInfoStatus = '253'; var oCfg = goN2U.getConfigurationObject('N2DynamicUpdateManager'); this.nTimeoutMS = oCfg.getValue('defaultTimeoutMS', 10000); this.baseURL = null; this.proxyURL = null; this.marketplace = null; this.sRID='NA'; var nSTATE_NOT_PROCESSING = 0; var nSTATE_WAITING = 1; var nSTATE_RESPONSE_RECEIVED = 2; var nSTATE_DATA_AVAILABLE = 3; var nSTATE_ABORTING_REQUEST = 4; this.nProcessState=nSTATE_NOT_PROCESSING; this.bExpectingResponseComplete = false; this.bXHREvalProcessing=false; this.stats = new N2DynUpStats(); this.optimize = true; this.bFirstSDFS = true; this.clearBuffer = true; this.sessionID = ''; this.bDisablePP = false; this.setBaseURL = function (sURL) { ; this.baseURL = sURL; this.baseDomain = null; var re = new RegExp('https?:\/\/[^/]+'); var m = re.exec(sURL); if (m != null) this.baseDomain = m[0]; } this.setMarketplace = function (mp) { this.marketplace = mp; } this.setSessionID = function (sID) { this.sessionID = sID; ; } this.setHTTPRID = function (sRID) { this.sRID = sRID; } this.disablePP = function (b) { this.bDisablePP = b; } this.setProxyURL = function (sURL) { this.proxyURL = sURL; ; } this.setDefaultTimeout = function (nMS) { this.nTimeoutMS = nMS; } this.clearCache = function () { requests.resetCache(); } this.clearSpecificCache = function(sNamespace) { requests.clearCache(sNamespace); } this.getCacheManager = function() { return requests; } this.getStats = function () { return this.stats; } this.requestTargetUpdate = function (oRequester, oTarget, sRequestMode, sHandler, sAction, sID, sType, params, nTimeoutMS, bImmediate, bCachable) { return this.requestUpdate (oRequester, sRequestMode, sHandler, sAction, sID, sType, params, nTimeoutMS, bImmediate, bCachable, null, null, oTarget); } this.requestUpdate = function (oRequester, sRequestMode, sHandler, sAction, sID, sType, params, nTimeoutMS, bImmediate, bCachable, fOverrideSuccess, fOverrideFailure, oOverride, sURLExtension, sReftag, sNamespace) { var oRequestInfo = this.getCurrentRequestInfo(); ; sNamespace = (typeof (sNamespace)!='undefined') ? sNamespace : null; if ((this.nProcessState == nSTATE_WAITING) && bImmediate) { this.cancelRequest(oRequestInfo.sRequestID, false, sNamespace); } bCachable = (typeof (bCachable)!='undefined') ? bCachable : true; sAction = n2DUExpandParameter(sAction, true); sID = n2DUExpandParameter(sID, true); sType = n2DUExpandParameter(sType, true); var sParams = n2DUExpandParameter(params, true); switch(sRequestMode) { case 'sd': sRequestMode = 'xhr'; ; break; case 'sdfs': sRequestMode = 'xhrfs'; ; break; } ; if (oRequester) { if (oRequester.sID) { ; } else { ; } } var sRequestID = this.genRequestID(sHandler,sAction,sID,sType,sParams); var oRequestInfo = new N2DynUpRequestInfo(oRequester, sRequestID, fOverrideSuccess, fOverrideFailure, oOverride, sNamespace); var oRequest = this.getRequest(sRequestID, sNamespace); if (oRequest) { oRequestInfo.oRequest = oRequest; if (oRequest.success) { ; this.stats.recordCacheHit(); this.processSuccess(oRequestInfo, oRequest.arHTML, oRequest.arJS, oRequest.nStatus, sRequestID); sRequestID = null; // there is no active request in this case. } else { ; this.addRequest(oRequestInfo); } } else { ; var sFullURL = this.genURL (sRequestMode, sHandler, sAction, sID, sType, sParams, sURLExtension, sReftag); nTimeoutMS = nTimeoutMS ? nTimeoutMS : this.nTimeoutMS; oRequestInfo.oRequest = new N2DynUpRequest(oRequester, sRequestMode, sFullURL, nTimeoutMS, bCachable, fOverrideSuccess, fOverrideFailure, oOverride); this.addRequest(oRequestInfo); } return sRequestID; } this.cancelRequest = function (sRequestID, bAbortRequestInProcess, sNamespace) { var bCancelled = false; if (bAbortRequestInProcess) { if (this.nProcessState == nSTATE_WAITING) { var oRequestInfo = this.getCurrentRequestInfo(); if (!oRequestInfo) { ; } else if (sRequestID == oRequestInfo.sRequestID) { ; this.stopWatchdog(); this.killCurrentRequest(oRequestInfo, false); bCancelled = true; } } else if (this.nProcessState > nSTATE_WAITING) { ; } } if (!bCancelled) { var oRequest = this.getRequest(sRequestID, sNamespace); if (oRequest) { ; oRequest.cancelled = true; } } } this.addRequest = function (oRequestInfo) { var sRequestID = oRequestInfo.sRequestID; ; requests.put(sRequestID, oRequestInfo.oRequest, oRequestInfo.sNamespace); queue.add(oRequestInfo); if (this.nProcessState) { ; } else { if (this.bExpectingResponseComplete) { ; this.responseComplete(); } else { this.remoteRequest(oRequestInfo.oRequest); } } return sRequestID; } this.cacheResponse = function (sRequestID, oRequest, sNamespace) { ; requests.put(sRequestID, oRequest, sNamespace); return sRequestID; } this.genRequestID = function (sHandler, sAction, sID, sType, sParams) { var reqID = sHandler; reqID += '^' + (sAction ? sAction : ''); reqID += '^' + (sType ? sType : ''); reqID += '^' + (sID ? sID : ''); reqID += '^' + (sParams ? sParams : ''); ; return reqID; } this.genURL = function (sMode, sHandler, sAction, sID, sType, sParams, sURLExtension, sReftag) { if (this.baseURL == null) { ; } if (this.sessionID == null || this.sessionID == '') { ; } if (this.marketplace == null) { ; } if (goN2U.isUndefOrNull(sURLExtension) ) { sURLExtension = '.html'; } if (goN2U.isUndefOrNull(sReftag) ) { sReftag = ''; } else { sReftag = '/ref=' + sReftag; } var sURL; if (sHandler.indexOf('\/') == 0 ) { sURL = this.baseDomain + sHandler + sURLExtension + sReftag + "/" + this.sessionID; } else { sURL = this.baseURL + sHandler + sURLExtension + sReftag + "/" + this.sessionID; } sURL += "?ie=UTF8"; sURL += "&rm="+sMode; if (this.proxyURL) { if(this.proxyURL.substr(1,2) == ':\\') { return 'file:///' +this.proxyURL + sHandler + '-' + sAction + '.html'; } else { sURL = this.proxyURL + "&url=" + sURL + "&ra="+sAction; } } else { if (typeof(sAction) != 'undefined' && sAction != null) sURL += "&ra="+sAction; } if (typeof(sID) != 'undefined' && sID != null) sURL += "&id="+sID; if (typeof(sType) != 'undefined' && sType != null) sURL += "&tt="+sType; if (this.marketplace != null) sURL += "&mp="+this.marketplace; sURL += "&vn="+this.version; if (!goN2U.isUndefOrNull(sParams)) sURL += "&ps="+sParams; if (this.optimize) { sURL += "&opt="+this.stats.summary(); } sURL += "&orid="+this.sRID; if (this.bDisablePP) sURL += '&PageProfiler=false&PowerBar=false'; ; return sURL; } this.getRequest = function (reqID, sNamespace) { var oRequest = requests.get(reqID, sNamespace); return oRequest; } this.removeRequest = function (reqID, sNamespace) { ; requests.remove(reqID, sNamespace); } this.getCurrentRequest = function () { var reqInfo = queue.current(); var reqID = reqInfo.sRequestID; var reqNamespace = reqInfo.sNamespace; if (reqID) return requests.get(reqID, reqNamespace); else return null; } this.getCurrentRequestInfo = function () { return queue.current(); } this._issueNextRequest = function () { ; var oRequestInfo = queue.next(); var oRequest, sRequestID; if (oRequestInfo) { sRequestID = oRequestInfo.sRequestID; oRequest = this.getRequest(sRequestID, oRequestInfo.sNamespace); ; ; ; } if (oRequest) { if (oRequest.success) { oRequestInfo.oRequest = oRequest; ; this.stats.recordCacheHit(); this.processSuccess(oRequestInfo, oRequest.arHTML, oRequest.arJS, oRequest.nStatus, sRequestID); this.issueNextRequest(); } else { ; this.remoteRequest(oRequest); } } else { ; } } this.issueNextRequest = this._issueNextRequest; this.remoteRequest = function (oRequest) { this.stats.recordRemoteRequest(); this.nProcessState = nSTATE_WAITING; this.bExpectingResponseComplete = true; this.startWatchdog(oRequest.nTimeoutMS); var now = new Date(); oRequest.reqStart = now.getTime(); switch ( oRequest.sRequestMode ) { case 'xd': ; oRequest.sScriptID = this.SCRIPTIDPREFIX+this.nScriptID.toString(); this.loadScript(oRequest.sURL, false, oRequest.sScriptID); this.nScriptID++; break; case 'sd': ; break; case 'xhr': ; this.XHRSend(oRequest.sURL, null); break; case 'xdfs': ; ; if (oRequest.oRequester && oRequest.oRequester.oForm) { var eF=oRequest.oRequester.oForm, sFields='', i=0, el; el=eF.elements[i]; while (!goN2U.isUndefOrNull(el)) { if (!eF.disabled) { if (el.type == "checkbox" || el.type == "radio") { if (el.checked) { sFields += '&'+el.name+"="+encodeURIComponent(el.value); } } else if (el.type == "select-multiple"){ for (var i=0; i < el.options.length; i++) if (el.options[i].selected) sFields += '&'+el.name+"="+encodeURIComponent(el.options[i].value); } else { sFields += '&'+el.name+"="+encodeURIComponent(el.value); } } el=eF.elements[++i] } var sURL= oRequest.sURL+sFields; ; oRequest.sScriptID = this.SCRIPTIDPREFIX+this.nScriptID.toString(); this.loadScript(sURL, false, oRequest.sScriptID); this.nScriptID++; } break; case 'sdfs': // MODIFIED for XHR case 'xhrfs': ; ; if (oRequest.oRequester && oRequest.oRequester.oForm) { var eF=oRequest.oRequester.oForm var sFields='', i=0, el; el=eF.elements[i]; while (!goN2U.isUndefOrNull(el)) { if (!eF.disabled) { if (el.type == "checkbox" || el.type == "radio") { if (el.checked) { sFields += '&'+el.name+"="+encodeURIComponent(el.value); } } else if (el.type == "select-multiple"){ for (var i=0; i < el.options.length; i++) if (el.options[i].selected) sFields += '&'+el.name+"="+encodeURIComponent(el.options[i].value); } else { sFields += '&'+el.name+"="+encodeURIComponent(el.value); } } el=eF.elements[++i]; } sFields = sFields.substring(1); var sURL= oRequest.sURL; if (window.goN2Debug) { ; this.nSdfsID++; } this.XHRSend(oRequest.sURL, sFields); } break; default: ; } } this.startWatchdog = function (nTimeoutMS){ nTimeoutMS = nTimeoutMS ? nTimeoutMS : this.nTimeoutMS; if (nTimeoutMS){ ; var tmpFn = function () { goN2DUManager.onTimeout(); }; this.watchdogTimer=setTimeout(tmpFn, nTimeoutMS); } } this.stopWatchdog = function (){ if (this.watchdogTimer){ clearTimeout(this.watchdogTimer); this.watchdogTimer = null; } } this.setWatchdog = function (delay, fn){ this.nTimeoutMS=delay; if (fn) this.on_timeout=fn; } this.onScriptError = function (sMsg, sFile, nLine) { sMsg = sMsg ? sMsg : "script error"; if (this.nProcessState) { // any processing state except nSTATE_NOT_PROCESSING var oRequestInfo = this.getCurrentRequestInfo(); if (!oRequestInfo) { return; } else { var oReq = oRequestInfo.oRequest; if ( oReq && (oReq.sRequestMode == 'xd' || oReq.sRequestMode == 'xdfs')){ this.killCurrentRequest(oRequestInfo, true, sMsg); } } } } this.onTimeout = function () { if (!this.watchdogTimer) { return; } this.watchdogTimer = null; var oRequestInfo = this.getCurrentRequestInfo(); if (!oRequestInfo) { ; return; } if (this.nProcessState == nSTATE_DATA_AVAILABLE) ; else ; var oRequest = oRequestInfo.oRequest; if (oRequest) { this.stats.recordTimeout(); oRequest.timedOut = true; } this.killCurrentRequest(oRequestInfo, true, 'timeout', nTimeoutStatus); } this.killCurrentRequest = function (oRequestInfo, bCallErrorCallback, sReason, nStatus) { var oRequest = oRequestInfo.oRequest; ; // supposed to be set if it's processing this.nProcessState=nSTATE_ABORTING_REQUEST; if (oRequest) { if (!oRequest.cancelled) { this.processFailure(oRequestInfo, sReason, nStatus, bCallErrorCallback); } this.removeRequest(oRequestInfo.sRequestID, oRequestInfo.sNamespace); } this.stopWatchdog(); if (this.bXHRPRocessing) { this.oXHR.abort(); this.bXHRPRocessing = false; if (goN2U.isMozilla5()) { goN2DUManager.oXHR = n2XHRFactory(); } } this.nProcessState = nSTATE_NOT_PROCESSING; // VITAL or next request will never be issued this.bExpectingResponseComplete = false; this.issueNextRequest(); } this.onDataAvailable = function (sRequestID, aHTML, aJSFunctions, nStatus, bJSData) { ; this.nProcessState = nSTATE_DATA_AVAILABLE; var bValidData=true; var msg = "Response contained no valid data. (0 HTML, 0 JS, no JSData). Status was "+ nStatus; if (!aHTML && !aJSFunctions && !bJSData) { ; bValidData=false; } var bCallProcessSuccess = false; var oRequestInfo = this.getCurrentRequestInfo(); var sNmSpace = (!oRequestInfo) ? null : oRequestInfo.sNamespace; var oRequest = this.getRequest(sRequestID, sNmSpace); if (!oRequestInfo && !oRequest) { ; return; } var sCurrentRequestID = ''; if (!oRequestInfo && oRequest) { oRequestInfo = oRequest; sNmSpace = (!oRequestInfo) ? null : oRequestInfo.sNamespace; } else { sCurrentRequestID = oRequestInfo.sRequestID; } var latency = "(cached)"; if (oRequest) { var now = new Date(); latency = now.getTime() - oRequest.reqStart; this.stats.recordSuccess(latency, oRequest.timedOut); ; if (!aHTML && !aJSFunctions && !bJSData) { this.processFailure(oRequestInfo, msg, nStatus, true); return; } oRequest.tripTime = latency; if (!oRequest.cancelled) { if (sCurrentRequestID == sRequestID) { bCallProcessSuccess = true; } else { ; } } } else if (bValidData) { ; oRequest = new N2DynUpRequest(null, '', ''); this.cacheResponse(sRequestID, oRequest, sNmSpace); } if (window.goN2Debug) { ; } if (oRequest && oRequest.bCachable) { ; oRequest.arJS = aJSFunctions; oRequest.arHTML = aHTML; oRequest.nStatus = nStatus; oRequest.success = true; // FIXME: Should this be the status code >=0 ? } if (bCallProcessSuccess ) this.processSuccess(oRequestInfo, aHTML, aJSFunctions, nStatus, sRequestID); if (oRequest && !oRequest.bCachable) { ;//goN2Debug.info("Removing request as it is not marked cachable...") this.removeRequest(sRequestID, sNmSpace); } } this.processSuccess = function (oRequestInfo, aHTML, aJSFunctions, nStatus, sRequestID) { var oRequester = oRequestInfo.oRequester; var oOverride = !goN2U.isUndefined(oRequestInfo.oOverride) && oRequestInfo.oOverride != null ? oRequestInfo.oOverride : oRequester; if (oRequester) { ; if (oRequester.sID) ; if (oRequestInfo.methodSuccess) { ; oRequestInfo.methodSuccess.call(oOverride, aHTML, aJSFunctions, nStatus, sRequestID); } else { ; oRequester.onRequestSuccess(aHTML, aJSFunctions, nStatus, sRequestID); } oRequester.requestComplete(); } } this.processFailure = function (oRequestInfo, sMessage, nStatus, bNotifyRequestor) { var oRequester = oRequestInfo.oRequester; var oOverride = oRequestInfo.oOverride ? oRequestInfo.oOverride : oRequester; if (oRequester) { if (bNotifyRequestor) { ; if (oRequestInfo.methodFailure) oRequestInfo.methodFailure.call(oOverride, sMessage, nStatus, oRequestInfo.sRequestID); else oRequester.onRequestFailure(sMessage, nStatus, oRequestInfo.sRequestID); } oRequester.requestComplete(); } } this.responseHead = function (sID) { this.nProcessState = nSTATE_RESPONSE_RECEIVED; ; ; } this.responseComplete = function () { this.bExpectingResponseComplete = false; var oRequestInfo = this.getCurrentRequestInfo(); this.stopWatchdog(); if (oRequestInfo) { var sRequestID = oRequestInfo.sRequestID; ; var oRequest = oRequestInfo.oRequest; if (nSTATE_NOT_PROCESSING < this.nProcessState && this.nProcessState < nSTATE_DATA_AVAILABLE ) { if (nSTATE_DATA_AVAILABLE <= this.nProcessState) { ; } else { ; } if (!oRequest.cancelled) { this.processFailure(oRequestInfo, 'Error: No information matching your request returned', nNoInfoStatus, true); } } if (oRequest) { if (oRequest.sScriptID) { goN2U.removeElementById(oRequest.sScriptID); oRequest.sScriptID = null; } } } else { ; ; } this.nProcessState=nSTATE_NOT_PROCESSING; // VITAL or next request will never be issued if (!this.bXHREvalProcessing) { this.issueNextRequest(); } } this.loadScript = function (sURL, bLocalCacheOK, sID) { ; var e = document.createElement("script"); e.type="text/javascript"; e.id=sID; e.charset = "utf-8"; if (bLocalCacheOK) { e.src = sURL; } else { e.src = sURL + (sURL.indexOf('?') == -1 ? '?' : '&') + 'n2t='+ new Date().getTime(); } oTheHead.appendChild(e); // test change 2005-04-06 } this.XHRSend = function(sURL, sData) { var sMode = "GET"; var bSuccess = true; var sDataLength = 'N/A'; if (sData) { sMode = "POST"; sDataLength = sData.length; } try { ; this.oXHR.open(sMode, sURL, true); this.oXHR.onreadystatechange= function() { goN2DUManager.onXHRReadyStateChange() }; if (sMode == "POST") { this.oXHR.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); this.oXHR.send(sData); } else { this.oXHR.send(null); } this.bXHRPRocessing = true; } catch(e) { ; this.bXHRPRocessing = false; this.killCurrentRequest(this.getCurrentRequestInfo(), true, 'Bad XHRResponse', goN2U.isDefined(this.oXHR) ? this.oXHR.status: '???'); bSuccess = false; } return bSuccess; } this.onXHRReadyStateChange = function() { var oXHR = this.oXHR; if (oXHR.readyState==4) { var oRequestInfo = this.getCurrentRequestInfo(); this.bXHRPRocessing = false; if (this.nProcessState!=nSTATE_ABORTING_REQUEST) { try { if (oXHR.status == 200) { var len = oXHR.responseText.length; ; try { this.bXHREvalProcessing=true; eval(oXHR.responseText); this.bXHREvalProcessing=false; if (this.nProcessState!=nSTATE_NOT_PROCESSING) { ; this.killCurrentRequest(oRequestInfo, true, 'Bad XHRResponse (incomplete?)', oXHR.status); } else { this.issueNextRequest(); } } catch (e) { this.bXHREvalProcessing=false; ;//goN2Debug.scriptError("Error eval-ing XHR response. (" + e.toString() + ")."); ; this.killCurrentRequest(oRequestInfo, true, 'Error eval-ing XHR response', oXHR.status); } } else { ; this.killCurrentRequest(oRequestInfo, true, 'Bad XHRResponse', oXHR.status); } } catch (e) { ; this.killCurrentRequest(oRequestInfo, true, 'XHR Exception', oXHR.status); } } } else { ; } } } window.goN2DUManager = new N2DynamicUpdateManager; N2DynUpObject.prototype.oUpdateManager = goN2DUManager; N2ChainEventHandler ('onerror', function(){ goN2DUManager.onScriptError(); }, 'goN2DUManager chain onError event' ); goN2Persist = { sPersistFormName: 'goN2PersistForm', aRenderContentCalled: {}, aEvalFunctionsCalled: {}, aSkipProcessing: {}, saveContent: function(sFormName, aHTML) { var oForm = document.forms[sFormName]; if (!oForm) { ; return; } ; var nFields = oForm.elements.length/2; if (!aHTML) { return; } var iNext; var aLookup = {}; for (iNext=0; iNext < nFields; ++iNext) { var sId = oForm['k_'+iNext].value; if (goN2U.isUndefOrNull(sId) || sId.length==0) { break; } aLookup[sId] = iNext; } ; for (var sId in aHTML) { if (goN2U.isDefined(aLookup[sId])) { ; oForm['v_'+aLookup[sId]].value = aHTML[sId]; ; } else { if (iNext >= nFields) { ; return false; } ; oForm['k_'+iNext].value = sId; oForm['v_'+iNext].value = aHTML[sId]; aLookup[sId] = iNext; // add to the lookup array for check below iNext++; } } return true; }, saveFunctions: function(sFormName, aFns) { var oForm = document.forms[sFormName]; if (oForm && aFns) { ; var nFields = oForm.elements.length/2; var nFns = aFns.length; var nCount = 0; if (nFns <= nFields) { var i; for (i=0;i=0) { oForm.elements['v_'+nIndex].value = sValue; bOK = true; } else { var nFields = oForm.elements.length/2; var i; for (i=0;i=0 && oForm) { sData = oForm.elements['v_'+nIndex].value; } } else { ; } return sData; }, getValueIndex: function (sFormName, sKey) { var oForm = document.forms[sFormName]; if (oForm) { var nFields = oForm.elements.length/2; var i; for (i=0;iPersistForms:[I|O]','beforeBegin'); } if (window.goN2LibMon) goN2LibMon.endLoad('dynUpdate'); } // END library code wrapper n2RunIfLoaded("utilities", n2DynUpdateInitLibrary, "dynupdate");