@Anthony_Tonev/

Music_Box

HTML, CSS, JS

No description

fork
loading
Files
  • index.html
  • notes
  • sounds
  • bg.PNG
  • script.js
  • style.css
  • toni piano.html

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.9955237181528802","path":"index.html","file":{"path":"index.html","content":{"asEncoding":{"base64":"PCFET0NUWVBFIGh0bWw+CjxodG1sIGxhbmc9ImVuIj4KCjxoZWFkPgoJPG1ldGEgY2hhcnNldD0iVVRGLTgiPgoJPHRpdGxlPlRPTkkgQkxPT1BFUlMgUElBTk88L3RpdGxlPgoJPGxpbmsgcmVsPSJzdHlsZXNoZWV0IiBocmVmPSJzdHlsZS5jc3MiPgo8L2hlYWQ+Cgo8Ym9keT4KPGRpdiBpZD0iVUkiPgoKCgk8YXVkaW8gZGF0YS1rZXk9IjEiIHNyYz0ibm90ZXMvMS5tcDMiPjwvYXVkaW8+Cgk8YXVkaW8gZGF0YS1rZXk9IjIiIHNyYz0ibm90ZXMvMi5tcDMiPjwvYXVkaW8+Cgk8YXVkaW8gZGF0YS1rZXk9IjMiIHNyYz0ibm90ZXMvMy5tcDMiPjwvYXVkaW8+Cgk8YXVkaW8gZGF0YS1rZXk9IjQiIHNyYz0ibm90ZXMvNC5tcDMiPjwvYXVkaW8+Cgk8YXVkaW8gZGF0YS1rZXk9IjUiIHNyYz0ibm90ZXMvNS5tcDMiPjwvYXVkaW8+Cgk8YXVkaW8gZGF0YS1rZXk9IjYiIHNyYz0ibm90ZXMvNi5tcDMiPjwvYXVkaW8+Cgk8YXVkaW8gZGF0YS1rZXk9IjciIHNyYz0ibm90ZXMvNy5tcDMiPjwvYXVkaW8+Cgk8YXVkaW8gZGF0YS1rZXk9IjgiIHNyYz0ibm90ZXMvOC5tcDMiPjwvYXVkaW8+Cgk8YXVkaW8gZGF0YS1rZXk9IjkiIHNyYz0ibm90ZXMvOS5tcDMiPjwvYXVkaW8+CgoJPHA+PC9wPgoKPHA+PC9wPgo8YnV0dG9uIGlk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yBrZXlzLmZvckVhY2goa2V5ID0+IGtleS5hZGRFdmVudExpc3RlbmVyKCd0cmFuc2l0aW9uZW5kJywgcmVtb3ZlVHJhbnNpdGlvbikpOwo8L3NjcmlwdD4KCjxwPjwvcD4KPGJ1dHRvbiBpZD0icGxheSIgb25jbGljaz0icmVzZXROb3RlcygpO3BsYXlOb3RlcygpIj5wbGF5PC9idXR0b24+CgoKPC9ib2R5Pgo8L2h0bWw+"},"asBuffer":null},"loaded":true}}
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<title>TONI BLOOPERS PIANO</title>
	<link rel="stylesheet" href="style.css">
</head>

<body>
<div id="UI">


	<audio data-key="1" src="notes/1.mp3"></audio>
	<audio data-key="2" src="notes/2.mp3"></audio>
	<audio data-key="3" src="notes/3.mp3"></audio>
	<audio data-key="4" src="notes/4.mp3"></audio>
	<audio data-key="5" src="notes/5.mp3"></audio>
	<audio data-key="6" src="notes/6.mp3"></audio>
	<audio data-key="7" src="notes/7.mp3"></audio>
	<audio data-key="8" src="notes/8.mp3"></audio>
	<audio data-key="9" src="notes/9.mp3"></audio>

	<p></p>

