// Generated by CoffeeScript 1.10.0 (function() { var Weather; window.Weather = observable(Weather = (function() { function Weather(conf) { this.init({ events: ['change'] }); } Weather.prototype.query = function(icao, year) { this.icao = icao; this.year = year; return d3.csv("wu_get_history.php?station=" + icao + "&year=" + year, (function(_this) { return function(days) { _this.days = days; _this.days.forEach(function(d) { d.t = d[_this.days.columns[0]]; d.date = new Date(d.t); d.day = d.date.getDOY(); d.MinTemperatureC = +d.MinTemperatureC; d.MaxTemperatureC = +d.MaxTemperatureC; d.MeanTemperatureC = +d.MeanTemperatureC; d.Precipitationmm = +d.Precipitationmm || 0; d.CloudCover = Math.max(0, +d.CloudCover); d['MeanWindSpeedKm/h'] = +d['MeanWindSpeedKm/h']; return d.WindDirDegrees = +d.WindDirDegrees; }); return _this.trigger('change'); }; })(this)); }; return Weather; })()); // code by Joe Orost // http://stackoverflow.com/questions/8619879/javascript-calculate-the-day-of-the-year-1-366 Date.prototype.isLeapYear = function() { var year = this.getFullYear(); if((year & 3) != 0) return false; return ((year % 100) != 0 || (year % 400) == 0); }; // Get Day of Year Date.prototype.getDOY = function() { var dayCount = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334]; var mn = this.getMonth(); var dn = this.getDate(); var dayOfYear = dayCount[mn] + dn; if(mn > 1 && this.isLeapYear()) dayOfYear++; return dayOfYear; }; ; }).call(this);