1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
// 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);
};
})();
function text_off(){
setTextEnable.call( $("#textbutton input").attr("checked",false) )
}
|