@@ -95,6 +95,40 @@ function set_image_settings(settings) {
9595}
9696
9797
98+ async function update_svg_color ( score , color ) {
99+ const svg = document . querySelector ( `#color${ score } ` ) . parentElement . querySelector ( "svg" ) ;
100+ if ( svg ) {
101+ svg . style . color = color ;
102+ }
103+ png_settings . colors [ score ] = color ;
104+ }
105+
106+
107+ async function setup_palette_settings ( ) {
108+ const colors = png_settings . colors ;
109+
110+ for ( let score = 1 ; score <= 5 ; score ++ ) {
111+ const cell = document . querySelector ( `#color${ score } ` ) . parentElement ;
112+ const input = document . getElementById ( `color${ score } ` ) ;
113+
114+ input . classList . add ( "color-picker-overlay" ) ;
115+
116+ let old_svg = cell . querySelector ( "svg" ) ;
117+ if ( ! old_svg ) {
118+ const svg = await load_colored_score_SVG ( score ) ;
119+ svg . classList . add ( "color-icon" ) ;
120+ svg . style . color = colors [ score ] ;
121+
122+ input . addEventListener ( "input" , ( ) => {
123+ update_svg_color ( score , input . value ) ;
124+ } ) ;
125+
126+ cell . appendChild ( svg ) ;
127+ }
128+ }
129+ }
130+
131+
98132function get_user_colors ( scores_map = null ) {
99133 const colors_array = [
100134 setting_color1 . value ,
@@ -502,6 +536,7 @@ function filter_pixels_by_keyword(keyword, isTag=false) {
502536 current_data . forEach ( pixel => {
503537 const date = normalize_date ( pixel . date ) ;
504538 const scores = pixel . scores || [ ] ;
539+ if ( scores . length === 0 ) { return ; }
505540 const notes = normalize_string ( pixel . notes || "" ) ;
506541
507542 let hasMatch = false ;
@@ -527,7 +562,7 @@ function filter_pixels_by_keyword(keyword, isTag=false) {
527562}
528563
529564
530- function filter_pixels_by_two_keywords ( keyword1 , keyword2 , isTag1 = false , isTag2 = false ) {
565+ function filter_pixels_by_two_keywords ( keyword1 , keyword2 , isTag1 = false , isTag2 = false , exclude = false ) {
531566 if (
532567 ! keyword1 || keyword1 . trim ( ) === "" ||
533568 ! keyword2 || keyword2 . trim ( ) === "" ||
@@ -544,6 +579,8 @@ function filter_pixels_by_two_keywords(keyword1, keyword2, isTag1 = false, isTag
544579
545580 current_data . forEach ( pixel => {
546581 const date = normalize_date ( pixel . date ) ;
582+ const scores = pixel . scores || [ ] ;
583+ if ( scores . length === 0 ) { return ; }
547584
548585 let match1 = false ;
549586 let match2 = false ;
@@ -578,14 +615,21 @@ function filter_pixels_by_two_keywords(keyword1, keyword2, isTag1 = false, isTag
578615 ) ;
579616 }
580617
581- if ( match1 && match2 ) {
582- result . push ( { date, scores : [ 3 ] } ) ;
583- }
584- else if ( match1 ) {
585- result . push ( { date, scores : [ 5 ] } ) ;
586- }
587- else if ( match2 ) {
588- result . push ( { date, scores : [ 1 ] } ) ;
618+ if ( exclude ) {
619+ if ( match1 && ! match2 ) {
620+ result . push ( { date, scores } ) ;
621+ }
622+ }
623+ else {
624+ if ( match1 && match2 ) {
625+ result . push ( { date, scores : [ 3 ] } ) ;
626+ }
627+ else if ( match1 ) {
628+ result . push ( { date, scores : [ 5 ] } ) ;
629+ }
630+ else if ( match2 ) {
631+ result . push ( { date, scores : [ 1 ] } ) ;
632+ }
589633 }
590634 } ) ;
591635
@@ -597,10 +641,11 @@ function get_compare_settings() {
597641 const showFilter = parseInt ( setting_showFilter . value , 10 ) ;
598642 const compareTag1 = compareSelect1 . value === "tag" ;
599643 const compareTag2 = compareSelect2 . value === "tag" ;
644+ const isExcludeMode = ( showFilter === 3 ) ;
600645 const value1 = compareTag1 ? compareTagSelect1 . value : compareWordInput1 . value . trim ( ) ;
601646 const value2 = compareTag2 ? compareTagSelect2 . value : compareWordInput2 . value . trim ( ) ;
602647 if ( ( showFilter > 1 ) && value1 && value2 ) {
603- return filter_pixels_by_two_keywords ( value1 , value2 , compareTag1 , compareTag2 ) ;
648+ return filter_pixels_by_two_keywords ( value1 , value2 , compareTag1 , compareTag2 , isExcludeMode ) ;
604649 }
605650 else if ( ( showFilter > 0 ) && value1 ) {
606651 return filter_pixels_by_keyword ( value1 , compareTag1 ) ;
@@ -620,9 +665,24 @@ async function set_filter_display() {
620665 div_compareSearchOptions1 . style . display = ( filterState === "0" ) ? "none" : "flex" ;
621666 div_compareSearchOptions2 . style . display = ( ( filterState === "0" ) || ( filterState === "1" ) ) ? "none" : "flex" ;
622667 label_compareSelect1 . innerText = ( filterState === "2" ) ? "Compare" : "Filter" ;
668+ label_compareSelect2 . innerText = ( filterState === "3" ) ? "Without" : "With" ;
623669
624670 label_compareSelect1 . style . color = ( filterState === "2" ) ? png_settings . colors [ 5 ] : "black" ;
625671 label_compareSelect2 . style . color = ( filterState === "2" ) ? png_settings . colors [ 1 ] : "black" ;
672+
673+ label_compareSelect2 . style . textDecoration = ( filterState === "3" ) ?"line-through" : "none" ;
674+
675+ if ( filterState === "1" ) {
676+ label_compareSelect1 . title = "The pixels with this word/tag will be shown" ;
677+ }
678+ else if ( filterState === "2" ) {
679+ label_compareSelect1 . title = "The pixels with this word/tag will be shown in color 5" ;
680+ label_compareSelect2 . title = "The pixels with this word/tag will be shown in color 1" ;
681+ }
682+ else if ( filterState === "3" ) {
683+ label_compareSelect1 . title = "The pixels with this word/tag but without the other will be shown" ;
684+ label_compareSelect2 . title = "The pixels with this word/tag will be hidden from the image" ;
685+ }
626686}
627687
628688
@@ -666,6 +726,7 @@ btn_reset_palette_settings.addEventListener("click", () => {
666726
667727btn_save_palette_settings . addEventListener ( "click" , ( ) => {
668728 close_dialog_settings ( save = true ) ;
729+ show_popup_message ( "Palette settings saved" , 3000 , "success" ) ;
669730} ) ;
670731
671732btn_save_dialog_settings . addEventListener ( "click" , ( ) => {
0 commit comments