PageSourceSearch

https://www.cvcclub.com/Chagrin-Valley-GC-theme/js/jquery.simpleWeather.js

js cvcclub.com collected 2026-10-09 00:57:22 UTC 5,969 bytes, 113 lines download raw bytes

vendor: 5,969 bytes, lines 1-113
1/*! simpleWeather v3.0.2 - http://simpleweatherjs.com */
2(function($) {
3  "use strict";
4
5  function getAltTemp(unit, temp) {
6    if(unit === 'f') {
7      return Math.round((5.0/9.0)*(temp-32.0));
8    } else {
9      return Math.round((9.0/5.0)*temp+32.0);
10    }
11  }
12
13  $.extend({
14    simpleWeather: function(options){
15      options = $.extend({
16        location: '',
17        woeid: '',
18        unit: 'f',
19        success: function(weather){},
20        error: function(message){}
21      }, options);
22
23      var now = new Date();
24      var weatherUrl = 'https://query.yahooapis.com/v1/public/yql?format=json&rnd='+now.getFullYear()+now.getMonth()+now.getDay()+now.getHours()+'&diagnostics=true&callback=?&q=';
25      if(options.location !== '') {
26        weatherUrl += 'select * from weather.forecast where woeid in (select woeid from geo.places(1) where text="'+options.location+'") and u="'+options.unit+'"';
27      } else if(options.woeid !== '') {
28        weatherUrl += 'select * from weather.forecast where woeid='+options.woeid+' and u="'+options.unit+'"';
29      } else {
30        options.error({message: "Could not retrieve weather due to an invalid location."});
31        return false;
32      }
33
34      $.getJSON(
35        encodeURI(weatherUrl),
36        function(data) {
37          if(data !== null && data.query !== null && data.query.results !== null && data.query.results.channel.description !== 'Yahoo! Weather Error') {
38            var result = data.query.results.channel,
39                weather = {},
40                forecast,
41                compass = ['N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW', 'N'],
42                image404 = "https://s.yimg.com/os/mit/media/m/weather/images/icons/l/44d-100567.png";
43
44            weather.title = result.item.title;
45            weather.temp = result.item.condition.temp;
46            weather.code = result.item.condition.code;
47            weather.todayCode = result.item.forecast[0].code;
48            weather.currently = result.item.condition.text;
49            weather.high = result.item.forecast[0].high;
50            weather.low = result.item.forecast[0].low;
51            weather.text = result.item.forecast[0].text;
52            weather.humidity = result.atmosphere.humidity;
53            weather.pressure = result.atmosphere.pressure;
54            weather.rising = result.atmosphere.rising;
55            weather.visibility = result.atmosphere.visibility;
56            weather.sunrise = result.astronomy.sunrise;
57            weather.sunset = result.astronomy.sunset;
58            weather.description = result.item.description;
59            weather.city = result.location.city;
60            weather.country = result.location.country;
61            weather.region = result.location.region;
62            weather.updated = result.item.pubDate;
63            weather.link = result.item.link;
64            weather.units = {temp: result.units.temperature, distance: result.units.distance, pressure: result.units.pressure, speed: result.units.speed};
65            weather.wind = {chill: result.wind.chill, direction: compass[Math.round(result.wind.direction / 22.5)], speed: result.wind.speed};
66
67            if(result.item.condition.temp < 80 && result.atmosphere.humidity < 40) {
68              weather.heatindex = -42.379+2.04901523*result.item.condition.temp+10.14333127*result.atmosphere.humidity-0.22475541*result.item.condition.temp*result.atmosphere.humidity-6.83783*(Math.pow(10, -3))*(Math.pow(result.item.condition.temp, 2))-5.481717*(Math.pow(10, -2))*(Math.pow(result.atmosphere.humidity, 2))+1.22874*(Math.pow(10, -3))*(Math.pow(result.item.condition.temp, 2))*result.atmosphere.humidity+8.5282*(Math.pow(10, -4))*result.item.condition.temp*(Math.pow(result.atmosphere.humidity, 2))-1.99*(Math.pow(10, -6))*(Math.pow(result.item.condition.temp, 2))*(Math.pow(result.atmosphere.humidity,2));
69            } else {
70              weather.heatindex = result.item.condition.temp;
71            }
72
73            if(result.item.condition.code == "3200") {
74              weather.thumbnail = image404;
75              weather.image = image404;
76            } else {
77              weather.thumbnail = "https://s.yimg.com/zz/combo?a/i/us/nws/weather/gr/"+result.item.condition.code+"ds.png";
78              weather.image = "https://s.yimg.com/zz/combo?a/i/us/nws/weather/gr/"+result.item.condition.code+"d.png";
79            }
80
81            weather.alt = {temp: getAltTemp(options.unit, result.item.condition.temp), high: getAltTemp(options.unit, result.item.forecast[0].high), low: getAltTemp(options.unit, result.item.forecast[0].low)};
82            if(options.unit === 'f') {
83              weather.alt.unit = 'c';
84            } else {
85              weather.alt.unit = 'f';
86            }
87
88            weather.forecast = [];
89            for(var i=0;i<result.item.forecast.length;i++) {
90              forecast = result.item.forecast[i];
91              forecast.alt = {high: getAltTemp(options.unit, result.item.forecast[i].high), low: getAltTemp(options.unit, result.item.forecast[i].low)};
92
93              if(result.item.forecast[i].code == "3200") {
94                forecast.thumbnail = image404;
95                forecast.image = image404;
96              } else {
97                forecast.thumbnail = "https://s.yimg.com/zz/combo?a/i/us/nws/weather/gr/"+result.item.forecast[i].code+"ds.png";
98                forecast.image = "https://s.yimg.com/zz/combo?a/i/us/nws/weather/gr/"+result.item.forecast[i].code+"d.png";
99              }
100
101              weather.forecast.push(forecast);
102            }
103
104            options.success(weather);
105          } else {
106            options.error({message: "There was an error retrieving the latest weather information. Please try again.", error: data.query.results.channel.item.title});
107          }
108        }
109      );
110      return this;
111    }
112  });
113})(jQuery);

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.