git.s-ol.nu leap-finger-scan / 3633e0d
load example on start s-ol 3 years ago
3 changed file(s) with 13 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
66
77 FROM nginx:alpine
88 COPY --from=build-env /build/dist /usr/share/nginx/html
9 COPY --from=build-env /build/examples /usr/share/nginx/html/examples
910 RUN chmod 555 -R /usr/share/nginx/html
66 ![](examples/screenshot.png)
77
88 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.
234234 return finger;
235235 });
236236
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));
244238
245239 let viewSliceOnly = false;
246240 window.onkeydown = (e) => {
256250
257251 input.onchange = e => {
258252 const reader = new FileReader();
259 reader.onload = e => restore(e.target.result);
253 reader.onload = e => restore(JSON.parse(e.target.result));
260254 reader.readAsText(e.target.files[0]);
261255 }
262256 } else if (e.key === 'Shift') {
288282 }
289283 }
290284
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
292293 setInterval(() => {
293294 const data = fingers.map(finger => finger.store());
294295 localStorage.setItem('data', JSON.stringify(data));