-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjuke.js
94 lines (82 loc) · 1.82 KB
/
juke.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
//example easing functions
function linearEase(currentIteration, startValue, changeInValue, totalIterations)
{
return changeInValue * currentIteration / totalIterations + startValue;
}
function easeOutCubic(currentIteration, startValue, changeInValue, totalIterations)
{
return changeInValue * (Math.pow(currentIteration / totalIterations - 1, 3) + 1) + startValue;
}
function updateFileList()
{
var fileList = document.getElementById('fileList');
var listHtml = '';
for (var i = 0; i < songList.length; i++)
{
var song = songList[i];
listHtml = listHtml + song.title + '<BR>';
}
fileList.innerHTML = listHtml;
}
function addFile(file, i)
{
if (file)
{
var song = new Song(i, file, updateFileList);
songList.push(song);
}
}
function addFiles(e)
{
var files = e.target.files;
songCount = files.length;
for (var i = 0; i < songCount; i++)
{
addFile(files[i], i);
}
}
function hideDiv(div)
{
div.classList.add('hiddenDiv');
}
function unHideDiv(div)
{
div.classList.remove('hiddenDiv');
}
function startPlayer()
{
if (songList.length == 0)
{
alert('Add some song files first!');
}
else
{
maxRests = songList.length / 2;
var buttons = document.getElementById('buttons');
var manage = document.getElementById('manage');
manage.classList.add('hiddenDiv');
for (var i = 0; i < songList.length; i++)
{
var song = songList[i];
song.drawButton(buttons);
song.loadAudio();
}
}
}
function AddListeners()
{
document.getElementById('addFiles').addEventListener('change', addFiles, false);
document.getElementById('startPlayer').addEventListener('click', startPlayer, false);
}
function appStart()
{
AddListeners();
}
(function ()
{
window.onload = appStart;
window.onbeforeunload = function ()
{
return "Are you sure?";
};
})();