| var subframeEnabled = false; |
| var cachedColors = {}; |
| var bm_rnd = Math.round; |
| |
| function styleDiv(element){ |
| element.style.position = 'absolute'; |
| element.style.top = 0; |
| element.style.left = 0; |
| element.style.display = 'block'; |
| element.style.verticalAlign = 'top'; |
| element.style.backfaceVisibility = element.style.webkitBackfaceVisibility = 'hidden'; |
| //element.style.transformStyle = element.style.webkitTransformStyle = "preserve-3d"; |
| styleUnselectableDiv(element); |
| } |
| |
| function styleUnselectableDiv(element){ |
| element.style.userSelect = 'none'; |
| element.style.MozUserSelect = 'none'; |
| element.style.webkitUserSelect = 'none'; |
| element.style.oUserSelect = 'none'; |
| |
| } |
| |
| function addEventListener(eventName, callback){ |
| |
| if (!this._cbs){ |
| this._cbs = []; |
| } |
| |
| if (!this._cbs[eventName]){ |
| this._cbs[eventName] = []; |
| } |
| |
| this._cbs[eventName].push(callback); |
| |
| } |
| |
| function triggerEvent(eventName, args){ |
| |
| if (!this._cbs){ |
| this._cbs = []; |
| } |
| |
| var delay = this._cbs.length === 0; |
| var that = this; |
| |
| if (this._cbs[eventName]) { |
| if (delay){ |
| setTimeout(function(){ |
| for (var i = 0; i < that._cbs[eventName].length; i++){ |
| that._cbs[eventName][i](args); |
| } |
| }, 0); |
| } |
| else { |
| for (var i = 0; i < this._cbs[eventName].length; i++){ |
| this._cbs[eventName][i](args); |
| } |
| } |
| } |
| } |
| |
| function randomString(length, chars){ |
| if(chars === undefined){ |
| chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'; |
| } |
| var i; |
| var result = ''; |
| for (i = length; i > 0; --i) result += chars[Math.round(Math.random() * (chars.length - 1))]; |
| return result; |
| } |
| |
| function componentToHex(c) { |
| var hex = c.toString(16); |
| return hex.length == 1 ? '0' + hex : hex; |
| } |
| |
| var rgbToHex = (function(){ |
| var colorMap = []; |
| var i; |
| var hex; |
| for(i=0;i<256;i+=1){ |
| hex = i.toString(16); |
| colorMap[i] = hex.length == 1 ? '0' + hex : hex; |
| } |
| |
| return function(r, g, b) { |
| if(r<0){ |
| r = 0; |
| } |
| if(g<0){ |
| g = 0; |
| } |
| if(b<0){ |
| b = 0; |
| } |
| return '#' + colorMap[r] + colorMap[g] + colorMap[b]; |
| }; |
| }()); |
| |
| function fillToRgba(hex,alpha){ |
| if(!cachedColors[hex]){ |
| var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); |
| cachedColors[hex] = parseInt(result[1], 16)+','+parseInt(result[2], 16)+','+parseInt(result[3], 16); |
| } |
| return 'rgba('+cachedColors[hex]+','+alpha+')'; |
| } |
| |
| var fillColorToString = (function(){ |
| |
| var colorMap = []; |
| return function(colorArr,alpha){ |
| if(alpha !== undefined){ |
| colorArr[3] = alpha; |
| } |
| if(!colorMap[colorArr[0]]){ |
| colorMap[colorArr[0]] = {}; |
| } |
| if(!colorMap[colorArr[0]][colorArr[1]]){ |
| colorMap[colorArr[0]][colorArr[1]] = {}; |
| } |
| if(!colorMap[colorArr[0]][colorArr[1]][colorArr[2]]){ |
| colorMap[colorArr[0]][colorArr[1]][colorArr[2]] = {}; |
| } |
| if(!colorMap[colorArr[0]][colorArr[1]][colorArr[2]][colorArr[3]]){ |
| colorMap[colorArr[0]][colorArr[1]][colorArr[2]][colorArr[3]] = 'rgba(' + colorArr.join(',')+')'; |
| } |
| return colorMap[colorArr[0]][colorArr[1]][colorArr[2]][colorArr[3]]; |
| }; |
| }()); |
| |
| function RenderedFrame(tr,o) { |
| this.tr = tr; |
| this.o = o; |
| } |