新增功能

This commit is contained in:
starlight_0208 2022-06-24 13:32:30 +08:00
parent be57a10b28
commit da09e7072a
2 changed files with 51 additions and 2 deletions

View File

@ -19,7 +19,7 @@
<button type="button" onclick="playthelist()" id="btngreen">播放列表</button>
<button type="button" onclick="playnext()" id="btngreen">立即切歌</button>
<button type="button" onclick="gethistory()" id="btngreen">播放历史</button>
<button type="button" onclick="removehistory()" id="btngreen">清空记录</button>
<button type="button" onclick="ClearList()" id="btngreen">清空记录</button>
<div>
<div id="nowplaystat">Now Playing: <span id="nowplay">None</span></div>
<audio src="#" controls id="Player"></audio>

View File

@ -222,4 +222,53 @@ function gethistory(){
function removehistory(){
localStorage.removeItem("historyList");
gethistory();
}
}
// 当点击清空列表的时候进行一次确认,如果确认之后再进行删除操作。
function ClearList(){
var Choose = confirm("确定清空歌单吗?(此操作不可逆!)")
if(Choose == true){
removehistory();
console.log("The History List Has been cleared.");
return true;
}else{
console.log("List Clear Canceled!");
return false;
}
}
// 添加所有歌曲到播放列表
function addAllHistorytoPlayList(){
var historyList = JSON.parse(localStorage.getItem("historyList"));
if(historyList == null){
historyList = [];
}
var reslist = document.getElementById("reslist");
reslist.innerHTML = "";
for(var i = 0; i < historyList.length; i++){
addlist(historyList[i].songid, historyList[i].songname, historyList[i].artist);
console.log(`${historyList[i].songname} - ${historyList[i].artist} is add to list.`);
}
alert("已把历史记录插入到了播放列表");
// Planning to Code...
}
// 清空播放列表
function ClearthePlaylist(){
if(!list.isEmpty()){
list.clear();
console.log("List Cleared!");
}else{
console.log("List is empty, not need to clear.")
}
}
// 推送到云播放列表
function PushToCloud(){
// Cloud Prepareing...
}
// 拉取云播放列表
function PullToCloud(){
// Cloud Prepareing...
}