summaryrefslogtreecommitdiff
path: root/static/init.js
blob: 6ec272527ce011d53939089434321522466e0d46 (plain)
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
soundManager.useHTML5Audio = true;
soundManager.preferFlash = false;

$(document).ready(function() {
	$.get('/json/list', function(data) {
		var dir_list = $('#directory-list');
		$.each(data, function(i, item) {
			dir_list.append($('<li></li>')
				.text(item.name)
				.addClass(item.type)
				.click(function() {
					console.log(item);
					var sound = soundManager.createSound({
						id: 'audio',
						url: '/track/' + item.id,
						whileplaying: function() {
							var seconds = (sound.position / 1000).toFixed(0);
							var minutes = Math.floor(seconds / 60).toFixed(0);
							seconds %= 60;
							if(seconds < 10)
								seconds = '0' + seconds;
							var pos = minutes + ':' + seconds;
							$('#status').text(pos);
						}
					});
					sound.play();
				})
			);
		});
	});
});