olympus-r
Version:
一个力求简单易用的前端开发框架 #### 开发语言 TypeScript #### 核心架构 MVC #### 模块间通讯和解耦 采用事件机制,利用一个全局唯一的事件派发器进行模块间通讯,解耦模块间依赖 #### 表现层结构 使用桥接模式拆分接口与实现,达到一套核心驱动多套表现层的目的(目前支持DOM、Egret、PixiJS三种表现层),同时支持表现层的未来可扩展性 #### TypeScript装饰器注入 框架提供TypeScript装饰器注入功能,便捷获取托管对象。例如:
1 lines • 4.77 kB
JavaScript
var olympus;(function(e){function o(){if(window.location.origin)return window.location.origin;return window.location.protocol+"//"+window.location.host}e.getCurOrigin=o;function a(e){e=e.replace(/([^:/])(\/)+/g,"$1/");if(e.charAt(0)=="/")e=e.substr(1);var t;while((t=e.indexOf("/./"))>=0){e=e.replace("/./","/")}var r=/\/[^\/\.]+?\/\.\.\//;while(r.test(e)){e=e.replace(r,"/")}return e}e.trimURL=a;function r(e){if(e==null)throw new Error("url不能为空");e=e.split("#")[0].split("?")[0];e=a(e);return e}e.getHostAndPathname=r;function i(e){e=r(e);var t=e.split("/");t.pop();return t.join("/")+"/"}e.getPath=i;function m(e){if(e==null)return false;return e.indexOf("://")>=0}e.isAbsolutePath=m;function s(e){if(e==null)return null;var t=e.indexOf("://");if(t<0)return e;var r=e.substring(0,t);if(r=="http"||r=="https"){return window.location.protocol+e.substr(t+1)}if(r=="ws"||r=="wss"){if(window.location.protocol=="https:")r="wss";else r="ws";return r+e.substr(t)}return e}e.validateProtocol=s;function u(e,t,r){if(r===void 0){r=false}t=t||o();var n=/^(?:[^\/]+):\/{2,}(?:[^\/]+)\//;var i=e.match(n);if(i&&i.length>0){if(r){e=e.substr(i[0].length);e=t+"/"+e}}else{e=t+"/"+e}e=s(e);e=a(e);return e}e.wrapHost=u;function O(e,t){var r=i(window.location.href);var n=a(r+"/"+e);if(t!=null){n=u(n,t,true)}return n}e.wrapAbsolutePath=O;var t=function(){function e(){this._hashDict={}}e.prototype.initialize=function(r,t,n){var f=this;if(window["__Olympus_Version_hashDict__"]){this._hashDict=window["__Olympus_Version_hashDict__"];r()}else{var i=null;if(window["XDomainRequest"]&&navigator.userAgent.indexOf("MSIE 10.")<0){i=new window["XDomainRequest"]}else if(window["XMLHttpRequest"]){i=new XMLHttpRequest}else if(window["ActiveXObject"]){i=new ActiveXObject("Microsoft.XMLHTTP")}i.onload=function(e){if(i.status===undefined){if(i.responseText===""){i.onerror(new Event("RequestError: "+JSON.stringify({filename:o})))}else{a(e);r()}}else{var t=Math.floor(i.status*.01);switch(t){case 2:case 3:a(e);r();break;case 4:case 5:i.onerror(new Event("RequestError: "+JSON.stringify({filename:o,message:i.status+" "+i.statusText})));break}}};var o;if(n){i.onerror=function(){var e=O("version.cfg?v="+n,t);i.abort();i.onerror=r;i.open("GET",e,true);i.send()};o=O("version.cfg",t);o=this.joinVersion(o,n)}else{i.onerror=r;o=O("version.cfg?v="+Date.now(),t)}i.open("GET",o,true);i.send()}function a(e){var t=e.target;var r=t.responseText;var n=r.split("\n");for(var i in n){var o=n[i];var a=o.split(" ");if(a.length==2){var s=a[1].substr(2);var u=a[0];f._hashDict[s]=u}}window["__Olympus_Version_hashDict__"]=f._hashDict}};e.prototype.getHash=function(e){e=a(e);var t=null;for(var r in this._hashDict){if(e.indexOf(r)>=0){t=this._hashDict[r];break}}return t};e.prototype.wrapHashUrl=function(e){var t=this.getHash(e);if(t!=null){e=this.joinVersion(e,t)}return e};e.prototype.joinVersion=function(e,t){if(t==null)return e;t=t.replace(/[^0-9a-z]+/gi,"");var r=/([a-zA-Z]+:\/+[^\/\?#]+\/[^\?#]+)\.([^\?]+)(\?.+)?/;var n=r.exec(e);if(n!=null){e=n[1]+"-r_"+t+"."+n[2]+(n[3]||"")}return e};e.prototype.removeVersion=function(e){e=e.replace(/\-r_[a-z0-9]+\./gi,".");return e};return e}();var T=new t;function n(e,t,r,n,i){if(n===void 0){n=true}T.initialize(function(){f(e,t||o(),function(e){if(r){r(e)}else if(e){alert(e.message+"\n点击确定5秒后将刷新页面。");setTimeout(function(){return window.location.reload(true)},5e3)}},n)},t,i)}e.preload=n;function f(e,t,r,n){if(!e){r();return}e=e.concat();var i=e.length;var o=0;var a=false;var s=[];for(var u in e){var f=e[u];if(typeof f==="string"){e[u]=f={url:f,mode:b.AUTO}}var l=f.url;if(!m(l))l=O(l,t);l=T.wrapHashUrl(l);var c=document.createElement("script");c.type="text/javascript";s.push(c);if(f.mode===b.JSONP||f.mode===b.AUTO&&!m(f.url)){var v=window["XDomainRequest"]&&navigator.userAgent.indexOf("MSIE 10.")<0?new window["XDomainRequest"]:window["XMLHttpRequest"]?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");v["index"]=u;v.open("GET",l,true);v.responseType="text";v.onload=h;v.onerror=d;v.send(null);o++}else{c.onload=g;c.onerror=_;c.src=l}}var w=0;p();function p(){if(o===0){for(var e=w,t=s.length;e<t;){var r=s[e];document.body.appendChild(r);w=++e;if(n&&r.src)break}}}function h(e){var n=e.target;var t=function(e){var t=n["index"];var r=s[t];r.innerHTML=n.responseText;o--;g()};if(n.status===undefined){if(n.responseText===""){d()}else{t(e)}}else{var r=Math.floor(n.status*.01);switch(r){case 2:case 3:t(e);break;case 4:case 5:d();break}}}function d(){_()}function g(){p();if(!a&&--i===0)r()}function _(){if(!a){a=true;r(new Error("JS加载失败"))}}}var b;(function(e){e[e["AUTO"]=0]="AUTO";e[e["JSONP"]=1]="JSONP";e[e["TAG"]=2]="TAG"})(b=e.JSLoadMode||(e.JSLoadMode={}))})(olympus||(olympus={}));