@@ -21,8 +21,22 @@ const exampleCalibrationJSON = `
2121
2222function CalibrationInput (
2323 onCompleted ,
24- initialCalibrationJSON = exampleCalibrationJSON ,
24+ initialCalibrationJSON = null
2525) {
26+ let initialJSON ;
27+
28+ if ( initialCalibrationJSON == null ) {
29+ let persistedJSON = localStorage . getItem ( "calibration-v1" ) ;
30+
31+ if ( persistedJSON == null ) {
32+ initialJSON = exampleCalibrationJSON ;
33+ } else {
34+ initialJSON = persistedJSON ;
35+ }
36+ } else {
37+ initialJSON = initialCalibrationJSON ;
38+ }
39+
2640 let popupDiv = document . createElement ( "div" ) ;
2741
2842 popupDiv . style = `
@@ -62,7 +76,7 @@ function CalibrationInput(
6276 editor . rows = 20 ;
6377 editor . cols = 80 ;
6478 editor . spellcheck = false ;
65- editor . value = initialCalibrationJSON ;
79+ editor . value = initialJSON ;
6680
6781 function validateCalibration ( ) {
6882 const maybeJson = editor . value ;
@@ -78,7 +92,9 @@ function CalibrationInput(
7892 link . innerText = "Click here to continue..." ;
7993 link . href = "#" ;
8094 link . style . color = "#EFEFEF" ;
95+
8196 link . onclick = function ( ) {
97+ localStorage . setItem ( "calibration-v1" , maybeJson ) ;
8298 onCompleted ( popupDiv , calibration ) ;
8399 return false ;
84100 }
0 commit comments