load example on start
s-ol
3 years ago
6 | 6 |
|
7 | 7 |
FROM nginx:alpine
|
8 | 8 |
COPY --from=build-env /build/dist /usr/share/nginx/html
|
|
9 |
COPY --from=build-env /build/examples /usr/share/nginx/html/examples
|
9 | 10 |
RUN chmod 555 -R /usr/share/nginx/html
|
6 | 6 |

|
7 | 7 |
|
8 | 8 |
You can try it in your browser at https://leap-finger-scan.s-ol.nu.
|
9 | |
If you don't have a Leap, you can still play with my saved scans:
|
10 | |
|
11 | |
1. download a scan from the `examples` folder
|
12 | |
2. open the website
|
13 | |
3. press `l` and load the data
|
|
9 |
If you don't have a Leap, it will load up one of my example captures automatically.
|
|
10 |
You can also load the other one (`examples/two.json`) and import it using the `L` key.
|
234 | 234 |
return finger;
|
235 | 235 |
});
|
236 | 236 |
|
237 | |
const restore = (str) => {
|
238 | |
if (!str)
|
239 | |
return;
|
240 | |
|
241 | |
const data = JSON.parse(str);
|
242 | |
data.forEach((data, i) => fingers[i].load(data));
|
243 | |
}
|
|
237 |
const restore = (data) => data.forEach((data, i) => fingers[i].load(data));
|
244 | 238 |
|
245 | 239 |
let viewSliceOnly = false;
|
246 | 240 |
window.onkeydown = (e) => {
|
|
256 | 250 |
|
257 | 251 |
input.onchange = e => {
|
258 | 252 |
const reader = new FileReader();
|
259 | |
reader.onload = e => restore(e.target.result);
|
|
253 |
reader.onload = e => restore(JSON.parse(e.target.result));
|
260 | 254 |
reader.readAsText(e.target.files[0]);
|
261 | 255 |
}
|
262 | 256 |
} else if (e.key === 'Shift') {
|
|
288 | 282 |
}
|
289 | 283 |
}
|
290 | 284 |
|
291 | |
restore(localStorage.getItem('data'));
|
|
285 |
if (localStorage.getItem('data')) {
|
|
286 |
restore(JSON.parse(localStorage.getItem('data')));
|
|
287 |
} else {
|
|
288 |
fetch('examples/one.json')
|
|
289 |
.then(r => r.json())
|
|
290 |
.then(restore);
|
|
291 |
}
|
|
292 |
|
292 | 293 |
setInterval(() => {
|
293 | 294 |
const data = fingers.map(finger => finger.store());
|
294 | 295 |
localStorage.setItem('data', JSON.stringify(data));
|