@@ -381,7 +381,8 @@ function updateDisplay(){
381381 curr_bin_size = LAB_BIN_SIZES . find ( ( bin ) => bin . abv == curr_bin_size )
382382
383383 if ( ! language_stats [ curr_bin_size ] || ! language_stats [ curr_bin_size ] [ curr_blur ] ) {
384- d3 . select ( "#main" )
384+ d3 . select ( "#maps_div" )
385+ . html ( "" )
385386 . append ( "p" )
386387 . attr ( "id" , "loading-p" )
387388 . html ( "loading..." )
@@ -401,7 +402,7 @@ function updateDisplay(){
401402 }
402403
403404 //TODO: have maximum for height too
404- currSvgSize [ 0 ] . width = $ ( "#main " ) . width ( )
405+ currSvgSize [ 0 ] . width = $ ( "#maps_div " ) . width ( )
405406 currSvgSize [ 0 ] . height = currSvgSize [ 0 ] . width * binView . display_offsets . y_height_in_bins / binView . display_offsets . x_width_in_bins
406407
407408 // const language_stat = language_stats[curr_bin_size][curr_blur][0]
@@ -414,7 +415,7 @@ function updateDisplay(){
414415 this . style [ "min-width" ] = svg_widths [ curr_bin_size ] + 5 + "px"
415416 } )
416417
417- d3 . select ( "#main " )
418+ d3 . select ( "#maps_div " )
418419 . selectAll ( "#vis" )
419420 . data ( currSvgSize ) // single data point, but uses d3 for updating
420421 . join ( "div" )
@@ -524,26 +525,6 @@ function createOrRefreshLang(i){
524525 } ) ;
525526 }
526527
527- let langLabel = "All Color Bins (Reference)"
528- if ( i != - 1 ) {
529- const language_stat = language_stats [ curr_bin_size ] [ curr_blur ] [ i ]
530- langLabel = language_stat . lang
531- }
532- $ ( "#" + lang_id_str + " .lang-label" ) . text ( langLabel )
533-
534-
535- if ( i != - 1 ) {
536- $ ( `#${ lang_id_str } #selected_color_${ i } option` ) . remove ( )
537- const language_stat = language_stats [ curr_bin_size ] [ curr_blur ] [ i ]
538- const newOptions = color_names_by_lang [ curr_bin_size ] [ curr_blur ] [ language_stat . lang ] . map ( ( colorInfo ) => {
539- return `<option value="${ colorInfo . colorName } " data-commonColorName="${ colorInfo . colorName } "
540- style='background-color:${ colorInfo . avgTermColor } '>
541- ${ colorInfo . colorName }
542- </option>`
543- } )
544- $ ( `#${ lang_id_str } #selected_color_${ i } ` ) . append ( newOptions ) . trigger ( 'change' ) ;
545- }
546-
547528 $ ( `#${ lang_id_str } #selected_color_${ i } ` ) . change ( function ( ) {
548529 const selection = lang_color_selections [ curr_bin_size ] [ curr_blur ] [ i ]
549530 if ( this . value == COLOR_NAME_UNSELECTED ) {
@@ -559,6 +540,37 @@ function createOrRefreshLang(i){
559540 svg = d3 . select ( "#" + lang_id_str ) . append ( "svg" )
560541 }
561542
543+ let langLabel = "All Color Bins (Reference)"
544+ if ( i != - 1 ) {
545+ const language_stat = language_stats [ curr_bin_size ] [ curr_blur ] [ i ]
546+ langLabel = language_stat . lang
547+ }
548+ $ ( "#" + lang_id_str + " .lang-label" ) . text ( langLabel )
549+
550+
551+ if ( i != - 1 ) {
552+ // if options (color names) have changed, replace them
553+ const language_stat = language_stats [ curr_bin_size ] [ curr_blur ] [ i ]
554+
555+ const currNames = $ ( `#${ lang_id_str } #selected_color_${ i } option` ) . map ( function ( a ) {
556+ return this . value } ) . get ( )
557+ const newNames = color_names_by_lang [ curr_bin_size ] [ curr_blur ] [ language_stat . lang ] . map ( colorInfo => colorInfo . colorName )
558+
559+ if ( JSON . stringify ( currNames ) != JSON . stringify ( newNames ) ) {
560+ $ ( `#${ lang_id_str } #selected_color_${ i } option` ) . remove ( )
561+ const language_stat = language_stats [ curr_bin_size ] [ curr_blur ] [ i ]
562+ const newOptions = color_names_by_lang [ curr_bin_size ] [ curr_blur ] [ language_stat . lang ] . map ( ( colorInfo ) => {
563+ return `<option value="${ colorInfo . colorName } " data-commonColorName="${ colorInfo . colorName } "
564+ style='background-color:${ colorInfo . avgTermColor } '>
565+ ${ colorInfo . colorName }
566+ </option>`
567+ } )
568+ $ ( `#${ lang_id_str } #selected_color_${ i } ` ) . append ( newOptions ) . trigger ( 'change' ) ;
569+ }
570+
571+
572+ }
573+
562574 svg . attr ( "width" , currSvgSize [ 0 ] . width )
563575 . attr ( "height" , currSvgSize [ 0 ] . height )
564576
0 commit comments