1const COMMUNITY_ID = 3 2 3function addAQI(pm25, element) { 4 let aqi; 5 if (pm25 >= 0 && pm25 <= 12.0) { 6 element.innerHTML = '<span class="material-icons text-green-500">check_circle</span>' 7 } else if (pm25 > 12.0 && pm25 <= 35.4) { 8 element.innerHTML = '<span class="material-icons text-yellow-500">warning</span>' 9 } else if (pm25 > 35.4 && pm25 <= 55.4) { 10 element.innerHTML = '<span class="material-icons text-red-500">dangerous</span>' 11 } else if (pm25 > 55.4 && pm25 <= 150.4) { 12 element.innerHTML = '<span class="material-icons text-red-500">dangerous</span>' 13 } else if (pm25 > 150.4 && pm25 <= 250.4) { 14 element.innerHTML = '<span class="material-icons text-red-900">dangerous</span>' 15 } else { 16 element.innerHTML = '<span class="material-icons text-red-900">dangerous</span>' 17 } 18 return; 19} 20 21export function initEcomonitoringVidget() { 22 const widget = document.querySelector(".ecomonitoring") 23 if (!widget) return 24 25 const communityId = widget.dataset.communityId || COMMUNITY_ID 26 27 const xmlhttp = new XMLHttpRequest(); 28 xmlhttp.onreadystatechange = function () { 29 if (this.readyState == 4 && this.status == 200) { 30 const response = JSON.parse(this.responseText) 31 //widget.querySelector('.aqi').style.padding = "12px 8px" 32 //widget.querySelector('.aqi').style.margin = "12px 0 -10px 0" 33 let aqi = addAQI(response.pm25, widget.querySelector('.aqi')) 34 widget.querySelector('.humidity').innerHTML = `${response.humidity}%` 35 widget.querySelector('.temperature').innerHTML = `${response.temperature}<sup>â</sup>` 36 } 37 } 38 xmlhttp.open("GET", `https://api.toolkit.in.ua/ecoapi/v1/get-data-short/${communityId}`, true); 39 xmlhttp.send(); 40} 41 42 43/* function calculateAQI(pm25) { 44 let aqi; 45 if (pm25 >= 0 && pm25 <= 12.0) { 46 aqi = interpolate(pm25, 0, 12.0, 0, 50); 47 } else if (pm25 > 12.0 && pm25 <= 35.4) { 48 aqi = interpolate(pm25, 12.1, 35.4, 51, 100); 49 } else if (pm25 > 35.4 && pm25 <= 55.4) { 50 aqi = interpolate(pm25, 35.5, 55.4, 101, 150); 51 } else if (pm25 > 55.4 && pm25 <= 150.4) { 52 aqi = interpolate(pm25, 55.5, 150.4, 151, 200); 53 } else if (pm25 > 150.4 && pm25 <= 250.4) { 54 aqi = interpolate(pm25, 150.5, 250.4, 201, 300); 55 } else if (pm25 > 250.4 && pm25 <= 350.4) { 56 aqi = interpolate(pm25, 250.5, 350.4, 301, 400); 57 } else if (pm25 > 350.4 && pm25 <= 500.4) { 58 aqi = interpolate(pm25, 350.5, 500.4, 401, 500); 59 } else { 60 aqi = "out of range"; 61 } 62 return aqi; 63 } 64 65 function interpolate(value, low1, high1, low2, high2) { 66 return Math.round(((high2 - low2) * (value - low1)) / (high1 - low1) + low2); 67 }*/
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.