forked from sebmatton/jQuery-Flight-Indicators
-
Notifications
You must be signed in to change notification settings - Fork 11
/
instrument_airspeed.html
executable file
·80 lines (61 loc) · 2.23 KB
/
instrument_airspeed.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
<!--
Skyhawk Flight Instruments (https://github.com/uw-ray/Skyhawk-Flight-Instruments)
By Raymond Blaga ([email protected]), Edward Hanna ([email protected]), Pavlo Kuzhel ([email protected])
Forked from jQuery Flight Indicators (https://github.com/sebmatton/jQuery-Flight-Indicators)
By Sébastien Matton ([email protected])
Published under GPLv3 License.
-->
<!DOCTYPE html>
<meta charset="utf-8">
<html lang="en" dir="ltr">
<head>
<title>Airspeed Indicator</title>
<script src="js/jquery-1.11.3.js"></script>
<script src="js/d3.min.js"></script>
<script src="js/jquery.flightindicators.js"></script>
<link rel="stylesheet" type="text/css" href="css/flightindicators.css" />
<script src="js/bootstrap.min.js"></script>
<link rel="stylesheet" href="css/bootstrap.min.css" />
</head>
<body>
<div class="examples text-center">
<div>
<span id="airspeed"></span>
</div>
<div>
<button id="airspeedButton" class="btn btn-default" type="submit">Button</button>
</div>
</div>
<script type="text/javascript">
var increment = 0;
var airspeed = $.flightIndicator('#airspeed', 'airspeed');
function sleep(milliseconds) {
var start = new Date().getTime();
for (var i = 0; i < 1e7; i++) {
if ((new Date().getTime() - start) > milliseconds) break;
}
}
function doAirSpeed(){
var myInterval = setInterval(function() {
// Airspeed update
airspeed.setAirSpeed(increment);
increment++;
if(increment == 300){
clearInterval(myInterval);
sleep(1000);
$("#airspeedButton").attr('disabled',false);
$("#airspeedButton").text("Start");
increment = 0;
airspeed.setAirSpeed(0);
}
}, 50);
}
$("#airspeedButton").text("Start");
$("#airspeedButton").on("click", function() {
$("#airspeedButton").attr('disabled', true);
$("#airspeedButton").text("Playing");
doAirSpeed();
});
</script>
</body>
</html>