// Utils emptyFunc = function(){}; falseFunc = function(){ return false }; isImgBroken = function(img){ return (img.height == 0 || img.width == 0 || img.height == NaN || img.width == NaN) } isEmptyObject = function(obj) { for (key in obj) { if (obj.hasOwnProperty(key)) return false; } return true } String.prototype.trim = function(){ return this.replace(/^\s+|\s+$/g,'') } function isCSSPropertySupported(prop){ return prop in document.body.style } function track(group, name) { if (typeof pageTracker !== 'undefined') { pageTracker._trackEvent(group, name, typeof Nick !== 'undefined' ? Nick : 'anon'); } } // generate a new CSS rule and apply it immediately // (more persistent than dumping a style tag) window.cssRule = function (selector, declaration) { var x = document.styleSheets,y=x.length-1; x[y].insertRule(selector+"{"+declaration+"}",x[y].cssRules.length); $(selector).css(declaration.split(": ")); }; var Log = { "Levels": ['info', 'warn', 'error'], "AjaxSubmitLevels": ['warn', 'error'], "AjaxSubmitPath": "/logerror", "SupplementalInfo": function() { return { 'user': UserInfo && UserInfo.nick }; }, "ajaxSubmit": function(level, component, msg) { var info = Log.SupplementalInfo(); var data = { 'level': level, 'component': component, 'msg': msg }; $.extend(info, data); $.ajax({type: 'POST', timeout: 5000, url: Log.AjaxSubmitPath, data: info }); }, "initialize": function() { $.each(Log.Levels, function(i, level) { Log[level] = function(component, msg) { if (window.console && window.console[level]) window.console[level](args); if (Log.AjaxSubmitLevels.indexOf(level) != -1) Log.ajaxSubmit(level, args); }; }); } }; Log.initialize(); // Time how long a function takes to complete function timeFunc(f){ var start = new Date().getTime(); var res = f(); // console.log((new Date().getTime()) - start + " msecs"); return res; } window.requestAnimFrame = (function(){ return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function( callback ){ window.setTimeout(callback, 1000 / 60); }; })();