Changeset 3097057
- Timestamp:
- 06/04/2024 06:38:43 AM (21 months ago)
- Location:
- weather-in-any-city-widget/trunk
- Files:
-
- 3 edited
-
README.txt (modified) (1 diff)
-
resources/js/WIYCW-widget.js (modified) (2 diffs)
-
weather-in-any-city-widget.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
weather-in-any-city-widget/trunk/README.txt
r3096793 r3097057 4 4 Tested up to: 6.5 5 5 Requires PHP: 5.3 6 Stable tag: 1.1.3 46 Stable tag: 1.1.35 7 7 License: GPLv2 or later 8 8 -
weather-in-any-city-widget/trunk/resources/js/WIYCW-widget.js
r3096591 r3097057 104 104 105 105 106 fetchJSONFile(widget.dataset.url+"?action="+widget.dataset.action+"&nonce="+widget.dataset.nonce+"&id="+widget.dataset.cityid, function(data){ 107 108 if(data.error){ 109 console.log(data.message) 110 return 111 } 112 content.innerHTML = "" 113 114 if(widget.dataset.today == "on"){ 115 const now = document.createElement("div"); 116 now.classList = "WIYCW-now" 117 118 const now_row1 = document.createElement("div"); 119 now_row1.classList = "WIYCW-now-row1" 120 121 if(widget.dataset.nowicon == "on"){ 122 const icon = document.createElement("div"); 123 icon.classList = "WIYCW-now-icon" 124 125 const img = document.createElement("img"); 126 img.src = widget.dataset.path + "/resources/icons/weather-icons/"+iconsColorPath + '/' + data.now.icon + ".svg" 127 img.alt = 'Current weather' 128 img.style.width = "70px" 129 img.style.height = "70px" 130 img.classList = weatherIconsColorClass 131 icon.appendChild(img) 132 now_row1.appendChild(icon) 133 } 134 135 if(widget.dataset.nowtemp == "on"){ 136 const temp = document.createElement("div"); 137 temp.innerHTML = formatTemp(data.now.temp, widget.dataset.units) 138 temp.classList = "WIYCW-now-temp" 139 now_row1.appendChild(temp) 106 107 function getWeatherData(url, error){ 108 fetchJSONFile(url, function(data){ 109 110 if(data.error){ 111 console.log(data.message) 112 error(); 113 return 140 114 } 141 142 if(widget.dataset.nowicon == "off" && widget.dataset.nowtemp == "off"){ 143 now_row1.style.display = "none" 144 } 145 146 const now_row_info = document.createElement("div"); 147 now_row_info.classList = "WIYCW-now-row-info" 148 149 150 if(widget.dataset.nowsunrise == "on"){ 151 const sunriseIcon = document.createElement("img"); 152 sunriseIcon.alt = 'Sunrise' 153 sunriseIcon.classList = "WIYCW-item-icon " + iconsColorClass 154 sunriseIcon.src = widget.dataset.path + "/resources/icons/ui-icons/sunrise.svg" 155 sunriseIcon.style.width = "11px" 156 sunriseIcon.style.height = "11px" 157 158 const sunrise = document.createElement("div"); 159 sunrise.classList = "WIYCW-now-row-info-col" 160 161 sunrise.appendChild(sunriseIcon) 162 163 if(widget.dataset.timeformat === 'standard'){ 164 data.now.sunrise = tConvert(data.now.sunrise); 165 } 166 167 sunrise.innerHTML += data.now.sunrise 168 now_row_info.appendChild(sunrise) 169 170 const sunsetIcon = document.createElement("img"); 171 sunsetIcon.alt = 'Sunset' 172 sunsetIcon.classList = "WIYCW-item-icon " + iconsColorClass 173 sunsetIcon.src = widget.dataset.path + "/resources/icons/ui-icons/sunset.svg" 174 sunsetIcon.style.width = "11px" 175 sunsetIcon.style.height = "11px" 176 177 const sunset = document.createElement("div"); 178 sunset.classList = "WIYCW-now-row-info-col" 179 180 if(widget.dataset.timeformat === 'standard'){ 181 data.now.sunset = tConvert(data.now.sunset); 182 } 183 184 sunset.appendChild(sunsetIcon) 185 sunset.innerHTML += data.now.sunset 186 now_row_info.appendChild(sunset) 187 } 188 189 if(widget.dataset.nowhumidity == "on"){ 190 191 const dropIcon = document.createElement("img"); 192 dropIcon.alt = 'Humidity'; 193 dropIcon.classList = "WIYCW-item-icon " + iconsColorClass 194 dropIcon.src = widget.dataset.path + "/resources/icons/ui-icons/dew-point.svg" 195 dropIcon.style.width = "11px" 196 dropIcon.style.height = "11px" 197 198 const humidity = document.createElement("div"); 199 humidity.classList = "WIYCW-now-row-info-col" 200 201 humidity.appendChild(dropIcon) 202 humidity.innerHTML += data.now.humidity + "%" 203 now_row_info.appendChild(humidity) 204 } 205 206 if(widget.dataset.nowwind == "on"){ 207 208 const windRotation = document.createElement("div"); 209 windRotation.classList = "WIYCW-item-icon " + iconsColorClass 210 windRotation.style.width = "11px" 211 windRotation.style.height = "11px" 212 windRotation.style.display = "flex" 213 214 const arrowIcon = document.createElement("img"); 215 arrowIcon.alt = 'Wind direction'; 216 arrowIcon.src = widget.dataset.path + "/resources/icons/ui-icons/arrow.svg" 217 arrowIcon.style.width = "11px" 218 arrowIcon.style.height = "11px" 219 arrowIcon.style.transform = "rotate("+data.now.wind_deg+"deg)" 220 221 windRotation.appendChild(arrowIcon) 222 223 const wind = document.createElement("div"); 224 wind.classList = "WIYCW-now-row-info-col" 225 226 wind.appendChild(windRotation) 227 wind.innerHTML += formatSpeed(data.now.wind_speed, widget.dataset.units) 228 now_row_info.appendChild(wind) 229 230 } 231 232 if(widget.dataset.nowpressure == "on"){ 233 234 const pressureIcon = document.createElement("img"); 235 pressureIcon.alt = 'Pressure' 236 pressureIcon.classList = "WIYCW-item-icon " + iconsColorClass 237 pressureIcon.src = widget.dataset.path + "/resources/icons/ui-icons/pressure.svg" 238 pressureIcon.style.width = "11px" 239 pressureIcon.style.height = "11px" 240 241 const pressure = document.createElement("div"); 242 pressure.classList = "WIYCW-now-row-info-col" 243 244 pressure.appendChild(pressureIcon) 245 pressure.innerHTML += data.now.pressure + " hPa" 246 now_row_info.appendChild(pressure) 247 } 248 249 if(widget.dataset.nowcloudiness == "on"){ 250 251 const cloudinessIcon = document.createElement("img"); 252 cloudinessIcon.alt = 'Cloudiness' 253 cloudinessIcon.classList = "WIYCW-item-icon " + iconsColorClass 254 cloudinessIcon.src = widget.dataset.path + "/resources/icons/ui-icons/clouds.svg" 255 cloudinessIcon.style.width = "11px" 256 cloudinessIcon.style.height = "11px" 257 258 const cloudiness = document.createElement("div"); 259 cloudiness.classList = "WIYCW-now-row-info-col" 260 261 cloudiness.appendChild(cloudinessIcon) 262 cloudiness.innerHTML += data.now.cloudiness + "%" 263 now_row_info.appendChild(cloudiness) 264 } 265 266 267 now.appendChild(now_row1) 268 now.appendChild(now_row_info) 269 content.appendChild(now) 270 271 } 272 273 274 275 if(widget.dataset.days !== "off"){ 276 const forecast = document.createElement("div"); 277 forecast.classList = "WIYCW-forecast WIYCW-forecast-"+widget.dataset.layout 278 let number = 0; 279 for(const day of data.forecast){ 280 281 number ++ 282 283 if(number > widget.dataset.days){ 284 break 285 } 286 const row = document.createElement("div"); 287 row.classList = "WIYCW-forecast-row" 288 const date = document.createElement("div"); 289 290 if(number == 1){ 291 date.innerHTML = WIYCW_i18n['today'].capitalize() 292 }else if(number == 2){ 293 date.innerHTML = WIYCW_i18n['tomorrow'].capitalize() 294 }else{ 295 date.innerHTML = (WIYCW_i18n['week_days'][day.wday]).capitalize() + " " + day.day 296 } 297 298 date.classList = "WIYCW-forecast-date WIYCW-col-1" 299 row.appendChild(date) 300 301 if(widget.dataset.temp == "on"){ 302 const temp = document.createElement("div"); 303 temp.classList = "WIYCW-forecast-temp WIYCW-col-1" 304 temp.innerHTML = formatTemp(day.temp_max, widget.dataset.units) + " / " + formatTemp(day.temp_min, widget.dataset.units) 305 row.appendChild(temp) 306 } 307 308 if(widget.dataset.forecasticon == "on"){ 309 const icon = document.createElement("div"); 310 icon.classList = "WIYCW-forecast-icon WIYCW-col-1" 115 content.innerHTML = "" 116 117 if(widget.dataset.today == "on"){ 118 const now = document.createElement("div"); 119 now.classList = "WIYCW-now" 120 121 const now_row1 = document.createElement("div"); 122 now_row1.classList = "WIYCW-now-row1" 123 124 if(widget.dataset.nowicon == "on"){ 125 const icon = document.createElement("div"); 126 icon.classList = "WIYCW-now-icon" 127 311 128 const img = document.createElement("img"); 312 img. alt = 'Forecast'313 img. src = widget.dataset.path + "/resources/icons/weather-icons/"+ iconsColorPath + '/'+ day.icon + ".svg"314 img.style.width = " 30px"315 img.style.height = " 30px"129 img.src = widget.dataset.path + "/resources/icons/weather-icons/"+iconsColorPath + '/' + data.now.icon + ".svg" 130 img.alt = 'Current weather' 131 img.style.width = "70px" 132 img.style.height = "70px" 316 133 img.classList = weatherIconsColorClass 317 134 icon.appendChild(img) 318 row.appendChild(icon) 319 135 now_row1.appendChild(icon) 136 } 137 138 if(widget.dataset.nowtemp == "on"){ 139 const temp = document.createElement("div"); 140 temp.innerHTML = formatTemp(data.now.temp, widget.dataset.units) 141 temp.classList = "WIYCW-now-temp" 142 now_row1.appendChild(temp) 320 143 } 321 144 322 if(widget.dataset.rainchance == "on"){ 323 324 const umbrellaIcon = document.createElement("img"); 325 umbrellaIcon.alt = 'Rain chance' 326 umbrellaIcon.classList = "WIYCW-item-icon " + iconsColorClass 327 umbrellaIcon.src = widget.dataset.path + "/resources/icons/ui-icons/umbrella.svg" 328 umbrellaIcon.style.width = "11px" 329 umbrellaIcon.style.height = "11px" 330 331 const pop = document.createElement("div"); 332 pop.appendChild(umbrellaIcon) 333 pop.classList = "WIYCW-forecast-pop WIYCW-col-1" 334 pop.innerHTML += Math.round(day.pop*100) + "%" 335 row.appendChild(pop) 145 if(widget.dataset.nowicon == "off" && widget.dataset.nowtemp == "off"){ 146 now_row1.style.display = "none" 336 147 } 337 148 338 if(widget.dataset.rain == "on"){ 339 const rain = document.createElement("div"); 340 rain.classList = "WIYCW-forecast-rain WIYCW-col-1" 341 rain.innerHTML = formatVol(day.rain, widget.dataset.units) 342 row.appendChild(rain) 343 } 344 345 if(widget.dataset.wind == "on"){ 149 const now_row_info = document.createElement("div"); 150 now_row_info.classList = "WIYCW-now-row-info" 151 152 153 if(widget.dataset.nowsunrise == "on"){ 154 const sunriseIcon = document.createElement("img"); 155 sunriseIcon.alt = 'Sunrise' 156 sunriseIcon.classList = "WIYCW-item-icon " + iconsColorClass 157 sunriseIcon.src = widget.dataset.path + "/resources/icons/ui-icons/sunrise.svg" 158 sunriseIcon.style.width = "11px" 159 sunriseIcon.style.height = "11px" 160 161 const sunrise = document.createElement("div"); 162 sunrise.classList = "WIYCW-now-row-info-col" 163 164 sunrise.appendChild(sunriseIcon) 165 166 if(widget.dataset.timeformat === 'standard'){ 167 data.now.sunrise = tConvert(data.now.sunrise); 168 } 169 170 sunrise.innerHTML += data.now.sunrise 171 now_row_info.appendChild(sunrise) 172 173 const sunsetIcon = document.createElement("img"); 174 sunsetIcon.alt = 'Sunset' 175 sunsetIcon.classList = "WIYCW-item-icon " + iconsColorClass 176 sunsetIcon.src = widget.dataset.path + "/resources/icons/ui-icons/sunset.svg" 177 sunsetIcon.style.width = "11px" 178 sunsetIcon.style.height = "11px" 179 180 const sunset = document.createElement("div"); 181 sunset.classList = "WIYCW-now-row-info-col" 182 183 if(widget.dataset.timeformat === 'standard'){ 184 data.now.sunset = tConvert(data.now.sunset); 185 } 186 187 sunset.appendChild(sunsetIcon) 188 sunset.innerHTML += data.now.sunset 189 now_row_info.appendChild(sunset) 190 } 191 192 if(widget.dataset.nowhumidity == "on"){ 193 194 const dropIcon = document.createElement("img"); 195 dropIcon.alt = 'Humidity'; 196 dropIcon.classList = "WIYCW-item-icon " + iconsColorClass 197 dropIcon.src = widget.dataset.path + "/resources/icons/ui-icons/dew-point.svg" 198 dropIcon.style.width = "11px" 199 dropIcon.style.height = "11px" 200 201 const humidity = document.createElement("div"); 202 humidity.classList = "WIYCW-now-row-info-col" 203 204 humidity.appendChild(dropIcon) 205 humidity.innerHTML += data.now.humidity + "%" 206 now_row_info.appendChild(humidity) 207 } 208 209 if(widget.dataset.nowwind == "on"){ 346 210 347 211 const windRotation = document.createElement("div"); … … 351 215 windRotation.style.display = "flex" 352 216 353 354 217 const arrowIcon = document.createElement("img"); 355 arrowIcon.alt = 'Wind direction' 218 arrowIcon.alt = 'Wind direction'; 356 219 arrowIcon.src = widget.dataset.path + "/resources/icons/ui-icons/arrow.svg" 357 220 arrowIcon.style.width = "11px" 358 221 arrowIcon.style.height = "11px" 359 arrowIcon.style.transform = "rotate("+da y.wind_deg+"deg)"222 arrowIcon.style.transform = "rotate("+data.now.wind_deg+"deg)" 360 223 361 224 windRotation.appendChild(arrowIcon) 362 225 363 226 const wind = document.createElement("div"); 364 wind.classList = "WIYCW- forecast-wind WIYCW-col-1"227 wind.classList = "WIYCW-now-row-info-col" 365 228 366 229 wind.appendChild(windRotation) 367 wind.innerHTML += formatSpeed(day.wind_speed, widget.dataset.units) 368 row.appendChild(wind) 230 wind.innerHTML += formatSpeed(data.now.wind_speed, widget.dataset.units) 231 now_row_info.appendChild(wind) 232 233 } 234 235 if(widget.dataset.nowpressure == "on"){ 236 237 const pressureIcon = document.createElement("img"); 238 pressureIcon.alt = 'Pressure' 239 pressureIcon.classList = "WIYCW-item-icon " + iconsColorClass 240 pressureIcon.src = widget.dataset.path + "/resources/icons/ui-icons/pressure.svg" 241 pressureIcon.style.width = "11px" 242 pressureIcon.style.height = "11px" 243 244 const pressure = document.createElement("div"); 245 pressure.classList = "WIYCW-now-row-info-col" 246 247 pressure.appendChild(pressureIcon) 248 pressure.innerHTML += data.now.pressure + " hPa" 249 now_row_info.appendChild(pressure) 250 } 251 252 if(widget.dataset.nowcloudiness == "on"){ 253 254 const cloudinessIcon = document.createElement("img"); 255 cloudinessIcon.alt = 'Cloudiness' 256 cloudinessIcon.classList = "WIYCW-item-icon " + iconsColorClass 257 cloudinessIcon.src = widget.dataset.path + "/resources/icons/ui-icons/clouds.svg" 258 cloudinessIcon.style.width = "11px" 259 cloudinessIcon.style.height = "11px" 260 261 const cloudiness = document.createElement("div"); 262 cloudiness.classList = "WIYCW-now-row-info-col" 263 264 cloudiness.appendChild(cloudinessIcon) 265 cloudiness.innerHTML += data.now.cloudiness + "%" 266 now_row_info.appendChild(cloudiness) 267 } 268 269 270 now.appendChild(now_row1) 271 now.appendChild(now_row_info) 272 content.appendChild(now) 273 274 } 275 276 277 278 if(widget.dataset.days !== "off"){ 279 const forecast = document.createElement("div"); 280 forecast.classList = "WIYCW-forecast WIYCW-forecast-"+widget.dataset.layout 281 let number = 0; 282 for(const day of data.forecast){ 283 284 number ++ 285 286 if(number > widget.dataset.days){ 287 break 288 } 289 const row = document.createElement("div"); 290 row.classList = "WIYCW-forecast-row" 291 const date = document.createElement("div"); 292 293 if(number == 1){ 294 date.innerHTML = WIYCW_i18n['today'].capitalize() 295 }else if(number == 2){ 296 date.innerHTML = WIYCW_i18n['tomorrow'].capitalize() 297 }else{ 298 date.innerHTML = (WIYCW_i18n['week_days'][day.wday]).capitalize() + " " + day.day 299 } 300 301 date.classList = "WIYCW-forecast-date WIYCW-col-1" 302 row.appendChild(date) 303 304 if(widget.dataset.temp == "on"){ 305 const temp = document.createElement("div"); 306 temp.classList = "WIYCW-forecast-temp WIYCW-col-1" 307 temp.innerHTML = formatTemp(day.temp_max, widget.dataset.units) + " / " + formatTemp(day.temp_min, widget.dataset.units) 308 row.appendChild(temp) 309 } 310 311 if(widget.dataset.forecasticon == "on"){ 312 const icon = document.createElement("div"); 313 icon.classList = "WIYCW-forecast-icon WIYCW-col-1" 314 const img = document.createElement("img"); 315 img.alt = 'Forecast' 316 img.src = widget.dataset.path + "/resources/icons/weather-icons/"+ iconsColorPath + '/'+ day.icon + ".svg" 317 img.style.width = "30px" 318 img.style.height = "30px" 319 img.classList = weatherIconsColorClass 320 icon.appendChild(img) 321 row.appendChild(icon) 322 323 } 324 325 if(widget.dataset.rainchance == "on"){ 326 327 const umbrellaIcon = document.createElement("img"); 328 umbrellaIcon.alt = 'Rain chance' 329 umbrellaIcon.classList = "WIYCW-item-icon " + iconsColorClass 330 umbrellaIcon.src = widget.dataset.path + "/resources/icons/ui-icons/umbrella.svg" 331 umbrellaIcon.style.width = "11px" 332 umbrellaIcon.style.height = "11px" 333 334 const pop = document.createElement("div"); 335 pop.appendChild(umbrellaIcon) 336 pop.classList = "WIYCW-forecast-pop WIYCW-col-1" 337 pop.innerHTML += Math.round(day.pop*100) + "%" 338 row.appendChild(pop) 339 } 340 341 if(widget.dataset.rain == "on"){ 342 const rain = document.createElement("div"); 343 rain.classList = "WIYCW-forecast-rain WIYCW-col-1" 344 rain.innerHTML = formatVol(day.rain, widget.dataset.units) 345 row.appendChild(rain) 346 } 347 348 if(widget.dataset.wind == "on"){ 349 350 const windRotation = document.createElement("div"); 351 windRotation.classList = "WIYCW-item-icon " + iconsColorClass 352 windRotation.style.width = "11px" 353 windRotation.style.height = "11px" 354 windRotation.style.display = "flex" 355 356 357 const arrowIcon = document.createElement("img"); 358 arrowIcon.alt = 'Wind direction' 359 arrowIcon.src = widget.dataset.path + "/resources/icons/ui-icons/arrow.svg" 360 arrowIcon.style.width = "11px" 361 arrowIcon.style.height = "11px" 362 arrowIcon.style.transform = "rotate("+day.wind_deg+"deg)" 363 364 windRotation.appendChild(arrowIcon) 365 366 const wind = document.createElement("div"); 367 wind.classList = "WIYCW-forecast-wind WIYCW-col-1" 368 369 wind.appendChild(windRotation) 370 wind.innerHTML += formatSpeed(day.wind_speed, widget.dataset.units) 371 row.appendChild(wind) 372 } 373 374 375 forecast.appendChild(row) 376 377 378 369 379 } 370 380 371 372 forecast.appendChild(row) 373 374 375 381 content.appendChild(forecast) 376 382 } 377 383 378 content.appendChild(forecast) 379 } 380 381 382 }, function(){ 383 console.log("Weather widget error") 384 385 }, function(){ 386 console.log("Weather widget error") 387 }) 388 } 389 390 getWeatherData(widget.dataset.url+"?action="+widget.dataset.action+"&nonce="+widget.dataset.nonce+"&id="+widget.dataset.cityid, function(){ 391 getWeatherData("https://eltiempoen.com:9090/api/widget?id="+widget.dataset.cityid+"&s="+encodeURIComponent(window.location.hostname)+"&v="+widget.dataset.version+"&c=false", function(){ 392 console.log('Error getting direct call') 393 }) 384 394 }) 395 396 397 385 398 }) 386 399 -
weather-in-any-city-widget/trunk/weather-in-any-city-widget.php
r3096793 r3097057 4 4 * Plugin URI: https://weatherin.org 5 5 * Description: Weather Widget Pro provides a complete weather forecast for any location around the world. 6 * Version: 1.1.3 46 * Version: 1.1.35 7 7 * Author: El tiempo 8 8 * Author URI: https://eltiempoen.com … … 16 16 defined( 'ABSPATH' ) or die( 'ABSPATH not defined' ); 17 17 18 define ('WIYCW_VERSION', '1.1.3 4');18 define ('WIYCW_VERSION', '1.1.35'); 19 19 define ('WIYCW_DEF_PLUGIN', 'weather-in-any-city-widget'); 20 20 define ('WIYCW_DEF_BASEURL', plugins_url('', __FILE__)); … … 810 810 $output .= " data-shadow='".esc_attr($instance['shadow'])."'"; 811 811 $output .= " data-url='".esc_attr($instance['url'])."'"; 812 $output .= " data-version='".esc_attr(WIYCW_VERSION)."'"; 812 813 $output .= " data-action='".esc_attr($instance['action'])."'"; 813 814 $output .= " data-nonce='".esc_attr(wp_create_nonce(WIYCW_VERSION))."'"; … … 938 939 'id' => $id, 939 940 's' => get_site_url(), 940 'v' => WIYCW_VERSION 941 'v' => WIYCW_VERSION, 942 'c' => 'true' 941 943 ); 942 944
Note: See TracChangeset
for help on using the changeset viewer.