移除大量无效代码和已被注释废弃的代码

This commit is contained in:
Starlight-0208 2022-12-20 02:55:19 +08:00
parent 9b5baa63f5
commit 0a43f924e4

View File

@ -7,13 +7,11 @@ window.onload = function(){
class TitleStat{
constructor( originTitle ){
this.originTitle = originTitle;
// this.TempTitle = this.TargetTitle;
}
GlobalInterval = null;
OriginTitle = document.title;
TargetTitle = "";
// TempTitle = ""; // Used to determine if the title has changed
SCROLL_SPEED = 1000;
ActivateStat = false;
@ -31,7 +29,6 @@ class TitleStat{
setTargetTitle( title ){
this.TargetTitle = title;
// console.log( this );
}
setScrollSpeed( speed ){
@ -81,13 +78,6 @@ class TitleStat{
}
scorllTheTitle() {
// console.log("Title Scroll!"); //Debug
// if ( this.TempTitle == undefined ) {
// console.warn( "this.TempTitle undefined" );
// console.log( this );
// this.TempTitle = this.TargetTitle;
// }
// 此处的this指的是window对象
if( document.getElementById("Player").paused == false ){
document.title = "[▶️] " + this.userdefines_title.TempTitle.substring(0,20) + "...";
@ -151,48 +141,12 @@ class PlayerControl{
}
// 切歌
playnext();
// 确认当前播放模式
// switch ( CyclePlayMode ){
// case 0: // 列表播放(仅一次)
// if ( nowPlay >= (list.size() + 1) ) {
// if( this.ListenerStatus ) {
// // 播放列表完毕就清除事件监听器
// this.disableListener(this.playStatCheck());
// console.log("播放完毕,已清除事件监听。");
// } else {
// // 事件监听器未打开
// console.error("关闭失败,事件监听器未启用。");
// }
// }
// break;
// case 1: // 列表循环
// if ( !this.ListenerStatus ) {
// // 如果未启用监听器,则启用
// this.enableListener(this.playStatCheck());
// console.log("启用列表,已清除事件监听。")
// }
// break;
// case 2: // 单曲循环
// // 持续不断的从头开始
// this.playerObject.play();
// break;
// default:
// // 缺省值
// console.error("模式错误疑似bug或者JS已被修改请注意")
// break;
// }
}
}
// Title Control
// var originTitle = document.title;
let TitleControl = new TitleStat(document.title);
// TitleControl.setTargetTitle("Song!");
window.onblur = () => {
// document.title = "Song!";
// TitleControl.setTargetTitle("Song!")
console.log("您已离开播放器!");
TitleControl.setScrollSpeed(500);
TitleControl.setTargetTitle(document.getElementById("nowplay").innerHTML);
@ -216,12 +170,9 @@ function getsongs(){
xhr.send();
xhr.onreadystatechange = function(){
if(xhr.readyState == 4 && xhr.status == 200){
//console.log(xhr.responseText);
var obj = JSON.parse(xhr.responseText);
//console.log(obj.result.songs);
console.log(obj);
var list = obj.result.songs;
//for(i = 0; i < obj.result.songs.length; i++){
for(var i = 0; i < list.length; i++){
artiststr = getArtist(list[i]);
console.log({"songid":list[i].id, "songname":list[i].name, "artist":artiststr});
@ -238,7 +189,6 @@ function getsongs(){
}
}
}else{
//alert(xhr.statusText);
console.warn("WARNNINGAPI服务器响应失败");
}
}
@ -270,43 +220,6 @@ function playmusic(playid, songname, artist){
inserthistory(playid, songname, artist);
}
// 队列 -- Writtrn By Copilot & Web
function Queue(){
this.items = [];
Queue.prototype.nqueue = (element) => {
this.items.push(element);
}
Queue.prototype.dequeue = () => {
return this.items.shift();
}
Queue.prototype.front = () => {
return this.items[0];
}
Queue.prototype.isEmpty = () => {
return this.items.length == 0;
}
Queue.prototype.clear = () => {
this.items = [];
}
Queue.prototype.size = () => {
return this.items.length;
}
Queue.prototype.toString = () => {
var str = "";
for(var i = 0; i < this.items.length; i++){
str += this.items[i] + " ";
}
return str;
}
}
// 列表
function List(){
this.items = [];
@ -373,7 +286,6 @@ function createlist(){
// 添加到播放列表
function addlist(songid, songname, artist){
// list.nqueue({"songid":songid, "songname":songname, "artist":artist});
for (var i = 0; i < list.getLength(); i++) {
if(list.getElem(i).songid == songid){
console.log(`${songname} - ${artist} 已存在于播放列表`);
@ -391,7 +303,6 @@ function playnext(){
alert("音乐列表已经播放完毕了哦,快加入新的音乐吧~");
return;
}
// var next = list.dequeue();
if(nowPlay >= (list.size() - 1)){
nowPlay = 0;
}else{
@ -462,29 +373,14 @@ function playthelist(){
// 获取播放列表
function getplaylist(){
//var playlist = document.getElementById("playlist");
//playlist.innerHTML = "";
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="javascript:RemoveItemFromListByID(${i})">删除</button></span></li>`;
//console.log(`${list.items[i].songname} - ${list.items[i].artist}`);
}
document.getElementById('keyword').innerHTML = "当前播放列表";
}
/* // -- Writtrn By Copilot
function RemoveItemFromList(songid){
for(var i = 0; i < list.size(); i++){
if(list.items[i].songid == songid){
list.items.splice(i, 1);
break;
}
}
getplaylist();
}
*/
// 删除指定序号的音乐 -- Writtrn By Copilot
function RemoveItemFromListByID(uid){
list.items.splice(uid, 1);
@ -510,7 +406,6 @@ function inserthistory(songid, songname, artist){
}
// 如果不存在,则插入
if(!flag){
// historyList.push({"songid":songid, "songname":songname, "artist":artist, "playtime":new Date().getTime()});
historyList.push({"songid":songid, "songname":songname, "artist":artist});
}
// 存储到本地
@ -595,7 +490,6 @@ function convertHist2CloudList(origin){
// 推送到云播放列表
function PushToCloud(){
// Cloud Prepareing...
var server_api = "http://localhost:8080/musiccloud.php?option=upload";
var xhr = new XMLHttpRequest();
var historyList = JSON.parse(localStorage.getItem("historyList"));
@ -627,9 +521,7 @@ function PushToCloud(){
// 拉取云播放列表
function PullToCloud(){
// Cloud Prepareing...
var listid = document.getElementById("listid").value;
// var server_api = `http://localhost:12345/getMusicList?listid=${listid}`;
var server_api = `http://localhost:8080/musiccloud.php?option=getlist&list=${listid}`;
var xhr = new XMLHttpRequest();
xhr.open("GET", server_api, true);