forked from lucmazon/heatmap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
287 lines (257 loc) · 9.42 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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Heatmap</title>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/underscore-min.js"></script>
<script type="text/javascript" src="js/d3.v3.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/prettify.js"></script>
<script type="text/javascript" src="js/heatmap.js"></script>
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/prettify.css">
<link rel="stylesheet" href="css/heatmap.css"/>
<script type="text/javascript">
$(function () {
$('.btn-file :file').change(function () {
var input = $(this),
numFiles = input.get(0).files ? input.get(0).files.length : 1,
label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
input.trigger('fileselect', [numFiles, label]);
});
$('.clickable').click(function () {
if ($(this).hasClass('panel-collapsed')) {
$(this).parent().find('.panel-body').slideDown();
$(this).removeClass('panel-collapsed');
$(this).find('i').removeClass('glyphicon-chevron-down').addClass('glyphicon-chevron-up');
} else {
$(this).parent().find('.panel-body').slideUp();
$(this).addClass('panel-collapsed');
$(this).find('i').removeClass('glyphicon-chevron-up').addClass('glyphicon-chevron-down');
}
});
});
</script>
</head>
<body>
<div class="container">
<div class="col-12">
<h4>JSON: Keycodes to Strings mapping</h4>
<div class="input-group">
<span class="input-group-btn">
<span class="btn btn-primary btn-file">
Browse… <input type="file" id="json-keycode-string-mapping">
</span>
</span>
<input class="form-control file-label" type="text" readonly="">
</div>
<div class="panel panel-default">
<div class="panel-heading clickable panel-collapsed">
<span class="panel-title">Explanation</span>
<span class="pull-right clickable"><i class="glyphicon glyphicon-chevron-down"></i></span>
</div>
<div class="panel-body" style="display: none;">
<p>This JSON file must contain the mapping between keycodes and their corresponding strings.
<p>
<p>It can either be a single value, or multiple values based on the modifier pressed (first value is for no
modifier, second for <code>shift</code>,
third for <code>alt gr</code>, and last for <code>shift + alt gr</code>.</p>
<p>Extract here:</p>
<pre class="prettyprint">
{
"9":"Esc",
"10":["\"", "1", "—", "„"],
"15":["@","6","^"],
"22":"⌫",
"23":"⇥"
}
</pre>
</div>
</div>
</div>
<div class="col-12">
<h4>TSV: Keyboard design file</h4>
<div class="input-group">
<span class="input-group-btn">
<span class="btn btn-primary btn-file">
Browse… <input type="file" id="tsv-keyboard-design">
</span>
</span>
<input class="form-control file-label" type="text" readonly="">
</div>
<div class="panel panel-default">
<div class="panel-heading clickable panel-collapsed">
<span class="panel-title">Explanation</span>
<span class="pull-right clickable"><i class="glyphicon glyphicon-chevron-down"></i></span>
</div>
<div class="panel-body" style="display: none;">
<p>This TSV (tab-separated-values) file contains the actual design of the keyboard you're using.</p>
<p>Each line represents a key, and is created based on the key position,
the kind of key (width by height), the rotation center coordinates and finally, the rotation angle.</p>
<p>Extract here:</p>
<pre class="prettyprint">
x y kind rx ry rotate
0 0.2 1.5x1 0 0 0
1.5 0.2 1x1 0 0 0
2.5 0.1 1x1 0 0 0
3.5 0 1x1 0 0 0
4.5 0.1 1x1 0 0 0
5.5 0.2 1x1 0 0 0
6.5 0.2 1x1 0 0 0
</pre>
</div>
</div>
</div>
<div class="col-12">
<h4>JSON: Hardware/keycodes mapping file</h4>
<div class="input-group">
<span class="input-group-btn">
<span class="btn btn-primary btn-file">
Browse… <input type="file" id="json-hardware-keycode-mapping">
</span>
</span>
<input class="form-control file-label" type="text" readonly="">
</div>
<div class="panel panel-default">
<div class="panel-heading clickable panel-collapsed">
<span class="panel-title">Explanation</span>
<span class="pull-right clickable"><i class="glyphicon glyphicon-chevron-down"></i></span>
</div>
<div class="panel-body" style="display: none;">
<p>This JSON file links the keycodes to the keyboard design.</p>
<p>It uses two keys:</p>
<dl>
<dt>hardwareKeycodeMapping</dt>
<dd>a list orderded the same way as the keyboard design keys, with each value being either the
corresponding keycode
or a displayable value (for example in case of function keys not sending signals)
</dd>
<dt>displayMapping</dt>
<dd>If you want specific keycodes to have a display value different than the one provided in the
keycodes to strings mapping file, place them here.
</dd>
</dl>
<p>For a more visual explanation, here's a complete file for the ergodox:</p>
<pre class="prettyprint">
{
"hardwareKeycodeMapping" : [
9, 10, 11, 12, 13, 14, 49,
35, 24, 25, 26, 27, 28, 23,
51, 38, 39, 40, 41, 42,
133, 52, 53, 54, 55, 56, 36,
112, 117, 119, 22, 37,
119, "+L3",
65, 50, "~L1",
64,
21, 15, 16, 17, 18, 19, 20,
" ", 29, 30, 31, 32, 33, 34,
43, 44, 45, 46, 47, 48,
" ", 57, 58, 59, 60, 61, 66,
105, 113, 111, 116, 114,
" ", " ",
" ", 62, 22,
108
],
"displayMapping" : {
"37": "ctrl",
"50": "shift",
"62": "shift",
"64": "alt",
"65": "␣",
"105": "ctrl"
}
}
</pre>
</div>
</div>
</div>
<div class="col-12">
<h4>Heatmap file</h4>
<div class="input-group">
<span class="input-group-btn">
<span class="btn btn-primary btn-file">
Browse… <input type="file" id="json-heatmap">
</span>
</span>
<input class="form-control file-label" type="text" readonly="">
</div>
<div class="panel panel-default">
<div class="panel-heading clickable panel-collapsed">
<span class="panel-title">Explanation</span>
<span class="pull-right clickable"><i class="glyphicon glyphicon-chevron-down"></i></span>
</div>
<div class="panel-body" style="display: none;">
<p>This is the most important file! It counts modifier by modifier the keys pressed.</p>
<p>It uses two keys:</p>
<dl>
<dt>count</dt>
<dd>the actual key count, nested depending on the modifiers.</dd>
<dt>modifiers</dt>
<dd>the list containing all possible modifiers</dd>
</dl>
<p>Here's a basic example:</p>
<pre class="prettyprint">
{
"count": {
"\"": 124,
"Esc": 45,
"F12": 14,
"←": 74,
"⇞": 2,
"→": 51,
"space": 2527,
"⇥": 248,
"a": 1401,
"b": 239,
"c": 1122,
"left alt": {
"/": 1,
"b": 431,
"g": 26,
"n": 2,
"right ctrl": {
"f": 21,
"w": 32
},
"w": 40,
"x": 94,
"y": 1,
"«": 1,
"é": 1
}
},
"modifiers": [
"left shift",
"❖",
"right shift",
"altGr",
"alt",
"right ctrl",
"left ctrl"]
}
</pre>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading panel-title">Active modifiers</div>
<div class="panel-body" id="modifiers">
</div>
</div>
<div>
<svg role="heatmap"></svg>
</div>
<div>
<svg role="scale"></svg>
</div>
</div>
<script type="text/javascript">
!function ($) {
$(function () {
window.prettyPrint && prettyPrint()
})
}(window.jQuery)
</script>
</body>
</html>