@@ -34,6 +34,7 @@ import './help_ui';
3434import { css , html , LitElement } from 'lit' ;
3535import { customElement , query } from 'lit/decorators.js' ;
3636
37+ import { sourceTagsFromBatchesAndCommonFields } from './common_field' ;
3738import { Batch } from './entry' ;
3839import { loadBatchJson , loadJsonContainingBatchJsonPaths } from './entry_loader' ;
3940import { dispatch , EventType , listen } from './events' ;
@@ -44,13 +45,17 @@ import {SettingsUi} from './settings_ui';
4445import { State } from './state' ;
4546import { Tab } from './tab' ;
4647import { UrlState } from './url_state' ;
48+ import { reverseMap } from './utils' ;
4749
4850/** Main component of the codec comparison static viewer. */
4951@customElement ( 'codec-compare' )
5052export class CodecCompare extends LitElement {
5153 /** The root data object containing the full state. */
5254 private readonly state = new State ( ) ;
5355 private readonly urlState = new UrlState ( ) ;
56+ /** Maps asset tags to the set of source asset names that have them. */
57+ private tagToAssetNames = new Map < string , Set < string > > ( ) ;
58+ private assetNameToTags = new Map < string , Set < string > > ( ) ;
5459 /** True if all batches are loaded into the state. */
5560 private isLoaded = false ;
5661 /** True if at least one batch failed to load. */
@@ -74,18 +79,20 @@ export class CodecCompare extends LitElement {
7479 }
7580
7681 private renderSentence ( ) {
77- // #sentenceContainer is an overlay of the whole #comparisons block.
7882 return html `
7983 <div id= "sentenceContainer" >
8084 <sentence- ui .state = ${ this . state } > </ sentence- ui>
8185 </ div> ` ;
8286 }
8387
8488 private renderGallery ( ) {
85- // #galleryContainer is an overlay of the whole #comparisons block.
8689 return html `
8790 <div id= "galleryContainer" >
88- <gallery- ui .state = ${ this . state } > </ gallery- ui>
91+ <gallery- ui
92+ .state = ${ this . state }
93+ .tagToAssetNames = ${ this . tagToAssetNames }
94+ .assetNameToTags = ${ this . assetNameToTags } >
95+ </ gallery- ui>
8996 </ div> ` ;
9097 }
9198
@@ -201,7 +208,7 @@ export class CodecCompare extends LitElement {
201208 </ p>
202209
203210 <p id= "credits" >
204- Codec Compare beta version 0.2.4 <br>
211+ Codec Compare beta version 0.2.5 <br>
205212 <a href= "https://github.com/webmproject/codec-compare" >
206213 Sources on GitHub
207214 </ a>
@@ -241,6 +248,9 @@ export class CodecCompare extends LitElement {
241248
242249 private async onAllBatchesLoaded ( ) {
243250 this . state . initialize ( ) ;
251+ this . tagToAssetNames = sourceTagsFromBatchesAndCommonFields (
252+ this . state . batches , this . state . commonFields ) ;
253+ this . assetNameToTags = reverseMap ( this . tagToAssetNames ) ;
244254 this . urlState . setDefaultValues ( this . state ) ;
245255 this . state . initializePostUrlStateDefaultValues ( ) ;
246256 this . urlState . load ( this . state ) ;
0 commit comments