成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

BaiduMusicbox用到的ajax代碼是怎么樣的

這篇文章給大家分享的是有關(guān)Baidu Musicbox用到的ajax代碼是怎么樣的的內(nèi)容。小編覺得挺實用的,因此分享給大家做個參考,一起跟隨小編過來看看吧。

創(chuàng)新互聯(lián)公司專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于網(wǎng)站制作、成都網(wǎng)站設(shè)計、富拉爾基網(wǎng)絡(luò)推廣、成都微信小程序、富拉爾基網(wǎng)絡(luò)營銷、富拉爾基企業(yè)策劃、富拉爾基品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運營等,從售前售中售后,我們都將竭誠為您服務(wù),您的肯定,是我們最大的嘉獎;創(chuàng)新互聯(lián)公司為所有大學生創(chuàng)業(yè)者提供富拉爾基建站搭建服務(wù),24小時服務(wù)熱線:18982081108,官方網(wǎng)址:jinyejixie.com

var names;
var Cs, St;
var rorw="";
var lrcT;

function getname(songname){
    if(songname==""){
        names=$("name").value;
    }else{
        names=songname;
    }
    geturl();
}
function geturl(){
    AJAXCALL("inc/songurl.asp?type=url1&keyword="+names,"musiclist","isXML=true");
    addbox(names);
}
function top(){
    AJAXCALL("inc/songlist.asp?ac=new","toplist","isXML=true");
}
function toplist(doc){
    var items=getElementsByClass(doc,"item");
        var linker=new Array();
        var linkers=new Array();
    var tmp="<ul>";
    for(var i=0;i<items.length;i++){
                if(getTagValue(items[i], "singer")=="")
                {
                  linker[i]="";
                  linkers[i]="";   
                }
                else
                {
                  linker[i]="("+getTagValue(items[i], 'singer').replace(/ /g,"&nbsp;")+")";
                  linkers[i]="&nbsp;"+getTagValue(items[i], 'singer').replace(/ /g,"&nbsp;");
                }
        var d=i+1;
        tmp+='<li>'+d+'. <a href=javascript:getname("'+getTagValue(items[i], 'songname').replace(/ /g,"&nbsp;")+linkers[i]+'") title="'+getTagValue(items[i], 'songname').replace(/ /g,"&nbsp;")+linker[i]+'">'+getTagValue(items[i], 'songname').replace(/ /g,"&nbsp;")+linker[i]+'</a></li>';
    }
    tmp+="</ul>";
    $("toplist").innerHTML=tmp;
}
function s2(){
    AJAXCALL("inc/songlist.asp?ac=all","s3","isXML=true");
}
function s3(doc){
    var items=getElementsByClass(doc,"item");
        var linker=new Array();
        var linkers=new Array();
    var tmp="<ul>";
    for(var i=0;i<items.length;i++){
                if(getTagValue(items[i], "singer")=="")
                {
                  linker[i]="";
                  linkers[i]="";
                }
                else
                {
                  linker[i]="("+getTagValue(items[i], 'singer').replace(/ /g,"&nbsp;")+")";
                  linkers[i]="&nbsp;"+getTagValue(items[i], 'singer').replace(/ /g,"&nbsp;");
                }
        var d=i+1;
        tmp+='<li>'+d+'. <a href=javascript:getname("'+getTagValue(items[i], 'songname').replace(/ /g,"&nbsp;")+linkers[i]+'") title="'+getTagValue(items[i], 'songname').replace(/ /g,"&nbsp;")+linker[i]+'">'+getTagValue(items[i], 'songname').replace(/ /g,"&nbsp;")+linker[i]+'</a></li>';
    }
    tmp+="</ul>";
    $("topalllist").innerHTML=tmp;
}
function musiclist(doc){
    var items=getElementsByClass(doc,"item");
    var tmp="<ul>";
    for(var i=0;i<22 && i<items.length;i++){
        var d=i+1;
        type=getTagValue(items[i], 'type');
        tmp+='<li> <img src="img/list.gif" /> <a title="試聽點 '+d+' ('+type+')" href=javascript:play("'+getTagValue(items[i], 'type')+'","'+getTagValue(items[i], 'link').replace(/ /g,'&nbsp;')+'")>'+names.replace(/ /g,'&nbsp;')+' ('+type+')</a></li>';
    }
    tmp+="</ul>";
    $("list").innerHTML=tmp;
    $("msg").style.display="none";
    play(getTagValue(items[0], "type"),getTagValue(items[0], "link"));
}
function play(obj,url){
        initLrc();
    $("guanxin").style.display="none";
    $("msg").style.display="block";
    AJAXCALL("inc/songurl.asp?type=url2&keyword="+url+"&attach="+obj,"gotoplay","isXML=true");
    AJAXCALL("inc/lyrics.asp?song="+names,"getlrc","isXML=true");
}
var tl;
function getlrc(doc){
    tl="";
    var items=getElementsByClass(doc,"item");
    var tmp="<div id=LrcDiv class=LrcDiv>";
    for(var i=0;i<items.length;i++){
        tmp+='<div class=div id=T_'+getTagValue(items[i], 'time')+' onclick=To(\''+getTagValue(items[i], 'time')+'\')>'+getTagValue(items[i], 'lrc')+'</div>';
        tl+=getTagValue(items[i], 'time')+"|";
    }
    tmp+="</div>";
    $("lrc").innerHTML=tmp;
}

