📄 atlasruntime.js
字号:
Web.Flags =new function(){function valueFromString(s){var parts =s.split('|');var value =0;for (var i =parts.length -1;i >=0;i--){var part =parts[i].trim();var found =false;for (var f in this){if (f ==part){value |=this[f];found =true;break;}}if (found ==false){throw 'Invalid Enumeration Value';}}return value;}function valueToString(value){var sb =new Web.StringBuilder();for (var i in this){if ((this[i]&value)!=0){if (sb.isEmpty()==false){sb.append(' | ');}sb.append(i);}}return sb.toString();}this.create =function(){var flags =new Object();flags.parse =valueFromString;flags.toString =valueToString;for (var i =0;i <arguments.length;i +=2){var name =arguments[i];var value =arguments[i +1];flags[name]=value;}return flags;}}Web.IArray =function(){this.get_length =Function.abstractMethod;this.getItem =Function.abstractMethod;}Type.registerInterface("Web.IArray");Array.prototype.get_length =function(){return this.length;}Array.prototype.getItem =function(index){return this[index];}Array._interfaces =[];Array._interfaces.add(Web.IArray);Web.IDisposable =function(){this.dispose =Function.abstractMethod;}Type.registerInterface('Web.IDisposable');Web.StringBuilder =function(initialText){var _parts =new Array();if ((typeof(initialText)=='string')&&(initialText.length !=0)){_parts.add(initialText);}this.append =function(text){if ((text ==null)||(typeof(text)=='undefined')){return;}if ((typeof(text)=='string')&&(text.length ==0)){return;}_parts.add(text);}this.appendLine =function(text){this.append(text);_parts.add('\r\n');}this.clear =function(){_parts.clear();}this.isEmpty =function(){return (_parts.length ==0);}this.toString =function(delimiter){delimiter =delimiter ||'';return _parts.join(delimiter);}}Type.registerSealedClass('Web.StringBuilder');Web.ActionSequence =Web.Enum.create('BeforeEventHandler','AfterEventHandler');Web.IAction =function(){this.get_sequence =Function.abstractMethod;this.execute =Function.abstractMethod;this.setOwner =Function.abstractMethod;}Type.registerInterface('Web.IAction');Web.Event =function(owner,autoInvoke){var _owner =owner;var _handlers =null;var _actions =null;var _autoInvoke =autoInvoke;var _invoked =false;this.get_autoInvoke =function(){return _autoInvoke;}this._getActions =function(){if (_actions ==null){_actions =Web.Component.createCollection(_owner);}return _actions;}this._getHandlers =function(){if (_handlers ==null){_handlers =[];}return _handlers;}this._getOwner =function(){return _owner;}this.isActive =function(){return ((_handlers !=null)&&(_handlers.length !=0))||((_actions !=null)&&(_actions.length !=0));}this.get_isInvoked =function(){return _isInvoked;}this.dispose =function(){if (_handlers){for (var h =_handlers.length -1;h >=0;h--){_handlers[h]=null;}_handlers =null;}if (_actions){_actions.dispose();_actions =null;}_owner =null;}this._setInvoked =function(value){_invoked =true;}}Type.registerSealedClass('Web.Event',null,Web.IDisposable);Web.Event.prototype.add =function(handler){this._getHandlers().add(handler);if (this.get_autoInvoke()&&this.get_isInvoked()){handler(this._getOwner(),Web.EventArgs.Empty);}}Web.Event.prototype.addAction =function(action){this._getActions().add(action);if (this.get_autoInvoke()&&this.get_isInvoked()){action.execute(this._getOwner(),Web.EventArgs.Empty);}}Web.Event.prototype.remove =function(handler){this._getHandlers().remove(handler);}Web.Event.prototype.removeAction =function(action){this._getActions().remove(action);}Web.Event.prototype.invoke =function(sender,eventArgs){if (this.isActive()){var actions =this._getActions();var handlers =this._getHandlers();var hasPostActions =false;var i;for (i =0;i <actions.length;i++){if (actions[i].get_sequence()==Web.ActionSequence.BeforeEventHandler){actions[i].execute(sender,eventArgs);}else {hasPostActions =true;}}for (i =0;i <handlers.length;i++){handlers[i](sender,eventArgs);}if (hasPostActions){for (i =0;i <actions.length;i++){if (actions[i].get_sequence()==Web.ActionSequence.AfterEventHandler){actions[i].execute(sender,eventArgs);}}}this._setInvoked();}}Web.EventArgs =function(){this.getDescriptor =function(){var td =new Web.TypeDescriptor();return td;}Web.EventArgs.registerBaseMethod(this,'getDescriptor');}Type.registerClass('Web.EventArgs',null,Web.ITypeDescriptorProvider);Web.EventArgs.Empty =new Web.EventArgs();Web.CancelEventArgs =function(){Web.CancelEventArgs.initializeBase(this);var _canceled =false;this.get_canceled =function(){return _canceled;}this.set_canceled =function(value){_canceled =value;}this.getDescriptor =function(){var td =Web.CancelEventArgs.callBaseMethod(this,'getDescriptor');td.addProperty('canceled',Boolean);return td;}Web.CancelEventArgs.registerBaseMethod(this,'getDescriptor');}Type.registerClass('Web.CancelEventArgs',Web.EventArgs);Web.ApplicationType =Web.Enum.create('Other','InternetExplorer','Firefox');Web._Application =function(){var _scriptDOM;var _scriptObjectsNode;var _references;var _currentLoadingReference;var _unloading;var _markupContext;var _disposableObjects;var _type;window.attachEvent('onload',onWindowLoad);window.attachEvent('onunload',onWindowUnload);this.get_type =function(){if (!_type){_type =Web.ApplicationType.Other;if (navigator.userAgent.indexOf('MSIE')!=-1){_type =Web.ApplicationType.InternetExplorer;}else if (navigator.userAgent.indexOf('Firefox')!=-1){_type =Web.ApplicationType.Firefox;}}return _type;}this.get_userAgent =function(){return navigator.userAgent;}this.load =new Web.Event(this);this.unload =new Web.Event(this);this.dispose =function(){}this.findObject =function(id){if (_markupContext){return _markupContext.findObject(id,false);}return null;}this.getProperty =function(name,key){}this.getService =function(serviceType){return null;}this._initialize =function(){var atlasScript;var scripts =document.getElementsByTagName('script');for (var s =0;s <scripts.length;s++){if (scripts[s].type =='text/xml-script'){atlasScript =scripts[s];break;}}if (!atlasScript){onLoad();return;}var scriptMarkup =atlasScript.text ?atlasScript.text :atlasScript.innerHTML;if (scriptMarkup.startsWith('<!--')){var startIndex =scriptMarkup.indexOf('<',1);var endIndex =scriptMarkup.lastIndexOf('>');endIndex =scriptMarkup.lastIndexOf('>',endIndex -1);scriptMarkup =scriptMarkup.substring(startIndex,endIndex +1);}var scriptDOM =new XMLDOM(scriptMarkup);var scriptDocumentNode =scriptDOM.childNodes[0];var scriptDocumentItemNodes =scriptDocumentNode.childNodes;var referencesNode;var node;for (var i =scriptDocumentItemNodes.length -1;i >=0;i--){node =scriptDocumentItemNodes[i];if (node.nodeType !=1){continue;}if (node.baseName =='components'){_scriptObjectsNode =node;}else if (node.baseName =='references'){referencesNode =node;}}if (referencesNode){_references =[];for (var r =0;r <referencesNode.childNodes.length;r++){node =referencesNode.childNodes[r];if (node.nodeType !=1){continue;}if (node.baseName =='add'){var srcAttribute =node.attributes.getNamedItem('src');if (srcAttribute){_references.queue(srcAttribute.nodeValue);}}}}if (_references &&_references.length){loadReferences();}else {loadObjects();}}this.invokeMethod =function(methodName,parameters){var method =Function.parse(methodName);if (typeof(method)=='function'){method();}}this.registerDisposableObject =function(object){if (!_disposableObjects){_disposableObjects =[];}_disposableObjects.add(object);}this.unregisterDisposableObject =function(object){if (!_unloading &&_disposableObjects){_disposableObjects.remove(object);}}this.requiresReference =function(scriptPath){}this.setProperty =function(name,value,key){}function loadObjects(){onLoad();}function loadReferences(){if (_currentLoadingReference){if ((_currentLoadingReference.readyState !='loaded')&&(_currentLoadingReference.readyState !='complete')){return;}else {if (Web.Application.get_type()!=Web.ApplicationType.InternetExplorer){_currentLoadingReference.onload =null;}else {_currentLoadingReference.onreadystatechange =null;}_currentLoadingReference =null;}}if (_references &&_references.length){var reference =_references.dequeue();var scriptElement =document.createElement('script');_currentLoadingReference =scriptElement;if (Web.Application.get_type()!=Web.ApplicationType.InternetExplorer){scriptElement.readyState ='loaded';scriptElement.onload =loadReferences;}else {scriptElement.onreadystatechange =loadReferences;}scriptElement.type ='text/javascript';scriptElement.src =reference;var headElement =document.getElementsByTagName('head')[0];headElement.appendChild(scriptElement);return;}loadObjects();}function onLoad(){Web.Application.load.invoke(Web.Application,Web.EventArgs.Empty);var pageLoadHandler =Function.parse('pageLoad');if (typeof(pageLoadHandler)=='function'){pageLoadHandler();}}function onWindowLoad(){window.detachEvent('onload',onWindowLoad);Web.Application._initialize();}function onWindowUnload(){window.detachEvent('onunload',onWindowUnload);Web.Application.unload.invoke(Web.Application,Web.EventArgs.Empty);var pageUnloadHandler =Function.parse('pageUnload');if (typeof(pageUnloadHandler)=='function'){pageUnloadHandler();}if (_disposableObjects){_unloading =true;var count =_disposableObjects.length;for (var i =0;i <count;i++){_disposableObjects[i].dispose();}_disposableObjects.clear();_disposableObjects =null;}}}Type.registerSealedClass('Web._Application',null,Web.IDisposable);Web.Application =new Web._Application();Web.Component =function(registerAsDisposable){var _id =null;var _initialized =false;var _updating =false;var _events =[];if (registerAsDisposable){Web.Application.registerDisposableObject(this);}this.get_id =function(){return _id;}this.set_id =function(value){_id =value;}this.get_isInitialized =function(){return _initialized;}this.get_isUpdating =function(){return _updating;}this.createEvent =function(autoInvoke){var eventObject =new Web.Event(this,autoInvoke);_events.add(eventObject);return eventObject;}this.beginUpdate =function(){_updating =true;}this.dispose =function(){if (_events){for (var e =_events.length -1;e >=0;e--){_events[e].dispose();_events[e]=null;}_events =null;}Web.Application.unregisterDisposableObject(this);}Web.Component.registerBaseMethod(this,'dispose');this.endUpdate =function(){_updating =false;if (!_initialized){this.initialize();}this.updated();}this.initialize =function(){_initialized =true;}Web.Component.registerBaseMethod(this,'initialize');this.updated =function(){}Web.Component.registerBaseMethod(this,'updated');}Type.registerAbstractClass('Web.Component',null,Web.IDisposable);Web.Component.createCollection =function(owner){var collection =[];collection._owner =owner;collection._add =collection.add;collection.add =function(item){this._add(item);item.setOwner(this._owner);}collection.dispose =function(){for (var i =this.length -1;i >=0;i--){this[i].dispose();this[i]=null;}this.clear();}return collection;}Type.registerNamespace('Web.Serialization');Web.Serialization.JSON =new function(){function serializeWithBuilder(object,stringBuilder){var i;switch (typeof object){case 'object':if (object){if (Array.isInstanceOfType(object)){stringBuilder.append('[');for (i =0;i <object.length;++i){if (i >0){stringBuilder.append(',');}stringBuilder.append(serializeWithBuilder(object[i],stringBuilder));}stringBuilder.append(']');} else {if (typeof object.serialize =='function'){stringBuilder.append(object.serialize());break;}stringBuilder.append('{');var needComma =false;for (var name in object){if (name.startsWith('$')){continue;}var value =object[name];if (typeof value !='undefined'&&typeof value !='function'){if (needComma){stringBuilder.append(',');}else {needComma =true;}stringBuilder.append(serializeWithBuilder(name,stringBuilder));stringBuilder.append(':');stringBuilder.append(serializeWithBuilder(value,stringBuilder));}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -