|
1 | 1 | {% assign e = site.data[page.lang]['heatmap-ui'] %} |
2 | 2 |
|
3 | | -<div style="flex-basis: 100%; display: flex; justify-content: center; align-items: center; pointer-events: auto"> |
4 | | - <select class="finger-select" id="finger-select"> |
| 3 | +<div style="flex-basis: 100%; display: flex; justify-content: center; align-items: center; pointer-events: auto; gap: 30px"> |
| 4 | + <!--<div role="select" style="border: 1px solid #e8e8e8; border-radius: .5em; padding: .5em;"> |
| 5 | + <input type="checkbox" style="display: none"> |
| 6 | + <div class="hand-select"> |
| 7 | + <span id="hand-selected"></span> |
| 8 | + <img src="/assets/img/arrow_down.png" alt="arrow_down" style="aspect-ratio: 1 / 1; height: 1.6em;"> |
| 9 | + </div> |
| 10 | + <div class="hand-select-options" style="display: flex; flex-direction: column; color: #383838"> |
| 11 | + <span class="hand-select-option">{{ e.total }}</span> |
| 12 | + <span class="hand-select-option">{{ e.preferred }}</span> |
| 13 | + <span class="hand-select-option">{{ e.hf_format | replace: '%h%', e.left | replace: '%f%', e.hand }}</span> |
| 14 | + <span class="hand-select-option">{{ e.hf_format | replace: '%h%', e.right | replace: '%f%', e.hand }}</span> |
| 15 | + </div> |
| 16 | + </div>--> |
| 17 | + |
| 18 | + <select class="finger-select active" id="all-fingers"> |
5 | 19 | <option value="total">{{ e.total }}</option> |
6 | 20 | <option value="preferred">{{ e.preferred }}</option> |
7 | | - <option value="LH">{{ e.hf_format | replace: '%h%', e.left | replace: '%f%', e.hand }}</option> |
8 | | - <option value="RH">{{ e.hf_format | replace: '%h%', e.right | replace: '%f%', e.hand }}</option> |
9 | | - <option value="LT">{{ e.hf_format | replace: '%h%', e.left | replace: '%f%', e.thumb }}</option> |
10 | | - <option value="LI">{{ e.hf_format | replace: '%h%', e.left | replace: '%f%', e.index }}</option> |
11 | | - <option value="LM">{{ e.hf_format | replace: '%h%', e.left | replace: '%f%', e.middle }}</option> |
12 | | - <option value="LR">{{ e.hf_format | replace: '%h%', e.left | replace: '%f%', e.ring }}</option> |
13 | | - <option value="LL">{{ e.hf_format | replace: '%h%', e.left | replace: '%f%', e.little }}</option> |
14 | | - <option value="RT">{{ e.hf_format | replace: '%h%', e.right | replace: '%f%', e.thumb }}</option> |
15 | | - <option value="RI">{{ e.hf_format | replace: '%h%', e.right | replace: '%f%', e.index }}</option> |
16 | | - <option value="RM">{{ e.hf_format | replace: '%h%', e.right | replace: '%f%', e.middle }}</option> |
17 | | - <option value="RR">{{ e.hf_format | replace: '%h%', e.right | replace: '%f%', e.ring }}</option> |
18 | | - <option value="RL">{{ e.hf_format | replace: '%h%', e.right | replace: '%f%', e.little }}</option> |
| 21 | + <option value="L">{{ e.hf_format | replace: '%h%', e.left | replace: '%f%', e.hand }}</option> |
| 22 | + <option value="R">{{ e.hf_format | replace: '%h%', e.right | replace: '%f%', e.hand }}</option> |
| 23 | + </select> |
| 24 | + <select class="finger-select" id="finger-select"> |
| 25 | + <option value="H">{{ e.all_button }}</option> |
| 26 | + <option value="T">{{ e.thumb }}</option> |
| 27 | + <option value="I">{{ e.index }}</option> |
| 28 | + <option value="M">{{ e.middle }}</option> |
| 29 | + <option value="R">{{ e.ring }}</option> |
| 30 | + <option value="L">{{ e.little }}</option> |
19 | 31 | </select> |
20 | 32 | </div> |
21 | 33 |
|
|
54 | 66 |
|
55 | 67 | <script src="/assets/js/dataviz.js"></script> |
56 | 68 | <script type="module"> |
57 | | - import langFinger from '/assets/js/ui-lang.json' with {type:"json"}; |
| 69 | + import langFinger from '/assets/js/ui-lang.json' with {type: 'json'}; |
58 | 70 |
|
59 | 71 | document.addEventListener('DOMContentLoaded', function () { |
60 | | - const fingerSelect = document.getElementById('finger-select'); |
61 | 72 | const selectionText = document.getElementById('selection-text'); |
62 | 73 | const selectionIcon = document.querySelector('#selection-badge .selection-icon'); |
63 | 74 | const fingerContext = document.getElementById('finger-context'); |
| 75 | + const fingerSelect = document.getElementById('finger-select'); |
| 76 | + const allFingers = document.getElementById('all-fingers'); |
64 | 77 |
|
65 | 78 | const FACES = ['R', 'B', 'G', 'W', 'Y']; |
66 | 79 | const ALL_FINGERS = ['LT', 'LI', 'LM', 'LR', 'LL', 'RT', 'RI', 'RM', 'RR', 'RL']; |
67 | 80 |
|
68 | 81 | const lang = document.documentElement.lang |
69 | 82 | const fingerData = langFinger[lang] ? langFinger[lang] : langFinger["en"]; |
70 | 83 |
|
71 | | - |
72 | 84 | function updateUI(key) { |
73 | 85 | const data = fingerData[key] || {name: key, icon: '', info: ''}; |
74 | 86 | if (selectionText) selectionText.textContent = data.name; |
|
80 | 92 | let min = fixedRange ? fixedRange.min : Infinity; |
81 | 93 | let max = fixedRange ? fixedRange.max : -Infinity; |
82 | 94 | if (!fixedRange) { |
83 | | - FACES.forEach(function (f) { data[f].forEach(function (v) { if (v < min) min = v; if (v > max) max = v; }); }); |
| 95 | + FACES.forEach(function (f) { |
| 96 | + data[f].forEach(function (v) { |
| 97 | + if (v < min) min = v; |
| 98 | + if (v > max) max = v; |
| 99 | + }); |
| 100 | + }); |
84 | 101 | } |
85 | 102 | if (window.updateModel) { |
86 | | - window.updateModel({ heatmap: data, heatmapMin: min, heatmapMax: max, scores: data, showScores: true, isReachability: true, scoreFormat: 'integer', figure6View: false }); |
| 103 | + window.updateModel({ |
| 104 | + heatmap: data, |
| 105 | + heatmapMin: min, |
| 106 | + heatmapMax: max, |
| 107 | + scores: data, |
| 108 | + showScores: true, |
| 109 | + isReachability: true, |
| 110 | + scoreFormat: 'integer', |
| 111 | + figure6View: false |
| 112 | + }); |
87 | 113 | } |
88 | 114 | } |
89 | 115 |
|
|
95 | 121 | let sum = 0; |
96 | 122 | fingers.forEach(function (f) { |
97 | 123 | const fData = window.perFingerReachability[f]; |
98 | | - if (fData) fData.forEach(function (p) { sum += p[face][i]; }); |
| 124 | + if (fData) fData.forEach(function (p) { |
| 125 | + sum += p[face][i]; |
| 126 | + }); |
99 | 127 | }); |
100 | 128 | result[face].push(sum); |
101 | 129 | } |
|
127 | 155 | const fData = window.perFingerReachability[f]; |
128 | 156 | if (fData) { |
129 | 157 | let s = 0; |
130 | | - fData.forEach(function (p) { s += p[face][i]; }); if (s > best) best = s; } |
| 158 | + fData.forEach(function (p) { |
| 159 | + s += p[face][i]; |
| 160 | + }); |
| 161 | + if (s > best) best = s; |
| 162 | + } |
131 | 163 | }); |
132 | 164 | result[face].push(best); |
133 | 165 | } |
134 | 166 | }); |
135 | | - applyHeatmap(result, { min: 0, max: 66 }); |
| 167 | + applyHeatmap(result, {min: 0, max: 66}); |
136 | 168 | updateUI('best', ALL_FINGERS); |
137 | 169 | } |
138 | 170 |
|
139 | 171 | function handleSelect() { |
140 | | - const selectValue = fingerSelect.value; |
| 172 | + let selectValue = allFingers.value; |
141 | 173 | if (selectValue === "total") { |
| 174 | + if (fingerSelect.classList.contains('active')) { |
| 175 | + fingerSelect.classList.remove('active'); |
| 176 | + fingerSelect.value = "H" |
| 177 | + } |
142 | 178 | updateSelection("total"); |
143 | 179 | } else if (selectValue === "preferred") { |
| 180 | + if (fingerSelect.classList.contains('active')) { |
| 181 | + fingerSelect.classList.remove('active'); |
| 182 | + fingerSelect.value = "H" |
| 183 | + } |
144 | 184 | handleBestFinger(); |
145 | 185 | } else { |
146 | | - if (selectValue.charAt(1) === 'H') { |
147 | | - if (selectValue.charAt(0) === 'L') { |
| 186 | + fingerSelect.classList.add('active') |
| 187 | + let selectFinger = fingerSelect.value; |
| 188 | + if (selectFinger === 'H') { |
| 189 | + if (selectValue === 'L') { |
148 | 190 | handleHandAll('left') |
149 | 191 | } else { |
150 | 192 | handleHandAll('right') |
151 | 193 | } |
152 | 194 | } else { |
153 | | - updateSelection(selectValue) |
| 195 | + updateSelection(selectValue + selectFinger) |
154 | 196 | } |
155 | 197 | } |
156 | 198 | } |
157 | 199 |
|
158 | | - fingerSelect.addEventListener('change', handleSelect); |
| 200 | + allFingers.addEventListener('change', handleSelect) |
| 201 | + fingerSelect.addEventListener('change', handleSelect) |
159 | 202 |
|
160 | 203 | handleSelect(); |
161 | 204 | document.getElementById('model-container').classList.add('active'); |
|
0 commit comments