save controls in localStorage
s-ol
3 years ago
0 | 0 | <!DOCTYPE html> |
1 | <!-- saved from url=(0029)https://dood.al/oscilloscope/ --> | |
2 | 1 | <html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
3 | 2 | <title>XXY Oscilloscope</title> |
4 | 3 | <style> |
10 | 9 | border-collapse: collapse; |
11 | 10 | } |
12 | 11 | #startOverlay { |
13 | display: block; | |
12 | display: none; | |
14 | 13 | position: fixed; |
15 | 14 | width: 100vw; |
16 | 15 | height: 100vh; |
79 | 78 | <td valign="top"> |
80 | 79 | <canvas id="crtCanvas" width="584" height="584" style="z-index: 0;"></canvas> |
81 | 80 | <div id="canvasFailure" style="position: relative; z-index: 1; font:25px arial; top:-40px; color:lightgreen;"></div> |
82 | <a href="javascript:toggleVisible('sidebar');">toggle sidebar</a> | |
81 | <a href="javascript:toggleVisible('sidebar'); window.onresize();">toggle sidebar</a> | |
83 | 82 | </td> |
84 | 83 | <td id="sidebar" width="360" valign="top"> |
85 | 84 | |
370 | 369 | setupControls : function() |
371 | 370 | { |
372 | 371 | var locationString = location.toString(); |
373 | if (!(locationString.includes('#'))) return; | |
372 | if (!(locationString.includes('#'))) { | |
373 | var stored = window.localStorage.getItem('controls'); | |
374 | if (!stored) | |
375 | return; | |
376 | locationString = '#' + stored; | |
377 | } | |
374 | 378 | var hash = locationString.split('#')[1]; |
375 | 379 | var arrayString = decodeURI(hash); |
376 | 380 | var a = arrayString.split(','); |
452 | 456 | } |
453 | 457 | } |
454 | 458 | |
459 | // autosave controls every second | |
460 | setInterval(function () { | |
461 | var text = Controls.getControlsArray().toString(); | |
462 | var hm = encodeURI(text); | |
463 | localStorage.setItem('controls', hm); | |
464 | }, 1000); | |
455 | 465 | </script> |
456 | 466 | |
457 | 467 | <div id="extraNotes" style="display:none"> |