Skip to content
This repository has been archived by the owner on Jan 23, 2019. It is now read-only.

Commit

Permalink
Removing deprecated geo.placefinder and using geo.places instead.
Browse files Browse the repository at this point in the history
Yahoo removed the geo.placefinder API which broke simpleWeather for most people. This fix moved to geo.places and continues to work for a city/state or geolocation. Fixes #174, #181, #175, #101
  • Loading branch information
fleeting committed Jan 29, 2016
1 parent ed11490 commit 59e0ce5
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 26 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

For a more complete changelog you can always check out the [commit log](https://github.com/monkeecreate/jquery.simpleWeather/commits/master).

## v3.1.0 - January 29 2016

* Fixed location errors due to Yahoo removing geo.placefinder from their API. It has been replaced with geo.places. [#174](https://github.com/monkeecreate/jquery.simpleWeather/issues/174)
* Fixed error callback to correctly return an error message. [#101](https://github.com/monkeecreate/jquery.simpleWeather/issues/101)

## v3.0.2 - June 2 2014

* Fixed result issue when more than one location was returned. [#90](https://github.com/monkeecreate/jquery.simpleWeather/issues/90)
Expand Down
4 changes: 2 additions & 2 deletions MIT-LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2014 James Fleeting, http://jamesfleeting.com/
Copyright (c) 2016 James Fleeting, http://jamesfleeting.com/

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand All @@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "simpleWeather",
"description": "A simple jQuery plugin to display current weather data for any location and doesn't get in your way. Handcrafted with ♥ from Austin, Texas by James Fleeting.",
"main": "jquery.simpleWeather.js",
"version": "3.0.2",
"version": "3.1.0",
"homepage": "http://simpleweatherjs.com",
"authors": [
"James Fleeting <[email protected]>"
Expand Down
2 changes: 1 addition & 1 deletion component.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "simpleWeather",
"repo": "monkeecreate/jquery.simpleWeather",
"description": "A simple jQuery plugin to display current weather data for any location and doesn't get in your way. Handcrafted with ♥ from Austin, Texas by James Fleeting.",
"version": "3.0.2",
"version": "3.1.0",
"main": "jquery.simpleWeather.js",
"scripts": [
"jquery.simpleWeather.js"
Expand Down
35 changes: 22 additions & 13 deletions jquery.simpleWeather.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*! simpleWeather v3.0.2 - http://simpleweatherjs.com */
/*! simpleWeather v3.1.0 - http://simpleweatherjs.com */
(function($) {
"use strict";
'use strict';

function getAltTemp(unit, temp) {
if(unit === 'f') {
Expand All @@ -21,13 +21,22 @@
}, options);

var now = new Date();
var weatherUrl = 'https://query.yahooapis.com/v1/public/yql?format=json&rnd='+now.getFullYear()+now.getMonth()+now.getDay()+now.getHours()+'&diagnostics=true&callback=?&q=';
var weatherUrl = 'https://query.yahooapis.com/v1/public/yql?format=json&rnd=' + now.getFullYear() + now.getMonth() + now.getDay() + now.getHours() + '&diagnostics=true&callback=?&q=';

if(options.location !== '') {
weatherUrl += 'select * from weather.forecast where woeid in (select woeid from geo.placefinder where text="'+options.location+'" and gflags="R" limit 1) and u="'+options.unit+'"';
/* If latitude/longitude coordinates, need to format a little different. */
var location = '';
if(/^(\-?\d+(\.\d+)?),\s*(\-?\d+(\.\d+)?)$/.test(options.location)) {
location = '(' + options.location + ')';
} else {
location = options.location;
}

weatherUrl += 'select * from weather.forecast where woeid in (select woeid from geo.places(1) where text="' + location + '") and u="' + options.unit + '"';
} else if(options.woeid !== '') {
weatherUrl += 'select * from weather.forecast where woeid='+options.woeid+' and u="'+options.unit+'"';
weatherUrl += 'select * from weather.forecast where woeid=' + options.woeid + ' and u="' + options.unit + '"';
} else {
options.error({message: "Could not retrieve weather due to an invalid location."});
options.error('Could not retrieve weather due to an invalid location.');
return false;
}

Expand All @@ -39,7 +48,7 @@
weather = {},
forecast,
compass = ['N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW', 'N'],
image404 = "https://s.yimg.com/os/mit/media/m/weather/images/icons/l/44d-100567.png";
image404 = 'https://s.yimg.com/os/mit/media/m/weather/images/icons/l/44d-100567.png';

weather.title = result.item.title;
weather.temp = result.item.condition.temp;
Expand Down Expand Up @@ -70,12 +79,12 @@
weather.heatindex = result.item.condition.temp;
}

if(result.item.condition.code == "3200") {
if(result.item.condition.code == '3200') {
weather.thumbnail = image404;
weather.image = image404;
} else {
weather.thumbnail = "https://s.yimg.com/zz/combo?a/i/us/nws/weather/gr/"+result.item.condition.code+"ds.png";
weather.image = "https://s.yimg.com/zz/combo?a/i/us/nws/weather/gr/"+result.item.condition.code+"d.png";
weather.thumbnail = 'https://s.yimg.com/zz/combo?a/i/us/nws/weather/gr/' + result.item.condition.code + 'ds.png';
weather.image = 'https://s.yimg.com/zz/combo?a/i/us/nws/weather/gr/' + result.item.condition.code + 'd.png';
}

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)};
Expand All @@ -94,16 +103,16 @@
forecast.thumbnail = image404;
forecast.image = image404;
} else {
forecast.thumbnail = "https://s.yimg.com/zz/combo?a/i/us/nws/weather/gr/"+result.item.forecast[i].code+"ds.png";
forecast.image = "https://s.yimg.com/zz/combo?a/i/us/nws/weather/gr/"+result.item.forecast[i].code+"d.png";
forecast.thumbnail = 'https://s.yimg.com/zz/combo?a/i/us/nws/weather/gr/' + result.item.forecast[i].code + 'ds.png';
forecast.image = 'https://s.yimg.com/zz/combo?a/i/us/nws/weather/gr/' + result.item.forecast[i].code + 'd.png';
}

weather.forecast.push(forecast);
}

options.success(weather);
} else {
options.error({message: "There was an error retrieving the latest weather information. Please try again.", error: data.query.results.channel.item.title});
options.error('There was a problem retrieving the latest weather information.');
}
}
);
Expand Down
4 changes: 2 additions & 2 deletions jquery.simpleWeather.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simpleweather",
"version": "3.0.2",
"version": "3.1.0",
"description": "A simple jQuery plugin to display current weather data for any location and doesn't get in your way. Handcrafted with ♥ from Austin, Texas by James Fleeting.",
"keywords": [
"jquery",
Expand Down Expand Up @@ -32,13 +32,13 @@
],
"devDependencies": {
"gulp": "latest",
"gulp-uglify": "latest",
"gulp-bump": "latest",
"gulp-git": "^1.7.0",
"gulp-jshint": "latest",
"gulp-notify": "latest",
"gulp-rename": "latest",
"gulp-bump": "latest",
"gulp-git": "~0.2.0",
"gulp-size": "latest",
"jshint-stylish": "latest",
"gulp-notify": "latest"
"gulp-uglify": "latest",
"jshint-stylish": "latest"
}
}
2 changes: 1 addition & 1 deletion simpleweather.jquery.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"monkeecreate",
"weather-data"
],
"version": "3.0.2",
"version": "3.1.0",
"author": {
"name": "James Fleeting",
"email": "[email protected]",
Expand Down

0 comments on commit 59e0ce5

Please sign in to comment.