Weather App
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.simpleWeather/3.1.0/jquery.simpleWeather.min.js"></script>
<div id="weather"></div>
CSS
/*
Docs at http://http://simpleweatherjs.com
Look inspired by http://www.degreees.com/
Used for demo purposes.
Weather icon font from http://fonts.artill.de/collection/artill-weather-icons
DO NOT hotlink the assets/font included in this demo. If you wish to use the same font icon then download it to your local assets at the link above. If you use the links below odds are at some point they will be removed and your version will break.
*/
@font-face {
font-family: 'weather';
src: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/93/artill_clean_icons-webfont.eot');
src: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/93/artill_clean_icons-webfont.eot?#iefix') format('embedded-opentype'),
url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/93/artill_clean_icons-webfont.woff') format('woff'),
url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/93/artill_clean_icons-webfont.ttf') format('truetype'),
url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/93/artill_clean_icons-webfont.svg#artill_clean_weather_iconsRg') format('svg');
font-weight: normal;
font-style: normal;
}
html {
width: 100%;
height: 100%;
background-size: cover;
background
}
body {
padding: 45px 0;
font: 13px 'Open Sans', "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
background: transparent;
}
#weather {
width: 500px;
margin: 0px auto;
text-align: center;
text-transform: uppercase;
}
i {
color: #fff;
font-family: weather;
font-size: 150px;
font-weight: normal;
font-style: normal;
line-height: 1.0;
text-transform: none;
}
.icon-0:before { content: ":"; }
.icon-1:before { content: "p"; }
.icon-2:before { content: "S"; }
.icon-3:before { content: "Q"; }
.icon-4:before { content: "S"; }
.icon-5:before { content: "W"; }
.icon-6:before { content: "W"; }
.icon-7:before { content: "W"; }
.icon-8:before { content: "W"; }
.icon-9:before { content: "I"; }
.icon-10:before { content: "W";...
JavaScript
// v3.1.0
//Docs at http://simpleweatherjs.com
$(document).ready(function() {
var searchQuery = "London, Uk";
$.ajax({
type: "GET",
dataType: "jsonp",
url: "https://www.googleapis.com/customsearch/v1",
data: {
key: "AIzaSyCzb6SI_JRrp6xLLYV617Ary6n59h36ros",
cx: "004286675445984025592:ypgpkv9fjd4",
filter: "1",
searchType: "image",
q: searchQuery,
prettyPrint: true
}
}).done(function(data) {
//$('html').append("<img src='" + data.items[0].link + "' />");
$('html').css('background-image','url("'+data.items[0].link+'")');
});
$.simpleWeather({
location: 'London, Uk',
woeid: '',
unit: 'f',
success: function(weather) {
html = '<h2><i class="icon-'+weather.code+'"></i> '+weather.temp+'°'+weather.units.temp+'</h2>';
html += '<ul><li>'+weather.city+', '+weather.region+'</li>';
html += '<li class="currently">'+weather.currently+'</li>';
html += '<li>'+weather.wind.direction+' '+weather.wind.speed+' '+weather.units.speed+'</li></ul>';
$("#weather").html(html);
},
error: function(error) {
$("#weather").html('<p>'+error+'</p>');
}
});
});