/*! catiline 2.9.3 2013-10-25*/ /*!(c)2013 Calvin Metcalf @license MIT https://github.com/calvinmetcalf/catiline */ /*!Includes Promiscuous (c)2013 Ruben Verborgh @license MIT https://github.com/RubenVerborgh/promiscuous*/ /*!Includes Material from setImmediate Copyright (c) 2012 Barnesandnoble.com, llc, Donavon West, and Domenic Denicola @license MIT https://github.com/NobleJS/setImmediate */ "undefined"==typeof document?(self._noTransferable=!0,self.onmessage=function(e){eval(e.data)}):!function(a){"use strict";function b(){var a,b=0,c=D;for(D=[];a=c[b++];)a()}function Deferred(){function Promise(){this.then=function(b,c){return a(b,c)}}var a=function(f,g,h){if(f!==a){var i=c();return a.queue.push({deferred:i,resolve:f,reject:g}),i.promise}for(var j=g?"resolve":"reject",k=0,l=a.queue.length;l>k;k++){var m=a.queue[k],n=m.deferred,o=m[j];typeof o!==E?n[j](h):e(o,h,n)}a=d(b,h,g)},b=new Promise;this.promise=b,a.queue=[],this.resolve=function(b){a.queue&&a(a,!0,b)},this.fulfill=this.resolve,this.reject=function(b){a.queue&&a(a,!1,b)}}function c(){return new Deferred}function d(a,b,d){return function(f,g){var h=d?f:g;if(typeof h!==E)return a;var i=c();return e(h,b,i),i.promise}}function e(a,b,c){w.nextTick(function(){try{var d=a(b);d&&typeof d.then===E?d.then(c.resolve,c.reject):c.resolve(d)}catch(e){c.reject(e)}})}function f(a){for(var b=a,c=!0,d={},e=function(a,b){b&&"importScripts("+b.split(",").forEach(function(a){d[w.makeUrl(a.match(/\s*[\'\"](\S*)[\'\"]\s*/)[1])]=!0})+");\n"};c;)c=b.match(/(importScripts\(.*?\);?)/),b=b.replace(/(importScripts\(\s*(?:[\'\"].*?[\'\"])?\s*\);?)/,"\n"),c&&c[0].replace(/importScripts\(\s*([\'\"].*?[\'\"])?\s*\);?/g,e);return d=Object.keys(d),[d,b]}function g(a,b){var c=f(a),d=c[0],e=c[1];return d.length>0?"importScripts('"+d.join("','")+b+e:e}function h(){if("undefined"!=typeof SHIM_WORKER_PATH)return SHIM_WORKER_PATH;if("SHIM_WORKER_PATH"in w)return w.SHIM_WORKER_PATH;for(var a=document.getElementsByTagName("script"),b=a.length,c=0;b>c;){if(/catiline(\.min)?\.js/.test(a[c].src))return a[c].src;c++}}function i(a,b){var c=a.createElement("script");"undefined"!=typeof c.text?c.text=b:c.innerHTML=b,"complete"===a.readyState?a.documentElement.appendChild(c):a.onreadystatechange=function(){"complete"===a.readyState&&a.documentElement.appendChild(c)}}function j(a,b){var c=document.createElement("iframe");c.style.display="none",document.body.appendChild(c);var d=c.contentWindow.document,e=["try{ ","var __scripts__='';function importScripts(scripts){"," if(Array.isArray(scripts)&&scripts.length>0){"," scripts.forEach(function(url){"," var ajax = new XMLHttpRequest();"," ajax.open('GET',url,false);"," ajax.send();__scripts__+=ajax.responseText;"," __scripts__+='\\n;';"," });"," }","};",a,"}catch(e){"," window.parent.postMessage(['"+b+"','error'],'*')","}"].join("\n");return i(d,e),c}function k(a,b){var c=w.deferred();return"complete"===document.readyState?c.resolve(j(a,b)):window.addEventListener("load",function(){c.resolve(j(a,b))},!1),c.promise}function l(a){w._noTransferable=!0;var b=new Worker(h());return b.postMessage(a),b}function m(a){var b="{",c=!0;for(var d in a)c?c=!1:b+=",",b+=d,b+=":",b+=w.stringify(a[d]);return b+="}"}function n(a){if(a.length){var b="[";b+=w.stringify(a[0]);for(var c=0,d=a.length;++c0)return b.split(" ").map(function(b){return a.on(b,c,e)},this),a;b in d||(d[b]=[]);var f=function(a){c.call(e,a,e)};return f.orig=c,d[b].push(f),a},a.one=function(b,c,d){function e(f){a.off(b,e),c.call(d,f,d)}return d=d||a,a.on(b,e)},a.trigger=function(b,c){return b.indexOf(" ")>0?(b.split(" ").forEach(function(b){a.trigger(b,c)}),a):b in d?(d[b].forEach(function(a){a(c)}),a):a},a.fire=function(b,d,e){return c([[b],d],e),a},a.off=function(b,c){return b.indexOf(" ")>0?(b.split(" ").map(function(b){return a.off(b,c)}),a):b in d?(c?d[b]=d[b].map(function(a){return a.orig===c?!1:a}).filter(function(a){return a}):delete d[b],a):a}}function p(a){if("undefined"!=typeof console){var b=console[a[0]]?a[0]:"log";"undefined"==typeof console[b].apply?console[b](a[1].join(" ")):console[b].apply(console,a[1])}}function q(a){function b(b){return function(){for(var c=arguments.length,d=[],e=0;c>e;)d.push(arguments[e]),e++;a.fire("console",[b,d])}}["log","debug","error","info","warn","time","timeEnd"].forEach(function(a){console[a]=b(a)})}function Catiline(a){"function"==typeof a&&(a={data:a});var b="com.catilinejs."+(Catiline._hasWorker?"iframe":"worker")+Math.random(),c=this,d=[];o(c,function(a,b){w._noTransferable?l.postMessage(a):l.postMessage(a,b)});var e=function(a){"string"!=typeof a&&"preventDefault"in a&&(a.preventDefault(),a=a.message),d.forEach(function(b){b&&b.reject(a)})};if(a.__codeWord__=b,a.__initialize__=[F,o,q],"initialize"in a?a.__initialize__.push(a.initialize):"init"in a&&a.__initialize__.push(a.init),"events"in a||(a.events={}),"listners"in a&&"function"!=typeof a.listners)for(var f in a.listners)c.on(f,a.listners[f]);var g="var _db = {\n ",h=function(a){var c=function(c,e){var f=d.length;return d[f]=w.deferred(),w._noTransferable?l.postMessage([[b,f],a,c]):l.postMessage([[b,f],a,c],e),d[f].promise};return c},i=!1;for(var j in a)if(!(["listners","initialize","init"].indexOf(j)>-1))if(i?g+=",\n ":i=!0,"function"==typeof a[j])g=g+j+":"+a[j].toString(),c[j]=h(j);else{var k=w.stringify(a[j]);"undefined"!=typeof k&&(g=g+j+":"+k)}g+="};";var l=w.makeWorker(["'use strict';","",g,"_db.__initialize__.forEach(function(f){"," f.call(_db,_db);","});","for(var key in _db.events){"," _db.on(key,_db.events[key]);","}"],b);l.onmessage=function(a){c.trigger("message",a.data[1]),a.data[0][0]===b?(d[a.data[0][1]].resolve(a.data[1]),d[a.data[0][1]]=0):c.trigger(a.data[0][0],a.data[1])},c.on("error",e),l.onerror=function(a){c.trigger("error",a)},c.on("console",p),c._close=function(){return l.terminate(),e("closed"),w.resolve()},"close"in c||(c.close=c._close)}function r(a,b){return{keyFunc:function(b){return function(c,d){return a(b,c,d)}},keyFuncBatch:function(b){return function(c){return w.all(c.map(function(c){return a(b,c)}))}},keyFuncBatchCB:function(c){return function(d){return w.all(d.map(function(d){return a(c,d).then(b.__cb__)}))}},keyFuncBatchTransfer:function(b){return function(c){return w.all(c.map(function(c){return a(b,c[0],c[1])}))}},keyFuncBatchTransferCB:function(c){return function(d){return w.all(d.map(function(d){return a(c,d[0],d[1]).then(b.__cb__)}))}}}}function s(a,b,c){var d=r(a,b);for(var e in c)b[e]=d.keyFunc(e),b.batch[e]=d.keyFuncBatch(e),b.__batchcb__[e]=d.keyFuncBatchCB(e),b.batchTransfer[e]=d.keyFuncBatchTransfer(e),b.__batchtcb__[e]=d.keyFuncBatchTransferCB(e)}function t(a,b,c){a.on=function(c,d,e){return b.forEach(function(a){a.on(c,d,e)}),a},a.off=function(c,d,e){return b.forEach(function(a){a.off(c,d,e)}),a},a.fire=function(d,e){return b[~~(Math.random()*c)].fire(d,e),a}}function u(a,b){return function(c,d,e,f){return f.promise.cancel=function(a){return f.reject(a)},a[~~(Math.random()*b)][c](d,e).then(function(a){return f.resolve(a)},function(a){return f.reject(a)}),f.promise}}function v(a,b,c){for(var d=[],e=-1;++e-1&&(j.splice(b,1),k--),f.reject(a)},k=j.push(m)}return f.promise}var g=this,h=b,i=[],j=[],k=0,l=v(b,i,a);t(g,l,b);var m=function(a,b){return l.forEach(function(c){c.fire(a,b)}),g};g.batch.fire=m,g.batchTransfer.fire=m,g.clearQueue=d,s(f,g,a);var n;c&&(n=u(l,b)),g._close=function(){return w.all(l.map(function(a){return a._close()}))},"close"in g||(g.close=g._close)}function w(a,b,c){return 1===arguments.length||!b||1>=b?new w.Worker(a):new w.Queue(a,b,c)}function x(b){var c=a.cw;b.noConflict=function(d){a.cw=c,d&&(a[d]=b)},a.catiline=b,a.cw=b,"communist"in a||(a.communist=b)}var y,z=a.MutationObserver||a.WebKitMutationObserver;if(z){var A=new z(b),B=document.createElement("div");A.observe(B,{attributes:!0}),addEventListener("unload",function(){A.disconnect(),A=null},!1),y=function(){B.setAttribute("drainQueue","drainQueue")}}else{var C="com.catiline.setImmediate"+Math.random();addEventListener("message",function(a){a.source===window&&a.data===C&&b()},!1),y=function(){postMessage(C,"*")}}var D=[];w.nextTick=function(a){1===D.push(a)&&y()};var E="function";w.deferred=c,w.resolve=function(a){var b={};return b.then=d(b,a,!0),b},w.reject=function(a){var b={};return b.then=d(b,a,!1),b},w.all=function(a){var b=c(),d=a.length,e=0,f=[],g=function(a){return function(c){f[a]=c,e++,e===d&&b.resolve(f)}};return a.forEach(function(a,c){a.then(g(c),function(a){b.reject(a)})}),b.promise},w._hasWorker="undefined"!=typeof Worker&&"undefined"==typeof fakeLegacy,w.URL=window.URL||window.webkitURL,w._noTransferable=!w.URL,w.makeIWorker=function(a,b){var c=g(a.join(""),"');eval(__scripts__);\n"),d={onmessage:function(){}},e=k(c,b);return window.addEventListener("message",function(a){a.data.slice&&a.data.slice(0,b.length)===b&&d.onmessage({data:JSON.parse(a.data.slice(b.length))})}),d.postMessage=function(a){e.then(function(b){b.contentWindow.postMessage(JSON.stringify(a),"*")})},d.terminate=function(){e.then(function(a){document.body.removeChild(a)})},d},w.makeWorker=function(a,b){if(!w._hasWorker)return w.makeIWorker(a,b);var c,d=g(a.join("\n"),"');\n");if(w._noTransferable)return l(d);try{c=new Worker(w.URL.createObjectURL(new Blob([d],{type:"text/javascript"})))}catch(e){try{c=l(d)}catch(f){c=w.makeIWorker(a,b)}}finally{return c}},w.makeUrl=function(a){var b=document.createElement("link");return b.href=a,b.href},w.stringify=function(a){return Array.isArray(a)?n(a):"function"==typeof a||"number"==typeof a||"boolean"==typeof a?a.toString():"string"==typeof a?'"'+a+'"':"[object Object]"===a.toString()?m(a):void 0};var F=function(a){self.__iFrame__="undefined"!=typeof document,self.__self__={onmessage:function(c){return a.trigger("messege",c.data[1]),c.data[0][0]===a.__codeWord__?b(c):(a.trigger(c.data[0][0],c.data[1]),void 0)}},__iFrame__?window.onmessage=function(a){"string"==typeof a.data&&(a={data:JSON.parse(a.data)}),__self__.onmessage(a)}:self.onmessage=__self__.onmessage,__self__.postMessage=function(b,c){if(self._noTransferable||__iFrame__)if(__iFrame__){var d=a.__codeWord__+JSON.stringify(b);window.parent.postMessage(d,"*")}else self._noTransferable&&self.postMessage(b);else self.postMessage(b,c)},self.console={};var b=function(b){var c,d=function(a,c){__self__.postMessage([b.data[0],a],c)};if(__iFrame__)try{c=a[b.data[1]](b.data[2],d,a)}catch(e){a.fire("error",JSON.stringify(e))}else c=a[b.data[1]](b.data[2],d,a);"undefined"!=typeof c&&d(c)}};w.Worker=Catiline,w.worker=function(a){return new Catiline(a)},CatilineQueue.prototype.__batchcb__={},CatilineQueue.prototype.__batchtcb__={},CatilineQueue.prototype.batch=function(a){return"function"==typeof a?(this.__cb__=a,this.__batchcb__):this.clearQueue(a)},CatilineQueue.prototype.batchTransfer=function(a){return"function"==typeof a?(this.__batchtcb__.__cb__=a,this.__batchtcb__):this.clearQueue(a)},w.Queue=CatilineQueue,w.queue=function(a,b,c){return new w.Queue(a,b,c)},w.setImmediate=w.nextTick,"function"==typeof define?define(function(a){return w.SHIM_WORKER_PATH=a.toUrl("./catiline.js"),w}):"undefined"!=typeof module&&"exports"in module?module.exports=w:x(w),w.version="2.9.3"}(this);