📄 common.js
字号:
function setOkMsg(element,msg){
msg="<p class='OkMsg'>"+msg+"</p>";
document.getElementById(element).innerHTML=msg;
}
function setWarningMsg(element,msg){
msg="<p class='WarningMsg'>"+msg+"</p>";
document.getElementById(element).innerHTML=msg;
}
function setErrorMsg(element,msg){
msg="<p class='ErrorMsg'>"+msg+"</p>";
document.getElementById(element).innerHTML=msg;
}
//格式化日期
Date.prototype.format = function(format)
{
var o = {
"M+" : this.getMonth()+1, //month
"d+" : this.getDate(), //day
"h+" : this.getHours(), //hour
"m+" : this.getMinutes(), //minute
"s+" : this.getSeconds(), //second
"q+" : Math.floor((this.getMonth()+3)/3), //quarter
"S" : this.getMilliseconds() //millisecond
}
if(/(y+)/.test(format)) format=format.replace(RegExp.$1,
(this.getFullYear()+"").substr(4 - RegExp.$1.length));
for(var k in o)if(new RegExp("("+ k +")").test(format))
format = format.replace(RegExp.$1,
RegExp.$1.length==1 ? o[k] :
("00"+ o[k]).substr((""+ o[k]).length));
return format;
}
//load bar functions
function loadBar(fl)
//fl is show/hide flag
{
var x,y;
if (self.innerHeight)
{// all except Explorer
x = self.innerWidth;
y = self.innerHeight;
}
else
if (document.documentElement && document.documentElement.clientHeight)
{// Explorer 6 Strict Mode
x = document.documentElement.clientWidth;
y = document.documentElement.clientHeight;
}
else
if (document.body)
{// other Explorers
x = document.body.clientWidth;
y = document.body.clientHeight;
}
var el=document.getElementById('loader');
if(null!=el)
{
var top = (y/2) - 50;
var left = (x/2) - 150;
if( left<=0 ) left = 10;
el.style.visibility = (fl==1)?'visible':'hidden';
el.style.display = (fl==1)?'block':'none';
el.style.left = left + "px"
el.style.top = top + "px";
el.style.zIndex = 2;
}
}
//ajax functions
function getDomDocumentPrefix() {
if (getDomDocumentPrefix.prefix)
return getDomDocumentPrefix.prefix;
var prefixes = ["MSXML2", "Microsoft", "MSXML", "MSXML3"];
var o;
for (var i = 0; i < prefixes.length; i++) {
try {
// try to create the objects
o = new ActiveXObject(prefixes[i] + ".DomDocument");
return getDomDocumentPrefix.prefix = prefixes[i];
}
catch (ex) {};
}
throw new Error("Could not find an installed XML parser");
}
function getXmlHttpPrefix() {
if (getXmlHttpPrefix.prefix)
return getXmlHttpPrefix.prefix;
var prefixes = ["MSXML2", "Microsoft", "MSXML", "MSXML3"];
var o;
for (var i = 0; i < prefixes.length; i++) {
try {
// try to create the objects
o = new ActiveXObject(prefixes[i] + ".XmlHttp");
return getXmlHttpPrefix.prefix = prefixes[i];
}
catch (ex) {};
}
throw new Error("Could not find an installed XML parser");
}
//////////////////////////
// Start the Real stuff //
//////////////////////////
// XmlHttp factory
function XmlHttp() {}
XmlHttp.create = function () {
try {
if (window.XMLHttpRequest) {
var req = new XMLHttpRequest();
// some versions of Moz do not support the readyState property
// and the onreadystate event so we patch it!
if (req.readyState == null) {
req.readyState = 1;
req.addEventListener("load", function () {
req.readyState = 4;
if (typeof req.onreadystatechange == "function")
req.onreadystatechange();
}, false);
}
return req;
}
if (window.ActiveXObject) {
return new ActiveXObject(getXmlHttpPrefix() + ".XmlHttp");
}
}
catch (ex) {}
// fell through
throw new Error("Your browser does not support XmlHttp objects");
};
// XmlDocument factory
function XmlDocument() {}
XmlDocument.create = function () {
try {
// DOM2
if (document.implementation && document.implementation.createDocument) {
var doc = document.implementation.createDocument("", "", null);
// some versions of Moz do not support the readyState property
// and the onreadystate event so we patch it!
if (doc.readyState == null) {
doc.readyState = 1;
doc.addEventListener("load", function () {
doc.readyState = 4;
if (typeof doc.onreadystatechange == "function")
doc.onreadystatechange();
}, false);
}
return doc;
}
if (window.ActiveXObject)
return new ActiveXObject(getDomDocumentPrefix() + ".DomDocument");
}
catch (ex) {}
throw new Error("Your browser does not support XmlDocument objects");
};
// Create the loadXML method and xml getter for Mozilla
if (window.DOMParser &&
window.XMLSerializer &&
window.Node && Node.prototype && Node.prototype.__defineGetter__) {
// XMLDocument did not extend the Document interface in some versions
// of Mozilla. Extend both!
XMLDocument.prototype.loadXML =
Document.prototype.loadXML = function (s) {
// parse the string to a new doc
var doc2 = (new DOMParser()).parseFromString(s, "text/xml");
// remove all initial children
while (this.hasChildNodes())
this.removeChild(this.lastChild);
// insert and import nodes
for (var i = 0; i < doc2.childNodes.length; i++) {
this.appendChild(this.importNode(doc2.childNodes[i], true));
}
};
/*
* xml getter
*
* This serializes the DOM tree to an XML String
*
* Usage: var sXml = oNode.xml
*
*/
// XMLDocument did not extend the Document interface in some versions
// of Mozilla. Extend both!
XMLDocument.prototype.__defineGetter__("xml", function () {
return (new XMLSerializer()).serializeToString(this);
});
Document.prototype.__defineGetter__("xml", function () {
return (new XMLSerializer()).serializeToString(this);
});
}
//added by sogui
function ScoolImageIMS(){}
ScoolImageIMS.postData=function(postAction,param){
try{
loadBar(1);
var xmlHttp = XmlHttp.create();
xmlHttp.open("POST",postAction,true);
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlHttp.onreadystatechange = function () {//start function
if(xmlHttp.readyState ==4 && xmlHttp.status==200){
var result=xmlHttp.responseText;
document.body.innerHTML=result;
}
};//end function
xmlHttp.setRequestHeader("If-Modified-Since","0");//LJN07-12-22修改
xmlHttp.send(param);
}catch(ex){
setErrorMsg("msg","æä½å¤±è´¥ï¼è¯·éè¯ä¸æ¬¡ï¼");
alert(ex);
}finally{
window.setTimeout("loadBar(0)",3000);
}
};
ScoolImageIMS.getData=function(requestUrl){
try{
loadBar(1);
var xmlHttp = XmlHttp.create();
xmlHttp.open("GET",requestUrl,true);
xmlHttp.onreadystatechange = function() {//start function
if(xmlHttp.readyState ==4 && xmlHttp.status==200){
var result=xmlHttp.responseText;
document.body.innerHTML=result;
}
};//end function
xmlHttp.setRequestHeader("If-Modified-Since","0");//LJN07-12-22修改
xmlHttp.send(null);
}catch(ex){
setErrorMsg("msg","æä½å¤±è´¥ï¼è¯·éè¯ä¸æ¬¡ï¼");
alert(ex);
}finally{
window.setTimeout("loadBar(0)",3000);
}
};
//dwr
ScoolImageIMS.objectEval=function(text){
// eval() breaks when we use it to get an object using the { a:42, b:'x' }
// syntax because it thinks that { and } surround a block and not an object
// So we wrap it in an array and extract the first element to get around
// this.
// The regex = [start of line][whitespace]{[stuff]}[whitespace][end of line]
text = text.replace(/\n/g, " ");
text = text.replace(/\r/g, " ");
if (text.match(/^\s*\{.*\}\s*$/))
{
text = "[" + text + "][0]";
}
return eval(text);
};
ScoolImageIMS.callOnLoad=function(init){
if (window.addEventListener)
{
window.addEventListener("load", init, false);
}
else if (window.attachEvent)
{
window.attachEvent("onload", init);
}
else
{
window.onload = init;
}
};
//cookie functions
ScoolImageIMS.setCookie=function(name,value,expires,path,domain,secure) {
document.cookie = name + "=" + escape (value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
};
ScoolImageIMS.getCookie=function(name){
var prefix = name + "="
var start = document.cookie.indexOf(prefix)
if (start==-1) {
return null;
}
var end = document.cookie.indexOf(";", start+prefix.length)
if (end==-1) {
end=document.cookie.length;
}
var value=document.cookie.substring(start+prefix.length, end)
return unescape(value);
};
/* This function is used to delete cookies */
ScoolImageIMS.deleteCookie=function(name,path,domain){
if (this.getCookie(name)) {
document.cookie = name + "=" +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
};
//div page used
function changeValue(element,elementName){
var objects=document.getElementsByName(elementName);
for(var i=0;i<objects.length;i++){
if(element!=objects[i]){objects[i].value=element.value;}
}
}
function goTo(requestUrl){
ScoolImageIMS.getData(requestUrl);
}
function goToSearch(action,queryStr){
var pageSize=document.getElementById('pageSize').value;
var pageNo=document.getElementById('pageNo').value;
var requestUrl=action+"?"+"pageNo="+pageNo+"&pageSize="+pageSize;
if(queryStr!=""){
requestUrl+="&"+queryStr;
}
goTo(requestUrl);
}
//page resize frame
function reSizeFrame(){
y= top.document.body.clientHeight;
y1= top.topFrame.document.body.clientHeight;
document.getElementById("treeViewLeft").height=(y-y1-30);
document.getElementById("treeViewRight").height=(y-y1-30);
}
function reSizeViewFrame(){
y= top.document.body.clientHeight;
y1= top.topFrame.document.body.clientHeight;
document.getElementById("viewFrame").height=(y-y1-30);
}
//switch bar
function switchBar(){
var switchPoint=document.getElementById("switchPoint");
if (switchPoint.innerText==3){
switchPoint.innerText=4;
document.all("treeViewLeft").style.display="none";
}else{
switchPoint.innerText=3;
document.all("treeViewLeft").style.display="";
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -