File size: 2,473 Bytes
3af080a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
import L from 'leaflet';
import { formattedTarkovTime } from '../components/Time.jsx';
let updateTimeInterval = false;
L.Control.RaidInfo = L.Control.extend({
onAdd: function(map) {
clearInterval(updateTimeInterval);
const wrapper = L.DomUtil.create('div');
wrapper.classList.add('time-wrapper', 'leaflet-control-raid-info');
if (this.options.map.normalizedName !== 'the-lab') {
const timeLeftDiv = L.DomUtil.create('div');
const timeRightDiv = L.DomUtil.create('div');
if (this.options.map.normalizedName === 'factory' || this.options.map.normalizedName === 'night-factory') {
timeLeftDiv.innerText = '15:28:00';
timeRightDiv.innerText = '03:28:00';
} else {
const updateTimes = () => {
timeLeftDiv.innerText = formattedTarkovTime(true);
timeRightDiv.innerText = formattedTarkovTime(false);
};
updateTimeInterval = setInterval(updateTimes, 50);
}
wrapper.append(timeLeftDiv);
wrapper.append(timeRightDiv);
}
const duration = L.DomUtil.create('div');
const durLabel = this.options.durationLabel ? this.options.durationLabel : 'Duration';
duration.innerText = `${durLabel}: ${this.options.map.duration}`;
wrapper.append(duration);
const players = L.DomUtil.create('div');
const playersLabel = this.options.playersLabel ? this.options.playersLabel : 'Players';
players.innerText = `${playersLabel}: ${this.options.map.players}`;
wrapper.append(players);
if (this.options.map.author) {
const author = L.DomUtil.create('div');
const byLabel = this.options.byLabel ? this.options.byLabel : 'By';
author.innerText = `${byLabel}: `;
const authorLink = L.DomUtil.create('a');
authorLink.setAttribute('href', this.options.map.authorLink);
authorLink.setAttribute('target', '_blank');
authorLink.setAttribute('re', 'noopener noreferrer');
authorLink.innerText = this.options.map.author;
author.append(authorLink);
wrapper.append(author);
}
return wrapper;
},
onRemove: function(map) {
// Nothing to do here
}
});
L.control.raidInfo = function(opts) {
return new L.Control.RaidInfo(opts);
} |