blob: 5484b53cbc68d6903bacb6fa6027246812786bc2 [file] [log] [blame]
var subframeEnabled = false;
var supportsPath2D = typeof Path2D === 'function';
var cachedColors = {};
var body;
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 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;
}
function rgbToHex(r, g, b) {
return '#' + componentToHex(r) + componentToHex(g) + componentToHex(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+')';
}