1 2 3var emptyDataCellColor = '#C9CECE'; 4 5 6 7function makeSafeForCSS(name) { 8 return name.replace(/[^a-z0-9]/g, function(s) { 9 var c = s.charCodeAt(0); 10 if (c == 32) return '-'; 11 if (c >= 65 && c <= 90) return '_' + s.toLowerCase(); 12 return '__' + ('000' + c.toString(16)).slice(-4); 13 }); 14} 15 16String.prototype.safeCSSId = function() { 17 return encodeURIComponent( 18 this.toLowerCase() 19 ).replace(/%[0-9A-F]{2}/gi,''); 20} 21 22 23 24 25function prePopulateSiteTable(siteNameList) { 26 27 $.tablesorter.addParser({ 28 id: 'customsort', 29 is: function (s) { 30 return false; 31 }, 32 format: function (s, table, cell, cellIndex) { 33 return $(cell).attr('data-sort-value'); 34 }, 35 type: 'numeric' 36 }); 37 38 $("#currentStatusTable").tablesorter({ 39 sortList: [[0,0]], 40 emptyTo: 'bottom', 41 headers: { 42 43 1: { 44 sorter: 'customsort' 45 }, 46 3: { 47 sorter: 'customsort' 48 }, 49 50 } 51 }); 52 53 54 55 56 $.each(siteNameList, function(key, siteName) { 57 58 var newRowContent = "<tr id=\"" + makeSafeForCSS(siteName) + "_row\" onclick=\"location.href='https://gbuapcd.org/cgi-bin/tabularViewer?siteName=AirVision/" + siteName + "'\">"; 59 newRowContent += "<td style=\"text-align: center;\">" + siteName + "</td>"; 60 newRowContent += "<td style=\"text-align: center;\"><i class=\"fad fa-cog fa-spin fa-2x\"></i></td>"; 61 newRowContent += "<td style=\"text-align: center;\"><i class=\"fad fa-cog fa-spin fa-2x\"></i></td>"; 62 newRowContent += "<td style=\"text-align: center;\"><i class=\"fad fa-cog fa-spin fa-2x\"></i></td>"; 63 newRowContent += "</tr>"; 64 $("#currentStatusTable tbody").append(newRowContent); 65 66 67 }); 68} 69 70 71 72 73function populateSiteTable(siteNameList) { 74 75 var isDST = checkforDST(); //From timeTools.js 76 // var offset; 77 78 if (isDST == true) { 79 var offset = 1000*60*60*7 80 } else { 81 var offset = 1000*60*60*8 82 } 83 84 var today = new Date(); 85 var adjustedtoPST = new Date(today.getTime() + 1000*60*today.getTimezoneOffset() - offset) 86 87 var minutesAfterCutoff = 13; 88 var pm10DataStale; 89 var pm10DataHourStart; //data start of hour. So 9:00 is from 9:00 to 10:00 etc. 90 var pm25DataStale; 91 var pm25DataHourStart; //data start of hour. So 9:00 is from 9:00 to 10:00 etc. 92 var windDataStale;
93 var windDataHourStart; //data start of hour. So 9:00 is from 9:00 to 10:00 etc. 94 var diffMs; 95 96 $.each(siteNameList, function(key, siteName) { 97 $.getJSON( "https://gbuapcd.org/bigiron/airvisionMeta/"+siteName+".json", function( data ) { 98 99 100 pm10DataStale = false; 101 if (typeof data.lastPM10 != 'undefined') { 102 pm10DataHourStart = new Date(data.lastPM10.dateTime); 103 // console.log(pm10DataHourStart) 104 if (data.DST == true) { 105 diffMs = (adjustedtoPST - pm10DataHourStart)-(1000*60*60); 106 } else { 107 diffMs = (adjustedtoPST - pm10DataHourStart); 108 } 109 if ((diffMs/1000/60 - 60 - 60 ) > minutesAfterCutoff) { 110 pm10DataStale = true; 111 112 // console.log(data) 113 } 114 } 115 116 117 pm25DataStale = false; 118 if (typeof data.lastPM25 != 'undefined') { 119 pm25DataHourStart = new Date(data.lastPM25.dateTime); 120 121 122 if (data.DST == true) { 123 diffMs = (adjustedtoPST - pm25DataHourStart)-(1000*60*60); 124 } else { 125 diffMs = (adjustedtoPST - pm25DataHourStart); 126 } 127 128 if ((diffMs/1000/60 - 60 -60 ) > minutesAfterCutoff) { 129 pm25DataStale = true; 130 // console.log("PM25 data is not current") 131 } 132 } 133 windDataStale = false; 134 if (typeof data.lastWindSpeed != 'undefined') { 135 windDataHourStart = new Date(data.lastWindSpeed.dateTime); 136 if (data.DST == true) { 137 diffMs = (adjustedtoPST - windDataHourStart)-(1000*60*60); 138 } else { 139 diffMs = (adjustedtoPST - windDataHourStart); 140 } 141 142 if ((diffMs/1000/60 - 60 -60 ) > minutesAfterCutoff) { 143 windDataStale = true; 144 // console.log("Wind data is not current") 145 } 146 } 147 148 149 var newRowContent = "<tr id=\"" + makeSafeForCSS(siteName) + "_row\" onclick=\"location.href='https://gbuapcd.org/cgi-bin/tabularViewer?siteName=AirVision/" + siteName + "'\">"; 150 151 toolTipAddOnString = ""; 152 153 if (typeof data.lastTemperature != 'undefined') { 154 toolTipAddOnString += "Temperature last hour: " + Math.round((data.lastTemperature.dataValue*1.8)+32) + " F\n"; 155 } 156 157 if (typeof data.lowTempLast24 != 'undefined') { 158 toolTipAddOnString += "Low last 24h: " + Math.round((data.lowTempLast24*1.8)+32) + " F\n"; 159 } 160 161 if (typeof data.lastMaxGustSpeed != 'undefined') { 162 toolTipAddOnString += "Max Gust Last Hour: " + Math.round(2.23694 * data.lastMaxGustSpeed.dataValue) + " mph\n"; 163 } 164 165 if (typeof data.todayMaxGustSpeed != 'undefined') { 166 toolTipAddOnString += "Max Gust Today: " + Math.round(2.23694 * data.todayMaxGustSpeed) + " mph\n"; 167 } 168 169 if (typeof data.yesterdayMaxGustSpeed != 'undefined') { 170 toolTipAddOnString += "Max Gust Yesterday: " + Math.round(2.23694 * data.yesterdayMaxGustSpeed) + " mph\n"; 171 } 172 173 if (typeof data.todayAveragePM10 != 'undefined') { 174 toolTipAddOnString += "Average PM10 Today: " + Math.round(data.todayAveragePM10) + "\n"; 175 } 176 if (typeof data.yesterdayAveragePM10 != 'undefined') { 177 toolTipAddOnString += "Average PM10 Yesterday: " + Math.round(data.yesterdayAveragePM10) + "\n"; 178 } 179 180 181 if (typeof data.todayAveragePM25 != 'undefined') { 182 toolTipAddOnString += "Average PM2.5 Today: " + Math.round(data.todayAveragePM25) + "\n"; 183 } 184 if (typeof data.yesterdayAveragePM25 != 'undefined') { 185 toolTipAddOnString += "Average PM2.5 Yesterday: " + Math.round(data.yesterdayAveragePM25) + "\n"; 186 } 187 188 var dataTimeObj = getLocalDateTime(data.lastPM10.dateTime, data.DST); 189 190 var ampm = (dataTimeObj.dataEndTime.getHours() >= 12) ? "PM" : "AM"; 191 dataTimeString = "\nCurrent Conditions based on data from " + ((dataTimeObj.dataStartTime.getHours() + 24) % 12 || 12) + " to " + ((dataTimeObj.dataEndTime.getHours() + 24) % 12 || 12) + " " + ampm + " PST"; 192 toolTipAddOnString += dataTimeString; 193 194 195 196 197 198 if (typeof data.AQColor != 'undefined') { 199 if ( ( pm10DataStale == true ) & ( (pm25DataStale == true) | (typeof data.lastPM25 == 'undefined') ) ) { 200 if (typeof data.fireStatement != 'undefined') { 201 newRowContent += "<td class=\"emptyDataCell\" title=\"" + data.HealthEffectStatement + "\n\n" + data.fireStatement + "Here\"><div class=\"whiteBox\">" + siteName.replace("NCORE", "Bishop"); 202 } else { 203 newRowContent += "<td class=\"emptyDataCell\" title=\"" + data.HealthEffectStatement + "\"><div class=\"whiteBox\">
203" + siteName.replace("NCORE", "Bishop"); 204 } 205 } else if (typeof data.fireStatement != 'undefined') { 206 newRowContent += "<td title=\"" + data.HealthEffectStatement + "\n\n" + data.fireStatement + "\n\n" + toolTipAddOnString + "\"><div class=\"whiteBox\">" + siteName.replace("NCORE", "Bishop"); 207 } else { 208 newRowContent += "<td title=\"" + data.HealthEffectStatement + "\n\n" + toolTipAddOnString + "\"><div class=\"whiteBox\">" + siteName.replace("NCORE", "Bishop"); 209 } 210 } else { 211 212 if (typeof data.fireStatement != 'undefined') { 213 newRowContent += "<td class=\"emptyDataCell\" title=\"" + data.HealthEffectStatement + "\n\n" + data.fireStatement + "Here\"><div class=\"whiteBox\">" + siteName.replace("NCORE", "Bishop"); 214 } else { 215 newRowContent += "<td class=\"emptyDataCell\" title=\"" + data.HealthEffectStatement + "\"><div class=\"whiteBox\">" + siteName.replace("NCORE", "Bishop"); 216 } 217 } 218 if (data.flaggedForFire) { 219 newRowContent += " <i class=\"fad fa-fire-smoke\" style=\"--fa-secondary-color: orange; --fa-primary-color: gray;\"></i>"; 220 } 221 newRowContent += "</div></td>"; 222 223 224 225 226 if (typeof data.lastPM10 != 'undefined') { 227 if (pm10DataStale == true) { 228 newRowContent += "<td class=\"emptyDataCell\" data-sort-value=\"\"><div class=\"whiteBox\">N/A</div></td>"; 229 } else if (data.lastPM10.dataValue !== null) { 230 if (data.lastPM10.dataValue < 0) { 231 data.lastPM10.dataValue = 0; 232 } 233 234 235 236 newRowContent += "<td style=\"background-color: " + getPM10Color(data.lastPM10.dataValue) + ";\" data-sort-value=\"" + Math.round(data.lastPM10.dataValue) + "\"><div class=\"whiteBox\">" + Math.round(data.lastPM10.dataValue) + "</div></td>"; 237 } else { 238 if (data.lastPM10.nullCodeDescription !== null) { 239 newRowContent += "<td class=\"emptyDataCell\" data-sort-value=\"\"><div class=\"whiteBox nullCodeDescription\"><small>" + data.lastPM10.nullCodeDescription.replace("/","​/​") + "</small></div></td>"; 240 } else { 241 newRowContent += "<td class=\"emptyDataCell\" data-sort-value=\"\"><div class=\"whiteBox\">No Data</div></td>"; 242 } 243 244 } 245 246 } else { 247 newRowContent += "<td class=\"emptyDataCell\"></td>"; 248 } 249 250 251 if (typeof data.lastPM25 != 'undefined') { 252 if (pm25DataStale == true) { 253 newRowContent += "<td class=\"emptyDataCell\" data-sort-value=\"\"><div class=\"whiteBox\">N/A</div></td>"; 254 } else if (data.lastPM25.dataValue !== null) { 255 if (data.lastPM25.dataValue < 0) { 256 data.lastPM25.dataValue = 0; 257 } 258 newRowContent += "<td style=\"background-color: " + getPM25Color(data.lastPM25.dataValue) + ";\" data-sort-value=\"" + Math.round(data.lastPM25.dataValue) + "\"><div class=\"whiteBox\">" + Math.round(data.lastPM25.dataValue) + "</div></td>"; 259 } else { 260 if (data.lastPM25.nullCodeDescription !== null) { 261 newRowContent += "<td class=\"emptyDataCell\" data-sort-value=\"\"><div class=\"whiteBox nullCodeDescription\"><small>" + data.lastPM25.nullCodeDescription.replace("/","​/​") + "</small></div></td>"; 262 } else { 263 newRowContent += "<td class=\"emptyDataCell\" data-sort-value=\"\"><div class=\"whiteBox\">No Data</div></td>"; 264 } 265 } 266 } else { 267 newRowContent += "<td class=\"emptyDataCell\"></td>"; 268 } 269 270 271 272 273 274 if (typeof data.lastWindSpeed != 'undefined') { 275 if (windDataStale == true) { 276 newRowContent += "<td class=\"emptyDataCell\" data-sort-value=\"\"><div class=\"whiteBox\">N/A</div></td>"; 277 } else if (data.lastWindSpeed.dataValue !== null) { 278 newRowContent += "<td style=\"background-color: " + data.lastWindSpeed.ingestDict.colorCoding + ";\" data-sort-value=\"" + Math.round(data.lastWindSpeed.dataValue*2.237) + "\"><div class=\"whiteBox\">" + Math.round(data.lastWindSpeed.dataValue*2.237) + " mph"; 279 } else { 280 newRowContent += "<td class=\"emptyDataCell\" data-sort-value=\"\"><div class=\"whiteBox\">No Data</div></td>"; 281 } 282 283 if (typeof data.lastWindDirection.ingestDict.cardinalWindDirection != 'undefined') { 284 285 if (Math.round(data.lastWindSpeed.dataValue) !== 0) { 286 newRowContent += " (" + data.lastWindDirection.ingestDict.cardinalWindDirection + ")"; 287 } 288 } 289 newRowContent += "</div></td>" 290 291 292 } else { 293 newRowContent += "<td class=\"emptyDataCell\" data-sort-value=\"\"><div class=\"whiteBox\">No Data</div></td>"; 294 } 295 296 297 298 299 300 newRowContent += "</tr>" 301 $("#" + makeSafeForCSS(siteName) + "_row").replaceWith(newRowContent); 302 303 var resort = true; 304 $("#currentStatusTable").trigger("update", [resort]); 305 306 }); 307 308 309}); 310} 311 312 313 314function createSiteTable(siteNameList) { 315 prePopulateSiteTable(siteNameList); 316 317 populateSiteTable(siteNameList); 318 319 window.setInterval(function(){ 320 populateSiteTable(siteNameList); 321 }, 60000); 322}
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.