function gotoplay(docs){
    var type=getTagValue(docs, "type");
    var link=getTagValue(docs, "link");
    if(type=="rm" || type=="ra" || type=="ram" || type=="rmvb" || type=="mpga" || type=="mp4" || type=="3gp")
      $("players").innerHTML=realplayer(link);
    else
      $("players").innerHTML=mdplayer(link);
    var link3=cuturl(link);
    $("msg").style.display="none";
    $("wmaurl").innerHTML="歌曲出處: <a href="+link.replace(/ /g,"&nbsp;")+" target='_blank' title='點右鍵另存:"+names.replace(/ /g,"&nbsp;")+"'>"+link3.replace(/ /g,"&nbsp;")+"</a>";
    setTimeout(guanxin,1000);
    playobj();
}

function initLrc(){
        clearTimeout(lrcT);
        rorw="";
        $("players").innerHTML="";
        $("lrc").innerHTML="";
    St=0;
        Cs=0;
}

function playobj(){
        if($("MPlayer"))
        {
          rorw="wmp";
          ldL();
        }
        else if($("RPlayer"))
        {
          rorw="rmp";
          try { RPlayer.SetWantErrors(true); } catch(hh){}
          ldL();
        }
        else
          playobj();
}

function guanxin(){
    $("guanxin").style.display="block";
    setTimeout(guanxin2,10000);
}
function guanxin2(){
    $("guanxin").style.display="none";
}

var player;
function mdplayer(str){
player='<object classid="clsid:6bf52a52-394a-11d3-b153-00c04f79faa6" id="MPlayer" width="100%" height="64"><param name="url" value="'+str+'"><param name="enablecontextmenu" value="0"><param name="enableerrordialogs" value="0"></object>';
return player;
}

function realplayer(str){
player='<object classid="clsid:cfcdaa03-8be4-11cf-b84b-0020afbbccfa" id="RPlayer" width="100%" height="60"><param name="src" value="'+str+'"><param name="controls" value="controlpanel,statusbar"><param name="autostart" value="true"></object>';
return player;
}

function cuturl(song_url){
    var len=getStrActualLen(song_url);
    var MAX_DISP_LEN=40;
    if(len<=MAX_DISP_LEN) return song_url;
    var disp_song_url=song_url;
    var pos1=song_url.indexOf("://");
    if(pos1>0){
        disp_song_url=song_url.substring(pos1+3,len);
        var pos2=disp_song_url.indexOf("/");
        if(pos2>0) disp_song_url=song_url.substring(0,pos1+pos2+4);
        var len2=MAX_DISP_LEN-3-getStrActualLen(disp_song_url);
        if(len2>0) disp_song_url=disp_song_url+'...'+song_url.substring(len-len2,len);
        return disp_song_url;
    }
}

function getStrActualLen(sChars){
    return sChars.replace(/[^\x00-\xff]/g,"xx").length;
}

function AJAXCALL(url,handleResponse,param){
    var isXML=false;//false:html or true:xml
    var isCache=false;//false:no-cache or true:cache
    var method="GET";//GET or POST
    var attach="";
    if(param){
        re = / /g; 
        param=param.replace(re, "");
        var tmp=param.split(",");
        for(var i=0;i<tmp.length;i++){
            var pa=tmp[i].substr(0,3);
            var ct=tmp[i].split("=")[1];
            switch (pa){
                case "isX":
                if(ct=="true"){
                    isXML= true; 
                }else{
                    isXML= false; 
                }
                break;
                case "isC":
                if(ct=="true"){
                    isCache= true; 
                }else{
                    isCache= false; 
                }
                break;
                case "met":
                method=ct;
                break;
                case "att":
                attach=ct;
                break;
            }
        }
    }
    if(!isCache){
        var t=new Date().getTime();
        if(url.indexOf("?")>0){
        url+="&t="+t;
        }else{
            url+="?t="+t;
        }
    }    
    var postdata=null;
    if(method=="POST"){
        purl=url.split("?");
        url=purl[0];
        postdata=purl[1];
    }
    RequestHTTP(url,handleResponse,method,isXML,postdata,attach);
}

