dispatch.to("Foundry/2.1 Core Plugins").at(function($){$.script=function(){var self=function(options){if(void 0!==options){"string"==typeof options&&(options={url:options});var script=new Script(options);return script}},Script=function(options){var script=$.extend(this,options);script.manager=$.Deferred(),$.extend(script,script.manager.promise()),script.load()},head=document.getElementsByTagName("head")[0],baseElement=document.getElementsByTagName("base")[0];return $.extend(Script.prototype,{timeout:7e3,retry:3,retryCount:1,type:"text/javascript",async:!1,charset:"UTF-8",verbose:!1,insert:function(){var node=this.node;
baseElement?head.insertBefore(node,baseElement):head.appendChild(node)},remove:function(){var node=this.node;setTimeout(function(){node.onload=node.onerror=node.onreadystatechange=null;try{head.removeChild(node)}catch(e){}},1e3)},load:function(){var node,script=this;script.endTime=void 0,script.startTime=new Date,script.node=node=document.createElement("script"),script.insert(),script._ready=$.proxy(script.ready,script),script._error=$.proxy(script.error,script),node.attachEvent&&!$.browser.opera?(node.attachEvent("onreadystatechange",script._ready),node.attachEvent("onerror",script._error)):(node.addEventListener("load",script._ready,!1),node.addEventListener("error",script._error,!1)),$(node).attr({type:script.type,async:script.async,charset:script.charset,src:script.url}),script.monitor()
},monitor:function(){var script=this;return script.retryCount>script.retry?(script._error(),void 0):(setTimeout(function(){"resolved"!==script.state()&&(script.verbose&&console.warn("$.script: Load timeout. [Retry: "+script.retryCount+"]",script),script.remove(),script.retryCount++,script.load())},script.timeout*script.retryCount),void 0)},ready:function(event){var script=this,node=script.node;("load"===event.type||/loaded|complete/.test(node.readyState))&&(script.complete.call(script,event),script.manager.resolve(script))
},error:function(event){var script=this;script.verbose&&console.error("$.script: Unable to load ",script),script.complete.call(script,event),script.remove(),script.manager.reject(script)},complete:function(){var script=this,node=script.node;script.endTime=new Date,node.detachEvent&&!$.browser.opera?(node.detachEvent("onreadystatechange",script._ready),node.detachEvent("onerror",script._error)):(node.removeEventListener("load",script._ready,!1),node.removeEventListener("error",script._error,!1))}}),self}()});
