-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
67 lines (49 loc) · 2.08 KB
/
script.js
File metadata and controls
67 lines (49 loc) · 2.08 KB
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
function getStatus() {
$.get('status.php', function(resp){
var parsed = $.parseJSON(resp);
$('.current-temp dd').text(parsed.temperature).append('℉');
$('.ideal-temp').val(parsed.desired);
$('.temp-readout').text(parsed.desired).append('℉');
$('.comp-status dd').text(parsed.cool==1?'On':'Off');
$('.comp-status').removeClass('status-is-1', 'status-is-0').addClass('status-is-'+parsed.cool);
$('.heat-status dd').text(parsed.heat==1?'On':'Off');
$('.heat-status').removeClass('status-is-1', 'status-is-0').addClass('status-is-'+parsed.heat);
$('.fan-status dd').text(parsed.fan==1?'On':'Off');
$('.fan-status').removeClass('status-is-1', 'status-is-0').addClass('status-is-'+parsed.fan);
$('.coil-temp dd').text(parsed.ac_coil_temp).append('℉');
$('.coil-cutoff-temp dd').text(parsed.ac_coil_protect).append('℉');
$('.latency dd').text(parsed.latency+'s');
});
}
function setDesiredTemp(desiredTemp) {
$.get('set.php?temp='+desiredTemp, getStatus);
}
$(function(){
$('.ideal-temp').hide().on('change', function(){
setDesiredTemp( $(this).val() );
});
$('#show-advanced-features').on('change', function(){
if( this.checked ) {
$('.advanced').show();
} else {
$('.advanced').hide();
}
});
$('body').on('dblclick', '.temperature-set button.temp-up', function(){
var input = $(this).closest('.temperature-set').find('input');
input.val( parseInt(input.val()) + 10 ).trigger('change');
});
$('body').on('click', '.temperature-set button.temp-up', function(){
var input = $(this).closest('.temperature-set').find('input');
input.val( parseInt(input.val()) + 1 ).trigger('change');
});
$('body').on('click', '.temperature-set button.temp-dn', function(){
var input = $(this).closest('.temperature-set').find('input');
input.val( parseInt(input.val()) - 1 ).trigger('change');
});
$('body').on('dblclick', '.temperature-set button.temp-dn', function(){
var input = $(this).closest('.temperature-set').find('input');
input.val( parseInt(input.val()) - 10 ).trigger('change');
});
window.setInterval(getStatus, 2000);
});