Skip to content

Commit

Permalink
Merge pull request #23 from gnehs/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
gnehs authored Aug 18, 2018
2 parents 9f77bd1 + 0863bfb commit 05af6b4
Show file tree
Hide file tree
Showing 5 changed files with 1,821 additions and 1,820 deletions.
6 changes: 3 additions & 3 deletions js/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async function getLrc(artist, title, id = false) {
result = false,
lrc;
// 如果沒有設定或是設定是 DSM,進行 DSM 搜尋
if (window.localStorage["lrcSource"] == 'dsm' || !window.localStorage["lrcSource"]) {
if (window.localStorage["lrcSource"] == 'DSM' || !window.localStorage["lrcSource"]) {
if (id) {
result = (await getAPI("AudioStation/lyrics.cgi", "SYNO.AudioStation.Lyrics", "getlyrics", [{ key: "id", "value": id }], 2)).data.lyrics
if (result.match(lyricRegex))
Expand All @@ -53,7 +53,7 @@ async function getLrc(artist, title, id = false) {
}
}
// 如果設定是 meting
if (window.localStorage["lrcSource"] == 'meting') {
if (window.localStorage["lrcSource"] == 'Meting') {
let search = await getMetingSearchResult(`${title} ${artist}`)
// 歌名必須匹配才找歌詞
if (search && search.name.toUpperCase() == title.toUpperCase())
Expand Down Expand Up @@ -86,7 +86,7 @@ async function getMetingLrcById(id) {
//- 取得歌曲連結
function getSong(song) {
let id = song.id
let res = window.localStorage["musicRes"]
let res = window.localStorage["musicRes"].toLowerCase()
let bitrate = song.additional.song_audio.bitrate / 1000
if (res == "wav" && bitrate > 320)
res = "wav"
Expand Down
8 changes: 1 addition & 7 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ const ap = new APlayer({
fixed: true
});

// 避免關閉 meting 後歌詞模組錯誤
axios.get('/meting').then(data => {
let metingIsEnabled = data.data.enabled;
if (!metingIsEnabled && window.localStorage["lrcSource"] == 'meting') window.localStorage.removeItem("lrcSource")
})

// 路由
const router = new Navigo(null, true, '#!');
router
Expand Down Expand Up @@ -834,7 +828,7 @@ function getSnackbarPosition() {
}

async function showLrcChoose() {
if (ap.list.audios[ap.list.index] && window.localStorage["lrcSource"] == 'meting') {
if (ap.list.audios[ap.list.index] && window.localStorage["lrcSource"] == 'Meting') {
let nowPlaying = ap.list.audios[ap.list.index],
name = nowPlaying.name || '',
artist = nowPlaying.artist || ''
Expand Down
61 changes: 34 additions & 27 deletions js/setting.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
// 初始化設定值
$(async() => {
///給定預設值
if (!window.localStorage["musicRes"]) window.localStorage["musicRes"] = "wav"
if (!window.localStorage["musicRes"]) window.localStorage["musicRes"] = "WAV"
if (!window.localStorage["randomImg"]) window.localStorage["randomImg"] = "/og/og.png"
if (!window.localStorage["randomImgName"]) window.localStorage["randomImgName"] = "預設圖庫"
if (!window.localStorage["lrcSource"]) window.localStorage["lrcSource"] = "dsm"
window.localStorage["lrcMetingUrl"] = (await axios.get('/meting')).data.url
if (!window.localStorage["lrcSource"]) window.localStorage["lrcSource"] = "DSM"
let lrcMetingEnabled = (await axios.get('/meting')).data.enabled
if (lrcMetingEnabled) {
window.localStorage["lrcMetingEnabled"] = "true"
window.localStorage["lrcMetingUrl"] = (await axios.get('/meting')).data.url
} else {
// 避免關閉 meting 後歌詞模組錯誤
window.localStorage["lrcSource"] = "DSM"
window.localStorage["lrcMetingEnabled"] = "false"
}
window.localStorage["PokaPlayerVersion"] = (await axios.get('/info/')).data.version
});

Expand All @@ -24,7 +32,7 @@ async function showSettings() {
}
let settingItems = `<ul class="mdui-list">
${item("主題","設定主題色、主色及強調色","color_lens","settings/theme")}
${item("音質",window.localStorage["musicRes"].toUpperCase(),"music_note","","data-music-res")}
${item("音質",window.localStorage["musicRes"],"music_note","","data-music-res")}
<li class="mdui-list-item mdui-ripple" data-imgRes>
<i class="mdui-list-item-icon mdui-icon material-icons">image</i>
<div class="mdui-list-item-content">
Expand All @@ -37,7 +45,7 @@ async function showSettings() {
</label>
</li>
${item("隨機圖片",window.localStorage["randomImgName"],"shuffle","settings/pic")}
${item("歌詞來源",window.localStorage["lrcSource"].toUpperCase(),"subtitles","","data-lrc-source")}
${item("歌詞來源",window.localStorage["lrcSource"],"subtitles","","data-lrc-source")}
${item("關於","PokaPlayer "+window.localStorage["PokaPlayerVersion"],"info","settings/about","data-about")}
</ul>`
$("#content").html(header + settingItems);
Expand All @@ -46,19 +54,19 @@ async function showSettings() {
mdui.dialog({
title: '音質設定',
content: `<ul class="mdui-list">
<li class="mdui-list-item mdui-ripple" onclick="window.localStorage['musicRes']='mp3'" mdui-dialog-close>
<li class="mdui-list-item mdui-ripple" onclick="window.localStorage['musicRes']='MP3'" mdui-dialog-close>
<div class="mdui-list-item-content">
<div class="mdui-list-item-title">MP3</div>
<div class="mdui-list-item-text">128K,夭壽靠北,在網路夭壽慢的情況下請選擇此選項</div>
</div>
</li>
<li class="mdui-list-item mdui-ripple" onclick="window.localStorage['musicRes']='wav'" mdui-dialog-close>
<li class="mdui-list-item mdui-ripple" onclick="window.localStorage['musicRes']='WAV'" mdui-dialog-close>
<div class="mdui-list-item-content">
<div class="mdui-list-item-title">WAV</div>
<div class="mdui-list-item-text">較高音質,音質較原始音質略差,可在 4G 網路下流暢的串流</div>
</div>
</li>
<li class="mdui-list-item mdui-ripple" onclick="window.localStorage['musicRes']='original'" mdui-dialog-close>
<li class="mdui-list-item mdui-ripple" onclick="window.localStorage['musicRes']='Original'" mdui-dialog-close>
<div class="mdui-list-item-content">
<div class="mdui-list-item-title">Original</div>
<div class="mdui-list-item-text">原始音質,在網路狀況許可下,建議選擇此選項聆聽高音質音樂</div>
Expand All @@ -69,40 +77,39 @@ async function showSettings() {
buttons: [{
text: '取消'
}],
onClose: ()=>$("[data-music-res] .mdui-list-item-text").text(window.localStorage["musicRes"].toUpperCase())
onClose: ()=>$("[data-music-res] .mdui-list-item-text").text(window.localStorage["musicRes"])
});

});
// 圖片流量節省
$("[data-imgRes]").click(function() {
$("[data-imgRes] input").prop('checked', !$("[data-imgRes] input").prop('checked'))
window.localStorage["imgRes"] = $("[data-imgRes] input").prop('checked');
$("[data-imgRes] .mdui-list-item-text").text($("[data-imgRes] input").prop('checked') ? "已開啟" : "已關閉");
});
$("[data-lrc-source]").click(async function() {
let isMetingEnabled = (await axios.get('/meting')).data.enabled
$("[data-lrc-source]").click( function() {
let isMetingEnabled = window.localStorage["lrcMetingEnabled"] == "true"
mdui.dialog({
title: '歌詞來源',
content: `<ul class="mdui-list">
<li class="mdui-list-item mdui-ripple" onclick="window.localStorage['lrcSource']='dsm'" mdui-dialog-close>
<div class="mdui-list-item-content">
<div class="mdui-list-item-title">DSM</div>
<div class="mdui-list-item-text">使用 DSM 當中的歌詞搜尋器</div>
</div>
</li>
<li class="mdui-list-item mdui-ripple ${isMetingEnabled?"":"mdui-hidden"}" onclick="${isMetingEnabled?"window.localStorage['lrcSource']='meting'":''}" mdui-dialog-close>
<div class="mdui-list-item-content">
<div class="mdui-list-item-title">Meting</div>
<div class="mdui-list-item-text">Meting, such a powerful music API framework</div>
</div>
</li>
</ul>`,
<li class="mdui-list-item mdui-ripple" onclick="window.localStorage['lrcSource']='DSM'" mdui-dialog-close>
<div class="mdui-list-item-content">
<div class="mdui-list-item-title">DSM</div>
<div class="mdui-list-item-text">使用 DSM 當中的歌詞搜尋器</div>
</div>
</li>
<li class="mdui-list-item mdui-ripple ${isMetingEnabled?"":"mdui-hidden"}" onclick="${isMetingEnabled?"window.localStorage['lrcSource']='Meting'":''}" mdui-dialog-close>
<div class="mdui-list-item-content">
<div class="mdui-list-item-title">Meting</div>
<div class="mdui-list-item-text">Meting, such a powerful music API framework</div>
</div>
</li>
</ul>`,
history: false,
buttons: [{
text: '取消'
}],
onClose: ()=>$("[data-lrc-source] .mdui-list-item-text").text(window.localStorage["lrcSource"].toUpperCase())
});
onClose: () => $("[data-lrc-source] .mdui-list-item-text").text(window.localStorage["lrcSource"])
});
});
}
async function showSettingsTheme() {
Expand Down
Loading

0 comments on commit 05af6b4

Please sign in to comment.