-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathindex.html
176 lines (144 loc) · 5.82 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
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
<html lang="en">
<head>
<meta charset="utf-8">
<title>Extract Samples from .sub File</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Ubuntu:ital,wght@0,300;0,400;0,500;0,700;1,300;1,400;1,500;1,700&display=swap" rel="stylesheet">
<script>
function extractSamples(){
var extractedSamples = new Array();
var fileContent = document.getElementById("fileContent").value;
var lines = fileContent.split("\n");
for( var i = 0; i < lines.length; i++ ) {
var currentLine = lines[i];
if(currentLine.includes("RAW_Data: ")){
var dataString = currentLine.replace("RAW_Data: ", "").trim();
var samples = dataString.split(" ");
for( var s = 0; s < samples.length; s++ ) {
var sample = parseInt(samples[s]);
extractedSamples.push(sample);
}
}
}
var prepend = "";
var arduinoCodeString = "";
arduinoCodeString += "#define LENGTH_SAMPLES_MY_SIGNAL " + extractedSamples.length + "\n";
arduinoCodeString += "int samples_my_signal[LENGTH_SAMPLES_MY_SIGNAL] = {";
for( var s = 0; s < extractedSamples.length; s++ ) {
arduinoCodeString += prepend + extractedSamples[s];
prepend = ",";
}
arduinoCodeString += "};";
var resultString = "<div class=\"inputWrapper\">";
resultString += "<div class=\"inputWrapperTop\">";
resultString += "<label for=\"fileContent\">"+extractedSamples.length +" Samples detected. Copy the following Code to your Arduino Sketch:</label>";
resultString += "</div>";
resultString += "<div class=\"clear\"></div>";
resultString += "<Textarea id=\"result\">"+ arduinoCodeString +"</Textarea>";
resultString += "<div class=\"clear\"></div>";
resultString += "</div>";
resultString += "";
resultString += "";
resultString += "";
var resultContainer = document.getElementById("result");
result.innerHTML = resultString;
}
</script>
<style>
*{margin: 0; padding: 0;}
:root{
--border-color: #30363d;
--border-radius: 5px;
--color-background: #0d1117;
--color-font: #bdc5cd;
--font-family: 'Ubuntu', sans-serif;
}
html, body {
width: 100%;
background: var(--color-background);
color: var(--color-font);
font-family: var(--font-family);
}
.clear {
float:none;
clear: both;
}
h1 {
text-align: center;
color: #fff;
margin: 50px 0;
}
#container {
width: 80vw;
margin: 0 10vw;
position: absolute;
}
.inputWrapper {
width: 100%;
border-radius: var(--border-radius);
border: 1px solid var(--border-color);
}
.inputWrapper .inputWrapperTop {
position: relative;
width: calc(100% - 30px);
height: 45px;
float:left;
background: #161b22;
border-top-left-radius: var(--border-radius);
border-top-right-radius: var(--border-radius);
padding: 0 15px;
}
.inputWrapper .inputWrapperTop label {
line-height: 45px;
}
.inputWrapper textarea {
width: 100%;
float:left;
border: 1px solid #cecece;
height: 250px;
background: var(--color-background);
color: var(--color-font);
font-family: var(--font-family);
padding: 15px;
border:none;
}
button {
float: right;
margin: 25px 0;
padding: 0 15px;
height: 35px;
line-height: 35px;
border: 1px solid var(--border-color);
color: var(--color-font);
background: #21262d;
border-radius: var(--border-radius);
cursor: pointer;
transition: all 0.2s ease;
}
button:hover {
background: #30363d;
border-color: #8b949e;
color: #fff;
}
</style>
</head>
<body>
<div id="container">
<h1>Extract Samples from .sub File</h1>
<div class="inputWrapper">
<div class="inputWrapperTop">
<label for="fileContent">Insert the Filecontent here</label>
</div>
<div class="clear"></div>
<Textarea id="fileContent"></Textarea>
<div class="clear"></div>
</div>
<button onclick="extractSamples();">Extract</button>
<div class="clear"></div>
<div id="result">
<!-- RESULT WILL BE RENDERED HERE -->
</div>
</div>
</body>
</html>