Skip to content

Commit

Permalink
Merge pull request #90 from gnehs/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
gnehs authored Oct 13, 2018
2 parents 47938ba + 0b7cbda commit 83aa124
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 47 deletions.
48 changes: 26 additions & 22 deletions dataModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ router.get("/home/", async(req, res) => {
resData.playlists.push(result.playlists[i]);
}
} catch (e) {
console.log(`[DataModules][${x.name}]發生了錯誤:(`, e);
showError(x.name, e)
}
}
}
Expand All @@ -106,7 +106,7 @@ router.post("/addPin/", async(req, res) => {
try {
res.json(await _module.addPin(req.query.type, req.query.id, req.query.name));
} catch (e) {
console.log(`[DataModules][${moduleList[moduleName].name}]發生了錯誤:(`, e);
showError(moduleList[moduleName].name, e)
return res.send("disabled");
}
});
Expand All @@ -122,7 +122,7 @@ router.post("/unPin/", async(req, res) => {
try {
res.json(await _module.unPin(req.query.type, req.query.id, req.query.name));
} catch (e) {
console.log(`[DataModules][${moduleList[moduleName].name}]發生了錯誤:(`, e);
showError(moduleList[moduleName].name, e)
return res.send("disabled");
}
});
Expand All @@ -138,7 +138,7 @@ router.post("/isPinned/", async(req, res) => {
try {
res.json(await _module.isPinned(req.query.type, req.query.id, req.query.name));
} catch (e) {
console.log(`[DataModules][${moduleList[moduleName].name}]發生了錯誤:(`, e);
showError(moduleList[moduleName].name, e)
return res.send("disabled");
}
});
Expand All @@ -161,7 +161,7 @@ router.get("/folders/", async(req, res) => {
folders.songs.push(folderList.songs[i]);
}
} catch (e) {
console.log(`[DataModules][${x.name}]發生了錯誤:(`, e);
showError(x.name, e)
}
}
}
Expand All @@ -183,7 +183,7 @@ router.get("/folderFiles/", async(req, res) => {
for (i = 0; i < info.folders.length; i++) resData.folders.push(info.folders[i]);
for (i = 0; i < info.songs.length; i++) resData.songs.push(info.songs[i]);
} catch (e) {
console.log(`[DataModules][${moduleName}]發生了錯誤:(`, e);
showError(moduleName, e)
}
return res.json(resData);
});
Expand Down Expand Up @@ -228,7 +228,7 @@ router.get("/search/", async(req, res) => {
resData.playlists.push(result.playlists[i]);
}
} catch (e) {
console.log(`[DataModules][${x.name}]發生了錯誤:(`, e);
showError(x.name, e)
}
}
}
Expand All @@ -250,7 +250,7 @@ router.get("/albums/", async(req, res) => {
albums.albums.push(albumList.albums[i]);
}
} catch (e) {
console.log(`[DataModules][${x.name}]發生了錯誤:(`, e);
showError(x.name, e)
}
}
}
Expand All @@ -271,7 +271,7 @@ router.get("/albumSongs/", async(req, res) => {
albumSongs = await _module.getAlbumSongs(req.query.data);
} catch (e) {
albumSongs = { songs: [] };
console.log(`[DataModules][${x.name}]發生了錯誤:(`, e);
showError(moduleName, e)
}
return res.json(albumSongs);
});
Expand All @@ -289,7 +289,7 @@ router.get("/album/", async(req, res) => {
try {
album = await _module.getAlbum(req.query.id);
} catch (e) {
console.log(`[DataModules][${x.name}]發生了錯誤:(`, e);
showError(x.name, e)
}
return res.json(album);
});
Expand All @@ -308,7 +308,7 @@ router.get("/playlists/", async(req, res) => {
for (i = 0; i < list.playlists.length; i++) r.playlists.push(list.playlists[i]);
}
} catch (e) {
console.log(`[DataModules][${x.name}]發生了錯誤:(`, e);
showError(x.name, e)
}
}
}
Expand All @@ -326,7 +326,7 @@ router.post("/playlists/", async(req, res) => {
try {
r = await _module.getPlaylists(req.body.playlists);
} catch (e) {
console.log(`[DataModules][${moduleName}]發生了錯誤:(`, e);
showError(moduleName, e)
}
return res.json(r || null);
});
Expand All @@ -343,7 +343,7 @@ router.get("/playlistSongs/", async(req, res) => {
try {
r = await _module.getPlaylistSongs(req.query.id);
} catch (e) {
console.log(`[DataModules][${moduleName}]發生了錯誤:(`, e);
showError(moduleName, e)
}
return res.json(r || null);
});
Expand All @@ -359,7 +359,7 @@ router.get("/userPlaylists/", async(req, res) => {
try {
r = await _module.getUserPlaylists();
} catch (e) {
console.log(`[DataModules][${moduleName}]發生了錯誤:(`, e);
showError(moduleName, e)
}
return res.json(r || null);
});
Expand All @@ -377,7 +377,7 @@ router.get("/artist/", async(req, res) => {
try {
r = await _module.getArtist(req.query.id);
} catch (e) {
console.log(`[DataModules][${moduleName}]發生了錯誤:(`, e);
showError(moduleName, e)
}
return res.json(r || null);
});
Expand All @@ -396,7 +396,7 @@ router.get("/artists/", async(req, res) => {
for (i = 0; i < list.artists.length; i++) r.artists.push(list.artists[i]);
}
} catch (e) {
console.log(`[DataModules][${x.name}]發生了錯誤:(`, e);
showError(x.name, e)
}
}
}
Expand All @@ -414,7 +414,7 @@ router.get("/artistAlbums/", async(req, res) => {
try {
r = await _module.getArtistAlbums(req.query.id);
} catch (e) {
console.log(`[DataModules][${moduleName}]發生了錯誤:(`, e);
showError(moduleName, e)
}
return res.json(r);
});
Expand All @@ -433,7 +433,7 @@ router.get("/composers/", async(req, res) => {
for (i = 0; i < list.composers.length; i++) r.composers.push(list.composers[i]);
}
} catch (e) {
console.log(`[DataModules][${x.name}]發生了錯誤:(`, e);
showError(x.name, e)
}
}
}
Expand All @@ -452,7 +452,7 @@ router.get("/composerAlbums/", async(req, res) => {
try {
r = await _module.getComposerAlbums(req.query.id);
} catch (e) {
console.log(`[DataModules][${moduleName}]發生了錯誤:(`, e);
showError(moduleName, e)
}
return res.json(r || { albums: [] });
});
Expand Down Expand Up @@ -529,7 +529,7 @@ router.get("/searchLyrics/", async(req, res) => {
for (i = 0; i < result.lyrics.length; i++)
resData.lyrics.push(result.lyrics[i]);
} catch (e) {
console.log(`[DataModules][${x.name}]發生了錯誤:(`, e);
showError(x.name, e)
}
}
}
Expand All @@ -546,7 +546,7 @@ router.get("/lyric/", async(req, res) => {
try {
lyric = await _module.getLyric(req.query.id);
} catch (e) {
console.log(`[DataModules][${moduleName}]發生了錯誤:(`, e);
showError(moduleName, e)
}
return res.json({
lyrics: [{
Expand All @@ -570,7 +570,7 @@ router.get("/randomSongs/", async(req, res) => {
if (result && result.songs)
for (i = 0; i < result.songs.length; i++) resData.songs.push(result.songs[i]);
} catch (e) {
console.log(`[DataModules][${x.name}]發生了錯誤:(`, e);
showError(x.name, e)
}
}
}
Expand All @@ -581,4 +581,8 @@ router.use((req, res, next) => {
res.status(404).send("PokaPlayer API - 404");
});

function showError(moduleName = false, error) {
console.log(`[DataModules]${moduleName?`[${moduleName}]`:''}發生了錯誤:(`);
console.error(e);
}
module.exports = router;
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ app.set("views", __dirname + "/views");
app.set("view engine", "pug");
app.use(bodyParser.urlencoded({ extended: true }));
app.use(helmet());
app.use(helmet.hidePoweredBy({ setTo: 'PHP 4.2.0' }))
app.use(session);
io.use(
sharedsession(session, {
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pokaplayer",
"version": "0.12.6",
"version": "0.12.7",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
10 changes: 10 additions & 0 deletions public/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,16 @@ header.mdui-appbar.mdui-appbar-fixed {
--album-size: calc(25% - 2em);
}

.poka.ten.cards .card {
--album-size: calc(10% - 2em);
}

@media (max-width: 575.98px) {
.poka.doubling.ten.cards .card {
--album-size: calc(20% - 2em);
}
}

#aplayer:not(.show) {
visibility: hidden;
height: 0;
Expand Down
30 changes: 30 additions & 0 deletions public/js/long-press.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*!
* long-press.js
* Pure JavaScript long-press event
* https://github.com/john-doherty/long-press
* @author John Doherty <www.johndoherty.info>
* @license MIT
*/
! function(t, e) {
"use strict";

function n() { this.dispatchEvent(new CustomEvent("long-press", { bubbles: !0, cancelable: !0 })), clearTimeout(o), console && console.log && console.log("long-press fired on " + this.outerHTML) }
var o = null,
u = "ontouchstart" in t || navigator.MaxTouchPoints > 0 || navigator.msMaxTouchPoints > 0,
s = u ? "touchstart" : "mousedown",
i = u ? "touchcancel" : "mouseout",
a = u ? "touchend" : "mouseup",
c = u ? "touchmove" : "mousemove";
"initCustomEvent" in e.createEvent("CustomEvent") && (t.CustomEvent = function(t, n) { n = n || { bubbles: !1, cancelable: !1, detail: void 0 }; var o = e.createEvent("CustomEvent"); return o.initCustomEvent(t, n.bubbles, n.cancelable, n.detail), o }, t.CustomEvent.prototype = t.Event.prototype), e.addEventListener(s, function(t) {
var e = t.target,
u = parseInt(e.getAttribute("data-long-press-delay") || "1500", 10);
o = setTimeout(n.bind(e), u)
}), e.addEventListener(a, function(t) { clearTimeout(o) }), e.addEventListener(i, function(t) { clearTimeout(o) }), e.addEventListener(c, function(t) { clearTimeout(o) })
}(this, document);

/*
* //listen for long-press events
* document.addEventListener('long-press', function(e) {
* e.target.setAttribute('data-editing', 'true');
* });
*/
2 changes: 2 additions & 0 deletions public/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,8 @@ async function showHome() {
if ($("#content").attr('data-page') == 'home') {
let parseResult = template.parseHome(result)
$("#content").html(parseResult != '' ? parseResult : nothingHere)
//初始化
mdui.mutation()
router.updatePageLinks()
}
}
Expand Down
19 changes: 9 additions & 10 deletions public/js/setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ async function showSettings() {
${settingsItem("網路和快取","流量節省、音質和快取設定","public","settings/network")}
${settingsItem("個人化","隨機圖片、主題配色、其他細節設定","face","settings/customize")}
${settingsItem("系統和更新","更新 PokaPlayer、重新啟動","system_update","settings/system")}
${settingsItem("關於","一些連結和開發者的資料","info","settings/about","data-about")}
${settingsItem("關於","PokaPlayer 相關訊息、錯誤回報等","info","settings/about","data-about")}
</ul>`
$("#content").html(settingItems);
}
Expand Down Expand Up @@ -330,7 +330,7 @@ async function showSettingsCustomize() {
});
$('[data-theme="mdui-theme-primary"],[data-theme="mdui-theme-accent"]').click(function() {
let accent = $(this).attr('data-theme')=="mdui-theme-accent",
option = `<br><div class="poka four cards" style="text-transform:capitalize;">`,
option = `<br><div class="poka ten doubling cards" style="text-transform:capitalize;">`,
colors = ['red','pink','purple','deep-purple','indigo','blue','light-blue','cyan','teal','green','light-green','lime','yellow','amber','orange','deep-orange','brown','grey','blue-grey']
for (i = 0 ; i < colors.length; i++) {
if (i<= (colors.length - 3 - 1) && accent || !accent){
Expand All @@ -341,7 +341,7 @@ async function showSettingsCustomize() {
data-color-type="${accent ? `accent` : `primary`}"
data-color="${color}">
<div class="image mdui-ripple mdui-color-${color}${accent?'-accent':''}"></div>
<div class="title mdui-text-color-theme-text">${color.replace("-"," ")}</div>
<!--<div class="title mdui-text-color-theme-text">${color.replace("-"," ")}</div>-->
</a>`
}
}
Expand All @@ -357,7 +357,7 @@ async function showSettingsCustomize() {
}
});
$('[data-color-type]').click(function(){
let isAccent= $(this).attr('data-color-type') == "accent"
let isAccent = $(this).attr('data-color-type') == "accent"
let color = $(this).attr('data-color')
let classStr = $('body').attr('class');
let classes = classStr.split(' ');
Expand Down Expand Up @@ -484,9 +484,8 @@ async function showSettingsCustomize() {
})
});
$('[data-pic-custom-link]').click(function(){
//似乎有 bug
let img=prompt("請輸入圖片網址", "https://images2.imgbox.com/99/e2/knJdNcns_o.jpg");
if(img != null){
let img = prompt("請輸入圖片網址", "https://images2.imgbox.com/99/e2/knJdNcns_o.jpg");
if (img != null){
window.localStorage["randomImg"] = img
$('[data-pic-custom-link] .mdui-list-item-text').text(img)
$('[data-pic-source] .mdui-list-item-text').text("自訂")
Expand All @@ -511,9 +510,9 @@ async function showSettingsAbout() {

// 點七次的彩蛋蛋
$("[data-version]").click(function(){
let click=$(this).attr("data-click")
$(this).attr("data-click",click?Number(click)+1:1)
if(Number(click)+1==7){
let click = $(this).attr("data-click")?Number($(this).attr("data-click"))+1:1
$(this).attr("data-click",click)
if (click == 7){
$(this).attr("data-click",0)
s = document.createElement('script');
s.src = 'https://anohito.tw/thisUnitIsAFlippinPlatelet/flippin_platelet.js';
Expand Down
Loading

0 comments on commit 83aa124

Please sign in to comment.