function RequestHTTP(burl,rdRandleResponse,bmethod,bXML,Formdata,attach){
    var http_request = false;
    function doHttpRequest(){    
        if (window.XMLHttpRequest){
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType){
                http_request.overrideMimeType('text/xml');
            }
        } else if (window.ActiveXObject){
            try{
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e){
                try{
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e){}
            }
        }
        if (!http_request){
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }
        http_request.onreadystatechange=handleStateChange;    
        http_request.open(bmethod,burl,true);
        if(Formdata){
            http_request.setRequestHeader("Content-Length",Formdata.length);   
            http_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
            http_request.send(Formdata);
        }else{
            http_request.setRequestHeader("Content-Type","text/html");
            http_request.send(null);
        }
    }
    function handleStateChange(){
        if(http_request.readyState==4 && http_request.status==200){
            var response_content;
            if(bXML){
                response_content=http_request.responseXML;
            }else{
                response_content=http_request.responseText;    
            }        
            if(typeof rdRandleResponse == "function"){
                rdRandleResponse(response_content, attach);
            }else{
                eval(rdRandleResponse+"(response_content,attach)");
            }
        }
    }
    doHttpRequest();
}

function getTagValue(doc, tag){
     var elems = doc.getElementsByTagName(tag)[0].firstChild.nodeValue;
     return elems; 
}

function $(obj){
  return document.getElementById(obj);    
}

function getElementsByClass(node,tag){
    var els = node.getElementsByTagName(tag);
    return els;
}
歌詞函數(shù):

復(fù)制代碼 代碼如下:


function setcookie(name,value){
    var Days = 30;
    var exp = new Date();
    exp.setTime(exp.getTime() + Days*24*60*60*1000);
    document.cookie = name + "="+ escape(value) +";expires="+ exp.toGMTString();
}
function getcookie(name){
    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
    if(arr != null) return unescape(arr[2]); return null;
}
setcookie("box",getcookie("box"));
function addbox(name){
    var a1=name+"|*|";
    var box=getcookie("box");
    box=box.replace(a1,"");
    var value=a1+box;
    setcookie("box",value);
    listbox();
}
function delbox(name){
    var del=name+"|*|";
    var s=getcookie("box");
    s = s.replace(del, "");
    setcookie("box",s);
    listbox();
}
function listbox(){
    var tmp="";
    var s2=getcookie("box");
    var s3=s2.split("|*|");
    var s4=s3.length-1;
        if(s4>8) $("boxlist").style.height="139px";
    for(var i=0;i<s4;i++){
        tmp+="<div id=\"box\"><div id=\"del\" style=\"float: right;\"><span onclick=javascript:delbox('"+s3[i]+"')>刪除</span></div><div id=\"boxtitle\"><a href=javascript:getname('"+s3[i]+"')>"+s3[i]+"</a></div></div>";
    }
    $("boxlist").innerHTML=tmp;
}

function GetEBID(id){return document.getElementById(id);}
function To(t){
        if(rorw=="") return;
    if(rorw=="rmp" && RPlayer.GetPlayState()==3) RPlayer.SetPosition(t*1000);
    if(rorw=="wmp" && MPlayer.playState==3) MPlayer.controls.CurrentPosition=t;
}

function lrcrun(){
        var rtl="|"+tl;
        if((rtl.indexOf("|"+Cs+"|")) != -1){
            GetEBID("LrcDiv").scrollTop=GetEBID("LrcDiv").offsetTop-parseInt(GetEBID("LrcDiv").offsetHeight/2)+GetEBID("T_"+Cs).offsetTop+10;
            GetEBID("T_"+St).className="";
            GetEBID("T_"+Cs).className="b";
            St=Cs;
        }
}

function ldL(){
    if(rorw=="rmp" && RPlayer.GetPlayState()==3) {Cs=Math.floor(RPlayer.GetPosition()/1000); lrcrun();}
    if(rorw=="wmp" && MPlayer.playState==3)    {Cs=Math.floor(MPlayer.controls.CurrentPosition); lrcrun();}
    lrcT=setTimeout("ldL()", 10);
}

感謝各位的閱讀!關(guān)于“Baidu Musicbox用到的ajax代碼是怎么樣的”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,讓大家可以學到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!

當前名稱:BaiduMusicbox用到的ajax代碼是怎么樣的
標題網(wǎng)址:http://jinyejixie.com/article18/ghohgp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供營銷型網(wǎng)站建設(shè)、自適應(yīng)網(wǎng)站、、App開發(fā)、手機網(wǎng)站建設(shè)、面包屑導(dǎo)航

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都app開發(fā)公司
奉贤区| 兴化市| 新乡市| 郁南县| 黄骅市| 海南省| 普格县| 东海县| 青岛市| 嘉禾县| 涟源市| 蒙山县| 隆安县| 常宁市| 平舆县| 忻城县| 涟源市| 富锦市| 伊金霍洛旗| 蓬莱市| 山西省| 屏山县| 肥西县| 扎鲁特旗| 绍兴市| 绍兴市| 加查县| 景洪市| 寻乌县| 富源县| 佳木斯市| 酒泉市| 黑龙江省| 天全县| 太白县| 临江市| 闽清县| 龙川县| 工布江达县| 双城市| 大同县|