1class BrusselsTimeComponent extends HTMLElement { 2 constructor() { 3 super(); 4 this.intervalId = null; 5 } 6 7 connectedCallback() { 8 this.render(); 9 this.startTimer(); 10 } 11 12 disconnectedCallback() { 13 this.stopTimer(); 14 } 15 16 getBrusselsTime() { 17 const options = { 18 timeZone: "Europe/Brussels", 19 hour12: false, 20 hour: "2-digit", 21 minute: "2-digit", 22 }; 23 const formatter = new Intl.DateTimeFormat([], options); 24 return formatter.format(new Date()); 25 } 26 27 updateTime() { 28 const timeContainer = this.querySelector("#time-container"); 29 timeContainer.textContent = `${this.getBrusselsTime()}`; 30 } 31 32 startTimer() { 33 this.updateTime(); 34 this.intervalId = setInterval(() => this.updateTime(), 10000); 35 } 36 37 stopTimer() { 38 if (this.intervalId) { 39 clearInterval(this.intervalId); 40 this.intervalId = null; 41 } 42 } 43 44 render() { 45 this.innerHTML = ` 46 <span id="time-container"></span> 47 `; 48 } 49} 50 51customElements.define("brussels-time", BrusselsTimeComponent); 52 53// remove hashes from in-page scroll links 54window.addEventListener("hashchange", () => { 55 history.replaceState( 56 null, 57 "", 58 window.location.pathname + window.location.search, 59 ); 60});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.