<p></p>
<button id="play" onclick="resetNotes();playNotes()">play</button>

<script>



function createInput(name, size, val = "") {



  let UIpanel = document.getElementById("UI");

    let el = document.createElement("input");
    el.setAttribute("size", size);
    el.id = name;
   
    UIpanel.appendChild(el);

    el.value = val;





}

function createP(val=""){
   let UIpanel = document.getElementById("UI");
   let p =document.createElement("p");
    p.innerHTML=val;
    UIpanel.appendChild(p);
   
}
function createButton(name, val = "") {



  let UIpanel = document.getElementById("UI");

    let el = document.createElement("button");
    el.setAttribute("onclick", `silence(this.id);addNote(${val},this.id)`);
    el.id = name;
    el.innerHTML = `🔷`
  
    UIpanel.appendChild(el);

    el.value = val;





}
createP()

for(let x=1;x<=9;x+=1){
for(let j =1; j<=9;j+=1){

let abc = [0,'a','b','c','d','e','f','g','j','k'];
for(let i = 1; i<=9;i+=1){
createButton(x+abc[j]+i,i)
  
}
createP()

}

 createP(x)
}
for(let j =1; j<=9;j+=1){
  
let abc = [0,'a','b','c','d','e','f','g','j','k'];
createInput('noteList'+abc[j],100,'0')

}



 










let noteList =[]
let notes= []
  function addNote(n,id){
document.getElementById(id).style="border:none;background:black";
document.getElementById(id).disabled=true;

 let last = document.getElementById('noteList'+id[1]).value[document.getElementById('noteList'+id[1]).value.length-1];
 let res;
if(last){
 res= +n-last;
}
   for(let s = 0; s<=res;s+=1){
    n+=" "
   }

 document.getElementById('noteList'+id[1]).value+=n;
    
  }


function silence(id){
  // let calc;
  // let arr = document.getElementById('noteList'+id[0]).value.split("");
  // for(let i=0;i<=arr.length-1;i+=1){
  //   if(arr[i-1]){
  // calc= arr[i]- arr[i-1];
  //   for(let s = 0; s<=calc;s+=1){
  //     arr[s].splice(s, 0, ' ');
  //   }
  //   }
  // }
  //  document.getElementById('noteList'+id[0]).value = arr
  
}


  function playSound(i) {
  
noteList= [document.getElementById('noteLista').value,
            document.getElementById('noteListb').value,
            document.getElementById('noteListc').value,
            document.getElementById('noteListd').value];
          
notes= [noteList[0].split(""),noteList[1].split(""),
        noteList[2].split(""), noteList[3].split("")]





 let audio = [document.querySelector(`audio[data-key="${notes[0][i]}"]`),
                document.querySelector(`audio[data-key="${notes[1][i]}"]`),
                  document.querySelector(`audio[data-key="${notes[2][i]}"]`),
                   document.querySelector(`audio[data-key="${notes[3][i]}"]`)]
    if (audio[0]) {
  audio[0].currentTime = 0;
       audio[0].play();
      
    }
  
  if (audio[1]) {
  audio[1].currentTime = 0;
       audio[1].play();
      
    }

 if (audio[2]) {
  audio[2].currentTime = 0;
       audio[2].play();
      
    }

 if (audio[3]) {
  audio[3].currentTime = 0;
       audio[3].play();
      
    }


  }
  let i = 0;
function playNotes(){
  
 let noteInt= setInterval(()=>{
    playSound(i);
     i+=1;
  },350);

  if(notes[0] && i===notes[0].length-1){
    clearInterval(noteInt)
  }
  
}
function resetNotes(){
  i=0;
notes= [];

  
}
  // const keys = Array.from(document.querySelectorAll('.key'));
  // keys.forEach(key => key.addEventListener('transitionend', removeTransition));
</script>

<p></p>
<button id="play" onclick="resetNotes();playNotes()">play</button>


</body>
</html>
result
console