-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathradio-ui.js
52 lines (37 loc) · 1.04 KB
/
radio-ui.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
function ajaxCall (name, onSuccess) {
$.ajax({
url: "/"+name,
dataType: "json",
success: onSuccess,
error: function(error, errorStr) { reportServerError(error, errorStr); }
});
}
function switchStation(name) {
ajaxCall(name, function(data) {
console.log(data);
$(".selected").removeClass('selected');
if (name != 'stop')
$("#"+name).addClass('selected');
$('.volume').val(data.volume);
});
}
function changeVolume(direction, button) {
ajaxCall(direction, function(data) {
$('.volume').val(data.volume);
});
}
function reportServerError(errorObject, errorString) {
alert(errorString);
// $('#errorPopup').text(errorString);
// $('#errorPopup').removeClass("hidden");
// $('#errorPopup').addClass("visible");
}
$('.station').unbind().on('click', function (event) {
switchStation(event.target.id);
});
$('.volumeup').unbind().on('click', function (event) {
changeVolume('up', $(this));
});
$('.volumedown').unbind().on('click', function (event) {
changeVolume('down', $(this));
});