From 4d39d8058e050c008d528f74d77526bc308105c2 Mon Sep 17 00:00:00 2001 From: Jim Chen Date: Tue, 30 May 2017 14:32:34 -0700 Subject: [PATCH] Recompile after fix --- dist/CommentCoreLibrary.js | 89 ++++++++++++++++++---------------- dist/CommentCoreLibrary.min.js | 3 +- src/CommentManager.js | 4 +- src/CommentProvider.js | 82 +++++++++++++++---------------- 4 files changed, 89 insertions(+), 89 deletions(-) diff --git a/dist/CommentCoreLibrary.js b/dist/CommentCoreLibrary.js index b3fe153..673e0cd 100644 --- a/dist/CommentCoreLibrary.js +++ b/dist/CommentCoreLibrary.js @@ -996,7 +996,7 @@ var CommentManager = (function() { this.runline = []; this.position = 0; this.limiter = 0; - + this.factory = null; this.filter = null; this.csa = { @@ -1134,7 +1134,7 @@ var CommentManager = (function() { }; CommentManager.prototype.rescale = function () { - + // TODO: Implement rescaling }; CommentManager.prototype.send = function (data) { @@ -1423,13 +1423,13 @@ var CommentProvider = (function () { /** * Provider for HTTP content. This returns a promise that resolves to TEXT. * - * @param method - HTTP method to use - * @param url - Base URL - * @param responseType - type of response expected. - * @param args - Arguments for query string. Note: This is only used when + * @param {string} method - HTTP method to use + * @param {string} url - Base URL + * @param {string} responseType - type of response expected. + * @param {Object} args - Arguments for query string. Note: This is only used when * method is POST or PUT - * @param body - Text body content. If not provided will omit a body - * @return Promise that resolves or rejects based on the success or failure + * @param {any} body - Text body content. If not provided will omit a body + * @return {Promise} that resolves or rejects based on the success or failure * of the request **/ CommentProvider.BaseHttpProvider = function (method, url, responseType, args, body) { @@ -1441,15 +1441,13 @@ var CommentProvider = (function () { var argsArray = []; for (var key in args) { if (args.hasOwnProperty(key)) { - argsArray.push(encodeURIComponent(key) + + argsArray.push(encodeURIComponent(key) + '=' + encodeURIComponent(args[key])); } } uri += argsArray.join('&'); } - xhr.responseType = typeof responseType === "string" ? - responseType : ""; xhr.onload = function () { if (this.status >= 200 && this.status < 300) { resolve(this.response); @@ -1463,6 +1461,11 @@ var CommentProvider = (function () { }; xhr.open(method, uri); + + // Limit the response type based on input + xhr.responseType = typeof responseType === "string" ? + responseType : ""; + if (typeof body !== 'undefined') { xhr.send(body); } else { @@ -1474,12 +1477,12 @@ var CommentProvider = (function () { /** * Provider for JSON content. This returns a promise that resolves to JSON. * - * @param method - HTTP method to use - * @param url - Base URL - * @param args - Arguments for query string. Note: This is only used when + * @param {string} method - HTTP method to use + * @param {string} url - Base URL + * @param {Object} args - Arguments for query string. Note: This is only used when * method is POST or PUT - * @param body - Text body content. If not provided will omit a body - * @return Promise that resolves or rejects based on the success or failure + * @param {any} body - Text body content. If not provided will omit a body + * @return {Promise} that resolves or rejects based on the success or failure * of the request **/ CommentProvider.JSONProvider = function (method, url, args, body) { @@ -1492,12 +1495,12 @@ var CommentProvider = (function () { /** * Provider for XML content. This returns a promise that resolves to Document. * - * @param method - HTTP method to use - * @param url - Base URL - * @param args - Arguments for query string. Note: This is only used when + * @param {string} method - HTTP method to use + * @param {string} url - Base URL + * @param {Object} args - Arguments for query string. Note: This is only used when * method is POST or PUT - * @param body - Text body content. If not provided will omit a body - * @return Promise that resolves or rejects based on the success or failure + * @param {any} body - Text body content. If not provided will omit a body + * @return {Promise} that resolves or rejects based on the success or failure * of the request **/ CommentProvider.XMLProvider = function (method, url, args, body) { @@ -1510,12 +1513,12 @@ var CommentProvider = (function () { /** * Provider for text content. This returns a promise that resolves to Text. * - * @param method - HTTP method to use - * @param url - Base URL - * @param args - Arguments for query string. Note: This is only used when + * @param {string} method - HTTP method to use + * @param {string} url - Base URL + * @param {Object} args - Arguments for query string. Note: This is only used when * method is POST or PUT - * @param body - Text body content. If not provided will omit a body - * @return Promise that resolves or rejects based on the success or failure + * @param {any} body - Text body content. If not provided will omit a body + * @return {Promise} that resolves or rejects based on the success or failure * of the request **/ CommentProvider.TextProvider = function (method, url, args, body) { @@ -1530,14 +1533,14 @@ var CommentProvider = (function () { * NOTE: Multiple static sources will race to determine the initial comment * list so it is imperative that they all parse to the SAME content. * - * @param source - Promise that resolves to one of the supported types - * @param type - Type that the provider resolves to - * @return this + * @param {Provider} source - Promise that resolves to one of the supported types + * @param {Type} type - Type that the provider resolves to + * @return {CommentProvider} this **/ CommentProvider.prototype.addStaticSource = function (source, type) { if (this._destroyed) { throw new Error( - 'Comment provider has been destroyed, ' + + 'Comment provider has been destroyed, ' + 'cannot attach more sources.'); } if (!(type in this._staticSources)) { @@ -1551,14 +1554,14 @@ var CommentProvider = (function () { * Attaches a dynamic source to the corresponding type * NOTE: Multiple dynamic sources will collectively provide comment data. * - * @param source - Listenable that resolves to one of the supported types - * @param type - Type that the provider resolves to - * @return this + * @param {DynamicProvider} source - Listenable that resolves to one of the supported types + * @param {Type} type - Type that the provider resolves to + * @return {CommentProvider} this **/ CommentProvider.prototype.addDynamicSource = function (source, type) { if (this._destroyed) { throw new Error( - 'Comment provider has been destroyed, ' + + 'Comment provider has been destroyed, ' + 'cannot attach more sources.'); } if (!(type in this._dynamicSources)) { @@ -1571,8 +1574,8 @@ var CommentProvider = (function () { /** * Attaches a target comment manager so that we can stream comments to it * - * @param commentManager - Comment Manager instance to attach to - * @return this + * @param {CommentManager} commentManager - Comment Manager instance to attach to + * @return {CommentProvider} this **/ CommentProvider.prototype.addTarget = function (commentManager) { if (this._destroyed) { @@ -1592,14 +1595,14 @@ var CommentProvider = (function () { * Adds a parser for an incoming data type. If multiple parsers are added, * parsers added later take precedence. * - * @param parser - Parser spec compliant parser - * @param type - Type that the provider resolves to - * @return this + * @param {CommentParser} parser - Parser spec compliant parser + * @param {Type} type - Type that the provider resolves to + * @return {CommentProvider} this **/ CommentProvider.prototype.addParser = function (parser, type) { if (this._destroyed) { throw new Error( - 'Comment provider has been destroyed, ' + + 'Comment provider has been destroyed, ' + 'cannot attach more parsers.'); } if (!(type in this._parsers)) { @@ -1656,9 +1659,9 @@ var CommentProvider = (function () { }; /** - * Reloads static comments + * (Re)loads static comments * - * @return Promise that is resolved when the static sources have been + * @return {Promise} that is resolved when the static sources have been * loaded */ CommentProvider.prototype.load = function () { @@ -1688,7 +1691,7 @@ var CommentProvider = (function () { /** * Commit the changes and boot up the provider * - * @return Promise that is resolved when all the static sources are loaded + * @return {Promise} that is resolved when all the static sources are loaded * and all the dynamic sources are hooked up **/ CommentProvider.prototype.start = function () { diff --git a/dist/CommentCoreLibrary.min.js b/dist/CommentCoreLibrary.min.js index a888cae..e6d96ee 100644 --- a/dist/CommentCoreLibrary.min.js +++ b/dist/CommentCoreLibrary.min.js @@ -1,3 +1,2 @@ /*!Copyright(c) CommentCoreLibrary v0.11.0 (//github.com/jabbany/CommentCoreLibrary) - Licensed under the MIT License */ -var BinArray=function(){var a={};return a.bsearch=function(a,b,c){if(!Array.isArray(a))throw new Error("Bsearch can only be run on arrays");if(0===a.length)return 0;if(c(b,a[0])<0)return 0;if(c(b,a[a.length-1])>=0)return a.length;for(var d=0,e=0,f=0,g=a.length-1;d<=g;){if(e=Math.floor((g+d+1)/2),f++,c(b,a[e-1])>=0&&c(b,a[e])<0)return e;if(c(b,a[e-1])<0)g=e-1;else{if(!(c(b,a[e])>=0))throw new Error("Program Error. Inconsistent comparator or unsorted array!");d=e}if(f>1500)throw new Error("Iteration depth exceeded. Inconsistent comparator or astronomical dataset!")}return-1},a.binsert=function(b,c,d){var e=a.bsearch(b,c,d);return b.splice(e,0,c),e},a}(),CommentUtils;!function(a){var b=function(){function a(a){if(this._internalArray=null,!Array.isArray(a))throw new Error("Not an array. Cannot construct matrix.");if(16!=a.length)throw new Error("Illegal Dimensions. Matrix3D should be 4x4 matrix.");this._internalArray=a}return Object.defineProperty(a.prototype,"flatArray",{get:function(){return this._internalArray.slice(0)},set:function(a){throw new Error("Not permitted. Matrices are immutable.")},enumerable:!0,configurable:!0}),a.prototype.isIdentity=function(){return this.equals(a.identity())},a.prototype.dot=function(b){for(var c=this._internalArray.slice(0),d=b._internalArray.slice(0),e=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],f=0;f<4;f++)for(var g=0;g<4;g++)for(var h=0;h<4;h++)e[4*f+g]+=c[4*f+h]*d[4*h+g];return new a(e)},a.prototype.equals=function(a){for(var b=0;b<16;b++)if(this._internalArray[b]!==a._internalArray[b])return!1;return!0},a.prototype.toCss=function(){for(var a=this._internalArray.slice(0),b=0;b0&&this.animate()},Object.defineProperty(a.prototype,"x",{get:function(){return null!==this._x&&void 0!==this._x||(this.axis%2==0?this.align%2==0?this._x=this.dom.offsetLeft:this._x=this.dom.offsetLeft+this.width:this.align%2==0?this._x=this.parent.width-this.dom.offsetLeft:this._x=this.parent.width-this.dom.offsetLeft-this.width),this.absolute?this._x:this._x/this.parent.width},set:function(a){this._x=a,this.absolute||(this._x*=this.parent.width),this.axis%2==0?this.dom.style.left=this._x+(this.align%2==0?0:-this.width)+"px":this.dom.style.right=this._x+(this.align%2==0?-this.width:0)+"px"},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"y",{get:function(){return null!==this._y&&void 0!==this._y||(this.axis<2?this.align<2?this._y=this.dom.offsetTop:this._y=this.dom.offsetTop+this.height:this.align<2?this._y=this.parent.height-this.dom.offsetTop:this._y=this.parent.height-this.dom.offsetTop-this.height),this.absolute?this._y:this._y/this.parent.height},set:function(a){this._y=a,this.absolute||(this._y*=this.parent.height),this.axis<2?this.dom.style.top=this._y+(this.align<2?0:-this.height)+"px":this.dom.style.bottom=this._y+(this.align<2?-this.height:0)+"px"},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"bottom",{get:function(){var a=Math.floor(this.axis/2)===Math.floor(this.align/2);return this.y+(a?this.height:0)},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"right",{get:function(){var a=this.axis%2==this.align%2;return this.x+(a?this.width:0)},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"width",{get:function(){return null!==this._width&&void 0!==this._width||(this._width=this.dom.offsetWidth),this._width},set:function(a){this._width=a,this.dom.style.width=this._width+"px"},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"height",{get:function(){return null!==this._height&&void 0!==this._height||(this._height=this.dom.offsetHeight),this._height},set:function(a){this._height=a,this.dom.style.height=this._height+"px"},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"size",{get:function(){return this._size},set:function(a){this._size=a,this.dom.style.fontSize=this._size+"px"},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"color",{get:function(){return this._color},set:function(a){this._color=a;var b=a.toString(16);b=b.length>=6?b:new Array(6-b.length+1).join("0")+b,this.dom.style.color="#"+b,0===this._color&&(this.dom.className=this.parent.options.global.className+" rshadow")},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"alpha",{get:function(){return this._alpha},set:function(a){this._alpha=a,this.dom.style.opacity=Math.min(this._alpha,this.parent.options.global.opacity)+""},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"border",{get:function(){return this._border},set:function(a){this._border=a,this._border?this.dom.style.border="1px solid #00ffff":this.dom.style.border="none"},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"shadow",{get:function(){return this._shadow},set:function(a){this._shadow=a,this._shadow||(this.dom.className=this.parent.options.global.className+" noshadow")},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"font",{get:function(){return this._font},set:function(a){this._font=a,this._font.length>0?this.dom.style.fontFamily=this._font:this.dom.style.fontFamily=""},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"transform",{get:function(){return this._transform.flatArray},set:function(a){this._transform=new CommentUtils.Matrix3D(a),null!==this.dom&&(this.dom.style.transform=this._transform.toCss())},enumerable:!0,configurable:!0}),a.prototype.time=function(a){this.ttl-=a,this.ttl<0&&(this.ttl=0),this.movable&&this.update(),this.ttl<=0&&this.finish()},a.prototype.update=function(){this.animate()},a.prototype.invalidate=function(){this._x=null,this._y=null,this._width=null,this._height=null},a.prototype._execMotion=function(a,b){for(var c in a)if(a.hasOwnProperty(c)){var d=a[c];this[c]=d.easing(Math.min(Math.max(b-d.delay,0),d.dur),d.from,d.to-d.from,d.dur)}},a.prototype.animate=function(){if(this._alphaMotion&&(this.alpha=(this.dur-this.ttl)*(this._alphaMotion.to-this._alphaMotion.from)/this.dur+this._alphaMotion.from),0!==this.motion.length){var a=Math.max(this.ttl,0),b=this.dur-a-this._motionStart[this._curMotion];return this._execMotion(this.motion[this._curMotion],b),this.dur-a>this._motionEnd[this._curMotion]?void(++this._curMotion>=this.motion.length&&(this._curMotion=this.motion.length-1)):void 0}},a.prototype.stop=function(){},a.prototype.finish=function(){this.parent.finish(this)},a.prototype.toString=function(){return["[",this.stime,"|",this.ttl,"/",this.dur,"]","(",this.mode,")",this.text].join("")},a.LINEAR=function(a,b,c,d){return a*c/d+b},a}(),ScrollComment=function(a){function b(b,c){a.call(this,b,c),this.dur*=this.parent.options.scroll.scale,this.ttl*=this.parent.options.scroll.scale}return __extends(b,a),Object.defineProperty(b.prototype,"alpha",{set:function(a){this._alpha=a,this.dom.style.opacity=Math.min(Math.min(this._alpha,this.parent.options.global.opacity),this.parent.options.scroll.opacity)+""},enumerable:!0,configurable:!0}),b.prototype.init=function(b){void 0===b&&(b=null),a.prototype.init.call(this,b),this.x=this.parent.width,this.parent.options.scroll.opacity<1&&(this.alpha=this._alpha),this.absolute=!0},b.prototype.update=function(){this.x=this.ttl/this.dur*(this.parent.width+this.width)-this.width},b}(CoreComment),__extends=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)},CssCompatLayer=function(){function a(){}return a.transform=function(a,b){a.style.transform=b,a.style.webkitTransform=b,a.style.msTransform=b,a.style.oTransform=b},a}(),CssScrollComment=function(a){function b(){a.apply(this,arguments),this._dirtyCSS=!0}return __extends(b,a),Object.defineProperty(b.prototype,"x",{get:function(){return this.ttl/this.dur*(this.parent.width+this.width)-this.width},set:function(a){if(null!==this._x&&"number"==typeof this._x){var b=a-this._x;this._x=a,CssCompatLayer.transform(this.dom,"translateX("+(this.axis%2==0?b:-b)+"px)")}else this._x=a,this.absolute||(this._x*=this.parent.width),this.axis%2==0?this.dom.style.left=this._x+(this.align%2==0?0:-this.width)+"px":this.dom.style.right=this._x+(this.align%2==0?-this.width:0)+"px"},enumerable:!0,configurable:!0}),b.prototype.update=function(){this._dirtyCSS&&(this.dom.style.transition="transform "+this.ttl+"ms linear",this.x=-this.width,this._dirtyCSS=!1)},b.prototype.invalidate=function(){a.prototype.invalidate.call(this),this._dirtyCSS=!0},b.prototype.stop=function(){a.prototype.stop.call(this),this.dom.style.transition="",this.x=this._x,this._x=null,this.x=this.x,this._dirtyCSS=!0},b}(ScrollComment),CommentFactory=function(){function a(){this._bindings={}}return a._simpleCssScrollingInitializer=function(a,b){var c=new CssScrollComment(a,b);switch(c.mode){case 1:c.align=0,c.axis=0;break;case 2:c.align=2,c.axis=2;break;case 6:c.align=1,c.axis=1}return c.init(),a.stage.appendChild(c.dom),c},a._simpleScrollingInitializer=function(a,b){var c=new ScrollComment(a,b);switch(c.mode){case 1:c.align=0,c.axis=0;break;case 2:c.align=2,c.axis=2;break;case 6:c.align=1,c.axis=1}return c.init(),a.stage.appendChild(c.dom),c},a._simpleAnchoredInitializer=function(a,b){var c=new CoreComment(a,b);switch(c.mode){case 4:c.align=2,c.axis=2;break;case 5:c.align=0,c.axis=0}return c.init(),a.stage.appendChild(c.dom),c},a._advancedCoreInitializer=function(a,b){var c=new CoreComment(a,b);return c.init(),c.transform=CommentUtils.Matrix3D.createRotationMatrix(0,b.rY,b.rZ).flatArray,a.stage.appendChild(c.dom),c},a.defaultFactory=function(){var b=new a;return b.bind(1,a._simpleScrollingInitializer),b.bind(2,a._simpleScrollingInitializer),b.bind(6,a._simpleScrollingInitializer),b.bind(4,a._simpleAnchoredInitializer),b.bind(5,a._simpleAnchoredInitializer),b.bind(7,a._advancedCoreInitializer),b.bind(17,a._advancedCoreInitializer),b},a.defaultCssRenderFactory=function(){var b=new a;return b.bind(1,a._simpleCssScrollingInitializer),b.bind(2,a._simpleCssScrollingInitializer),b.bind(6,a._simpleCssScrollingInitializer),b.bind(4,a._simpleAnchoredInitializer),b.bind(5,a._simpleAnchoredInitializer),b.bind(7,a._advancedCoreInitializer),b.bind(17,a._advancedCoreInitializer),b},a.defaultCanvasRenderFactory=function(){throw new Error("Not implemented")},a.defaultSvgRenderFactory=function(){throw new Error("Not implemented")},a.prototype.bind=function(a,b){this._bindings[a]=b},a.prototype.canCreate=function(a){return this._bindings.hasOwnProperty(a.mode)},a.prototype.create=function(a,b){if(null===b||!b.hasOwnProperty("mode"))throw new Error("Comment format incorrect");if(!this._bindings.hasOwnProperty(b.mode))throw new Error("No binding for comment type "+b.mode);return this._bindings[b.mode](a,b)},a}(),__extends=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)},CommentSpaceAllocator=function(){function a(a,b){void 0===a&&(a=0),void 0===b&&(b=0),this._pools=[[]],this.avoid=1,this._width=a,this._height=b}return a.prototype.willCollide=function(a,b){return a.stime+a.ttl>=b.stime+b.ttl/2},a.prototype.pathCheck=function(a,b,c){for(var d=a+b.height,e=b.right,f=0;fd||c[f].bottome))return!1;if(this.willCollide(c[f],b))return!1}return!0},a.prototype.assign=function(a,b){for(;this._pools.length<=b;)this._pools.push([]);var c=this._pools[b];if(0===c.length)return a.cindex=b,0;if(this.pathCheck(0,a,c))return a.cindex=b,0;for(var d=0,e=0;ethis._height);e++)if(this.pathCheck(d,a,c))return a.cindex=b,d;return this.assign(a,b+1)},a.prototype.add=function(a){a.height>this._height?(a.cindex=-2,a.y=0):(a.y=this.assign(a,0),BinArray.binsert(this._pools[a.cindex],a,function(a,b){return a.bottomb.bottom?1:0}))},a.prototype.remove=function(a){if(!(a.cindex<0)){if(a.cindex>=this._pools.length)throw new Error("cindex out of bounds");var b=this._pools[a.cindex].indexOf(a);b<0||this._pools[a.cindex].splice(b,1)}},a.prototype.setBounds=function(a,b){this._width=a,this._height=b},a}(),AnchorCommentSpaceAllocator=function(a){function b(){a.apply(this,arguments)}return __extends(b,a),b.prototype.add=function(b){a.prototype.add.call(this,b),b.x=(this._width-b.width)/2},b.prototype.willCollide=function(a,b){return!0},b.prototype.pathCheck=function(a,b,c){for(var d=a+b.height,e=0;ed||c[e].bottom0)){var a=(new Date).getTime(),c=this;b=window.setInterval(function(){var b=(new Date).getTime()-a;a=(new Date).getTime(),c.onTimerEvent(b,c)},10)}},this._stopTimer=function(){window.clearInterval(b),b=0}}var b=function(a,b){return a.stime>b.stime?2:a.stimeb.date?1:a.dateb.dbid?1:a.dbidb.stime?1:0})},a.prototype.validate=function(a){return null!=a&&this.filter.doValidate(a)},a.prototype.load=function(a){this.timeline=a,this.timeline.sort(b),this.dispatchEvent("load")},a.prototype.insert=function(a){BinArray.binsert(this.timeline,a,b)<=this.position&&this.position++,this.dispatchEvent("insert")},a.prototype.clear=function(){for(;this.runline.length>0;)this.runline[0].finish();this.dispatchEvent("clear")},a.prototype.setBounds=function(){this.width=this.stage.offsetWidth,this.height=this.stage.offsetHeight,this.dispatchEvent("resize");for(var a in this.csa)this.csa[a].setBounds(this.width,this.height);this.stage.style.perspective=this.width/Math.tan(55*Math.PI/180)/2+"px",this.stage.style.webkitPerspective=this.width/Math.tan(55*Math.PI/180)/2+"px"},a.prototype.init=function(a){if(this.setBounds(),null==this.filter&&(this.filter=new CommentFilter),null==this.factory)switch(a){case"legacy":this.factory=CommentFactory.defaultFactory();break;default:case"css":this.factory=CommentFactory.defaultCssRenderFactory()}},a.prototype.time=function(a){if(a-=1,this.position>=this.timeline.length||Math.abs(this._lastPosition-a)>=2e3){if(this.seek(a),this._lastPosition=a,this.timeline.length<=this.position)return}else this._lastPosition=a;for(;this.position0&&this.runline.length>this.limiter||this.validate(this.timeline[this.position])&&this.send(this.timeline[this.position])},a.prototype.rescale=function(){},a.prototype.send=function(a){if(8===a.mode)return console.log(a),void(this.scripting&&console.log(this.scripting.eval(a.code)));if(null==this.filter||null!=(a=this.filter.doModify(a))){var b=this.factory.create(this,a);switch(b.mode){default:case 1:this.csa.scroll.add(b);break;case 2:this.csa.scrollbtm.add(b);break;case 4:this.csa.bottom.add(b);break;case 5:this.csa.top.add(b);break;case 6:this.csa.reverse.add(b);break;case 7:case 17:}b.y=b.y,this.dispatchEvent("enterComment",b),this.runline.push(b)}},a.prototype.finish=function(a){this.dispatchEvent("exitComment",a),this.stage.removeChild(a.dom);var b=this.runline.indexOf(a);switch(b>=0&&this.runline.splice(b,1),a.mode){default:case 1:this.csa.scroll.remove(a);break;case 2:this.csa.scrollbtm.remove(a);break;case 4:this.csa.bottom.remove(a);break;case 5:this.csa.top.remove(a);break;case 6:this.csa.reverse.remove(a);break;case 7:}},a.prototype.addEventListener=function(a,b){void 0!==this._listeners[a]?this._listeners[a].push(b):this._listeners[a]=[b]},a.prototype.dispatchEvent=function(a,b){if(void 0!==this._listeners[a])for(var c=0;c0;){var f=d.shift();if(""!==f&&(e.hasOwnProperty(f)&&(e=e[f]),null===e||void 0===e)){e=null;break}}if(null===e)return!0;switch(b.op){case"<":return e":return e>b.value;case"~":case"regexp":return new RegExp(b.value).test(e.toString());case"=":case"eq":return b.value===("number"==typeof e?e:e.toString());case"NOT":return!a(b.value,e);case"AND":return!!Array.isArray(b.value)&&b.value.every(function(b){return a(b,e)});case"OR":return!!Array.isArray(b.value)&&b.value.some(function(b){return a(b,e)});default:return!1}}function b(){this.rules=[],this.modifiers=[],this.allowUnknownTypes=!0,this.allowTypes={1:!0,2:!0,4:!0,5:!0,6:!0,7:!0,8:!0,17:!0}}return b.prototype.doModify=function(a){return this.modifiers.reduce(function(a,b){return b(a)},a)},b.prototype.beforeSend=function(a){return a},b.prototype.doValidate=function(b){return!((!this.allowUnknownTypes||b.mode.toString()in this.allowTypes)&&!this.allowTypes[b.mode.toString()])&&this.rules.every(function(c){try{var d=a(c,b)}catch(a){var d=!1}return"accept"===c.mode?d:!d})},b.prototype.addRule=function(a){if("accept"!==a.mode&&"reject"!==a.mode)throw new Error("Rule must be of accept type or reject type.");this.rules.push(a)},b.prototype.addModifier=function(a){if("function"!=typeof a)throw new Error("Modifiers need to be functions.");this.modifiers.push(a)},b}(),CommentProvider=function(){function a(){this._started=!1,this._destroyed=!1,this._staticSources={},this._dynamicSources={},this._parsers={},this._targets=[]}return a.SOURCE_JSON="JSON",a.SOURCE_XML="XML",a.SOURCE_TEXT="TEXT",a.BaseHttpProvider=function(a,b,c,d,e){return new Promise(function(f,g){var h=new XMLHttpRequest,i=b;if(d&&("POST"===a||"PUT"===a)){i+="?";var j=[];for(var k in d)d.hasOwnProperty(k)&&j.push(encodeURIComponent(k)+"="+encodeURIComponent(d[k]));i+=j.join("&")}h.responseType="string"==typeof c?c:"",h.onload=function(){this.status>=200&&this.status<300?f(this.response):g(new Error(this.status+" "+this.statusText))},h.onerror=function(){g(new Error(this.status+" "+this.statusText))},h.open(a,i),void 0!==e?h.send(e):h.send()})},a.JSONProvider=function(b,c,d,e){return a.BaseHttpProvider(b,c,"json",d,e).then(function(a){return a})},a.XMLProvider=function(b,c,d,e){return a.BaseHttpProvider(b,c,"document",d,e).then(function(a){return a})},a.TextProvider=function(b,c,d,e){return a.BaseHttpProvider(b,c,"text",d,e).then(function(a){return a})},a.prototype.addStaticSource=function(a,b){if(this._destroyed)throw new Error("Comment provider has been destroyed, cannot attach more sources.");return b in this._staticSources||(this._staticSources[b]=[]),this._staticSources[b].push(a),this},a.prototype.addDynamicSource=function(a,b){if(this._destroyed)throw new Error("Comment provider has been destroyed, cannot attach more sources.");return b in this._dynamicSources||(this._dynamicSources[b]=[]),this._dynamicSources[b].push(a),this},a.prototype.addTarget=function(a){if(this._destroyed)throw new Error("Comment provider has been destroyed, cannot attach more targets.");if(!(a instanceof CommentManager))throw new Error("Expected the target to be an instance of CommentManager.");return this._targets.push(a),this},a.prototype.addParser=function(a,b){if(this._destroyed)throw new Error("Comment provider has been destroyed, cannot attach more parsers.");return b in this._parsers||(this._parsers[b]=[]),this._parsers[b].unshift(a),this},a.prototype.applyParsersOne=function(a,b){return new Promise(function(c,d){if(!(b in this._parsers))return void d(new Error('No parsers defined for "'+b+'"'));for(var e=0;e=7&&(f.rZ=parseInt(g[5],10),f.rY=parseInt(g[6],10)),f.motion=[],f.movable=!1,g.length>=11){f.movable=!0;var h=500,i={x:{from:f.x,to:parseFloat(g[7]),dur:h,delay:0},y:{from:f.y,to:parseFloat(g[8]),dur:h,delay:0}};if(""!==g[9]&&(h=parseInt(g[9],10),i.x.dur=h,i.y.dur=h),""!==g[10]&&(i.x.delay=parseInt(g[10],10),i.y.delay=parseInt(g[10],10)),g.length>11&&(f.shadow="false"!==g[11]&&!1!==g[11],null!=g[12]&&(f.font=g[12]),g.length>14)){"relative"===f.position&&(this._logBadComments&&console.warn("Cannot mix relative and absolute positioning!"),f.position="absolute");for(var j=g[14],k={x:i.x.from,y:i.y.from},l=[],m=new RegExp("([a-zA-Z])\\s*(\\d+)[, ](\\d+)","g"),n=j.split(/[a-zA-Z]/).length-1,o=m.exec(j);null!==o;){switch(o[1]){case"M":k.x=parseInt(o[2],10),k.y=parseInt(o[3],10);break;case"L":l.push({x:{from:k.x,to:parseInt(o[2],10),dur:h/n,delay:0},y:{from:k.y,to:parseInt(o[3],10),dur:h/n,delay:0}}),k.x=parseInt(o[2],10),k.y=parseInt(o[3],10)}o=m.exec(j)}i=null,f.motion=l}null!==i&&f.motion.push(i)}f.dur=2500,g[3]<12&&(f.dur=1e3*g[3]);var p=g[2].split("-");if(null!=p&&p.length>1){var q=parseFloat(p[0]),r=parseFloat(p[1]);f.opacity=q,q!==r&&(f.alpha={from:q,to:r})}}catch(a){this._logBadComments&&(console.warn("Error occurred in JSON parsing. Could not parse comment."),console.log("[DEBUG] "+e))}else 8===f.mode?f.code=e:this._logBadComments&&(console.warn("Unknown comment type : "+f.mode+". Not doing further parsing."),console.log("[DEBUG] "+e));return null!==f.text&&"string"==typeof f.text&&(f.text=f.text.replace(/\u25a0/g,"█")),f},a.XMLParser.prototype.parseMany=function(a){var b=[];try{b=a.getElementsByTagName("d")}catch(a){return null}for(var c=[],d=0;d=6){if(b.stime=1e3*parseFloat(c[0]),b.color=parseInt(c[1]),b.mode=parseInt(c[2]),b.size=parseInt(c[3]),b.hash=c[4],b.date=parseInt(c[5]),b.position="absolute",7!==b.mode)b.text=a.m.replace(/(\/n|\\n|\n|\r\n|\\r)/g,"\n"),b.text=b.text.replace(/\r/g,"\n"),b.text=b.text.replace(/\s/g," ");else{try{var d=JSON.parse(a.m)}catch(a){return this._logBadComments&&(console.warn("Error parsing internal data for comment"),console.log("[Dbg] "+b.text)),null}if(b.position="relative",b.text=d.n,b.text=b.text.replace(/\ /g," "),"number"==typeof d.a?b.opacity=d.a:b.opacity=1,"object"==typeof d.p?(b.x=d.p.x/1e3,b.y=d.p.y/1e3):(b.x=0,b.y=0),"number"==typeof d.c)switch(d.c){case 0:b.align=0;break;case 2:b.align=1;break;case 6:b.align=2;break;case 8:b.align=3;break;default:this._logNotImplemented&&console.log("Cannot handle aligning to center! AlignMode="+d.c)}if(b.axis=0,b.shadow=d.b,b.dur=4e3,"number"==typeof d.l&&(b.dur=1e3*d.l),null!=d.z&&d.z.length>0){b.movable=!0,b.motion=[];for(var e=0,f={x:b.x,y:b.y,alpha:b.opacity,color:b.color},g=0;g0&&this._logNotImplemented&&console.log("[Dbg] Filters not supported! "+JSON.stringify(d.w.l))),null!=d.r&&null!=d.k&&(b.rX=d.r,b.rY=d.k)}return b}return this._logBadComments&&(console.warn("Dropping this comment due to insufficient parameters. Got: "+c.length),console.log("[Dbg] "+a.c)),null},a.JSONParser.prototype.parseMany=function(a){if(!Array.isArray(a))return null;for(var b=[],c=0;c=0)return t.length;for(var i=0,n=0,o=0,s=t.length-1;i<=s;){if(n=Math.floor((s+i+1)/2),o++,r(e,t[n-1])>=0&&r(e,t[n])<0)return n;if(r(e,t[n-1])<0)s=n-1;else{if(!(r(e,t[n])>=0))throw new Error("Program Error. Inconsistent comparator or unsorted array!");i=n}if(o>1500)throw new Error("Iteration depth exceeded. Inconsistent comparator or astronomical dataset!")}return-1},t.binsert=function(e,r,i){var n=t.bsearch(e,r,i);return e.splice(n,0,r),n},t}(),CommentUtils;!function(t){var e=function(){function t(t){if(this._internalArray=null,!Array.isArray(t))throw new Error("Not an array. Cannot construct matrix.");if(16!=t.length)throw new Error("Illegal Dimensions. Matrix3D should be 4x4 matrix.");this._internalArray=t}return Object.defineProperty(t.prototype,"flatArray",{get:function(){return this._internalArray.slice(0)},set:function(t){throw new Error("Not permitted. Matrices are immutable.")},enumerable:!0,configurable:!0}),t.prototype.isIdentity=function(){return this.equals(t.identity())},t.prototype.dot=function(e){for(var r=this._internalArray.slice(0),i=e._internalArray.slice(0),n=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],o=0;o<4;o++)for(var s=0;s<4;s++)for(var a=0;a<4;a++)n[4*o+s]+=r[4*o+a]*i[4*a+s];return new t(n)},t.prototype.equals=function(t){for(var e=0;e<16;e++)if(this._internalArray[e]!==t._internalArray[e])return!1;return!0},t.prototype.toCss=function(){for(var t=this._internalArray.slice(0),e=0;e0&&this.animate()},Object.defineProperty(t.prototype,"x",{get:function(){return null!==this._x&&void 0!==this._x||(this.axis%2==0?this.align%2==0?this._x=this.dom.offsetLeft:this._x=this.dom.offsetLeft+this.width:this.align%2==0?this._x=this.parent.width-this.dom.offsetLeft:this._x=this.parent.width-this.dom.offsetLeft-this.width),this.absolute?this._x:this._x/this.parent.width},set:function(t){this._x=t,this.absolute||(this._x*=this.parent.width),this.axis%2==0?this.dom.style.left=this._x+(this.align%2==0?0:-this.width)+"px":this.dom.style.right=this._x+(this.align%2==0?-this.width:0)+"px"},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return null!==this._y&&void 0!==this._y||(this.axis<2?this.align<2?this._y=this.dom.offsetTop:this._y=this.dom.offsetTop+this.height:this.align<2?this._y=this.parent.height-this.dom.offsetTop:this._y=this.parent.height-this.dom.offsetTop-this.height),this.absolute?this._y:this._y/this.parent.height},set:function(t){this._y=t,this.absolute||(this._y*=this.parent.height),this.axis<2?this.dom.style.top=this._y+(this.align<2?0:-this.height)+"px":this.dom.style.bottom=this._y+(this.align<2?-this.height:0)+"px"},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bottom",{get:function(){var t=Math.floor(this.axis/2)===Math.floor(this.align/2);return this.y+(t?this.height:0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){var t=this.axis%2==this.align%2;return this.x+(t?this.width:0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"width",{get:function(){return null!==this._width&&void 0!==this._width||(this._width=this.dom.offsetWidth),this._width},set:function(t){this._width=t,this.dom.style.width=this._width+"px"},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return null!==this._height&&void 0!==this._height||(this._height=this.dom.offsetHeight),this._height},set:function(t){this._height=t,this.dom.style.height=this._height+"px"},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"size",{get:function(){return this._size},set:function(t){this._size=t,this.dom.style.fontSize=this._size+"px"},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"color",{get:function(){return this._color},set:function(t){this._color=t;var e=t.toString(16);e=e.length>=6?e:new Array(6-e.length+1).join("0")+e,this.dom.style.color="#"+e,0===this._color&&(this.dom.className=this.parent.options.global.className+" rshadow")},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"alpha",{get:function(){return this._alpha},set:function(t){this._alpha=t,this.dom.style.opacity=Math.min(this._alpha,this.parent.options.global.opacity)+""},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"border",{get:function(){return this._border},set:function(t){this._border=t,this._border?this.dom.style.border="1px solid #00ffff":this.dom.style.border="none"},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadow",{get:function(){return this._shadow},set:function(t){this._shadow=t,this._shadow||(this.dom.className=this.parent.options.global.className+" noshadow")},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"font",{get:function(){return this._font},set:function(t){this._font=t,this._font.length>0?this.dom.style.fontFamily=this._font:this.dom.style.fontFamily=""},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"transform",{get:function(){return this._transform.flatArray},set:function(t){this._transform=new CommentUtils.Matrix3D(t),null!==this.dom&&(this.dom.style.transform=this._transform.toCss())},enumerable:!0,configurable:!0}),t.prototype.time=function(t){this.ttl-=t,this.ttl<0&&(this.ttl=0),this.movable&&this.update(),this.ttl<=0&&this.finish()},t.prototype.update=function(){this.animate()},t.prototype.invalidate=function(){this._x=null,this._y=null,this._width=null,this._height=null},t.prototype._execMotion=function(t,e){for(var r in t)if(t.hasOwnProperty(r)){var i=t[r];this[r]=i.easing(Math.min(Math.max(e-i.delay,0),i.dur),i.from,i.to-i.from,i.dur)}},t.prototype.animate=function(){if(this._alphaMotion&&(this.alpha=(this.dur-this.ttl)*(this._alphaMotion.to-this._alphaMotion.from)/this.dur+this._alphaMotion.from),0!==this.motion.length){var t=Math.max(this.ttl,0),e=this.dur-t-this._motionStart[this._curMotion];return this._execMotion(this.motion[this._curMotion],e),this.dur-t>this._motionEnd[this._curMotion]?void(++this._curMotion>=this.motion.length&&(this._curMotion=this.motion.length-1)):void 0}},t.prototype.stop=function(){},t.prototype.finish=function(){this.parent.finish(this)},t.prototype.toString=function(){return["[",this.stime,"|",this.ttl,"/",this.dur,"]","(",this.mode,")",this.text].join("")},t.LINEAR=function(t,e,r,i){return t*r/i+e},t}(),ScrollComment=function(t){function e(e,r){t.call(this,e,r),this.dur*=this.parent.options.scroll.scale,this.ttl*=this.parent.options.scroll.scale}return __extends(e,t),Object.defineProperty(e.prototype,"alpha",{set:function(t){this._alpha=t,this.dom.style.opacity=Math.min(Math.min(this._alpha,this.parent.options.global.opacity),this.parent.options.scroll.opacity)+""},enumerable:!0,configurable:!0}),e.prototype.init=function(e){void 0===e&&(e=null),t.prototype.init.call(this,e),this.x=this.parent.width,this.parent.options.scroll.opacity<1&&(this.alpha=this._alpha),this.absolute=!0},e.prototype.update=function(){this.x=this.ttl/this.dur*(this.parent.width+this.width)-this.width},e}(CoreComment),__extends=this&&this.__extends||function(t,e){function r(){this.constructor=t}for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)},CssCompatLayer=function(){function t(){}return t.transform=function(t,e){t.style.transform=e,t.style.webkitTransform=e,t.style.msTransform=e,t.style.oTransform=e},t}(),CssScrollComment=function(t){function e(){t.apply(this,arguments),this._dirtyCSS=!0}return __extends(e,t),Object.defineProperty(e.prototype,"x",{get:function(){return this.ttl/this.dur*(this.parent.width+this.width)-this.width},set:function(t){if(null!==this._x&&"number"==typeof this._x){var e=t-this._x;this._x=t,CssCompatLayer.transform(this.dom,"translateX("+(this.axis%2==0?e:-e)+"px)")}else this._x=t,this.absolute||(this._x*=this.parent.width),this.axis%2==0?this.dom.style.left=this._x+(this.align%2==0?0:-this.width)+"px":this.dom.style.right=this._x+(this.align%2==0?-this.width:0)+"px"},enumerable:!0,configurable:!0}),e.prototype.update=function(){this._dirtyCSS&&(this.dom.style.transition="transform "+this.ttl+"ms linear",this.x=-this.width,this._dirtyCSS=!1)},e.prototype.invalidate=function(){t.prototype.invalidate.call(this),this._dirtyCSS=!0},e.prototype.stop=function(){t.prototype.stop.call(this),this.dom.style.transition="",this.x=this._x,this._x=null,this.x=this.x,this._dirtyCSS=!0},e}(ScrollComment),CommentFactory=function(){function t(){this._bindings={}}return t._simpleCssScrollingInitializer=function(t,e){var r=new CssScrollComment(t,e);switch(r.mode){case 1:r.align=0,r.axis=0;break;case 2:r.align=2,r.axis=2;break;case 6:r.align=1,r.axis=1}return r.init(),t.stage.appendChild(r.dom),r},t._simpleScrollingInitializer=function(t,e){var r=new ScrollComment(t,e);switch(r.mode){case 1:r.align=0,r.axis=0;break;case 2:r.align=2,r.axis=2;break;case 6:r.align=1,r.axis=1}return r.init(),t.stage.appendChild(r.dom),r},t._simpleAnchoredInitializer=function(t,e){var r=new CoreComment(t,e);switch(r.mode){case 4:r.align=2,r.axis=2;break;case 5:r.align=0,r.axis=0}return r.init(),t.stage.appendChild(r.dom),r},t._advancedCoreInitializer=function(t,e){var r=new CoreComment(t,e);return r.init(),r.transform=CommentUtils.Matrix3D.createRotationMatrix(0,e.rY,e.rZ).flatArray,t.stage.appendChild(r.dom),r},t.defaultFactory=function(){var e=new t;return e.bind(1,t._simpleScrollingInitializer),e.bind(2,t._simpleScrollingInitializer),e.bind(6,t._simpleScrollingInitializer),e.bind(4,t._simpleAnchoredInitializer),e.bind(5,t._simpleAnchoredInitializer),e.bind(7,t._advancedCoreInitializer),e.bind(17,t._advancedCoreInitializer),e},t.defaultCssRenderFactory=function(){var e=new t;return e.bind(1,t._simpleCssScrollingInitializer),e.bind(2,t._simpleCssScrollingInitializer),e.bind(6,t._simpleCssScrollingInitializer),e.bind(4,t._simpleAnchoredInitializer),e.bind(5,t._simpleAnchoredInitializer),e.bind(7,t._advancedCoreInitializer),e.bind(17,t._advancedCoreInitializer),e},t.defaultCanvasRenderFactory=function(){throw new Error("Not implemented")},t.defaultSvgRenderFactory=function(){throw new Error("Not implemented")},t.prototype.bind=function(t,e){this._bindings[t]=e},t.prototype.canCreate=function(t){return this._bindings.hasOwnProperty(t.mode)},t.prototype.create=function(t,e){if(null===e||!e.hasOwnProperty("mode"))throw new Error("Comment format incorrect");if(!this._bindings.hasOwnProperty(e.mode))throw new Error("No binding for comment type "+e.mode);return this._bindings[e.mode](t,e)},t}(),__extends=this&&this.__extends||function(t,e){function r(){this.constructor=t}for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)},CommentSpaceAllocator=function(){function t(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this._pools=[[]],this.avoid=1,this._width=t,this._height=e}return t.prototype.willCollide=function(t,e){return t.stime+t.ttl>=e.stime+e.ttl/2},t.prototype.pathCheck=function(t,e,r){for(var i=t+e.height,n=e.right,o=0;oi||r[o].bottomn))return!1;if(this.willCollide(r[o],e))return!1}return!0},t.prototype.assign=function(t,e){for(;this._pools.length<=e;)this._pools.push([]);var r=this._pools[e];if(0===r.length)return t.cindex=e,0;if(this.pathCheck(0,t,r))return t.cindex=e,0;for(var i=0,n=0;nthis._height);n++)if(this.pathCheck(i,t,r))return t.cindex=e,i;return this.assign(t,e+1)},t.prototype.add=function(t){t.height>this._height?(t.cindex=-2,t.y=0):(t.y=this.assign(t,0),BinArray.binsert(this._pools[t.cindex],t,function(t,e){return t.bottome.bottom?1:0}))},t.prototype.remove=function(t){if(!(t.cindex<0)){if(t.cindex>=this._pools.length)throw new Error("cindex out of bounds");var e=this._pools[t.cindex].indexOf(t);e<0||this._pools[t.cindex].splice(e,1)}},t.prototype.setBounds=function(t,e){this._width=t,this._height=e},t}(),AnchorCommentSpaceAllocator=function(t){function e(){t.apply(this,arguments)}return __extends(e,t),e.prototype.add=function(e){t.prototype.add.call(this,e),e.x=(this._width-e.width)/2},e.prototype.willCollide=function(t,e){return!0},e.prototype.pathCheck=function(t,e,r){for(var i=t+e.height,n=0;ni||r[n].bottom0)){var t=(new Date).getTime(),r=this;e=window.setInterval(function(){var e=(new Date).getTime()-t;t=(new Date).getTime(),r.onTimerEvent(e,r)},10)}},this._stopTimer=function(){window.clearInterval(e),e=0}}var e=function(t,e){return t.stime>e.stime?2:t.stimee.date?1:t.datee.dbid?1:t.dbide.stime?1:0})},t.prototype.validate=function(t){return null!=t&&this.filter.doValidate(t)},t.prototype.load=function(t){this.timeline=t,this.timeline.sort(e),this.dispatchEvent("load")},t.prototype.insert=function(t){BinArray.binsert(this.timeline,t,e)<=this.position&&this.position++,this.dispatchEvent("insert")},t.prototype.clear=function(){for(;this.runline.length>0;)this.runline[0].finish();this.dispatchEvent("clear")},t.prototype.setBounds=function(){this.width=this.stage.offsetWidth,this.height=this.stage.offsetHeight,this.dispatchEvent("resize");for(var t in this.csa)this.csa[t].setBounds(this.width,this.height);this.stage.style.perspective=this.width/Math.tan(55*Math.PI/180)/2+"px",this.stage.style.webkitPerspective=this.width/Math.tan(55*Math.PI/180)/2+"px"},t.prototype.init=function(t){if(this.setBounds(),null==this.filter&&(this.filter=new CommentFilter),null==this.factory)switch(t){case"legacy":this.factory=CommentFactory.defaultFactory();break;default:case"css":this.factory=CommentFactory.defaultCssRenderFactory()}},t.prototype.time=function(t){if(t-=1,this.position>=this.timeline.length||Math.abs(this._lastPosition-t)>=2e3){if(this.seek(t),this._lastPosition=t,this.timeline.length<=this.position)return}else this._lastPosition=t;for(;this.position0&&this.runline.length>this.limiter||this.validate(this.timeline[this.position])&&this.send(this.timeline[this.position])},t.prototype.rescale=function(){},t.prototype.send=function(t){if(8===t.mode)return console.log(t),void(this.scripting&&console.log(this.scripting.eval(t.code)));if(null==this.filter||null!=(t=this.filter.doModify(t))){var e=this.factory.create(this,t);switch(e.mode){default:case 1:this.csa.scroll.add(e);break;case 2:this.csa.scrollbtm.add(e);break;case 4:this.csa.bottom.add(e);break;case 5:this.csa.top.add(e);break;case 6:this.csa.reverse.add(e);break;case 7:case 17:}e.y=e.y,this.dispatchEvent("enterComment",e),this.runline.push(e)}},t.prototype.finish=function(t){this.dispatchEvent("exitComment",t),this.stage.removeChild(t.dom);var e=this.runline.indexOf(t);switch(e>=0&&this.runline.splice(e,1),t.mode){default:case 1:this.csa.scroll.remove(t);break;case 2:this.csa.scrollbtm.remove(t);break;case 4:this.csa.bottom.remove(t);break;case 5:this.csa.top.remove(t);break;case 6:this.csa.reverse.remove(t);break;case 7:}},t.prototype.addEventListener=function(t,e){void 0!==this._listeners[t]?this._listeners[t].push(e):this._listeners[t]=[e]},t.prototype.dispatchEvent=function(t,e){if(void 0!==this._listeners[t])for(var r=0;r0;){var o=i.shift();if(""!==o&&(n.hasOwnProperty(o)&&(n=n[o]),null===n||void 0===n)){n=null;break}}if(null===n)return!0;switch(e.op){case"<":return n":return n>e.value;case"~":case"regexp":return new RegExp(e.value).test(n.toString());case"=":case"eq":return e.value===("number"==typeof n?n:n.toString());case"NOT":return!t(e.value,n);case"AND":return!!Array.isArray(e.value)&&e.value.every(function(e){return t(e,n)});case"OR":return!!Array.isArray(e.value)&&e.value.some(function(e){return t(e,n)});default:return!1}}function e(){this.rules=[],this.modifiers=[],this.allowUnknownTypes=!0,this.allowTypes={1:!0,2:!0,4:!0,5:!0,6:!0,7:!0,8:!0,17:!0}}return e.prototype.doModify=function(t){return this.modifiers.reduce(function(t,e){return e(t)},t)},e.prototype.beforeSend=function(t){return t},e.prototype.doValidate=function(e){return!((!this.allowUnknownTypes||e.mode.toString()in this.allowTypes)&&!this.allowTypes[e.mode.toString()])&&this.rules.every(function(r){try{i=t(r,e)}catch(t){var i=!1}return"accept"===r.mode?i:!i})},e.prototype.addRule=function(t){if("accept"!==t.mode&&"reject"!==t.mode)throw new Error("Rule must be of accept type or reject type.");this.rules.push(t)},e.prototype.addModifier=function(t){if("function"!=typeof t)throw new Error("Modifiers need to be functions.");this.modifiers.push(t)},e}(),CommentProvider=function(){function t(){this._started=!1,this._destroyed=!1,this._staticSources={},this._dynamicSources={},this._parsers={},this._targets=[]}return t.SOURCE_JSON="JSON",t.SOURCE_XML="XML",t.SOURCE_TEXT="TEXT",t.BaseHttpProvider=function(t,e,r,i,n){return new Promise(function(o,s){var a=new XMLHttpRequest,h=e;if(i&&("POST"===t||"PUT"===t)){h+="?";var l=[];for(var p in i)i.hasOwnProperty(p)&&l.push(encodeURIComponent(p)+"="+encodeURIComponent(i[p]));h+=l.join("&")}a.onload=function(){this.status>=200&&this.status<300?o(this.response):s(new Error(this.status+" "+this.statusText))},a.onerror=function(){s(new Error(this.status+" "+this.statusText))},a.open(t,h),a.responseType="string"==typeof r?r:"",void 0!==n?a.send(n):a.send()})},t.JSONProvider=function(e,r,i,n){return t.BaseHttpProvider(e,r,"json",i,n).then(function(t){return t})},t.XMLProvider=function(e,r,i,n){return t.BaseHttpProvider(e,r,"document",i,n).then(function(t){return t})},t.TextProvider=function(e,r,i,n){return t.BaseHttpProvider(e,r,"text",i,n).then(function(t){return t})},t.prototype.addStaticSource=function(t,e){if(this._destroyed)throw new Error("Comment provider has been destroyed, cannot attach more sources.");return e in this._staticSources||(this._staticSources[e]=[]),this._staticSources[e].push(t),this},t.prototype.addDynamicSource=function(t,e){if(this._destroyed)throw new Error("Comment provider has been destroyed, cannot attach more sources.");return e in this._dynamicSources||(this._dynamicSources[e]=[]),this._dynamicSources[e].push(t),this},t.prototype.addTarget=function(t){if(this._destroyed)throw new Error("Comment provider has been destroyed, cannot attach more targets.");if(!(t instanceof CommentManager))throw new Error("Expected the target to be an instance of CommentManager.");return this._targets.push(t),this},t.prototype.addParser=function(t,e){if(this._destroyed)throw new Error("Comment provider has been destroyed, cannot attach more parsers.");return e in this._parsers||(this._parsers[e]=[]),this._parsers[e].unshift(t),this},t.prototype.applyParsersOne=function(t,e){return new Promise(function(r,i){if(e in this._parsers){for(var n=0;n=7&&(o.rZ=parseInt(s[5],10),o.rY=parseInt(s[6],10)),o.motion=[],o.movable=!1,s.length>=11){o.movable=!0;var a=500,h={x:{from:o.x,to:parseFloat(s[7]),dur:a,delay:0},y:{from:o.y,to:parseFloat(s[8]),dur:a,delay:0}};if(""!==s[9]&&(a=parseInt(s[9],10),h.x.dur=a,h.y.dur=a),""!==s[10]&&(h.x.delay=parseInt(s[10],10),h.y.delay=parseInt(s[10],10)),s.length>11&&(o.shadow="false"!==s[11]&&!1!==s[11],null!=s[12]&&(o.font=s[12]),s.length>14)){"relative"===o.position&&(this._logBadComments&&console.warn("Cannot mix relative and absolute positioning!"),o.position="absolute");for(var l=s[14],p={x:h.x.from,y:h.y.from},c=[],u=new RegExp("([a-zA-Z])\\s*(\\d+)[, ](\\d+)","g"),d=l.split(/[a-zA-Z]/).length-1,m=u.exec(l);null!==m;){switch(m[1]){case"M":p.x=parseInt(m[2],10),p.y=parseInt(m[3],10);break;case"L":c.push({x:{from:p.x,to:parseInt(m[2],10),dur:a/d,delay:0},y:{from:p.y,to:parseInt(m[3],10),dur:a/d,delay:0}}),p.x=parseInt(m[2],10),p.y=parseInt(m[3],10)}m=u.exec(l)}h=null,o.motion=c}null!==h&&o.motion.push(h)}o.dur=2500,s[3]<12&&(o.dur=1e3*s[3]);var f=s[2].split("-");if(null!=f&&f.length>1){var y=parseFloat(f[0]),g=parseFloat(f[1]);o.opacity=y,y!==g&&(o.alpha={from:y,to:g})}}catch(t){this._logBadComments&&(console.warn("Error occurred in JSON parsing. Could not parse comment."),console.log("[DEBUG] "+n))}else 8===o.mode?o.code=n:this._logBadComments&&(console.warn("Unknown comment type : "+o.mode+". Not doing further parsing."),console.log("[DEBUG] "+n));return null!==o.text&&"string"==typeof o.text&&(o.text=o.text.replace(/\u25a0/g,"█")),o},t.XMLParser.prototype.parseMany=function(t){var e=[];try{e=t.getElementsByTagName("d")}catch(t){return null}for(var r=[],i=0;i=6){if(e.stime=1e3*parseFloat(r[0]),e.color=parseInt(r[1]),e.mode=parseInt(r[2]),e.size=parseInt(r[3]),e.hash=r[4],e.date=parseInt(r[5]),e.position="absolute",7!==e.mode)e.text=t.m.replace(/(\/n|\\n|\n|\r\n|\\r)/g,"\n"),e.text=e.text.replace(/\r/g,"\n"),e.text=e.text.replace(/\s/g," ");else{try{var i=JSON.parse(t.m)}catch(t){return this._logBadComments&&(console.warn("Error parsing internal data for comment"),console.log("[Dbg] "+e.text)),null}if(e.position="relative",e.text=i.n,e.text=e.text.replace(/\ /g," "),"number"==typeof i.a?e.opacity=i.a:e.opacity=1,"object"==typeof i.p?(e.x=i.p.x/1e3,e.y=i.p.y/1e3):(e.x=0,e.y=0),"number"==typeof i.c)switch(i.c){case 0:e.align=0;break;case 2:e.align=1;break;case 6:e.align=2;break;case 8:e.align=3;break;default:this._logNotImplemented&&console.log("Cannot handle aligning to center! AlignMode="+i.c)}if(e.axis=0,e.shadow=i.b,e.dur=4e3,"number"==typeof i.l&&(e.dur=1e3*i.l),null!=i.z&&i.z.length>0){e.movable=!0,e.motion=[];for(var n=0,o={x:e.x,y:e.y,alpha:e.opacity,color:e.color},s=0;s0&&this._logNotImplemented&&console.log("[Dbg] Filters not supported! "+JSON.stringify(i.w.l))),null!=i.r&&null!=i.k&&(e.rX=i.r,e.rY=i.k)}return e}return this._logBadComments&&(console.warn("Dropping this comment due to insufficient parameters. Got: "+r.length),console.log("[Dbg] "+t.c)),null},t.JSONParser.prototype.parseMany=function(t){if(!Array.isArray(t))return null;for(var e=[],r=0;r