simpleWeather v2 Demo Liverpool
Sample usage for the simpleWeather plugin. http://simpleweather.monkeecreate.com
by lovromar
HTML
<!-- Docs at http://simpleweather.monkeecreate.com -->
<div id="weather"></div>
CSS
/*
Docs at http://simpleweather.monkeecreate.com
Look inspired by http://www.degreees.com/
Used for demo purposes.
*/
body {
font: 13px 'Open Sans', "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
background: #0091c2;
}
#weather {
width: 425px;
margin: 0px auto;
text-align: center;
text-transform: uppercase;
}
#weather h2 {
margin: 0 0 8px;
color: #fff;
font-size: 150px;
font-weight: 300;
text-align: center;
text-shadow: 0px 1px 3px rgba(0, 0, 0, 0.15);
}
#weather ul {
margin: 0;
padding: 0;
}
#weather li {
background: #fff;
background: rgba(255,255,255,0.90);
padding: 20px;
display: inline-block;
border-radius: 5px;
}
#weather .currently {
margin: 0 20px;
}
JavaScript
// Docs at http://simpleweather.monkeecreate.com
$(document).ready(function() {
$.simpleWeather({
zipcode: '',
woeid: '26734',
location: '',
unit: 'c',
success: function(weather) {
html = '<h2>'+weather.temp+'°'+weather.units.temp+'</h2>';
html += '<ul><li>'+weather.city+', '+weather.region+'</li>';
html += '<li class="currently">'+weather.currently+'</li>';
html += '<li>'+weather.tempAlt+'°C</li></ul>';
html += '<img src='+weather.image+' />';
$("#weather").html(html);
},
error: function(error) {
$("#weather").html('<p>'+error+'</p>');
}
});
});
/*
* simpleWeather - http://simpleweather.monkeecreate.com
* Version 2.1 - Last updated: January 11 2013
*/
(function($){"use strict";$.extend({simpleWeather:function(m){m=$.extend({zipcode:'',woeid:'2357536',location:'',unit:'f',success:function(a){},error:function(a){}},m);var n=new Date();var o='http://query.yahooapis.com/v1/public/yql?format=json&rnd='+n.getFullYear()+n.getMonth()+n.getDay()+n.getHours()+'&diagnostics=true&callback=?&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&q=';if(m.location!==''){o+='select * from weather.forecast where location in (select id from weather.search where query="'+m.location+'") and u="'+m.unit+'"'}else if(m.zipcode!==''){o+='select * from weather.forecast where location in ("'+m.zipcode+'") and u="'+m.unit+'"'}else if(m.woeid!==''){o+='select * from weather.forecast where woeid='+m.woeid+' and u="'+m.unit+'"'}else{m.error("No location given. Please provide either a US zip code, WOEID or location.");return false}$.getJSON(o,function(l){if(l!==null&&l.query.results!==null){$.each(l.query.results,function(i,a){if(a.constructor.toString().indexOf("Array")!==-1){a=a[0]}var b=new Date();var c=new Date(b.toDateString()+' '+a.astronomy.sunrise);var d=new Date(b.toDateString()+' '+a.astronomy.sunset);if(b>c&&b<d){var e='d'}else{var e='n'}var...