📄 atlas.js
字号:
return object;
}
this.hideDataContext = function() {
if (!_dataContextHidden) {
_dataContextHidden = true;
return true;
}
return false;
}
this._reopen = function() {
debug.assert(_global);
_document = document;
_pendingReferences = [];
_pendingEndUpdates = [];
}
this.restoreDataContext = function() {
_dataContextHidden = false;
}
}
Web.ISupportBatchedUpdates = function() {
this.beginUpdate = Function.abstractMethod;
this.endUpdate = Function.abstractMethod;
}
Type.registerInterface('Web.ISupportBatchedUpdates');
Web.ICustomTypeDescriptor = function() {
this.getProperty = Function.abstractMethod;
this.setProperty = Function.abstractMethod;
this.invokeMethod = Function.abstractMethod;
}
Type.registerInterface('Web.ICustomTypeDescriptor');
Web.ITypeDescriptorProvider = function() {
this.getDescriptor = Function.abstractMethod;
}
Type.registerInterface('Web.ITypeDescriptorProvider');
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 _references;
var _currentLoadingReference;
var _components;
var _markupContext;
var _disposableObjects;
var _unloading;
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.getDescriptor = function() {
var td = new Web.TypeDescriptor();
td.addEvent('load', true);
td.addEvent('unload', true);
return td;
}
this.getProperty = function(name, key) {
}
this.getService = function(serviceType) {
return null;
}
this._initialize = function() {
_references = [];
_components = [];
var atlasScripts = [];
var scriptElements = document.getElementsByTagName('script');
for (var e = 0; e < scriptElements.length; e++) {
if (scriptElements[e].type == 'text/xml-script') {
atlasScripts.add(scriptElements[e]);
}
}
if (!atlasScripts.length) {
onLoad();
return;
}
for (var s = 0; s < atlasScripts.length; s++) {
var atlasScript = atlasScripts[s];
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;
for (var i = scriptDocumentItemNodes.length - 1; i >= 0; i--) {
var node = scriptDocumentItemNodes[i];
if (node.nodeType != 1) {
continue;
}
if (node.baseName == 'components') {
for (var c = 0; c < node.childNodes.length; c++) {
var componentNode = node.childNodes[c];
if (componentNode.nodeType != 1) {
continue;
}
_components.add(componentNode);
}
}
else if (node.baseName == 'references') {
for (var r = 0; r < node.childNodes.length; r++) {
var referenceNode = node.childNodes[r];
if (referenceNode.nodeType != 1) {
continue;
}
if (referenceNode.baseName == 'add') {
var srcAttribute = referenceNode.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() {
_markupContext = new Web.TypeDescriptor.MarkupContext(document, true);
if (_components && _components.length) {
Web.TypeDescriptor.processMarkupNodes(_components, _markupContext);
_components = null;
}
_markupContext.complete();
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);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -