📄 common.js
字号:
///////////////////////////////////////////////
// Author:daong | E-mail: dahongy@gmail.com
// Copyright © Http://stcms.vicp.net
// $Id: 09-03-23 final version $
///////////////////////////////////////////////
$(function(){
$(".specialBox").mouseover(
function(){$(this).css("background","#e6f0ff")});
$(".specialBox").mouseout(
function(){$(this).css("background","#FFF")});
$("#musicList tr").mouseover(
function(){$(this).css({background:"#e6f0ff"})});
$("#musicList tr").mouseout(
function(){$(this).css({background:""})});
$(".musicList li").mouseover(
function(){$(this).css({background:"#e6f0ff"})});
$(".musicList li").mouseout(
function(){$(this).css({background:"#FFF",listStyleImage:""})});
$("#webMenu li").mouseover(
function(){$(this).css({background:"#e6f0ff",color:"#003300"})});
$("#webMenu li").mouseout(
function(){$(this).css({background:"",color:""})});
$("a,img").mouseover(
function(){window.status=this.title? this.title : "欢迎访问!";return true});
$("a,img").mouseout(
function(){window.status='欢迎访问!'});
});
function setHomepage()
{
url = location.href;
if (document.all)
{
document.body.style.behavior='url(#default#homepage)';
document.body.setHomePage(url);
}
else if (window.sidebar)
{
if(window.netscape)
{
try
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
}
catch (e)
{
alert( "该操作被浏览器拒绝,如果想启用该功能,请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为true" );
}
}
var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
prefs.setCharPref('browser.startup.homepage',url);
}
}
function addFavourite(name)
{
url = location.href;
if (document.all)
{
window.external.addFavorite(url,name);
}
else if (window.sidebar)
{
window.sidebar.addPanel(name, url, "");
}
}
function showDialog(str,width,height,isClose,time)
{
var msgw,msgh,bordercolor,titleMsg;
titleMsg = "提示信息";
time = time ? time : 3000;
msgw = width ? width : 600; //提示窗口的宽度
msgh = height ? height : 75; //提示窗口的高度
titleheight=20; //提示窗口标题高度
bordercolor="#6692cb"; //提示窗口的边框颜色
titlecolor="#99CCFF"; //提示窗口的标题颜色
var sWidth,sHeight;
sWidth=document.body.offsetWidth; //浏览器工作区域内页面宽度
sHeight=screen.height; //屏幕高度(垂直分辨率)
var bgObj=document.createElement("div");//创建一个div对象(背景层)
bgObj.setAttribute("id","bgDiv");
bgObj.style.position="absolute";
bgObj.style.top="0px";
bgObj.style.background="#FFFFFF";
bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
bgObj.style.opacity="0.6";
bgObj.style.left="0";
bgObj.style.width=sWidth + "px";
bgObj.style.height=sHeight+document.documentElement.scrollTop+ "px";
bgObj.style.zIndex = "10000";
document.body.appendChild(bgObj);//在body内添加该div对象
var msgObj=document.createElement("div")//创建一个div对象(提示框层)
msgObj.setAttribute("id","msgDiv");
msgObj.setAttribute("align","center");
msgObj.style.background="white";
msgObj.style.border="1px solid " + bordercolor;
msgObj.style.position = "absolute";
msgObj.style.left = (sWidth-msgw)/2+230;
msgObj.style.top = (sHeight-msgh)/2-50;
msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
msgObj.style.marginLeft = "-225px" ;
msgObj.style.marginTop = -75+document.documentElement.scrollTop+"px";
msgObj.style.width = msgw + "px";
msgObj.style.height = msgh + "px";
msgObj.style.textAlign = "center";
msgObj.style.lineHeight = "25px";
msgObj.style.zIndex = "10001";
var title=document.createElement("div");//创建一个h4对象(提示框标题栏)
title.setAttribute("id","msgTitle");
title.setAttribute("align","left");
title.style.margin="0";
title.style.padding="3px";
title.style.background=bordercolor;
//title.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);";
title.style.opacity="0.75";
title.style.border="1px solid " + bordercolor;
title.style.height="12px";
title.style.font="12px Verdana, Geneva, Arial, Helvetica, sans-serif";
title.style.color="white";
title.style.cursor="pointer";
title.innerHTML=titleMsg;
title.onclick=removeObj;
var button=document.createElement("input");//创建一个input对象(提示框按钮)
button.setAttribute("type","button");
button.setAttribute("value","关闭");
button.style.width = "60px";
button.style.align = "center";
button.style.marginLeft = "250px";
button.style.marginBottom = "10px";
button.style.background = bordercolor;
button.style.border="1px solid " + bordercolor;
button.style.color="white";
button.onclick=removeObj;
function removeObj(){//点击标题栏触发的事件
document.body.removeChild(bgObj);//删除背景层Div
document.getElementById("msgDiv").removeChild(title);//删除提示框的标题栏
document.body.removeChild(msgObj);//删除提示框层
}
document.body.appendChild(msgObj);//在body内添加提示框div对象msgObj
document.getElementById("msgDiv").appendChild(title);//在提示框div中添加标题栏对象title
var txt=document.createElement("div");//创建一个p对象(提示框提示信息)
txt.setAttribute("id","msgTxt");
txt.style.margin="0";
txt.style.height = msgh-35+"px";
txt.style.color="red";
txt.style.fontSize = "16px";
txt.style.padding="3px";
txt.innerHTML=str;//来源于函数调用时的参数值
document.getElementById("msgDiv").appendChild(txt);//在提示框div中添加提示信息对象txt
document.getElementById("msgDiv").appendChild(button);//在提示框div中添加按钮对象button
if(isClose){
setTimeout(function(){removeObj();},time)
}
button.focus();
}
function del(url,id)
{
if(confirm("删除后将无法恢复数据,是否真的要删除?"))
{
location.href = url + "?action=del&id=" + id;
}
}
function edit(sUrl,sId)
{
location.href = sUrl + "?action=edit&id=" + sId;
}
function checkAll(id)
{
$("#"+id+" input[type=checkbox]").each(function(){$(this).attr("checked",true);});
}
function cancleAll(id)
{
$("#"+id+" input[type=checkbox]").each(function(){$(this).attr("checked",false);});
}
function delAll(id,url)
{
var ids = "";
$("#"+id+" input[type=checkbox][checked]").each(function(){ids = ids + $(this).val() + ",";});
if(!ids)
{showDialog("请选择列表!",'400','50',true,1000);return false;}
else
{
if(confirm("删除后将无法恢复数据,是否真的要删除?"))
{
location.href = url + "?action=del&id=" + ids;
}
}
}
function cancle()
{
history.back();
}
function getCommentPage(page,type,typeid)
{
$.ajax({
url:"ajax.php?action=getComment&type="+type+"&typeid="+typeid+"&page="+page,
type:"POST",
beforeSend:function(){$("#comment_div").html("<img src='images/loading.gif' />")},
success:function (data){handComment(data);}
});
}
function handComment(data)
{
arr = eval("("+data+")");
document.getElementById("pageCode").innerHTML=arr[1];
list = arr[0];
var html="";
if(!list){showDialog("没有任何评论!");return false;}
for(i=0;i<list.length;i++){
html = html + '<div class="commentTitle">Guest:'+list[i]['guest']+' E-mail:<a href="mailto:'+list[i]['mail']+'" title="'+list[i]['mail']+'">'+list[i]['mail']+'</a> QQ:'+list[i]['qq']+' <span title="'+list[i]['from']+'">From:'+list[i]['from']+'</span></div><div class="content">'+list[i]['content'];
if(list[i]['reply'])
{
html = html + '<div class="box"><b>回复:</b>'+ list[i]['reply'] +'</div>';
}
html = html +'<br><br><br><div class="box">IP:'+list[i]['ip']+' Time:'+list[i]['time']+'</div></div>';
}
document.getElementById("commentList").innerHTML=html;
}
function comment(type,typeid)
{
$("#addComment").ajaxSubmit({
url:"ajax.php?action=addComment&type="+type+"&typeid="+typeid,
data:$("#addCommnet").formSerialize(),
success:function (data){
var info = eval("("+data+")");
showDialog(info['msg']);
if(info['reload']== "1"){
if(info['url'])
{
location.href = info['url'];
}
else
{
location.reload();
}
}
}
});
}
function listenAll(id)
{
var ids = "";
$("#"+id+" input[type=checkbox][checked]").each(function(){ids = ids + $(this).val() + ",";});
if(!ids)
{showDialog("请选择列表!",'400','50',true,1000);return false;}
else
{
window.open("player.php?id="+ids,"听音乐");
}
}
function $$(id){return document.getElementById(id)}
function login(form,url)
{
$("#"+form).ajaxSubmit({
url:url,
data:$("#"+form).formSerialize(),
success:function(data){
info = eval("("+data+")");
if(info['type']=="n")
{
showDialog(info['msg']) ;
}
else if(info['type']=="y")
{
showDialog(info['msg']);
}
else
{
alert(info['msg']);
}
if(info['url']) location.href=info['url'];
}
});
}
function download(id)
{
if(id){
$.ajax({
url:"download.php?id="+id,
success:function(data){info = eval("("+data+")");if(info['msg']){showDialog(info['msg']); setTimeout(function(){location.href=info['url']},3000);}else{location.href = info['url']}}
});
}
else
{
showDialog("参数错误!");
}
}
function reportError(id)
{
if(id)
{
$.ajax({
url:"ajax.php?action=reportError&id="+id,
type:"POST",
success:function(data){showDialog(data)}
})
}
else
{
showDialog("参数错误!")
}
}
function recommend(id)
{
if(id)
{
$.ajax({
url:"ajax.php?action=recommend&id="+id,
type:"POST",
success:function(data){showDialog(data)}
})
}
else
{
showDialog("参数错误!")
}
}
function selectAdminType()
{
var type = $$("admin_group").value;
if(type == "categoryAdmin")
{
$.ajax({
url:"ajax.php?action=getCategory",
type:"POST",
success:function(data){$$("categorySelect").innerHTML = data}
});
}
else
{
$$("categorySelect").innerHTML="";
}
}
function tblStruct(table)
{
$.ajax({
url:"data.php?action=tblStruct&table="+table,
success:function(data){$$("result").innerHTML = "<pre>"+data+"</pre>";}
});
}
function backUp(table)
{
url="data.php?action=backup&table="+table;
location.href=url;
}
function truncate(table)
{
if(confirm("数据将无法恢复,你真的要清空吗?"))
{
url="data.php?action=truncate&table="+table;
location.href=url;
}
}
function delBackUp(id)
{
if(confirm("你真的要删该除备份吗?"))
{
url="data.php?action=delbackup&id="+id;
location.href=url;
}
}
function backUpAll()
{
location.href = "data.php?action=backup&table=allTable";
}
function delBackUpAll(id)
{
var ids = "";
$("#"+id+" input[type=checkbox][checked]").each(function(){ids = ids + $(this).val() + ",";});
if(!ids)
{showDialog("请选择列表!",'400','50',true,1000);return false;}
else
{
if(confirm("删除后将无法恢复数据,是否真的要删除?"))
{
location.href = "data.php?action=delbackup&id=" + ids;
}
}
}
function repair()
{
location.href="data.php?action=repair";
}
function optimize()
{
location.href="data.php?action=optimize";
}
function alter()
{
location.href="data.php?action=alter";
}
function recover(id)
{
if(confirm("还原后数据将改变,你真的要还原该次备份吗?"))
{
location.href="data.php?action=recover&from=file&id="+id;
}
}
function showDiv(id)
{
var styleDis = $$(id).style.display;
$$(id).style.display = styleDis != "none" ? "none" : "block";
}
function mRegister(url)
{
if($$('name').value==""){showDialog('会员名不能为空!');return false;}
if($$('pwd1').value==""){showDialog('密码不能为空!'); return false;}
if($$('pwd2').value==""){showDialog('密码不能为空!'); return false;}
if($$('pwdquestion').value==""){showDialog("密码提示问题不能为空!");return false;}
if($$('pwdanswer').value==""){showDialog("密码提示问题答案不能为空!");return false;}
$.ajax({
url:"?action=registered&url="+url,
data:$('#registerForm').formSerialize(),
type:"POST",
success:function(data){data = eval("("+data+")");data['msg'] && showDialog(data['msg']); data['url'] && setTimeout(function(){location.href=data['url']},2000)}
});
}
function mLogin(url)
{
if($$('name').value==""){showDialog('会员名不能为空!');return false;}
if($$('pwd').value==""){showDialog('密码不能为空!'); return false;}
$.ajax({
url:"?action=logined&url="+url,
data:$('#mLoginForm').formSerialize(),
type:"POST",
success:function(data){data = eval("("+data+")");data['msg'] && showDialog(data['msg']); data['url'] && setTimeout(function(){location.href=data['url']},2000)}
});
}
function inputMedia(path,type)
{
if(confirm("真的要录入该文件或文件夹下的音乐文件吗?")){
location.href="input.php?action=input&path="+path+"&type="+type;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -