-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
105 lines (92 loc) · 2.17 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// initialize current page
var current = 'browse'
// play mode
var currentPlayMode = 'normal'
var playerHide = true
// player setup
var player = document.getElementById('player')
var isStop = true
// music list
var currentIndex = 0
var isUserNameInputShow = false
var allTracks = [
{
img: './img/songsImg/faded.jpg',
url: './songs/song1.mp3',
name: 'Faded',
singer: 'Alan Walker',
album: 'Different World',
duration: '3:33',
},
{
img: './img/songsImg/autumn.jpg',
url: './songs/song2.mp3',
name: 'Autumn Leaves',
singer: 'Unknown',
album: 'Instrument',
duration: '7:01',
},
{
img: './img/songsImg/slamdumk.jpg',
url: './songs/song3.mp3',
name: 'Slam Dumk',
singer: 'Unknown',
album: 'Instrument',
duration: '2:37',
},
{
img: './img/songsImg/cherry.jpg',
url: './songs/song4.mp3',
name: 'Cherry blossom time',
singer: 'Kotaro Oshio',
album: 'Unknown',
duration: '3:39',
},
{
img: './img/songsImg/lovesong.jpg',
url: './songs/song5.mp3',
name: '情歌',
singer: '梁静茹',
album: '静茹&情歌',
duration: '4:18',
},
]
player.src = allTracks[currentIndex].url
/*
show current page
*/
function showCurrentPage(currentPage) {
switchCurrentPageName(currentPage)
let pageArr = document.getElementsByClassName('page')
for (item of pageArr) {
item.style.display = 'none'
}
let current = document.getElementById(currentPage)
if (current) {
current.style.transform = 'scale(0)'
current.style.display = 'block'
setTimeout(() => {
current.style.transform = 'scale(1)'
}, 300)
}
}
function switchCurrentPageName(currentPageName) {
if (!playerHide) hidePlayer()
document.getElementById('currentPageName').innerText = currentPageName.toUpperCase()
}
showCurrentPage(current)
function getClass(className) {
return document.getElementsByClassName(className)[0]
}
function getId(idName) {
return document.getElementById(idName)
}
function showUserInput() {
isUserNameInputShow = true
renderAvatar()
}
function userNameChange(e) {
localStorage.setItem('username', e.target.value)
isUserNameInputShow = false
renderAvatar()
}