-
Notifications
You must be signed in to change notification settings - Fork 0
/
camera.html
116 lines (99 loc) · 3.62 KB
/
camera.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
110
111
112
113
114
115
116
<!DOCTYPE html>
<html lang="en">
<HEAD>
<TITLE>Camera Controller</TITLE>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="http://netdna.bootstrapcdn.com/bootswatch/2.3.2/slate/bootstrap.min.css" rel="stylesheet">
<script src="http://code.jquery.com/jquery.js"></script>
<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
<style>
.wrapper {
margin : 5px;
}
[class^="icon-"], [class*=" icon-"] {
width: 12px;
}
.red-led.active {
color: red;
}
.green-led.active {
color: green;
}
</style>
</HEAD>
<BODY style="width:380px;">
<div class="navbar">
<div class="navbar-inner">
<ul class="nav">
<li><a href="180"><i class="icon-fast-backward icon-white"></i></a></li>
<li><a href="135"><i class="icon-step-backward icon-white"></i></a></li>
<li><a href="LEFT"><i class="icon-backward icon-white"></i></a></li>
<li><a href="90"><i class="icon-arrow-up icon-white"></i></a></li>
<li><a href="RIGHT"><i class="icon-forward icon-white"></i></a></li>
<li><a href="45"><i class="icon-step-forward icon-white"></i></a></li>
<li><a href="0"><i class="icon-fast-forward icon-white"></i></a></li>
</ul>
</div>
</div>
<div class="container-fluid">
<div class="row-fluid">
<div class="span10">
<img src="https://lh6.googleusercontent.com/hu8Xxe5ixOnxjn583L_Han3jMllKSGQ0EcbEbFsYuic=w281-h210-p-no"/>
<div id="levelBar" class="progress">
<div class="bar bar-error" style="width: #PCT#%;"></div>
<div class="bar bar-success" style="width: #RPCT#%;"></div>
</div>
</div>
<div class="row-fluid">
<div class="input-append span6">
<input class="span3" id="moveValue" type="text">
<button id="moveButton" class="btn" type="button">Move</button>
</div>
<div id="btn-power" class="btn-group span6" xdata-toggle="buttons-radio">
<button type="button" class="btn btn-primary green-led active">On</button>
<button type="button" class="btn btn-primary red-led">Off</button>
</div>
</div>
<div class="span3">
</div>
</div>
</div>
<script>
$(function(){
// Quick validation for numeric content
function isNumber(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}
// set the bar position/
function setBar(position) {
if (!isNumber(position))
return
$("#moveValue").val(position)
$(".bar-error").width(100 -parseInt((position/180)*100,10) + "%")
$(".bar-success").width(parseInt((position/180)*100,10) + "%")
};
function moveCamera(position) {
setBar(position);
$.ajax("/"+position+"?ajax=1");
};
$("#moveButton").click(function(){
moveCamera(parseInt($("#moveValue").val() , 10))
});
$("#levelBar").click(function(e){
var scale = 180 / $(this).width(), x = e.pageX - $(this).position().left
moveCamera(parseInt(180 - (x * scale) , 10))
});
$("A").click(function(e){
moveCamera($(this).attr("href"))
e.stopPropagation();
return false;
});
$("#btn-power").click(function() {
$('#btn-power button').toggleClass('active');
console.log("clickety" , $("#btn-power button .active").text())
});
setBar(#POS#);
});
</script>
</BODY>
</HTML>