-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxylo.js
132 lines (131 loc) · 3.11 KB
/
xylo.js
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
var r = document.getElementById("red");
r.addEventListener('click',myPlay);
var audio1 = new Audio('note1.wav');
function myPlay(){
audio1.play();
}
var o = document.getElementById("orange");
o.addEventListener('click',myPlay1);
var audio2 = new Audio('note2.wav');
function myPlay1(){
audio2.play();
}
var y = document.getElementById("yellow");
y.addEventListener('click',myPlay2);
var audio3 = new Audio('note3.wav');
function myPlay2(){
audio3.play();
}
var g = document.getElementById("green");
g.addEventListener('click',myPlay3);
var audio4 = new Audio('note4.wav');
function myPlay3(){
audio4.play();
}
var b = document.getElementById("blue");
b.addEventListener('click',myPlay4);
var audio5 = new Audio('note5.wav');
function myPlay4(){
audio5.play();
}
var i = document.getElementById("indigo");
i.addEventListener('click',myPlay5);
var audio6 = new Audio('note6.wav');
function myPlay5(){
audio6.play();
}
var v = document.getElementById("violet");
v.addEventListener('click',myPlay6);
var audio7 = new Audio('note7.wav');
function myPlay6(){
audio7.play();
}
window.addEventListener("keypress",function(event){
switch(event.key){
case "c" :
case "C" : myPlay();
break;
case "d":
case "D":myPlay1();
break;
case "e":
case "E":myPlay2();
break;
case "f":
case "F":myPlay3();
break;
case "g":
case "G":myPlay4();
break;
case "a":
case "A":myPlay5();
break;
case "b":
case "B":myPlay6();
break;
}
});
// 88 minutes for javascript
/*
$("#red").click(function f1(){
var audio = new Audio("note1.wav");
audio.play();
});
$("#orange").click(function f2(){
var audio = new Audio("note2.wav");
audio.play();
});
$("#yellow").click(function f3(){
var audio = new Audio("note3.wav");
audio.play();
});
$("#green").click(function f4(){
var audio = new Audio("note4.wav");
audio.play();
});
$("#blue").click(function f5(){
var audio = new Audio("note5.wav");
audio.play();
});
$("#indigo").click(function f6(){
var audio = new Audio("note6.wav");
audio.play();
});
$("#violet").click(function f7(){
var audio = new Audio("note7.wav");
audio.play();
});
$(document).on('keypress', function(e){
switch (e.keyCode){
case 97:
case 65: var audio = new Audio("note6.wav");
audio.play();
break;
case 98:
case 66:var audio = new Audio("note7.wav");
audio.play();
break;
case 99:
case 67:var audio = new Audio("note1.wav");
audio.play();
break;
case 100:
case 68:var audio = new Audio("note2.wav");
audio.play();
break;
case 101:
case 69:var audio = new Audio("note3.wav");
audio.play();
break;
case 102:
case 70:var audio = new Audio("note4.wav");
audio.play();
break;
case 103:
case 71:var audio = new Audio("note5.wav");
audio.play();
break;
}
});
46 minutes for jQuery
*/