-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvibration.html
71 lines (64 loc) · 2.16 KB
/
vibration.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="UTF-8">
<title>Vibration API</title>
<!-- Le styles -->
<link href="css/bootstrap.css" rel="stylesheet">
<link href="css/custom.css" rel="stylesheet">
<link href="css/bootstrap-responsive.css" rel="stylesheet">
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="index.html">Device APIs demos</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li class="active"><a href="index.html">Home</a></li>
<li><a href="about.html">About/Contact</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>
<!-- Important bit starts HERE -->
<div class="container">
<div class="row-fluid">
<div class="span12"><p class="lead">Triggering Device Vibration</p> </div>
</div>
<div class="row-fluid">
<div id="grid" class="span12"><p id="supported"></p> <div id="doVibrate"></div>
</div>
</div>
</div>
</div>
<script src="js/jquery.js"></script>
<script src="js/utils.js"></script>
<script type="text/javascript">
support= $('#supported');
var supportsVibrate = "vibrate" in navigator;
if (supportsVibrate) {
support.html("Vibration API is supported! How nice! :-)");
doVibrate= $('#doVibrate');
doVibrate.append('<button>Vibrate</button>');
doVibrate.append('<p>');
doVibrate.bind('click', function () {
colored = $("<p>Did you notice that?! :-) <img src=img/vibration.jpg class='icon_large' /></p>");
changeTextColor(colored);
doVibrate.append(colored);
navigator.vibrate(1000);
});
}
else {
support.html("NOT supported. Buggers! >:( <img src=img/vibration.jpg class='icon_large' />");
}
</script>
</body>
</html>