2020-06-29 19:21:56 +00:00
|
|
|
// Copyright 2020 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
2020-11-03 08:01:33 +00:00
|
|
|
import './stats-panel.mjs';
|
|
|
|
import './map-panel/map-details.mjs';
|
|
|
|
import './map-panel/map-transitions.mjs';
|
2020-06-29 19:21:56 +00:00
|
|
|
|
2020-11-03 08:01:33 +00:00
|
|
|
import {FocusEvent} from './events.mjs';
|
|
|
|
import {DOM, V8CustomElement} from './helper.mjs';
|
|
|
|
import {MapLogEntry} from './log/map.mjs';
|
2020-06-29 19:21:56 +00:00
|
|
|
|
2020-11-03 08:01:33 +00:00
|
|
|
DOM.defineCustomElement('map-panel',
|
|
|
|
(templateText) =>
|
|
|
|
class MapPanel extends V8CustomElement {
|
|
|
|
_map;
|
|
|
|
constructor() {
|
|
|
|
super(templateText);
|
|
|
|
this.searchBarBtn.addEventListener('click', e => this.handleSearchBar(e));
|
|
|
|
this.addEventListener(FocusEvent.name, e => this.handleUpdateMapDetails(e));
|
|
|
|
}
|
2020-06-29 19:21:56 +00:00
|
|
|
|
2020-11-03 08:01:33 +00:00
|
|
|
handleUpdateMapDetails(e) {
|
|
|
|
if (e.entry instanceof MapLogEntry) {
|
2020-11-10 13:21:40 +00:00
|
|
|
this.mapDetailsPanel.map = e.entry;
|
2020-08-13 09:14:29 +00:00
|
|
|
}
|
2020-11-03 08:01:33 +00:00
|
|
|
}
|
2020-06-29 19:21:56 +00:00
|
|
|
|
2020-11-03 08:01:33 +00:00
|
|
|
get mapTransitionsPanel() {
|
|
|
|
return this.$('#map-transitions');
|
|
|
|
}
|
2020-07-15 04:51:13 +00:00
|
|
|
|
2020-11-03 08:01:33 +00:00
|
|
|
get mapDetailsPanel() {
|
|
|
|
return this.$('#map-details');
|
|
|
|
}
|
2020-07-10 10:02:08 +00:00
|
|
|
|
2020-11-03 08:01:33 +00:00
|
|
|
get searchBarBtn() {
|
|
|
|
return this.$('#searchBarBtn');
|
|
|
|
}
|
2020-07-22 15:00:22 +00:00
|
|
|
|
2020-11-03 08:01:33 +00:00
|
|
|
get searchBar() {
|
|
|
|
return this.$('#searchBar');
|
|
|
|
}
|
2020-07-10 10:02:08 +00:00
|
|
|
|
2020-11-03 08:01:33 +00:00
|
|
|
set timeline(timeline) {
|
|
|
|
this._timeline = timeline;
|
|
|
|
}
|
2020-06-29 19:21:56 +00:00
|
|
|
|
2020-11-03 08:01:33 +00:00
|
|
|
set map(value) {
|
|
|
|
this._map = value;
|
|
|
|
this.mapTransitionsPanel.map = this._map;
|
|
|
|
}
|
2020-07-10 10:02:08 +00:00
|
|
|
|
2020-11-03 08:01:33 +00:00
|
|
|
handleSearchBar(e) {
|
|
|
|
let searchBar = this.$('#searchBarInput');
|
|
|
|
let searchBarInput = searchBar.value;
|
|
|
|
// access the map from model cache
|
|
|
|
let selectedMap = MapLogEntry.get(parseInt(searchBarInput));
|
|
|
|
if (selectedMap) {
|
|
|
|
searchBar.className = 'success';
|
|
|
|
} else {
|
|
|
|
searchBar.className = 'failure';
|
2020-08-13 09:14:29 +00:00
|
|
|
}
|
2020-11-03 08:01:33 +00:00
|
|
|
this.dispatchEvent(new FocusEvent(selectedMap));
|
|
|
|
}
|
2020-07-16 11:34:03 +00:00
|
|
|
|
2020-11-03 08:01:33 +00:00
|
|
|
set selectedMapLogEntries(list) {
|
|
|
|
this.mapTransitionsPanel.selectedMapLogEntries = list;
|
|
|
|
}
|
|
|
|
get selectedMapLogEntries() {
|
|
|
|
return this.mapTransitionsPanel.selectedMapLogEntries;
|
|
|
|
}
|
|
|
|
});
|