Commit 171101d1 authored by Mateusz Wojczal's avatar Mateusz Wojczal 💬
Browse files

pizza responsive

parent 33ddd698
......@@ -47,7 +47,7 @@
<h1 id="h1">Is pizza today?</h1>
<div id="bg"></div>
<script>
function getGif(q, callback) {
function getGif(q, id) {
var request = new XMLHttpRequest;
request.open('GET', 'http://api.giphy.com/v1/gifs/random?api_key=dc6zaTOxFJmzC&tag='+q, true);
......@@ -55,7 +55,8 @@
request.onload = function() {
if (request.status >= 200 && request.status < 400){
var img = JSON.parse(request.responseText).data.image_url;
callback(img);
document.getElementById(id).style.backgroundImage = 'url(' + img + ')';
//callback(img);
} else {
console.log('reached giphy, but API returned an error');
}
......@@ -68,12 +69,22 @@
request.send();
}
getGif('colors', function(img) {
document.getElementById("h1").style.backgroundImage = 'url(' + img + ')';
})
getGif((new Date()).getDay() == 5 ? 'pizza':'no', function(img) {
document.getElementById("bg").style.backgroundImage = 'url(' + img + ')';
})
if (window.location.hash) {
a = atob(window.location.hash.substr(1)).split('|');
if (a.length == 2) {
document.getElementById('h1').innerText = a[0];
getGif(a[1], 'bg');
} else {
alert('proboj dalej hakierze');
}
} else {
getGif((new Date()).getDay() == 5 ? 'pizza':'no', 'bg')
}
getGif('colors', 'h1');
</script>
</body>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment