Partial upload-202212092302
This commit is contained in:
parent
c5e4517e4b
commit
9f3fc4b906
31
index.html
31
index.html
@ -31,36 +31,7 @@
|
||||
</div>
|
||||
<div id="search-result">
|
||||
<span id="searchtext">以下是查询 <span id="keyword">None</span> 的结果</span><br />
|
||||
<ul id="reslist">
|
||||
<!-- 测试样例 -->
|
||||
<li id="listitem">
|
||||
TestMusic-Artist
|
||||
<span class="btn-series">
|
||||
<button type="button" id="delbtn" onclick="">删除</button>
|
||||
<button type="button" id="playbtn" onclick="">加入播放列表</button>
|
||||
</span>
|
||||
</li>
|
||||
<li id="listitem">
|
||||
TestMusic-Artist-long-long-long-long-long-long-long-long-long
|
||||
<span class="btn-series">
|
||||
<button type="button" id="delbtn" onclick="">删除</button>
|
||||
<button type="button" id="playbtn" onclick="">加入播放列表</button>
|
||||
</span>
|
||||
</li>
|
||||
<li id="listitem">
|
||||
TestMusic-Artist
|
||||
<span class="btn-series">
|
||||
<button type="button" id="delbtn" onclick="">删除</button>
|
||||
<button type="button" id="playbtn" onclick="">加入播放列表</button>
|
||||
</span>
|
||||
</li>
|
||||
<li id="listitem">
|
||||
TestMusic-Artist
|
||||
<span class="btn-series">
|
||||
<button type="button" id="playbtn" onclick="">加入播放列表</button>
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
<ul id="reslist"></ul>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
39
js/main.js
39
js/main.js
@ -24,19 +24,20 @@ function getsongs(){
|
||||
artiststr = getArtist(list[i]);
|
||||
console.log({"songid":list[i].id, "songname":list[i].name, "artist":artiststr});
|
||||
if(list[i].fee == 0 || list[i].fee == 8){
|
||||
reslist.innerHTML += `<li id="listitem"><a href="javascript:void(0)" onclick="playmusic(${list[i].id}, '${list[i].name}', '${artiststr}')">${list[i].name} - ${getArtist(list[i])}</a>`+
|
||||
reslist.innerHTML += `<li id="listitem"><a href="javascript:void(0)" onclick="javascript:playmusic(${list[i].id}, '${list[i].name}', '${artiststr}')">${list[i].name} - ${getArtist(list[i])}</a>` +
|
||||
`<span class="">` +
|
||||
`<button type="button" id="playbtn" onclick="addlist(${list[i].id}, '${list[i].name}', '${artiststr}')">加入播放列表</button></li>` +
|
||||
`</span>`;
|
||||
`<button type="button" id="playbtn" onclick="javascript:addlist(${list[i].id}, '${list[i].name}', '${artiststr}')">加入播放列表</button>` +
|
||||
`</span></li>`;
|
||||
}else{
|
||||
reslist.innerHTML += `<li id="listitem">${list[i].name} - ${getArtist(list[i])}`+
|
||||
`<span class="">` +
|
||||
`<button type="button" id="disablebtn" onclick="console.log(\"Wait.\")">跳转到网易云</button></li>` +
|
||||
`</span>`;
|
||||
`<button type="button" id="disablebtn" onclick="javascript:jumpTo163CM(${list[i].id})">跳转到网易云</button>` +
|
||||
`</span></li>`;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
//alert(xhr.statusText);
|
||||
console.warn("WARNNING:API服务器响应失败");
|
||||
}
|
||||
}
|
||||
document.getElementById("keyword").innerHTML = search.value;
|
||||
@ -230,7 +231,7 @@ function getplaylist(){
|
||||
var reslist = document.getElementById("reslist");
|
||||
reslist.innerHTML = "";
|
||||
for(var i = 0; i < list.size(); i++){
|
||||
reslist.innerHTML += `<li>${list.items[i].songname} - ${list.items[i].artist}<span class="btn-series"><button type="button" id="delbtn" onclick="RemoveItemFromListByID(${i})">删除</button></span></li>`;
|
||||
reslist.innerHTML += `<li>${list.items[i].songname} - ${list.items[i].artist}<span class="btn-series"><button type="button" id="delbtn" onclick="javascript:RemoveItemFromListByID(${i})">删除</button></span></li>`;
|
||||
//console.log(`${list.items[i].songname} - ${list.items[i].artist}`);
|
||||
}
|
||||
document.getElementById('keyword').innerHTML = "当前播放列表";
|
||||
@ -291,8 +292,8 @@ function gethistory(){
|
||||
for(var i = 0; i < historyList.length; i++){
|
||||
reslist.innerHTML += `<li>${historyList[i].songname} - ${historyList[i].artist}` +
|
||||
`<span class="btn-series">` +
|
||||
`<button type="button" id="delbtn" onclick="deleteHistory(${i})">删除</button>` +
|
||||
`<button type="button" id="playbtn" onclick="addlist(${historyList[i].songid}, '${historyList[i].songname}', '${historyList[i].artist}')">加入播放列表</button></li>` +
|
||||
`<button type="button" id="delbtn" onclick="javascript:deleteHistory(${i})">删除</button>` +
|
||||
`<button type="button" id="playbtn" onclick="javascript:addlist(${historyList[i].songid}, '${historyList[i].songname}', '${historyList[i].artist}')">加入播放列表</button></li>` +
|
||||
`</span>`;
|
||||
}
|
||||
document.getElementById('keyword').innerHTML = "历史记录";
|
||||
@ -409,8 +410,10 @@ function PullToCloud(){
|
||||
reslist.innerHTML = "";
|
||||
for(var i = 0; i < obj.list.length; i++){
|
||||
reslist.innerHTML += `<li>${obj.list[i].name} - ${obj.list[i].author}` +
|
||||
`<button type="button" id="playbtn" onclick="addlist(${obj.list[i].id}, '${obj.list[i].name}', '${obj.list[i].author}')">加入播放列表</button></li>`;
|
||||
}
|
||||
`<span class="">` +
|
||||
`<button type="button" id="playbtn" onclick="javascript:addlist(${obj.list[i].id}, '${obj.list[i].name}', '${obj.list[i].author}')">加入播放列表</button>` +
|
||||
`</span></li>`;
|
||||
}
|
||||
}else{
|
||||
;
|
||||
}
|
||||
@ -448,12 +451,22 @@ function deleteHistory( count ) {
|
||||
for( var i = 0; i < historyList.length; i++ ){
|
||||
reslist.innerHTML += `<li>${historyList[i].songname} - ${historyList[i].artist}` +
|
||||
`<span class="btn-series">` +
|
||||
`<button type="button" id="delbtn" onclick="deleteHistory(${i})">删除</button>` +
|
||||
`<button type="button" id="playbtn" onclick="addlist(${historyList[i].songid}, '${historyList[i].songname}', '${historyList[i].artist}')">加入播放列表</button></li>` +
|
||||
`</span>`;
|
||||
`<button type="button" id="delbtn" onclick="javascript:deleteHistory(${i})">删除</button>` +
|
||||
`<button type="button" id="playbtn" onclick="javascript:addlist(${historyList[i].songid}, '${historyList[i].songname}', '${historyList[i].artist}')">加入播放列表</button>` +
|
||||
`</span></li>`;
|
||||
}
|
||||
document.getElementById( 'keyword' ).innerHTML = "历史记录";
|
||||
|
||||
// put the HistoryList back into the LocalStorage
|
||||
localStorage.setItem( "historyList", JSON.stringify( historyList ) );
|
||||
}
|
||||
|
||||
function jumpTo163CM( songid ) {
|
||||
console.log("因为没钱,所以放不了,要不你自己去官网开会员听?");
|
||||
if ( confirm( "因为没钱,所以放不了,要不你自己去官网开会员听?" ) ){
|
||||
window.open( 'https://music.163.com/#/song?id=' + songid );
|
||||
console.log("感谢你的理解!^_^");
|
||||
} else {
|
||||
console.log("好吧,那我也没有办法了,总之是放不了。\(sad")
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user