创建JFAST对象并赋值给JF对象,后面调用框架就可以直接调用JF对象了,这样有助于减少代码量
var JF = JFAST = (function() {
var jFastObj = {};
var logs = [];
jFastObj.inc = function(d, c) {
return true
};
//给jFastObj在某命名空间下添加方法
jFastObj.register = function(e, c) {
var g = e.split(".");
var f = jFastObj;
var d = null;
while (d = g.shift()) {
if (g.length) {
if (f[d] === undefined) {
f[d] = {}
}
f = f[d]
} else {
if (f[d] === undefined) {
try {
f[d] = c(jFastObj)
} catch(h) {
b.push(h)
}
}
}
}
};
jFastObj.regShort = function(c, d) {
if (jFastObj[c] !== undefined) {
throw "[" + c + "] : short : has been register"
}
jFastObj[c] = d
};
//判断是否是IE浏览器
jFastObj.IE = /msie/i.test(navigator.userAgent);
//根据ID字符找到对应的DOM
jFastObj.E = function(c) {
if (typeof c === "string") {
return document.getElementById(c)
} else {
return c
}
};
//创建DOM
jFastObj.C = function(c) {
var d;
c = c.toUpperCase();
if (c == "TEXT") {
d = document.createTextNode("")
} else {
if (c == "BUFFER") {
d = document.createDocumentFragment()
} else {
d = document.createElement(c)
}
}
return d
};
jFastObj.log = function(msg) {
logs.push("[" + ((new Date()).getTime() % 100000) + "]: " + msg)
};
jFastObj.getErrorLogInforList = function(maxLenth) {
return logs.splice(0, maxLenth || logs.length)
};
return jFastObj
})();
如果本篇文章帮到了你,那么,请点击右侧的百度分享,让我们一起帮助更多的朋友!