simpleWeather Original Demo

Sample usage for the simpleWeather plugin. http://simpleweather.monkeecreate.com

by James Fleeting

HTML

<!-- Docs at http://simpleweather.monkeecreate.com -->
<div id="weather"></div>

CSS

/* Docs at http://simpleweather.monkeecreate.com */

#weather {
    background: #6f9dbe;
    background: -webkit-gradient(linear, left top, left bottom, from(#adc7db), to(#6f9dbe));
    background: -moz-linear-gradient(top, #b2bcc8, #adc7db);
    width: 185px;
    padding: 5px 10px;
    overflow: hidden;
    border: 1px solid #6591b3;
}

#weather h2 {
    color: #000;
    text-shadow: rgba(250, 250, 250, 0.6) 2px 2px 0;
}

#weather p {
    font-size: 25px;
    margin: 30px 0 0;
}

#weather p span {
    font-size: 16px;
}

#weather a {
    display: block;
    clear: both;
    text-decoration: none;
    color: #222;
    font-size: 12px;
}

#weather a:hover {
    color: #000;
    text-decoration: underline;
}

JavaScript

// Docs at http://simpleweather.monkeecreate.com
$(document).ready(function() {
  $.simpleWeather({
    zipcode: '',
    woeid: '2357536',
    location: '',
    unit: 'f',
    success: function(weather) {
    html = '<h2>'+weather.city+', '+weather.region+'</h2>';
    html += '<img style="float:left;" width="125px" src="'+weather.image+'">';
    html += '<p>'+weather.temp+'&deg; '+weather.units.temp+'<br /><span>'+weather.currently+'</span></p>';
    html += '<a href="'+weather.link+'">View Forecast &raquo;</a>';
  
      $("#weather").html(html);
    },
    error: function(error) {
      $("#weather").html('<p>'+error+'</p>');
    }
  });
});



/* 
 * simpleWeather - http://simpleweather.monkeecreate.com
 * Version 2.1 - Last updated: November 17 2012
 */
(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...