35 lines
978 B
JavaScript
35 lines
978 B
JavaScript
class DatesIndicator extends HTMLElement{
|
|
constructor(oldestTimestamp, newestTimestamp){
|
|
super();
|
|
this.oldestDate = this.timestampToString(oldestTimestamp);
|
|
this.newestDate = this.timestampToString(newestTimestamp);
|
|
}
|
|
|
|
timestampToString(timestamp){
|
|
let date = new Date(timestamp);
|
|
return date.toUTCString();
|
|
}
|
|
|
|
update(oldestTimestamp, newestTimestamp){
|
|
this.oldestDate = this.timestampToString(oldestTimestamp);
|
|
this.newestDate = this.timestampToString(newestTimestamp);
|
|
this.render()
|
|
}
|
|
|
|
connectedCallback(){
|
|
this.render();
|
|
}
|
|
|
|
render(){
|
|
this.innerHTML = `
|
|
<link rel="stylesheet" href="components/states_indicator/dates/dates.css">
|
|
<div class="dates">
|
|
${this.oldestDate}
|
|
->
|
|
${this.newestDate}
|
|
</div>
|
|
`
|
|
}
|
|
}
|
|
|
|
customElements.define("sea-dates-indicator", DatesIndicator) |