Created
April 12, 2015 07:06
-
-
Save tjoskar/ce0b94dbe96045c6ccc4 to your computer and use it in GitHub Desktop.
Demonstrate bad internet connection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>VT</title> | |
<style> | |
* { | |
margin: 0; | |
padding: 0; | |
} | |
html, body, #view { | |
width: 100%; | |
height: 100%; | |
} | |
img { | |
width: 100%; | |
transition: all .2s ease-out; | |
} | |
.hidden { | |
opacity: 0; | |
} | |
.visible { | |
opacity: 1; | |
} | |
.gray { | |
-webkit-filter: grayscale(100%); | |
} | |
.loader-holder { | |
position: absolute; | |
top: 0; | |
left: 0; | |
height: 20px; | |
width: 100%; | |
} | |
.loader { | |
background-color: rgba(30, 140, 255, 0.74); | |
transition: all .2s ease-out; | |
width: 0%; | |
height: 100%; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="view"> | |
<div class="loader-holder "> | |
<div id="loader" class="loader"></div> | |
</div> | |
<img id="vt" src="vt.se.png" /> | |
</div> | |
<script type="text/javascript"> | |
document.getElementById('vt').onclick = function() { | |
document.getElementById('vt').setAttribute('src', 'nyhet.png'); | |
}; | |
window.onfocus = function(e) { | |
console.log('You are back'); | |
setTimeout(function() { | |
console.log('Make it black and white'); | |
document.getElementById('vt').setAttribute('class', 'gray'); | |
}, 1000); | |
setTimeout(function() { | |
document.getElementById('loader').style.width = '20%'; | |
}, 1500); | |
setTimeout(function() { | |
document.getElementById('vt').setAttribute('class', 'hidden'); | |
document.getElementById('loader').style.width = '100%'; | |
document.getElementById('loader').style.transition = 'all 60s ease-out'; | |
}, 3000); | |
setTimeout(function() { | |
document.getElementById('vt').setAttribute('src', 'offline.png') | |
document.getElementById('vt').setAttribute('class', 'visible'); | |
document.getElementById('loader').setAttribute('class', 'hidden'); | |
document.getElementById('loader').style.transition = 'all .25s ease-out'; | |
}, 20000); | |
}; | |
window.onblur = function(e) { | |
console.log('You are out', e); | |
}; | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment