-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
110 lines (87 loc) · 1.91 KB
/
index.html
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
106
107
108
109
<html>
<style>
div {
font-family: "Courier New", Courier, monospace;
font-size: xx-small;
}
</style>
<script type="text/javascript" src="jquery-1.7.1.min.js"></script>
<script>
function dump(a) {
var e = document.getElementById("log");
e.innerHTML = e.innerHTML + ". " + a;
}
function updateVolume() {
$.getJSON('StatusHandler.asp', function (data) {
volumeSetting = data.Z[0].V;
volumeSetting-=161;
volumeSetting*=0.5;
updateVolumeTxt();
});
};
function updateVolumeTxt() {
$("#db").html(volumeSetting +"dB");
}
var volumeChangeInProgress=false;
function changeVolume(up) {
if (volumeChangeInProgress)
return;
volumeChangeInProgress = true;
var url = 'EventHandler.asp?WebToHostItem=';
if (up)
url += 'VU';
else
url += 'VD';
$.ajax({
type: 'GET',
url: url,
dataType: "text", // pioneer sends back invalid json.
success: function(json) {
// to prevent a round trip, just nudge this up.
if (up)
volumeSetting += 0.5;
else
volumeSetting -= 0.5;
updateVolumeTxt();
volumeChangeInProgress = false;
},
error: function(x,y,z) {
dump("changeVolume resulted in an error.... " + x + " " + y + " " + z);
volumeChangeInProgress = false;
}
});
}
function volumeUp(){
changeVolume(true);
}
function volumeDown(){
changeVolume(false);
}
var volumeSetting = false;
var timeout;
$(document).ready(function() {
updateVolume();
$('#up')
.mousedown(function() {
timeout = setInterval(function(){
volumeUp();
}, 50);
});
$('#down')
.mousedown(function() {
timeout = setInterval(function(){
volumeDown();
}, 50);
});
$(document).mouseup(function(){
clearInterval(timeout);
return false;
});
});
</script>
<div id="db"></div>
<div id="volume">
<button id="up">+</button>
<button id="down">-</button>
</div>
<div id="log"></div>