Skip to content

Instantly share code, notes, and snippets.

@ruuda
Last active October 22, 2016 18:48
Show Gist options
  • Save ruuda/aa16f683a7bc75f9c4c0a6833069cfc6 to your computer and use it in GitHub Desktop.
Save ruuda/aa16f683a7bc75f9c4c0a6833069cfc6 to your computer and use it in GitHub Desktop.
Can I keep my beer outdoors?
<html>
<!--
Copyright 2016 Ruud van Asseldonk
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
-->
<head>
<title>Kan ik mijn bier buiten zetten?</title>
<style>
body
{
font-size: 50px;
font-family: serif;
text-align: center;
margin-top: 3em;
}
h1, p
{
font-size: 1em;
font-weight: normal;
}
</style>
</head>
<body>
<h1>Kan ik mijn bier buiten zetten?</h1>
<p id="result">Momentje, ik denk er even over na ...</p>
<script>
var handleWeatherData = function(data)
{
var temperatureDegrees = data.query.results.channel.item.condition.temp;
var resultParagraph = document.getElementById("result");
if (temperatureDegrees <= 6.0)
{
resultParagraph.innerText = "Ja"
}
else
{
resultParagraph.innerText = "Nee"
}
};
var queryUrl =
"https://query.yahooapis.com/v1/public/yql?q=" +
// Get the current weather condition, we don't care about the forecast.
"select item.condition from weather.forecast " +
// Ask for the weather in The Bilt. (Woeid means "Where-on-earth ID".)
"where woeid in (select woeid from geo.places(1) where text='De Bilt, NL') " +
// Normal SI units please, not some retarded imperial system.
"and u = 'c'" +
// Get the data as json. When it arrives, call 'handleWeatherData' with
// the results.
"&format=json&callback=handleWeatherData";
// Create an exra <script> element and append it below. This will initiate
// the request to Yahoo.
var script = document.createElement("script");
script.src = queryUrl;
document.body.appendChild(script);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment