專輯列表最近加入
@@ -281,17 +280,17 @@ async function show_album() {
}
}
//- 展示專輯歌曲
-async function show_album_songs(a, b, c) {
- var artist = a == '#' ? '' : a,
+async function showAlbumSongs(a, b, c) {
+ let artist = a == '#' ? '' : a,
album = b == '#' ? '' : b,
- album_artist = c == '#' ? '' : c
+ albumArtist = c == '#' ? '' : c
//如果從首頁按進去頁籤沒切換
$("#content").attr('data-page', 'album')
- var albumInfo = `
+ let albumInfo = `
@@ -306,7 +305,7 @@ async function show_album_songs(a, b, c) {
`
- var actions = `
+ let actions = `
`
// 展示讀取中
- $("#content").html(albumInfo + HTML_getSpinner())
+ $("#content").html(albumInfo + HTML.getSpinner())
mdui.mutation()
//抓資料
- var data = await getAlbumSong(album, album_artist, artist),
- html = HTML_showSongs(data.data.songs)
+ let data = await getAlbumSong(album, albumArtist, artist),
+ html = HTML.showSongs(data.data.songs)
if ($("#content").attr('data-page') == 'album') {
$("#content").html(albumInfo + html)
$("#content>:not(.album-info):not(.mdui-divider)")
}
// 獲取總時間
- var time = 0
+ let time = 0
for (i = 0; i < data.data.songs.length; i++) time += data.data.songs[i].additional.song_audio.duration
$("#content .album-info .time").html(`${data.data.songs.length} 首歌曲/${secondToTime(time)}`)
$("#content .album-info .actions").html(actions)
}
// 資料夾
-async function show_folder(folder) {
+async function showFolder(folder) {
$("#content").attr('data-page', 'folder')
// 展示讀取中
- var header = HTML_getHeader("資料夾")
- $("#content").html(header + HTML_getSpinner())
+ let header = HTML.getHeader("資料夾")
+ $("#content").html(header + HTML.getSpinner())
mdui.mutation()
- var PARAMS_JSON = [
+ let PARAMS_JSON = [
{ key: "additional", "value": "song_tag,song_audio,song_rating" },
{ key: "library", "value": "shared" },
{ key: "limit", "value": 1000 },
@@ -350,22 +349,22 @@ async function show_folder(folder) {
if (folder) {
PARAMS_JSON.push({ key: "id", "value": folder })
}
- var data = await getAPI("AudioStation/folder.cgi", "SYNO.AudioStation.Folder", "list", PARAMS_JSON, 2),
- folderHTML = HTML_showFolder(data.data.items)
+ let data = await getAPI("AudioStation/folder.cgi", "SYNO.AudioStation.Folder", "list", PARAMS_JSON, 2),
+ folderHTML = HTML.showFolder(data.data.items)
if ($("#content").attr('data-page') == 'folder') {
$("#content").html(header + folderHTML)
$("#content>:not(#header-wrapper)")
router.updatePageLinks()
}
}
-async function show_artist(artist) {
- var header = HTML_getHeader("演出者")
+async function showArtist(artist) {
+ let header = HTML.getHeader("演出者")
$("#content").attr('data-page', 'artist')
- $("#content").html(header + HTML_getSpinner())
+ $("#content").html(header + HTML.getSpinner())
mdui.mutation()
if (artist) {
- var header = HTML_getHeader("演出者 / " + artist)
- var PARAMS_JSON = [
+ let header = HTML.getHeader("演出者 / " + artist)
+ let PARAMS_JSON = [
{ key: "additional", "value": "avg_rating" },
{ key: "library", "value": "shared" },
{ key: "limit", "value": 1000 },
@@ -374,21 +373,21 @@ async function show_artist(artist) {
{ key: "sort_direction", "value": "ASC" },
{ key: "artist", "value": artist != "未知" ? artist : '' },
]
- var data = await getAPI("AudioStation/album.cgi", "SYNO.AudioStation.Album", "list", PARAMS_JSON, 3),
- albumHTML = HTML_showAlbums(data.data.albums)
+ let data = await getAPI("AudioStation/album.cgi", "SYNO.AudioStation.Album", "list", PARAMS_JSON, 3),
+ albumHTML = HTML.showAlbums(data.data.albums)
if ($("#content").attr('data-page') == 'artist')
$("#content").html(header + albumHTML)
} else {
//請求資料囉
- var PARAMS_JSON = [
+ let PARAMS_JSON = [
{ key: "limit", "value": 1000 },
{ key: "library", "value": "shared" },
{ key: "additional", "value": "avg_rating" },
{ key: "sort_by", "value": "name" },
{ key: "sort_direction", "value": "ASC" }
]
- var data = await getAPI("AudioStation/artist.cgi", "SYNO.AudioStation.Artist", "list", PARAMS_JSON, 4),
- artistsHTML = HTML_showArtist(data.data.artists)
+ let data = await getAPI("AudioStation/artist.cgi", "SYNO.AudioStation.Artist", "list", PARAMS_JSON, 4),
+ artistsHTML = HTML.showArtist(data.data.artists)
if ($("#content").attr('data-page') == 'artist')
$("#content").html(header + artistsHTML)
}
@@ -397,14 +396,14 @@ async function show_artist(artist) {
router.updatePageLinks()
}
}
-async function show_composer(composer) {
- var header = HTML_getHeader("作曲者")
+async function showComposer(composer) {
+ let header = HTML.getHeader("作曲者")
$("#content").attr('data-page', 'composer')
- $("#content").html(header + HTML_getSpinner())
+ $("#content").html(header + HTML.getSpinner())
mdui.mutation()
if (composer) {
- var header = HTML_getHeader("作曲者 / " + composer)
- var PARAMS_JSON = [
+ let header = HTML.getHeader("作曲者 / " + composer)
+ let PARAMS_JSON = [
{ key: "additional", "value": "avg_rating" },
{ key: "library", "value": "shared" },
{ key: "limit", "value": 1000 },
@@ -414,12 +413,12 @@ async function show_composer(composer) {
{ key: "composer", "value": composer != "未知" ? composer : '' },
],
data = await getAPI("AudioStation/album.cgi", "SYNO.AudioStation.Album", "list", PARAMS_JSON, 3),
- albumHTML = HTML_showAlbums(data.data.albums)
+ albumHTML = HTML.showAlbums(data.data.albums)
if ($("#content").attr('data-page') == 'composer')
$("#content").html(header + albumHTML)
} else {
//請求資料囉
- var PARAMS_JSON = [
+ let PARAMS_JSON = [
{ key: "limit", "value": 1000 },
{ key: "library", "value": "shared" },
{ key: "additional", "value": "avg_rating" },
@@ -427,7 +426,7 @@ async function show_composer(composer) {
{ key: "sort_direction", "value": "ASC" }
],
data = await getAPI("AudioStation/composer.cgi", "SYNO.AudioStation.Composer", "list", PARAMS_JSON, 2),
- composersHTML = HTML_showComposer(data.data.composers)
+ composersHTML = HTML.showComposer(data.data.composers)
if ($("#content").attr('data-page') == 'composer')
$("#content").html(header + composersHTML)
}
@@ -437,13 +436,13 @@ async function show_composer(composer) {
}
}
//- 播放清單
-async function show_playlist() {
+async function showPlaylist() {
// 展示讀取中
- var header = HTML_getHeader("所有清單")
- $("#content").html(header + HTML_getSpinner())
+ let header = HTML.getHeader("所有清單")
+ $("#content").html(header + HTML.getSpinner())
$('#content').attr('data-page', 'playlist')
mdui.mutation()
- var playlist = await getAPI("AudioStation/playlist.cgi", "SYNO.AudioStation.Playlist", "list", [
+ let playlist = await getAPI("AudioStation/playlist.cgi", "SYNO.AudioStation.Playlist", "list", [
{ key: "limit", "value": 1000 },
{ key: "library", "value": "shared" },
{ key: "sort_by", "value": "" },
@@ -453,22 +452,22 @@ async function show_playlist() {
if (playlist.data.playlists.length < 0) {
$("#content").html(header + `
沒有任何播放清單
`)
}
- $("#content").html(header + HTML_showPlaylists(playlist.data.playlists))
+ $("#content").html(header + HTML.showPlaylists(playlist.data.playlists))
router.updatePageLinks()
}
}
//- 播放清單歌曲
-async function show_playlist_songs(id) {
+async function showPlaylistSongs(id) {
//如果從首頁按進去
$("#content").attr('data-page', 'playlist')
// 展示讀取中
- var header = HTML_getHeader("正在讀取播放清單")
- $("#content").html(header + HTML_getSpinner())
+ let header = HTML.getHeader("正在讀取播放清單")
+ $("#content").html(header + HTML.getSpinner())
mdui.mutation()
//抓資料
- var playlist = await getAPI("AudioStation/playlist.cgi", "SYNO.AudioStation.Playlist", "getinfo", [
+ let playlist = await getAPI("AudioStation/playlist.cgi", "SYNO.AudioStation.Playlist", "getinfo", [
{ key: "limit", "value": 1000 },
{ key: "library", "value": "shared" },
{ key: "sort_by", "value": "" },
@@ -476,39 +475,39 @@ async function show_playlist_songs(id) {
{ key: "id", "value": id },
{ key: "sort_direction", "value": "ASC" }
], 3)
- var result = playlist.data.playlists[0]
- var name = result.name
- var songs = HTML_showSongs(result.additional.songs)
- var header = HTML_getHeader(name)
+ let result = playlist.data.playlists[0]
+ let name = result.name
+ let songs = HTML.showSongs(result.additional.songs)
+ let header = HTML.getHeader(name)
if ($("#content").attr('data-page') == 'playlist') {
$("#content").html(header + songs)
$("#content>:not(#header-wrapper)")
}
}
//- 隨機播放
-async function show_random() {
+async function showRandom() {
// 展示讀取中
- var header = HTML_getHeader("隨機播放")
- $("#content").html(header + HTML_getSpinner())
+ let header = HTML.getHeader("隨機播放")
+ $("#content").html(header + HTML.getSpinner())
$('#content').attr('data-page', 'random')
mdui.mutation()
- var PARAMS_JSON = [
+ let PARAMS_JSON = [
{ key: "additional", "value": "song_tag,song_audio,song_rating" },
{ key: "library", "value": "shared" },
{ key: "limit", "value": 100 },
{ key: "sort_by", "value": "random" }
],
data = await getAPI("AudioStation/song.cgi", "SYNO.AudioStation.Song", "list", PARAMS_JSON, 1),
- album = HTML_showSongs(data.data.songs)
+ album = HTML.showSongs(data.data.songs)
if ($("#content").attr('data-page') == 'random') {
$("#content").html(header + album)
$("#content>:not(#header-wrapper)")
}
}
-async function play_random() {
+async function playRandom() {
router.navigate('now')
- var PARAMS_JSON = [
+ let PARAMS_JSON = [
{ key: "additional", "value": "song_tag,song_audio,song_rating" },
{ key: "library", "value": "shared" },
{ key: "limit", "value": 100 },
@@ -518,14 +517,14 @@ async function play_random() {
playSongs(data.data.songs, false, false)
}
//- 現正播放
-async function show_now() {
+async function showNow() {
$('#content').attr('data-page', 'now')
- var html = `
`
+ let html = `
`
for (i = 0; i < ap.list.audios.length; i++) {
let focus = ap.list.index == i ? 'mdui-list-item-active' : '',
title = ap.list.audios[i].name,
artist = ap.list.audios[i].artist,
- album_artist = ap.list.audios[i].album_artist,
+ albumArtist = ap.list.audios[i].albumArtist,
album = ap.list.audios[i].album,
img = window.localStorage["imgRes"] == "true" ? '' : ``
html += `
@@ -542,7 +541,7 @@ async function show_now() {
html += `
`
- var nowPlaying = ap.list.audios[ap.list.index],
+ let nowPlaying = ap.list.audios[ap.list.index],
name = nowPlaying ? nowPlaying.name : "PokaPlayer",
artist = nowPlaying ? nowPlaying.artist || "未知的歌手" : "點擊播放鍵開始隨機播放",
album = nowPlaying ? `${nowPlaying.album}` || "" : "",
@@ -582,11 +581,11 @@ async function show_now() {
// random&loop
$("[data-player]>.info>.ctrl>.random").html($('.aplayer-icon.aplayer-icon-order').html())
$("[data-player]>.info>.ctrl>.loop").html($('.aplayer-icon.aplayer-icon-loop').html())
- $("[data-player]>.info>.ctrl>.random").click(function() {
+ $("[data-player]>.info>.ctrl>.random").click(() => {
$('#aplayer .aplayer-icon.aplayer-icon-order').click()
$(this).html($('.aplayer-icon.aplayer-icon-order').html())
})
- $("[data-player]>.info>.ctrl>.loop").click(function() {
+ $("[data-player]>.info>.ctrl>.loop").click(() => {
$('#aplayer .aplayer-icon.aplayer-icon-loop').click()
$(this).html($('.aplayer-icon.aplayer-icon-loop').html())
});
@@ -603,7 +602,7 @@ async function show_now() {
}
// 歌詞
if (lrc.getLyrics()) {
- var html = ``
+ let html = ``
for (i = 0; i < lrc.getLyrics().length; i++) {
let text = lrc.getLyrics()[i].text
if (text == "歌詞讀取中")
@@ -620,10 +619,10 @@ async function show_now() {
}
}
- ap.on("pause", function() {
+ ap.on("pause", () => {
$('[data-player] button.play[onclick="ap.toggle()"] i').text("play_arrow")
})
- ap.on("play", async function() {
+ ap.on("play", async () => {
//卷軸轉轉
if ($(window).width() > 850 && $(window).height() > 560) {
$('.mdui-list.songs').animate({ scrollTop: 72 * ap.list.index - 100 }, 400);
@@ -633,11 +632,11 @@ async function show_now() {
$(".songs>li.song").eq(ap.list.index).addClass('mdui-list-item-active');
//- 播放器
$('[data-player] button.play[onclick="ap.toggle()"] i').text("pause")
- var nowPlaying = ap.list.audios[ap.list.index]
- var name = nowPlaying ? nowPlaying.name : "PokaPlayer"
- var artist = nowPlaying ? nowPlaying.artist || "未知的歌手" : "點擊播放鍵開始隨機播放"
- var album = nowPlaying ? `${nowPlaying.album}` || "" : ""
- var img = (nowPlaying && window.localStorage["imgRes"] != "true") ? nowPlaying.cover : getBackground() //一定會有圖片
+ let nowPlaying = ap.list.audios[ap.list.index]
+ let name = nowPlaying ? nowPlaying.name : "PokaPlayer"
+ let artist = nowPlaying ? nowPlaying.artist || "未知的歌手" : "點擊播放鍵開始隨機播放"
+ let album = nowPlaying ? `${nowPlaying.album}` || "" : ""
+ let img = (nowPlaying && window.localStorage["imgRes"] != "true") ? nowPlaying.cover : getBackground() //一定會有圖片
$('[data-player]>.mdui-card').attr('style', `background-image:url(${img});`)
$('[data-player]>.info .title').text(name)
$('[data-player]>.info .artist').html(artist + album)
@@ -648,7 +647,7 @@ async function show_now() {
// 歌詞
if (lrc.getLyrics()) {
- var html = ``
+ let html = ``
for (i = 0; i < lrc.getLyrics().length; i++) {
let text = lrc.getLyrics()[i].text
if (text == "歌詞讀取中")
@@ -659,10 +658,10 @@ async function show_now() {
$('[data-lrc="inner"]').html(html)
}
})
- ap.on("timeupdate", function() {
+ ap.on("timeupdate", () => {
currentTime = ap.audio.currentTime ? secondToTime(ap.audio.currentTime) : "0:00"
duration = ap.audio.currentTime ? secondToTime(ap.audio.duration) : "0:00"
- var cent = ap.audio.currentTime / ap.audio.duration * 100
+ let cent = ap.audio.currentTime / ap.audio.duration * 100
$('[data-player]>.info>.player-bar>.timer').text(currentTime + '/' + duration);
// 更新 timer
$("[data-player]>.info>.player-bar input[type=range]").val(cent);
@@ -681,32 +680,32 @@ async function show_now() {
}
});
- $("[data-player]>.info>.player-bar input[type=range]").on("input", function() {
- var time = $("[data-player]>.info>.player-bar input[type=range]").val() / 100 * ap.audio.duration
+ $("[data-player]>.info>.player-bar input[type=range]").on("input", () => {
+ let time = $("[data-player]>.info>.player-bar input[type=range]").val() / 100 * ap.audio.duration
ap.seek(time);
})
$(".songs [data-now-play-id].songinfo").click(function() {
$(".songs>li.song").removeClass('mdui-list-item-active')
$(this).parent().eq(0).addClass('mdui-list-item-active')
- var song = $(this).attr('data-now-play-id')
+ let song = $(this).attr('data-now-play-id')
ap.list.switch(song)
ap.play()
})
$(".songs [data-now-play-id].close").click(function() {
- var song = $(this).attr('data-now-play-id')
+ let song = $(this).attr('data-now-play-id')
if (song == ap.list.index) ap.skipForward()
ap.list.remove(song)
- show_now()
+ showNow()
})
}
//- 歌詞
-function show_lrc() {
+function showLrc() {
$("#content").html(`
`)
$('#content').attr('data-page', 'lrc')
// 歌詞
if (lrc.getLyrics()) {
- var html = ``
+ let html = ``
for (i = 0; i < lrc.getLyrics().length; i++) {
let text = lrc.getLyrics()[i].text
if (text == "歌詞讀取中")
@@ -722,7 +721,7 @@ function show_lrc() {
$('#content>div[data-lrc]').animate({ scrollTop: top }, 0);
}
}
- ap.on("timeupdate", function() {
+ ap.on("timeupdate", () => {
// 歌詞亮亮
let nowLrc = lrc.select(ap.audio.currentTime)
let before = $('#content>div[data-lrc]>div[data-lrc="inner"] p.mdui-text-color-theme-accent')[0]
@@ -736,17 +735,17 @@ function show_lrc() {
});
}
//- 設定
-async function show_settings() {
+async function showSettings() {
$('#content').attr('data-page', 'settings')
///給定預設值
if (!window.localStorage["musicRes"]) window.localStorage["musicRes"] = "wav"
if (!window.localStorage["randomImg"]) window.localStorage["randomImg"] = "/og/og.png"
///
- var header = HTML_getHeader("設定")
- var title = (title) => `
${title}
`
- var subtitle = (subtitle) => `
${subtitle}
`
- var colors = [
+ let header = HTML.getHeader("設定")
+ let title = title => `
${title}
`
+ let subtitle = subtitle => `
${subtitle}
`
+ let colors = [
'red',
'pink',
'purple',
@@ -767,14 +766,11 @@ async function show_settings() {
'grey',
'blue-grey'
]
- var colorOption = (colors, accent = false) => {
- var option = ''
+ let colorOption = (colors, accent = false) => {
+ let option = ''
for (i = 0; i < colors.length; i++) {
let color = colors[i]
- if (accent)
- var checked = window.localStorage["mdui-theme-accent"] == color ? " checked" : ''
- else
- var checked = window.localStorage["mdui-theme-primary"] == color ? " checked" : ''
+ let checked = window.localStorage[accent ? "mdui-theme-accent" : "mdui-theme-primary"] == color ? " checked" : ''
if (i <= (colors.length - 3 - 1) && accent || !accent)
option += `