(function() { var CheckingScriptObjectCommand = ASPx.CreateClass(null, { constructor: function(scriptName, markerObjectName) { this.scriptName = scriptName; this.markerObjectName = markerObjectName; this.isExisted = false; }, Run: function() { var markerObj = this.GetMarkerObject(); this.isExisted = !!markerObj; if(this.isExisted) markerObj.DXPatched = true; }, GetErrorMessage: function() { return this.GetErrorMessageCore(true); }, GetErrorMessageCore: function(isScriptRequired){ var markerObj = this.GetMarkerObject(); if(this.isExisted & markerObj && markerObj.DXPatched || !isScriptRequired && !markerObj) return null; if(isScriptRequired & !this.GetMarkerObject()){ if(this.isExisted) return this.scriptName + " script was attached but has been overridden."; else return this.scriptName + " script was not attached."; } if(!this.isExisted) return this.scriptName + " script was attached after DevExpress scripts."; return this.scriptName + " script was attached multiple times and mixed up with DevExpress scripts."; }, GetMarkerObject: function() { return ASPx.GetGlobalObject(this.markerObjectName); } }); var PatchScriptCommand = ASPx.CreateClass(CheckingScriptObjectCommand, { constructor: function(scriptName, markerObjectName, patchMethod, required) { this.constructor.prototype.constructor.call(this, scriptName, markerObjectName); this.required = required; this.patchMethod = patchMethod; }, Run: function() { CheckingScriptObjectCommand.prototype.Run.call(this); if(this.isExisted) this.patchMethod(); }, GetErrorMessage: function() { return this.GetErrorMessageCore(this.required); } }); var ExternalScriptProcessor = ASPx.CreateClass(null, { constructor: function() { this.commands = {}; }, Process: function(scriptName, markerObjectName, patchMethod, required) { var newCommand = this.CreateCommand(scriptName, markerObjectName, patchMethod, !!required); var oldCommand = this.commands[markerObjectName]; if(oldCommand) { if(!oldCommand.patchMethod & !newCommand.patchMethod) newCommand = null; else if(newCommand.patchMethod & (!oldCommand.patchMethod || oldCommand.required)) newCommand.required = true; else if(oldCommand.patchMethod & !newCommand.patchMethod) { oldCommand.required = true; newCommand = null; } } if(newCommand) { this.commands[markerObjectName] = newCommand; newCommand.Run(); } }, CreateCommand: function(scriptName, markerObjectName, patchMethod, required) { if(patchMethod) return new PatchScriptCommand(scriptName, markerObjectName, patchMethod, required); return new CheckingScriptObjectCommand(scriptName, markerObjectName); }, ShowErrorMessages: function() { var messages = this.GetErrorMessages(); var console = window.console; if(!messages.length || !console || !ASPx.IsFunction(console.error)) return; for(var i = 0; i < messages.length; i++) { console.error(messages[i]); } ASPx.ShowKBErrorMessage("Please check the correctness of script registration on the page. For details, see ", "T272309"); }, GetErrorMessages: function() { var messages = []; for (var key in this.commands) { if (this.commands.hasOwnProperty(key)) { var message = this.commands[key].GetErrorMessage(); if (message) messages.push(message); } } return messages; } }); ExternalScriptProcessor.Instance = null; ExternalScriptProcessor.getInstance = function() { if(!ExternalScriptProcessor.Instance) ExternalScriptProcessor.Instance = new ExternalScriptProcessor(); return ExternalScriptProcessor.Instance; }; ASPx.ExternalScriptProcessor = ExternalScriptProcessor; })(); 5c6z7