console.js
来自「基于struts的网上商店源码」· JavaScript 代码 · 共 192 行
JS
192 行
var currentItem=document.getElementById("console_item_1");
var currentTable=document.getElementById("console_table_1");
var msgconsole=document.getElementById("messageConsole");
var lgconsole = document.getElementById("LoginConsole")
var console=document.getElementById("StyleConsole");
var consolebg=document.getElementById("StyleConsoleBg");
document.getElementById("title").style.left=document.getElementById("title").offsetLeft+document.getElementById("main_table").offsetLeft;
document.getElementById("subtitle").style.left=document.getElementById("subtitle").offsetLeft+document.getElementById("main_table").offsetLeft
//接受键盘Enter事件
function enter(evt){
evt=evt?evt:window.event;
if(13==evt.keyCode){
login();
}
}
//调整IFrame大小
function frameResize(){
if (mainFrameName.document.body!=null) document.getElementById("mainFrame").style.height=mainFrameName.document.body.scrollHeight;
if (document.mainFrameName.frameResize!=undefined) document.mainFrameName.frameResize();
}
//显示消息层
function showMessage() {
consolebg.style.width=document.body.scrollWidth;
consolebg.style.height=document.body.scrollHeight;
consolebg.style.display="block";
msgconsole.style.left=document.body.scrollWidth/2-320;
msgconsole.style.display="block";
}
//显示登陆层
function showLogin() {
consolebg.style.width=document.body.scrollWidth;
consolebg.style.height=document.body.scrollHeight;
consolebg.style.display="block";
lgconsole.style.left=document.body.scrollWidth/2-240;
lgconsole.style.top=document.body.clientHeight/2-150;
lgconsole.style.display="block";
}
//显示控制台
function showConsole() {
consolebg.style.width=document.body.scrollWidth;
consolebg.style.height=document.body.scrollHeight;
consolebg.style.display="block";
console.style.left=document.body.scrollWidth/2-320;
console.style.display="block";
switchItem(currentItem);
}
//隐藏消息层
function hideMessage() {
msgconsole.style.display="none";
consolebg.style.display="none";
}
//隐藏登陆层
function hideLogin() {
lgconsole.style.display="none";
consolebg.style.display="none";
}
//隐藏控制台
function hideConsole() {
console.style.display="none";
consolebg.style.display="none";
}
//切换Tab标签面板
function switchItem(consoleItem) {
var n=consoleItem.id.substring(consoleItem.id.length-1,consoleItem.id.length);
if (currentItem.id!="console_item_1") {
currentItem.className="style_console_tab";
} else {
currentItem.className="style_console_tab_first";
}
if (consoleItem.id!="console_item_1") {
consoleItem.className="style_console_tab_selected";
} else {
consoleItem.className="style_console_tab_first_selected";
}
currentItem=consoleItem;
switchTable(document.getElementById("console_table_"+n));
}
//切换表格
function switchTable(consoleTable) {
currentTable.style.display="none";
consoleTable.style.display="block";
currentTable=consoleTable;
}
//更改主题风格
function changeStyle(dir) {
document.getElementById("style_link").href=dir+"/style.css";
if (document.mainFrameName!=null) {
document.mainFrameName.document.getElementById("style_link").href=dir+"/style.css";
if (document.mainFrameName.layoutDiv!=undefined) document.mainFrameName.layoutDiv();
if (document.mainFrameName.document.detailFrameName!=null) {
document.mainFrameName.document.detailFrameName.document.getElementById("style_link").href=dir+"/style.css";
}
}
}
//Ajax通讯模块
function ajaxCommunication(url,args,func) {
var xmlhttp;
try {
xmlhttp=new ActiveXObject('Msxml2.XMLHTTP');
} catch (e) {
try {
xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
} catch (e) {
try {
xmlhttp=new XMLHttpRequest();
} catch (e) {}
}
}
xmlhttp.open("POST",url,true);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {
if (xmlhttp.status==200) {
func(xmlhttp.responseText);
} else {
alert("ç½ç»å¼å¸¸: "+xmlhttp.status);
}
}
}
xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlhttp.send(args);
}
//更新主题风格
function updateStyle() {
var userID=document.getElementById("userID").value;
var style=document.getElementById("style_link").href.split('/')[1];
var url="servlet/updateStyle";
var args="action=1&cid="+userID+"&style="+style;
ajaxCommunication(url,args,reloadPage);
}
//更新主题名称
function updateTheme() {
document.getElementById("title").innerText=document.getElementById("titleInput").value;
document.getElementById("subtitle").innerText=document.getElementById("subTitleInput").value;
var url="servlet/updateStyle";
var args="action=2&cid="+document.getElementById("userID").value+"&title="+document.getElementById("titleInput").value+"&subtitle="+document.getElementById("subTitleInput").value;
ajaxCommunication(url,args,hideConsole);
}
//重新加载页面
function reloadPage() {
var end=document.location.href.indexOf("?style=");
end=(end==0?document.location.href.length:end);
document.location.replace(document.location.href.substring(0,end)+"?style="+document.getElementById("style_link").href.split('/')[1]);
}
//登陆动作
function login() {
var name=document.getElementById("UserName").value;
var pass0=document.getElementById("UserPassOri").value;
var pass=document.getElementById("UserPass").value;
pass=hex_md5(pass0).toUpperCase();
var url="servlet/checkWork";
var args="action=login&name="+name+"&pass="+pass+"&role=0";
ajaxCommunication(url,args,refreshLogin);
}
//刷新登陆层
function refreshLogin(message) {
var tip = document.getElementById("loginTip");
if (message=="0") {
tip.style.color="#999999";
tip.innerText="登陆成功!";
document.location.replace(document.location.href);
} else if (message=="-1") {
tip.style.color="red";
tip.innerText="您输入的用户名不存在!";
document.getElementById("UserName").focus();
} else if (message=="-2") {
tip.style.color="red";
tip.innerText="您输入的密码不正确!";
document.getElementById("UserPassOri").focus();
}
}
//重新登陆
function resetLogin() {
document.getElementById("UserName").value="";
document.getElementById("UserPass").value="";
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?