Skip to content
This repository
Browse code

remove ie worker polyfill

  • Loading branch information...
commit b546d335413e9da30c8393c24f09526d3ea0f35f 1 parent 5b8ae13
Yuguang Zhang authored

Showing 1 changed file with 0 additions and 21 deletions. Show diff stats Hide diff stats

  1. +0 21 static/js/ie-worker.js
21 static/js/ie-worker.js
... ... @@ -1,21 +0,0 @@
1   -var fakeworker=(function(global){function extend(dest,src){for(var i in src){dest[i]=src[i];}}
2   -var userAgent=navigator.userAgent.toLowerCase();var browser={version:(userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[])[1],safari:/webkit/.test(userAgent),opera:/opera/.test(userAgent),msie:/msie/.test(userAgent)&&!/opera/.test(userAgent),mozilla:/mozilla/.test(userAgent)&&!/(compatible|webkit)/.test(userAgent)};function httpSuccess(xhr){try{return!xhr.status&&location.protocol=="file:"||(xhr.status>=200&&xhr.status<300)||xhr.status==304||xhr.status==1223||browser.safari&&xhr.status==undefined;}
3   -catch(e){}
4   -return false;};function __syncXhrGet(url,fn){var xhr=window.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();xhr.open("GET",url,false);xhr.send("");if(httpSuccess(xhr)){fn(xhr);}
5   -else{throw new Error("Could not load resource("+url+") result="+xhr.status+":"+xhr.statusText);}}
6   -function parseUri(str){var o=parseUri.options,m=o.parser[o.strictMode?"strict":"loose"].exec(str),uri={},i=14;while(i--)
7   -uri[o.key[i]]=m[i]||"";uri[o.q.name]={};uri[o.key[12]].replace(o.q.parser,function($0,$1,$2){if($1)
8   -uri[o.q.name][$1]=$2;});return uri;};parseUri.options={strictMode:false,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}};function absolutePath(path){var e=document.createElement('span');e.innerHTML='<a href="'+path+'" />';return e.firstChild.href;}
9   -function FakeMessageEvent(worker){extend(this,Event);Event.constructor.call(this);this.currentTarget=worker;this.srcElement=worker;this.target=worker;this.timestamp=new Date().getTime();}
10   -FakeMessageEvent.prototype={initMessageEvent:function(type,canBubble,cancelable,data,origin,lastEventId,source,ports){this.initMessageEventNS("",type,canBubble,cancelable,data,origin,lastEventId,source,ports);},initMessageEventNS:function(namespaceURI,type,canBubble,cancelable,data,origin,lastEventId,source,ports){this.namespaceURI=namespaceURI;this.type=type;this.canBubble=canBubble;this.cancelable=cancelable;this.data=data;this.origin=origin;this.lastEventId=lastEventId;this.source=source;this.ports=ports;}};function FakeErrorEvent(worker){extend(this,Event);Event.constructor.call(this);this.currentTarget=worker;this.srcElement=worker;this.target=worker;this.timestamp=new Date().getTime();}
11   -FakeErrorEvent.prototype={initErrorEvent:function(type,canBubble,cancelable,message,filename,lineno){this.initErrorEventNS("",type,canBubble,cancelable,message,filename,lineno);},initErrorEventNS:function(namespaceURI,type,canBubble,cancelable,message,filename,lineno){this.namespaceURI=namespaceURI;this.type=type;this.canBubble=canBubble;this.cancelable=cancelable;this.message=message;this.filename=filename;this.lineno=lineno;}};var nativeWorker=global["Worker"];var FakeWorker=function(url){var self=this;this._listenerNamespaces={};this._eventQueues={};__syncXhrGet(url,function(xhr){try{self._workerContext=new FakeWorkerContext(url,xhr.responseText,self);}
12   -catch(e){throw e;}});};FakeWorker.prototype={isFake:true,addEventListener:function(type,listener,useCapture){this.addEventListenerNS("",type,listener,useCapture);},addEventListenerNS:function(namespaceURI,type,listener,useCapture){var namespace=this._listenerNamespaces[namespaceURI];if(!namespace){this._listenerNamespaces[namespaceURI]=namespace={};}
13   -var listeners=namespace[type];if(!listeners){namespace[type]=listeners=[];}
14   -listeners.push(listener);},removeEventListener:function(type,listener,useCapture){this.removeEventListener("",type,listener,useCapture);},removeEventListenerNS:function(namespaceURI,eventName,fn,useCapture){var namespace=this._listenerNamespaces[namespaceURI];if(namespace){var listeners=namespace[type];if(listeners){for(var i=0;i<listeners.length;i++){if(listeners[i]===listener){delete listeners[i];}}}}},dispatchEvent:function(event){if(typeof this["on"+event.type]=="function"){this["on"+event.type].call(this,event);}
15   -var namespace=this._listenerNamespaces[event.namespaceURI];if(namespace){var listeners=namespace[event.type];if(listeners){for(var i=0;i<listeners.length;i++){listeners[i].call(this,event);}}}
16   -return true;},postMessage:function(msg){var self=this;var workerContext=this._workerContext;if(typeof workerContext.onmessage=="function"){var event=new FakeMessageEvent(self);event.initMessageEvent("message",false,false,msg,"","",null,null);setTimeout(function(){try{workerContext.onmessage.call(workerContext,event);}
17   -catch(e){var errorEvent=new FakeErrorEvent(self);var lineno=e.line||e.lineNumber;errorEvent.initErrorEvent("error",false,false,e.message,workerContext.location.filename,lineno);self.dispatchEvent(errorEvent);throw e;}},0);}},terminate:function(){this._workerContext.close();}};function FakeWorkerLocation(url){var absolute=absolutePath(url);var parsed=parseUri(absolute);this.href=absolute;this.protocol=parsed.protocol+":";this.host=parsed.port?parsed.host+":"+parsed.port:parsed.host;this.hostname=parsed.host;this.port=parsed.port;this.pathname=parsed.path;this.search=parsed.query?"?"+parsed.query:"";this.hash=parsed.anchor?"#"+parsed.anchor:"";this.filename=parsed.file;}
18   -FakeWorkerLocation.prototype={toString:function(){return this.href;}};function FakeWorkerContext(url,source,worker){var postMessage=this.postMessage=function(msg){var event=new FakeMessageEvent(worker);event.initMessageEvent("message",false,false,msg,"","",null,null);setTimeout(function(){worker.dispatchEvent(event);},0);};var setTimeout=this.setTimeout=global.setTimeout;var clearTimeout=this.clearTimeout=global.clearTimeout;var setInterval=this.setInterval=global.setInterval;var clearInterval=this.clearInterval=global.clearInterval;var XMLHttpRequest=this.XMLHttpRequest=global.XMLHttpRequest;var openDatabase=this.openDatabase=global.openDatabase;var openDatabaseSync=this.openDatabaseSync=global.openDatabaseSync;var WebSocket=this.WebSocket=global.WebSocket;var EventSource=this.EventSource=global.EventSource;var MessageChannel=this.MessageChannel=global.MessageChannel;var Worker=this.Worker=FakeWorker;var location=this.location=new FakeWorkerLocation(url);var close=this.close=function(){this.closing=true};var navigator=this.navigator=global.navigator;var self=this.self=this;var importScripts=this.importScripts=function(){throw new Error("importScripts is not supported.");}
19   -eval(source);try{if(typeof onmessage=="function"){this.onmessage=onmessage;}}
20   -catch(e){}}
21   -var ret={nativeWorker:nativeWorker,install:function(){global["Worker"]=FakeWorker;},uninstall:function(){global["Worker"]=nativeWorker;}};ret.install();return ret;})(this);

0 comments on commit b546d33

Please sign in to comment.
Something went wrong with that request. Please try again.