-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.htm
79 lines (62 loc) · 2.37 KB
/
index.htm
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
<!DOCTYPE html>
<html>
<head>
<title>touchbuttons</title>
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css" rel="stylesheet">
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<audio id="soundYe" style="display: none;">
<source src="horse.mp3" type="audio/mpeg">
</audio>
<audio id="soundNo" style="display: none;">
<source src="buzz.mp3" type="audio/mpeg">
</audio>
<style>
body {
padding: 0;
overflow: hidden;
}
h1 {
margin: 30px;
text-align: center;
}
.square {
position: absolute;
background: #9fe1e7;
border-radius: 0px;
width: 200px;
height: 400px;
}
.square1 { background: #42d692; left: 100px; top: 100px;}
.square2 { background: #4986e7; left: 400px; top: 100px;}
.square3 { background: #d64242; left: 700px; top: 100px;}
.highlight{background: yellow;}
</style>
</head>
<body id="body">
<h1>Touch the squares!</h1>
<div class="square square1" id="rect_green">t</div>
<div class="square square2" id="rect_blue">t</div>
<div class="square square3" id="rect_red">t</div>
<script>
var itemInHand = 0;
var soundYe=document.getElementById("soundYe");
var soundNo=document.getElementById("soundNo");
var obj = new Array('green', 'blue', 'red');
for(i=0;i<=2;i++){
obj[i] = document.getElementById('rect_'+obj[i]);
obj[i].addEventListener('touchstart', function(event) {
soundYe.pause(); soundNo.pause();
if ('rect_'+itemInHand==this.getAttribute("id")){
//this.textContent = "YEEES";
soundYe.play();
}else{
//this.textContent = "NOOOO";
soundNo.play();
}
}, false );
} // test test
document.body.addEventListener('touchmove', function(event) { event.preventDefault();}, false);
</script>
</body>
</html>