Skip to content

Instantly share code, notes, and snippets.

@uknick
Created April 24, 2013 13:14
Show Gist options
  • Save uknick/5452024 to your computer and use it in GitHub Desktop.
Save uknick/5452024 to your computer and use it in GitHub Desktop.
Yahoo weather API stuff. You'll need the zWeatherFeed jquery plugin - http://www.zazar.net/developers/jquery/zweatherfeed/
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>
<style>
.weatherDesc {display:none;}
#result {background:#ccc; padding:10px;}
</style>
</head>
<body>
<h1>Weather</h1>
<hr>
<div id="feed"></div>
<hr>
<div id="result"></div>
<script>
$(document).ready(function () {
// london, uk feed
$('#feed').weatherfeed(['UKXX0085'],{
unit: 'c',
image: false,
highlow: false,
wind: false,
link: false,
showerror: false,
});
// wait a bit
setTimeout(function() {
var theTemp = $(".weatherTemp").text();
var cleanTemp = theTemp.slice(0, -1); // trim degrees
if(cleanTemp > 12 ){
$("#result").html("More than 12 degrees!");
} else {
$("#result").html("less than 12 degrees!");
}
}, 800);
});
</script>
<script src="jquery.zweatherfeed.min.js" ></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment