-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
204 lines (129 loc) · 5.77 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
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
<html>
<!-- Chord Explorer v.1a
made by roch (2023) -->
<head>
<title>Chord Explorer</title>
<style>
.c1{background-color:#820f0f !important;}
.c2{background-color:#84190f !important;}
.c3{background-color:#87340e !important;}
.c4{background-color:#8d5a0d !important;}
.c5{background-color:#927e0c !important;}
.c6{background-color:#95940b !important;}
.c7{background-color:#93970b !important;}
.c8{background-color:#6d870e !important;}
.c9{background-color:#387111 !important;}
.c10{background-color:#1a6413 !important;}
.c11{background-color:#175f31 !important;}
.c12{background-color:#13567d !important;}
.grey{ background-color: rgb(158, 155, 155); color: rgb(117, 117, 117); }
td,tr,table,body,input,select { margin:0; padding:0; border-radius: 6px;}
#neck-view { margin-right:20px; }
table:not(#neck-view) { border:1px solid rgb(199, 198, 198); background-color: #b3b1b1; margin-top:20px; }
body { font-family:MS Sans Serif; font-size:32px; background-color: darkgrey; padding: 20px; width:800px; margin:auto; }
table { border-spacing: 6px; }
#neck-view > tr:first-child > td { background-color: rgba(1,1,1,.50); }
option { text-align: left;}
b { font-size:172px; color: rgb(65, 65, 65); }
.diat>td { color: rgb(54, 53, 53); background-color: rgb(173, 170, 170); }
#neck-view > tr > td:hover { padding:2px; border: 2px solid red; }
select,input {
background-color: #c2c1c1;
text-align: center;
border:1px solid rgb(199, 198, 198);
color: #605f5f;
font-weight: bolder;
font-size: 26px;
padding:6px;
}
input { color: #9e9c9c; font-size: 50px; width: 230px; }
td {
color: rgb(185, 185, 185);
font-size:14px;
width:22px;
text-align:center;
padding:8px;
vertical-align:100%;
}
</style>
</head>
<body>
<div style="position: absolute; right:0;bottom:0;background-color:rgba(1,1,1,.2); color:rgba(1,1,1,.5); padding:4px;font-size:10px">made with love by <a href="#" id="mailto">roch</a></div>
<table id ="neck-view" style="float:left"></table>
<center>
<br ><b>none</b><br />
<input type="range" id="chord-picker"/> <br ><br >
<select></select><br ><br >
<table>
<tr class="diat"><td>1th</td><td></td><td>2nd</td><td></td><td>3rd</td><td>4th</td><td></td><td>5th</td><td></td><td>6th</td><td></td><td>7th</td></tr>
<tr id="chord-view"></tr>
</table><br ><br >
<input type="text" id="tune" onclick="this.select()" />
</center>
</div>
</body>
<script>
notes = [ "A", "A#", "B", "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#" ];
chords = [
{"name":"minor", "notes":[0,3,7]},
{"name":"major", "notes":[0,4,7]},
{"name":"6th", "notes":[0,4,7,9]},
{"name":"7th (minor)", "notes":[0,3,7,10]},
{"name":"7th", "notes":[0,4,7,10]},
{"name":"7th (major)", "notes":[0,4,7,11]},
{"name":"9th", "notes":[0,4,7,2]},
{"name":"augmented", "notes":[0,4,8]},
{"name":"diminished", "notes":[0,9,3,6]},
]
strings = []
current_chord = 0
chord_type = 1
function splitNotes(str) {
// window.location.href
str = str.replaceAll(/(\w\#?)/g, "$1 ").trim().toUpperCase().split(" ")
for (e in str) for (n in notes) if (str[e] == notes[n]) { str[e] = Number(n); break; }
return str;
}
function createTR(dest) { tr = document.createElement('tr'); dest.appendChild(tr); return tr; }
function createTD(id) { td = document.createElement('td'); td.id="id"+Number(id); td.innerHTML = notes[id]; return td; }
neck_view = document.querySelector('#neck-view');
chord_view = document.querySelector('#chord-view');
input = document.querySelector('input#chord-picker');
tune = document.querySelector('input#tune');
note_view = document.querySelector("b");
document.querySelector("#mailto").href = ("msasislstsos:srsoscshs@tsosusrsksists.snsest".replaceAll("s",""))
function draw() {
neck_view.innerHTML = ""
chord_view.innerHTML = ""
// neck part
for (f = 0; f < 18; f++) {
tr = createTR(neck_view);
for (id in strings) tr.appendChild(createTD((f+strings[id])%notes.length));
}
// chord part
note_view.innerHTML = notes[current_chord]
for (f = 0; f < notes.length; f++) chord_view.appendChild(createTD((f+current_chord)%notes.length));
document.querySelectorAll("td:not(.grey)").forEach(function(e){ e.className = "grey" })
chords[chord_type].notes.forEach((e)=>{
document.querySelectorAll("#id"+String((e+current_chord)%notes.length)).forEach(function(f){ f.className = ("c"+(e+1)) })
})
}
tune.onkeyup = function(e) { strings = splitNotes(e.target.value); draw(); window.location.href = "#?tuning="+e.target.value }
input.value = current_chord;
input.max = notes.length-1;
input.onmousemove = (e) => {current_chord=Number(e.target.value); draw()}
for (c in chords) {
select = document.querySelector("select")
opt = document.createElement("option")
opt.innerHTML = chords[c].name
opt.value = c
if (chord_type == c) opt.selected = "selected"
select.onchange = function(e) { chord_type = Number(e.target.value); draw() }
select.appendChild(opt)
}
draw()
url_string = window.location.href.split("tuning=")[1];
tune.value = (url_string && url_string.length) ? url_string : "ADF#B"
tune.dispatchEvent(new Event('keyup'));
</script>
</html>