-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.html
95 lines (66 loc) · 2.4 KB
/
test.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
<!-- Prototype dynamic meeting web page
Author: Keith Blackstock
University: WPI
License: Open Source usage allowed
-->
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<meta charset="utf-8"/>
</head>
<body>
<input id="audio1" type="button" value="Click here to enable audio" onclick="playSound()"> <br>
<a href="index.html"> links first page </a>
<script>
var sound = new Audio();
var soundfile = "./file_example_MP3_700KB.mp3";
function playSound() {
sound.src = soundfile;
console.log("SOUND:" + sound.currentTime);
if (sound.currentTime == 0) {
var playPromise = sound.play();
}
}
function changeBGImage(imagefile, soundf){
if (document.body.background != "drawing_board.J3.jpg" ) {
document.body.background = imagefile;
document.body.style.backgroundRepeat = "repeat-y";
document.body.style.background = "background-repeat: no-repeat;background-position: 0% 0%";
soundfile = soundf;
document.getElementById("audio1").click();
}
}
changeBGImage("test-html1.jpg","" ); // load start image
// event handler function
function handler(e) {
e = e || window.event;
var pageX = e.pageX;
var pageY = e.pageY;
// IE 8
if (pageX === undefined) {
pageX = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
pageY = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
}
console.log("hi Keith: " + pageX, pageY);
if (((pageX > 622) && (pageX < 812)) && ((pageY > 450) && (pageY < 620))) {
console.log("target1");
changeBGImage("drawing_board.J3.jpg","./file_example_MP3_700KB.mp3" );
} else if (((pageX > 300) && (pageX < 500)) && ((pageY > 550) && (pageY < 650))) {
console.log("target2");
changeBGImage("drawing_board.J.jpg","viola.mp3" );
} else if (((pageX > 510) && (pageX < 600)) && ((pageY > 500) && (pageY < 570))) {
console.log("target3");
changeBGImage("drawing_board.J2.jpg","" );
} else {
changeBGImage("test-html1.jpg","" );
}
}
// attach handler to the click event of the document
// if (document.attachEvent) document.attachEvent('onclick', handler);
if (document.attachEvent) document.attachEvent('onmousemove', handler);
else document.addEventListener('mousemove', handler);
// else document.addEventListener('click', handler);
</script>
</body>
</html>