@@ -22,6 +22,7 @@ function setFontSettingsPerLine() {
2222 style : $ ( '#fontStyle option:selected' ) . text ( ) ,
2323 size : $ ( '#fontSize' ) . val ( ) ,
2424 inverted : $ ( '#fontInverted' ) . is ( ':checked' ) ,
25+ todo : $ ( '#fontCheckbox' ) . is ( ':checked' ) ,
2526 align : $ ( 'input[name=fontAlign]:checked' ) . val ( ) ,
2627 line_spacing : $ ( 'input[name=lineSpacing]:checked' ) . val ( ) ,
2728 color : $ ( 'input[name=fontColor]:checked' ) . val ( )
@@ -115,6 +116,8 @@ $(document).ready(function () {
115116 // Set font color
116117 $ ( 'input[name=fontColor]' ) . prop ( 'checked' , false ) . parent ( ) . removeClass ( 'active' ) ;
117118 $ ( 'input[name=fontColor][value="' + fs . color + '"]' ) . prop ( 'checked' , true ) . parent ( ) . addClass ( 'active' ) ;
119+ // Set TODO item
120+ $ ( '#fontCheckbox' ) . prop ( 'checked' , fs . todo ) ;
118121 } ) ;
119122
120123 // When the user changes the caret/selection in the textarea, update #lineSelect and font controls
@@ -210,8 +213,7 @@ function gen_label(preview = true, cut_once = false) {
210213 // Check label against installed label in the printer
211214 updatePrinterStatus ( ) ;
212215
213- if ( preview )
214- {
216+ if ( preview ) {
215217 // Update preview image based on label size
216218 if ( $ ( '#labelSize option:selected' ) . data ( 'round' ) == 'True' ) {
217219 $ ( 'img#previewImg' ) . addClass ( 'roundPreviewImage' ) ;
@@ -283,7 +285,7 @@ function setStatus(data, what = null) {
283285 // Status icon green checkmark
284286 $ ( '#statusIcon' ) . removeClass ( ) . addClass ( 'float-right fas fa-check text-success' ) ;
285287 }
286- else {
288+ else if ( what !== null ) {
287289 // We are currently busy preparing the preview / printing
288290 const what = data . hasOwnProperty ( 'printing' ) ? "Printing" : "Generating preview" ;
289291 $ ( '#statusPanel' ) . html ( '<div id="statusBox" class="alert alert-info" role="alert"><i class="fas fa-hourglass-half"></i><span>' + what + '...</span></div>' ) ;
@@ -297,10 +299,12 @@ function setStatus(data, what = null) {
297299 $ ( '#statusIcon' ) . removeClass ( ) . addClass ( 'float-right fas fa-print text-success' ) ;
298300 } else {
299301 extra_info = ''
300- if ( 'message' in data ) {
302+ if ( 'message' in data ) {
301303 extra_info = ':<br />' + data [ 'message' ]
302304 }
303- $ ( '#statusPanel' ) . html ( '<div id="statusBox" class="alert alert-warning" role="alert"><i class="fas fa-exclamation-triangle"></i><span>' + what + extra_info + '</span></div>' ) ;
305+ if ( what !== null ) {
306+ $ ( '#statusPanel' ) . html ( '<div id="statusBox" class="alert alert-warning" role="alert"><i class="fas fa-exclamation-triangle"></i><span>' + what + extra_info + '</span></div>' ) ;
307+ }
304308 // Status icon red exclamation
305309 $ ( '#statusIcon' ) . removeClass ( ) . addClass ( 'float-right fas fa-exclamation-triangle text-danger' ) ;
306310 }
@@ -409,7 +413,7 @@ function updatePrinterStatus() {
409413 if ( $ ( '#labelSize option:selected' ) . val ( ) . includes ( 'red' ) ) {
410414 $ ( ".red-support" ) . show ( ) ;
411415 } else {
412- $ ( '#print_color_black' ) . prop ( 'active' , true ) ;
416+ $ ( '#print_color_black' ) . prop ( 'active' , true ) ;
413417 $ ( ".red-support" ) . hide ( ) ;
414418 }
415419
@@ -445,7 +449,7 @@ function updatePrinterStatus() {
445449
446450 if ( printer_status . errors && printer_status . errors . length > 0 ) {
447451 setStatus ( { 'success' : false } )
448- const printerErrors = document . getElementById ( 'statusBox ' ) ;
452+ const printerErrors = document . getElementById ( 'printerStatusBox ' ) ;
449453 if ( printerErrors ) {
450454 printerErrors . innerHTML = '' ;
451455 printer_status . errors . forEach ( ( error ) => {
@@ -456,6 +460,14 @@ function updatePrinterStatus() {
456460 printerErrors . parentElement . style . display = '' ;
457461 }
458462 }
463+ else {
464+ // Clear printer errors
465+ const printerErrors = document . getElementById ( 'printerStatusBox' ) ;
466+ if ( printerErrors ) {
467+ printerErrors . innerHTML = '' ;
468+ printerErrors . parentElement . style . display = 'none' ;
469+ }
470+ }
459471}
460472
461473function getPrinterStatus ( ) {
@@ -472,7 +484,7 @@ const LS_KEY = 'labeldesigner_settings_v1';
472484function saveAllSettingsToLocalStorage ( ) {
473485 const data = { } ;
474486 // Save all input/select/textarea values
475- $ ( 'input, select, textarea' ) . each ( function ( ) {
487+ $ ( 'input, select, textarea' ) . each ( function ( ) {
476488 const key = this . id . length > 0 ? this . id : this . name ;
477489 if ( key . length == 0 ) return ;
478490 if ( this . type === 'checkbox' ) {
@@ -498,7 +510,7 @@ function restoreAllSettingsFromLocalStorage() {
498510 if ( ! raw ) return ;
499511 let data ;
500512 try { data = JSON . parse ( raw ) ; } catch { return ; }
501- $ ( 'input, select, textarea' ) . each ( function ( ) {
513+ $ ( 'input, select, textarea' ) . each ( function ( ) {
502514 const key = this . id || this . name ;
503515 if ( ! ( key in data ) ) return ;
504516 if ( this . type === 'checkbox' || this . type === 'radio' ) {
@@ -515,15 +527,15 @@ function restoreAllSettingsFromLocalStorage() {
515527 try {
516528 window . fontSettingsPerLine = JSON . parse ( data [ 'fontSettingsPerLine' ] ) ;
517529 $ ( '#lineSelect' ) . val ( 0 ) . trigger ( 'change' ) ;
518- } catch { }
530+ } catch { }
519531 }
520532 // Trigger preview after restore
521533 setTimeout ( ( ) => { if ( typeof preview === 'function' ) preview ( ) ; } , 100 ) ;
522534}
523535
524536function exportSettings ( ) {
525537 const data = localStorage . getItem ( LS_KEY ) || '{}' ;
526- const blob = new Blob ( [ data ] , { type : 'application/json' } ) ;
538+ const blob = new Blob ( [ data ] , { type : 'application/json' } ) ;
527539 const url = URL . createObjectURL ( blob ) ;
528540 const a = document . createElement ( 'a' ) ;
529541 a . href = url ;
@@ -537,15 +549,15 @@ function importSettings() {
537549 const input = document . createElement ( 'input' ) ;
538550 input . type = 'file' ;
539551 input . accept = 'application/json' ;
540- input . onchange = function ( e ) {
552+ input . onchange = function ( e ) {
541553 const file = e . target . files [ 0 ] ;
542554 if ( ! file ) return ;
543555 const reader = new FileReader ( ) ;
544- reader . onload = function ( evt ) {
556+ reader . onload = function ( evt ) {
545557 try {
546558 localStorage . setItem ( LS_KEY , evt . target . result ) ;
547559 restoreAllSettingsFromLocalStorage ( ) ;
548- } catch { }
560+ } catch { }
549561 } ;
550562 reader . readAsText ( file ) ;
551563 } ;
@@ -564,7 +576,7 @@ function resetSettings() {
564576
565577function set_all_inputs_default ( force = false ) {
566578 // Iterate over those <input> that have a data-default propery and set the value if empty
567- $ ( 'input[data-default], select[data-default], textarea[data-default]' ) . each ( function ( ) {
579+ $ ( 'input[data-default], select[data-default], textarea[data-default]' ) . each ( function ( ) {
568580 if ( this . type === 'checkbox' || this . type === 'radio' ) {
569581 $ ( this ) . prop ( 'checked' , $ ( this ) . data ( 'default' ) == 1 || $ ( this ) . data ( 'default' ) === true ) ;
570582 }
@@ -589,7 +601,7 @@ window.onload = function () {
589601 restoreAllSettingsFromLocalStorage ( ) ;
590602
591603 // Save on change
592- $ ( document ) . on ( 'change input' , 'input, select, textarea' , function ( ) {
604+ $ ( document ) . on ( 'change input' , 'input, select, textarea' , function ( ) {
593605 saveAllSettingsToLocalStorage ( ) ;
594606 } ) ;
595607 // Export/Import/Reset buttons
0 commit comments