Файл: CloudBox-main/CloudBox/admin_assets/js/jquery.zweatherfeed.min.js
Строк: 125
<?php
(function (j) {
j.fn.weatherfeed = function (s, h, v) {
h = j.extend({unit: "c", image: !0, country: !1, highlow: !0, wind: !0, humidity: !1, visibility: !1, sunrise: !1, sunset: !1, forecast: !1, link: !0, showerror: !0, linktarget: "_self", woeid: !1}, h);
var p = "odd";
return this.each(function (q, t) {
var l = j(t);
l.hasClass("weatherFeed") || l.addClass("weatherFeed");
if (!j.isArray(s))return!1;
var m = s.length;
10 < m && (m = 10);
var k = "";
for (q = 0; q < m; q++)"" != k && (k += ","), k += "'" + s[q] + "'";
now = new Date;
m = "http://query.yahooapis.com/v1/public/yql?q=" + encodeURIComponent("select * from weather.forecast where " +
(h.woeid ? "woeid" : "location") + " in (" + k + ") and u='" + h.unit + "'") + "&rnd=" + now.getFullYear() + now.getMonth() + now.getDay() + now.getHours() + "&format=json&callback=?";
j.ajax({type: "GET", url: m, dataType: "json", success: function (f) {
if (f.query) {
if (0 < f.query.results.channel.length)for (var c = f.query.results.channel.length, e = 0; e < c; e++)w(t, f.query.results.channel[e], h); else w(t, f.query.results.channel, h);
j.isFunction(v) && v.call(this, l)
} else h.showerror && l.html("<p>Weather information unavailable</p>")
}, error: function () {
h.showerror &&
l.html("<p>Weather request failed</p>")
}});
var w = function (f, c, e) {
f = j(f);
if ("Yahoo! Weather Error" != c.description) {
var a = c.wind.direction;
348.75 <= a && 360 >= a && (a = "N");
0 <= a && 11.25 > a && (a = "N");
11.25 <= a && 33.75 > a && (a = "NNE");
33.75 <= a && 56.25 > a && (a = "NE");
56.25 <= a && 78.75 > a && (a = "ENE");
78.75 <= a && 101.25 > a && (a = "E");
101.25 <= a && 123.75 > a && (a = "ESE");
123.75 <= a && 146.25 > a && (a = "SE");
146.25 <= a && 168.75 > a && (a = "SSE");
168.75 <= a && 191.25 > a && (a = "S");
191.25 <= a && 213.75 > a && (a = "SSW");
213.75 <= a && 236.25 > a && (a = "SW");
236.25 <= a && 258.75 >
a && (a = "WSW");
258.75 <= a && 281.25 > a && (a = "W");
281.25 <= a && 303.75 > a && (a = "WNW");
303.75 <= a && 326.25 > a && (a = "NW");
326.25 <= a && 348.75 > a && (a = "NNW");
var g = c.item.forecast[0];
wpd = c.item.pubDate;
n = wpd.indexOf(":");
tpb = u(wpd.substr(n - 2, 8));
tsr = u(c.astronomy.sunrise);
tss = u(c.astronomy.sunset);
daynight = tpb > tsr && tpb < tss ? "day" : "night";
var b = '<div class="weatherItem ' + p + " " + daynight + '"';
e.image && (b += ' style="background-image: url(http://l.yimg.com/a/i/us/nws/weather/gr/' + c.item.condition.code + daynight.substring(0, 1) + '.png); background-repeat: no-repeat;"');
b = b + ">" + ('<div class="weatherCity">' + c.location.city + "</div>");
e.country && (b += '<div class="weatherCountry">' + c.location.country + "</div>");
b += '<div class="weatherTemp">' + c.item.condition.temp + "°</div>";
b += '<div class="weatherDesc">' + c.item.condition.text + "</div>";
e.highlow && (b += '<div class="weatherRange">High: ' + g.high + "° Low: " + g.low + "°</div>");
e.wind && (b += '<div class="weatherWind">Wind: ' + a + " " + c.wind.speed + c.units.speed + "</div>");
e.humidity && (b += '<div class="weatherHumidity">Humidity: ' +
c.atmosphere.humidity + "</div>");
e.visibility && (b += '<div class="weatherVisibility">Visibility: ' + c.atmosphere.visibility + "</div>");
e.sunrise && (b += '<div class="weatherSunrise">Sunrise: ' + c.astronomy.sunrise + "</div>");
e.sunset && (b += '<div class="weatherSunset">Sunset: ' + c.astronomy.sunset + "</div>");
if (e.forecast) {
b += '<div class="weatherForecast">';
a = c.item.forecast;
for (g = 0; g < a.length; g++)b += '<div class="weatherForecastItem" style="background-image: url(http://l.yimg.com/a/i/us/nws/weather/gr/' + a[g].code +
's.png); background-repeat: no-repeat;">', b += '<div class="weatherForecastDay">' + a[g].day + "</div>", b += '<div class="weatherForecastDate">' + a[g].date + "</div>", b += '<div class="weatherForecastText">' + a[g].text + "</div>", b += '<div class="weatherForecastRange">High: ' + a[g].high + " Low: " + a[g].low + "</div>", b += "</div>";
b += "</div>"
}
e.link && (b += '<div class="weatherLink"><a href="' + c.link + '" target="' + e.linktarget + '" title="Read full forecast">Full forecast</a></div>')
} else b = '<div class="weatherItem ' + p + '">', b +=
'<div class="weatherError">City not found</div>';
b += "</div>";
p = "odd" == p ? "even" : "odd";
f.append(b)
}, u = function (f) {
d = new Date;
return r = new Date(d.toDateString() + " " + f)
}
})
}
})(jQuery);
?>