@@ -201,6 +201,7 @@ <h1 style="display: flex; align-items: center;">
201201 var gradientLength = rect . width ;
202202 var mOffs = Math . round ( ( gradientLength / 256 ) / 2 ) - 5 ;
203203 var paletteArray = [ ] ; //Holds the palettes after load.
204+ var paletteName = [ ] ; // Holds the names of the palettes after load.
204205 var svgSave = '<svg style="width:25px;height:25px" viewBox="0 0 24 24"><path fill=#fff d="M22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1 12,2A10,10 0 0,1 22,12M7,12L12,17V14H16V10H12V7L7,12Z"/></svg>'
205206 var svgEdit = '<svg style="width:25px;height:25px" viewBox="0 0 24 24"><path fill=#fff d="M12,2C6.47,2 2,6.47 2,12C2,17.53 6.47,22 12,22C17.53,22 22,17.53 22,12C22,6.47 17.53,2 12,2M15.1,7.07C15.24,7.07 15.38,7.12 15.5,7.23L16.77,8.5C17,8.72 17,9.07 16.77,9.28L15.77,10.28L13.72,8.23L14.72,7.23C14.82,7.12 14.96,7.07 15.1,7.07M13.13,8.81L15.19,10.87L9.13,16.93H7.07V14.87L13.13,8.81Z"/></svg>'
206207
@@ -520,8 +521,10 @@ <h1 style="display: flex; align-items: center;">
520521 if ( hst . length > 0 ) {
521522 try {
522523 var arr = [ ] ;
523- const response = await fetch ( 'http://' + hst + '/json/info' ) ;
524- const json = await response . json ( ) ;
524+ const responseInfo = await fetch ( 'http://' + hst + '/json/info' ) ;
525+ const responsePalettes = await fetch ( 'http://' + hst + '/json/palettes' ) ;
526+ const json = await responseInfo . json ( ) ;
527+ paletteName = await responsePalettes . json ( ) ;
525528 cpalc = json . cpalcount ;
526529 fetchPalettes ( cpalc - 1 ) ;
527530 } catch ( error ) {
@@ -560,6 +563,7 @@ <h1 style="display: flex; align-items: center;">
560563 alert ( "The cache of palettes are missig from your browser. You should probably return to the main page and let it load properly for the palettes cache to regenerate before returning here." , "Missing cached palettes!" )
561564 } else {
562565 for ( const key in wledPalx . p ) {
566+ wledPalx . p [ key ] . name = paletteName [ key ] ;
563567 if ( key > 245 ) {
564568 delete wledPalx . p [ key ] ;
565569 continue ;
@@ -591,8 +595,11 @@ <h1 style="display: flex; align-items: center;">
591595 }
592596
593597 const pArray = Object . entries ( wledPalx . p ) . map ( ( [ key , value ] ) => ( {
594- [ key ] : value . flat ( )
598+ [ key ] : value . flat ( ) ,
599+ name : value . name
595600 } ) ) ;
601+ // Sort pArray by name
602+ pArray . sort ( ( a , b ) => a . name . localeCompare ( b . name ) ) ;
596603
597604 paletteArray . push ( ...pArray ) ;
598605 }
@@ -634,6 +641,9 @@ <h1 style="display: flex; align-items: center;">
634641 editSpan . id = `editSpan${ i } ` ;
635642 editSpan . onclick = function ( ) { loadForEdit ( i ) } ;
636643 editSpan . setAttribute ( 'title' , `Copy slot ${ i } palette to editor` ) ;
644+ if ( paletteArray [ i ] . name ) {
645+ editSpan . setAttribute ( 'title' , `Copy ${ paletteArray [ i ] . name } palette to editor` ) ;
646+ }
637647 editSpan . innerHTML = svgEdit ;
638648 editSpan . classList . add ( "editSpan" )
639649
0 commit comments