class BlueWeatherIndex { constructor() { this.initDone = false this.blueweather = new BlueWeather() this.initDone = true this.loadLocations() } loadLocations () { // page: -1 for dashboard or sensor id var mainContent = document.getElementById('locationsList') var loader = document.getElementById('loader') mainContent.style = "opacity: 0;" loader.style = "padding-left: 50%; padding-top:15px; opacity: 1; width:0;" this.blueweather.getLocations(true, function(locations) { var locationsList = document.getElementById("locationsList") locationsList.innerHTML = "" for(var location in locations) { var thisLocation = locations[location] var locDiv = document.createElement("div") locationsList.appendChild(locDiv) locDiv.classList.add("media", "text-muted", "pt-3") locDiv.innerHTML = '32x32' var locBody = document.createElement("p") locDiv.appendChild(locBody) locBody.classList.add("media-body", "pb-3", "mb-0", "small", "lh-125", "border-bottom", "border-gray") var locHeading = document.createElement("strong") locBody.appendChild(locHeading) locHeading.classList.add("d-block", "text-gray-dark") var locHeadingText = document.createElement("a") locHeading.appendChild(locHeadingText) locHeadingText.href = "dashboard.html?params=" + JSON.stringify({loc: parseInt(thisLocation.id)}) locHeadingText.innerHTML = thisLocation.locationname var locLocationLink = document.createElement("a") locBody.appendChild(locLocationLink) locLocationLink.href = "https://www.openstreetmap.org/#map=19/" + thisLocation.latitude + "/" + thisLocation.longitude locLocationLink.target = "blank" locLocationLink.innerHTML = "View on map" } loader.style = "padding-left: 50%; padding-top:0px; opacity: 0; width:0; height:0;" mainContent.classList.add("opacity-animated"); mainContent.style = "opacity: 1;" }) } } index = new BlueWeatherIndex()