📄 index.js
字号:
function trim(str)
{
var t = str.replace(/(^\s*)|(\s*$)/g, ""); // 用正则表达式将前后空格
return t.replace(/(^ *)|( *$)/g, ""); // 用空字符串替代。
}
var xmlHttp;
var count=0;
var pagecount;
var page=0;
var shang="";
var xia="";
var liebiao="";
var pageshow=5;
var strings="all";
function changeshu()
{
var shu=document.getElementById("shuzi").value;
if(shu==null||shu=="") pageshow=3;
else pageshow=shu;
callback();
}
function q(str)
{
strings=str;
document.title=str;
create();
}
function reloads()
{
strings="all";
document.title="主页";
create();
}
function del(id,a,b)
{
var word="你确定删除["+b+"]的["+a+"]吗?";
if(confirm(word)==1)
{
createA();
var url="del.jsp";
var strs="id="+id+"";
xmlHttp.open("GET",url,true);
xmlHttp.onreadystatechange=callback2;
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlHttp.send(strs);
}
else
{}
}
function callback2()
{
if(xmlHttp.readyState==2){document.getElementById("show2").innerHTML="处理中……";}
else if(xmlHttp.readyState==4)
{
var s=xmlHttp.responseText;
if(trim(s)==1)
{
alert("删除成功");create();document.getElementById("show2").innerHTML="";
}
else if(trim(s)==0)
{
alert("出现异常!");create();document.getElementById("show2").innerHTML="";
}
}
}
function createA()
{
if(window.ActiveXObject){
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest){
xmlHttp=new XMLHttpRequest();
}
}
function create()
{
createA();
var url="ajax_index.jsp";
var strs="q="+strings+"";
xmlHttp.open("GET",url,true);
xmlHttp.onreadystatechange=callback;
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlHttp.send(strs);
if(strings=="all"){document.getElementById("rel").style.display="none";}
else{document.getElementById("rel").style.display="";}
}
function callback(n){
if(n==null||n=="")
{
page=0;
}
else
{
page=n;
}
if(xmlHttp.readyState==2){document.getElementById("show").innerHTML="数据加载中……";}
else if(xmlHttp.readyState==4)
{
//document.getElementById("show").style.display="none";
//document.getElementById("show").innerHTML="加载完成";
var xmldoc=xmlHttp.responseXML;
count=xmldoc.documentElement.childNodes.length;
pagecount= Math.ceil(count/pageshow);
var HTMLCode="<table Border='0' align='center' class='table' width='500'><tr class='1'><th>图片</th><th>歌曲</th><th>歌手</th><th>播放</th><th>删除</th></tr>";
if (!page) page=0;
i=page*pageshow;
endNum=(page+1)*pageshow;
if (endNum>count) endNum=count;
for(;i<endNum;i++)
{var img="";
if(xmldoc.documentElement.childNodes(i).childNodes(4).text==1) img="play.gif";
else img="video.gif";
var pic="";
if(xmldoc.documentElement.childNodes(i).childNodes(1).text==""||xmldoc.documentElement.childNodes(i).childNodes(1).text==null||xmldoc.documentElement.childNodes(i).childNodes(1).text=="null") {pic="bg.jpg";}
else {pic=xmldoc.documentElement.childNodes(i).childNodes(1).text;}
HTMLCode+="<tr class='3'><td align='center'><img src='img/"+pic+"'height='71' width='91'></td><td align='center'><a href='javascript:fgo()' onclick='q(\""+xmldoc.documentElement.childNodes(i).childNodes(2).text+"\")'>"+xmldoc.documentElement.childNodes(i).childNodes(2).text+"</a></td><td align='center'><a href='javascript:fgo()' onclick='q(\""+xmldoc.documentElement.childNodes(i).childNodes(3).text+"\")'>"+xmldoc.documentElement.childNodes(i).childNodes(3).text+"</a></td><td align='center'><a href='javascript:fgo()' onClick='popen("+xmldoc.documentElement.childNodes(i).childNodes(0).text+")'><img src='"+img+"' height='20' width='20'></a></td><td align='center'><a href='javascript:fgo()' id='"+xmldoc.documentElement.childNodes(i).childNodes(0).text+"' onclick='del("+xmldoc.documentElement.childNodes(i).childNodes(0).text+",\""+xmldoc.documentElement.childNodes(i).childNodes(2).text+"\",\""+xmldoc.documentElement.childNodes(i).childNodes(3).text+"\")'>删除</a></td></tr>";
//document.getElementById("show").innerText="1";
}
HTMLCode=HTMLCode+"</table>";
document.getElementById("show").innerHTML=HTMLCode;
document.getElementById("gong").innerText=count;
document.getElementById("shu").innerText=pagecount;
document.getElementById("dang").innerText=page+1;
document.getElementById("shuzi").value=pageshow;
}
if(page==0)
{
shang="第一页|上一页";
}
else
{
syy=page-1;
shang="<a href='javascript:fgo()' onclick='callback(0)'>第一页</a>|<a href='javascript:fgo()' onclick='callback("+syy+")'>上一页</a>";
}
document.getElementById("shang").innerHTML=shang;
if(page==pagecount-1)
{
xia="下一页|最后一页";
}
else
{
xyy=page+1;
zh=pagecount-1;
xia="<a href='javascript:fgo()' onclick='callback("+xyy+")'>下一页</a>|<a href='javascript:fgo()' onclick='callback("+zh+")'>最后一页</a>";
}
document.getElementById("xia").innerHTML=xia;
liebiao="<select onchange='callback(this.selectedIndex)' style='z-index:1;'>";
for(i=1;i<=pagecount;i++)
{
if(page+1==i) liebiao+="<option selected='selected'>第"+i+"页</option>";
else liebiao+="<option >第"+i+"页</option>";
}
liebiao=liebiao+"</select>";
document.getElementById("liebiao").innerHTML=liebiao;
}
function popen(id)
{
window.open("play.jsp?id="+id+"","newwindow","height=600,width=650,top=0,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no,screenX=200,screenY=200");
}
function sea()
{
var words=document.getElementById("sea").value;
if(words==null||words==""||words==" ")
{
alert("关键字不能为空!");
document.getElementById("sea").focus();
return false;
}
else
{
q(words);
document.title=words;
}
}
function on_submit()
{
if(form1.music.value=="")
{
document.getElementById("geming").innerHTML="<img src=error.gif height=15 width=15>";
form1.music.focus();
return false;
}
else
{
document.getElementById("geming").innerHTML="<img src=yes.gif height=15 width=15>";
}
if(form1.name.value=="")
{
document.getElementById("geshou").innerHTML="<img src=error.gif height=15 width=15>";
form1.name.focus();
return false;
}
else
{
document.getElementById("geshou").innerHTML="<img src=yes.gif height=15 width=15>";
}
if(form1.music2.value=="")
{
document.getElementById("gequ").innerHTML="<img src=error.gif height=15 width=15>";
form1.music2.focus();
return false;
}
else
{
document.getElementById("gequ").innerHTML="<img src='yes.gif' height=15 width=15>";
}
document.getElementById("shch").disabled=true;
document.getElementById("shch").value="上传中……";
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -