This repository has been archived by the owner on Dec 4, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
events.js
82 lines (82 loc) · 1.73 KB
/
events.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
var search = require("./search")
document.querySelector("form").addEventListener("submit", function(e){
var torrents = document.querySelectorAll(".results > span")
for(var t = 0; t < torrents.length; t++){
results.removeChild(torrents[t])
}
lastData = []
lastSearch = {page: 2, query: searchBar.value}
search(1, searchBar.value)
e.preventDefault()
})
player.addEventListener("ended", next)
function next(){
fileId = file.nextId(fileId)
goBack = false
goFurther = false
song.playNext()
}
document.querySelector(".btn > input").addEventListener("input", function(){
player.volume = 1 * volume.value
if(1 * volume.value === 0){
buttons[1].innerHTML = "🔇"
}
else{
buttons[1].innerHTML = "🔉"
}
})
document.querySelector(".more").addEventListener("click", function(e){
search(lastSearch.page++, lastSearch.query)
e.preventDefault()
})
function changePlay(){
if(this.innerHTML === "⏸"){
buttons[0].innerHTML = "►"
player.pause()
}
else{
buttons[0].innerHTML = "⏸"
player.play()
}
this.onclick = changePlay
return false
}
player.onplay = function(){
buttons[0].innerHTML = "⏸"
}
player.onpause = function(){
buttons[0].innerHTML = "►"
}
buttons[0].onclick = changePlay
buttons[2].addEventListener("click", function(e){
goBack = true
next()
e.preventDefault()
})
buttons[3].addEventListener("click", function(e){
goFurther = true
next()
e.preventDefault()
})
buttons[4].addEventListener("click", function(e){
if(loop){
loop = false
this.className = ""
}
else{
loop = true
this.className = "active"
}
e.preventDefault()
})
buttons[5].addEventListener("click", function(e){
if(random){
random = false
this.className = ""
}
else{
random = true
this.className = "active"
}
e.preventDefault()
})