@@ -36,6 +36,7 @@ function loadGrblBackupFile(f) {
3636 checkifchanged ( ) ;
3737 enableLimits ( ) ; // Enable or Disable
3838 displayDirInvert ( ) ;
39+ $ ( "#grblSettingsAdvTab" ) . click ( ) ;
3940 }
4041 }
4142}
@@ -78,6 +79,40 @@ function restoreAutoBackup(index) {
7879 console . log ( 'Restoring backup:' , selectedBackup ) ;
7980 // Call your function to restore the backup here, e.g., update grblParams
8081 // Example: grblParams = selectedBackup.grblParams;
82+
83+ // Retrieve grblParams from the backup
84+ const grblParamsBackup = selectedBackup . grblParams ;
85+
86+ // Iterate through the keys in the grblParams object and apply them using jQuery
87+ for ( const key in grblParamsBackup ) {
88+ if ( grblParamsBackup . hasOwnProperty ( key ) ) {
89+ const paramValue = grblParamsBackup [ key ] ;
90+ const parsedValue = parseFloat ( paramValue ) ;
91+
92+ // Check if the parsed value is a valid number
93+ if ( ! isNaN ( parsedValue ) ) {
94+ // Update the input field based on the parameter using jQuery
95+ const inputElement = $ ( "#val-" + key . substring ( 1 ) + "-input" ) ;
96+
97+ if ( inputElement . length ) {
98+ inputElement . val ( parsedValue ) ; // Apply the value to the input field
99+ }
100+ } else {
101+ console . warn ( `Invalid value for ${ key } : ${ paramValue } ` ) ;
102+ }
103+
104+ // Optionally, fix or apply any GrblHAL-specific settings
105+ fixGrblHALSettings ( key . substring ( 1 ) ) ; // Adjust as needed
106+
107+ // Optionally, other functions you might call for updating the machine state
108+ // Example: checkifchanged(); enableLimits(); displayDirInvert();
109+ }
110+ }
111+ // Call any post-restoration functions you need (e.g., re-enable limits, etc.)
112+ checkifchanged ( ) ;
113+ enableLimits ( ) ;
114+ displayDirInvert ( ) ;
115+ $ ( "#grblSettingsAdvTab" ) . click ( ) ;
81116}
82117
83118
@@ -189,8 +224,8 @@ function grblPopulate() {
189224 <form id="grblSettingsTable">
190225
191226 <ul data-role="tabs" data-expand="true" class="mb-2">
192- <li onclick="showBasicSettings()"><a href="#"><small><i class="fas fa-fw fa-cog mr-1 fg-darkGreen"></i>Basic Settings</a></small></li>
193- <li onclick="showAdvSettings()"><a href="#"><small><i class="fas fa-fw fa-cogs mr-1 fg-darkRed"></i>Advanced Settings</a></small></li>
227+ <li id="grblSettingsBasicTab" onclick="showBasicSettings()"><a href="#"><small><i class="fas fa-fw fa-cog mr-1 fg-darkGreen"></i>Basic Settings</a></small></li>
228+ <li id="grblSettingsAdvTab" onclick="showAdvSettings()"><a href="#"><small><i class="fas fa-fw fa-cogs mr-1 fg-darkRed"></i>Advanced Settings</a></small></li>
194229 </ul>
195230
196231
@@ -521,9 +556,9 @@ function checkifchanged() {
521556 ( ! compareAsNumber && newVal !== oldVal ) ) {
522557 hasChanged = true ;
523558
524- console . log ( "changed: " + key ) ;
525- console . log ( "old: " + oldVal ) ;
526- console . log ( "new: " + newVal ) ;
559+ // console.log("changed: " + key);
560+ // console.log("old: " + oldVal);
561+ // console.log("new: " + newVal);
527562
528563 if ( ! $ ( "#val-" + j + "-input" ) . parent ( ) . is ( 'td' ) ) {
529564 $ ( "#val-" + j + "-input" ) . parent ( ) . addClass ( 'alert' ) ;
0 commit comments