-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathindex.html
140 lines (118 loc) · 4.28 KB
/
index.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
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
<html lang="">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel='shortcut icon' type='image/x-icon' href='volume-control.png' />
<link href="https://fonts.googleapis.com/css?family=Didact+Gothic" rel="stylesheet">
<title>Arduino Buzzer Code Generator</title>
<style>
body {
padding: 0;
margin: 0;
}
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.2/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.2/addons/p5.dom.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.2/addons/p5.sound.min.js"></script>
<script src="Note.js"></script>
<script src="sketch.js"></script>
<style>
.textContainer {
width: 600px;
text-align: left;
color: black;
background-color: #EBF1F1;
overflow-y: scroll;
max-height: 400px;
padding: 5px 10px 0px 10px;
margin-right: 2%;
}
.function {
color: #E47128;
font-weight: 800;
font-family: monospace;
}
.typeFunction {
font-family: monospace;
color: #E47128
}
.typeFunctionTab {
font-family: monospace;
color: #E47128;
padding-left: 2em;
}
.value {
color: rgba(0, 0, 0, 0.87);
font-family: monospace;
}
.define {
color: #62AEB2;
font-family: monospace;
}
button {
margin-top: 1em;
font-family: 'Didact Gothic', sans-serif !important;
background-color: #4CAF50; /* Green */
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
}
#defaultCanvas0 {}
</style>
<script>
function myf() {
var elm = document.getElementById("code");
if (document.body.createTextRange) {
var range = document.body.createTextRange();
range.moveToElementText(elm);
range.select();
document.execCommand("copy");
alert("Copied to clipboard.");
// For some Browsers
} else if (window.getSelection) {
var selection = window.getSelection();
var range = document.createRange();
range.selectNodeContents(elm);
selection.removeAllRanges();
selection.addRange(range);
document.execCommand("copy");
alert("Copied to clipboard.");
}
}
function download(filename, text) {
var div = document.getElementById("code");
console.log(div.textContent);
console.log(div.textContent.replace(/ +(?= )/g,''))
var element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(div.textContent.replace(/ +(?= )/g,'')));
element.setAttribute('download', 'buzzer.ino');
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}
</script>
</head>
<body style="background-color:#000; display:flex; flex-direction: column">
<h1 style="color:aliceblue; text-align: center; font-family: 'Didact Gothic', sans-serif !important; margin-top:3%; margin-bottom:1%;">Arduino
Buzzer Code Generator</h1>
<h2 style="color:white; font-family: 'Didact Gothic', sans-serif !important; text-align: center; margin-bottom: 0px">Play on a pseudo Piano and create your arduino
code lively. Use it on a buzzer.</h2>
<h3 style="color:white; font-family: 'Didact Gothic', sans-serif !important; text-align: center; margin-bottom: 0px">Record, Stop, Download it. </h3>
<h3 style="color:white; font-family: 'Didact Gothic', sans-serif !important; text-align: center; margin-bottom: 0px ">W: Record, E: Stop, R: Restart </h3>
<div style="display:flex; flex-wrap: wrap; align-items: center; justify-content: space-around">
<div id="sketch-holder" style="flex:1; width: 200px;"></div>
<div style="flex:1; justify-items: center; align-items: center">
<div disable class="textContainer" id="code"></div>
<div style="flex: 1; justify-items: center; align-items: center; margin: auto auto">
<button onclick="myf()">Copy</button>
<button onclick="download()">Download</button>
</div>
</div>
</div>
</body>
</html>