1class FavoritesCounter { 2 keyLocalStorage = 'vehicles-favorites'; 3 4 static _instance; 5 6 static the() { 7 if (!FavoritesCounter._instance) { 8 FavoritesCounter._instance = new FavoritesCounter(); 9 } 10 11 return FavoritesCounter._instance; 12 } 13 14 constructor() { 15 window.addEventListener('storage', this.processFavoritesStorageEvent.bind(this), false); 16 this.updateFavoritesCounter(); 17 } 18 19 updateFavoritesCounter() { 20 const json_vehicles_favorites = localStorage.getItem(this.keyLocalStorage) 21 let storage_vehicle_favorites = JSON.parse(json_vehicles_favorites); 22 23 const vehiclesFavoritesCount_value = document.querySelector('.dpdsh-vehicles-favorites-count__value'); 24 if (vehiclesFavoritesCount_value) { 25 vehiclesFavoritesCount_value.innerHTML = storage_vehicle_favorites.length; 26 } 27 } 28 29 processFavoritesStorageEvent({ key }) { 30 if (key === 'vehicles-favorites') { 31 this.updateFavoritesCounter(); 32 } 33 } 34} 35 36window.addEventListener('DOMContentLoaded', () => { 37 FavoritesCounter.the(); 38})
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.