Skip to content
This repository was archived by the owner on Jan 23, 2019. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
93 changes: 25 additions & 68 deletions index.html

Large diffs are not rendered by default.

23 changes: 15 additions & 8 deletions jquery.simpleWeather.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,31 @@
$.extend({
simpleWeather: function(options){
options = $.extend({
location: '',
location: null,
woeid: '2357536',
unit: 'f',
success: function(weather){},
error: function(message){}
}, options);

var now = new Date();
var weatherUrl = '//query.yahooapis.com/v1/public/yql?format=json&rnd='+now.getFullYear()+now.getMonth()+now.getDay()+now.getHours()+'&diagnostics=true&callback=?&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&q=';
if(options.location !== '') {
weatherUrl += 'select * from weather.forecast where woeid in (select woeid from geo.placefinder where text="'+options.location+'" and gflags="R") and u="'+options.unit+'"';
} else if(options.woeid !== '') {
weatherUrl += 'select * from weather.forecast where woeid='+options.woeid+' and u="'+options.unit+'"';
} else {
var weatherUrl;
var selectQuery;

if (options.location) {
selectQuery = 'select * from weather.forecast where woeid in (select woeid from geo.placefinder where text="' + options.location + '" and gflags="R") and u="' + options.unit + '"';
}

else if (options.woeid) {
selectQuery = 'select * from weather.forecast where woeid=' + options.woeid + ' and u="' + options.unit + '"';
}

else {
options.error("Could not retrieve weather due to an invalid location.");
return false;
}

weatherUrl = 'https://query.yahooapis.com/v1/public/yql?q=' + selectQuery + ' and u="f"&format=json&diagnostics=true&callback=';

$.getJSON(
encodeURI(weatherUrl),
function(data) {
Expand Down
2 changes: 1 addition & 1 deletion jquery.simpleWeather.min.js

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