58 lines
No EOL
2.6 KiB
JavaScript
Executable file
58 lines
No EOL
2.6 KiB
JavaScript
Executable file
class BlueWeatherIndex {
|
|
|
|
constructor() {
|
|
this.initDone = false
|
|
this.blueweather = new BlueWeather("profileContainer")
|
|
|
|
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 = '<svg class="bd-placeholder-img mr-2 rounded" width="32" height="32" src="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid slice" focusable="false" role="img" aria-label="Placeholder: 32x32"><rect width="100%" height="100%" fill="#007bff" /><text x="50%" y="50%" fill="#007bff" dy=".3em">32x32</text></svg>'
|
|
|
|
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;"
|
|
})
|
|
}
|
|
}
|
|
feather.replace()
|
|
index = new BlueWeatherIndex() |