📄 jspp.js
字号:
window.JavaScriptPlus = new function()
{
this.version = "1.0";
this.JSPP_HOME = "/jspp/";
this.CLASSPATH = this.JSPP_HOME + "classes/";
this.Caption = "WAPmo";
var ua = window.navigator.userAgent;
this.isMO = (/gecko/i.test(ua));
this.isOA = (/opera/i.test(ua));
this.isIE = !this.isOA && (/msie/i.test(ua));
this.ieVersion = this.isIE ? parseInt(ua.match(/msie\s(\d)/i)[1]) : 7;
this.cache = {};
this.window = {};
this.index = 0;
this.count = {};
this.count['win'] = 0;
this.count['tray'] = 0;
this.Home = "./";
if (this.isIE)
{
var vector = document.firstChild;
try
{
vector.addBehavior("#default#userdata");
}
catch(ex)
{
}
}
this.getClassName = function(cls)
{
return("jspp_class_" + cls.replace(/\./g, "_"));
};
this.getClassFile = function(cls)
{
return(this.CLASSPATH + cls.replace(/\./g, "/") + ".js?pid=" + Math.floor(Math.random() * 9999));
};
this.getCacheName = function(cls)
{
return("jspp_cache_" + cls.replace(/\./g, "_"));
};
this.getLastModified = function(cls)
{
var _rpc = new XMLHttpRequest();
var _ret = new Date();
_rpc.open("HEAD", this.getClassFile(cls), false);
_rpc.send(null);
if (_rpc.readyState == 4 && _rpc.status == 200)
{
_ret = new Date(_rpc.getResponseHeader("LAST-MODIFIED"));
}
_rpc = null;
return(_ret.getTime());
};
this.getClass = function(cls)
{
var name = this.getCacheName(cls);
var _ret = this.cache[name];
if (_ret == null || _ret == "" && this.isIE)
{
try
{
vector.load(name);
if (this.getLastModified(cls) == vector.getAttribute("expires"))
{
_ret = this.cache[name] = vector.getAttribute("source");
}
}
catch(ex)
{
}
}
if (_ret == null || _ret == "")
{
_ret = this.loadClass(cls);
}
return(_ret);
};
this.setClass = function(cls, val, exp)
{
var name = this.getCacheName(cls);
this.cache[name] = val;
if (this.isIE)
{
try
{
var dtmPtr = new Date(exp);
vector.load(name);
vector.setAttribute("source", val);
vector.setAttribute("expires", dtmPtr.getTime());
vector.save(name);
}
catch(ex)
{
}
}
};
this.loadClass = function(cls)
{
var _rpc = new XMLHttpRequest();
var _ret = null;
var _exp = null;
_rpc.open("GET", this.getClassFile(cls), false);
_rpc.send(null);
if (_rpc.readyState == 4 && _rpc.status == 200)
{
_ret = _rpc.responseText;
_exp = _rpc.getResponseHeader("LAST-MODIFIED");
}
_rpc = null;
this.setClass(cls, _ret, _exp);
return(_ret);
};
this.using = function(cls)
{
try
{
var _ret = this.getClass(cls);
var _api = cls.match("\\.([^\\.]+)$")[1];
this.package(cls.substring(0, cls.lastIndexOf(".")));
eval(_ret);
eval("JavaScriptPlus." + cls + " = " + _api);
}
catch(ex)
{
alert("using(" + cls + ") failed: " + ex.description);
}
};
this.package = function(cls)
{
var _list = cls.split(/\./g);
var _ptr = new Array();
for (var i = 0; i < _list.length; i++)
{
if (i == 0)
{
JavaScriptPlus.namespace(_list[i]);
}
else
{
eval("JavaScriptPlus." + _ptr.join(".") + ".namespace(\"" + _list[i] + "\");");
}
_ptr.push(_list[i]);
}
};
};
loadModule = JavaScriptPlus.loadModule = function(mo)
{
var jspp = JavaScriptPlus;
document.write("<script language=\"javascript\" src=\"" + jspp.JSPP_HOME + "bin/" + mo + ".js\"></script>");
};
JavaScriptPlus.Initialize = function()
{
loadModule("application");
if (this.isIE)
{
loadModule("ie");
}
else if (this.isMO)
{
loadModule("moz");
}
else if (this.isOA)
{
loadModule("opera");
}
loadModule("share");
loadModule("mocom");
};
JavaScriptPlus.QueryString = function(name)
{
var arr = location.href.match(new RegExp("[\?&]" + name + "=([^&]*)", ""));
if (arr) return arr[1];
return "";
};
JavaScriptPlus.Initialize();
var jspp = JavaScriptPlus;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -