Last active
February 3, 2016 04:36
-
-
Save nicolehe/cb6facf4ddac8e03049a to your computer and use it in GitHub Desktop.
live web week 1 homework, interactive self portrait
This file contains 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
<html> | |
<head> | |
<title>~self portrait~</title> | |
<link href='https://fonts.googleapis.com/css?family=Arvo' rel='stylesheet' type='text/css'> | |
<style> | |
body { | |
margin: 0; | |
font-family: 'Arvo'; | |
color: #545A9E; | |
font-size: 36pt; | |
} | |
div.video { | |
width: 500px; | |
margin-left: auto; | |
margin-right: auto; | |
margin-top: 100px; | |
} | |
div.bottom { | |
width: 500px; | |
margin-left: auto; | |
margin-right: auto; | |
margin-top: 10px; | |
} | |
div.left { | |
width: 300px; | |
margin-left: 100px; | |
margin-right: auto; | |
float: left; | |
} | |
</style> | |
<script type="text/javascript"> | |
var myVideo; | |
var yesButton; | |
var noButton; | |
function init() { | |
myVideo = document.getElementById("theVideo"); | |
yesButton = document.getElementById("yesButton"); | |
yesButton.addEventListener('click', yesButtonClicked); | |
noButton = document.getElementById("noButton"); | |
noButton.addEventListener('click', noButtonClicked); | |
myVideo.addEventListener('timeupdate', function() { | |
if (myVideo.currentTime > 0.5 && myVideo.currentTime < 2) { | |
hello.style.display = "block"; | |
} else { | |
hello.style.display = "none"; | |
} | |
if (myVideo.currentTime > 2 && myVideo.currentTime < 4) { | |
hello2.style.display = "block"; | |
} else { | |
hello2.style.display = "none"; | |
} | |
if (myVideo.currentTime > 4 && myVideo.currentTime < 8) { | |
music.style.display = "block"; | |
} else { | |
music.style.display = "none"; | |
noMusic.style.display = "none"; | |
} | |
if (myVideo.currentTime > 8 && myVideo.currentTime < 10) { | |
typing.style.display = "block"; | |
} else { | |
typing.style.display = "none"; | |
} | |
if (myVideo.currentTime > 10 && myVideo.currentTime < 15) { | |
document.body.style.backgroundImage = "url('http://nicole.pizza/itp/liveweb/week1-selfportrait/typing.gif')"; | |
} | |
if (myVideo.currentTime > 15 && myVideo.currentTime < 18) { | |
learning.style.display = "block"; | |
document.body.style.backgroundImage = ""; | |
} else { | |
learning.style.display = "none"; | |
} | |
if (myVideo.currentTime > 19 && myVideo.currentTime < 23) { | |
document.body.style.backgroundImage = "url('http://nicole.pizza/itp/liveweb/week1-selfportrait/water.gif')"; | |
} | |
if (myVideo.currentTime > 26 && myVideo.currentTime < 29) { | |
sick.style.display = "block"; | |
document.body.style.backgroundImage = ""; | |
} else { | |
sick.style.display = "none"; | |
} | |
if (myVideo.currentTime > 29 && myVideo.currentTime < 33) { | |
document.body.style.backgroundImage = "url('http://nicole.pizza/itp/liveweb/week1-selfportrait/barf.gif')"; | |
} | |
if (myVideo.currentTime > 33 && myVideo.currentTime < 36) { | |
better.style.display = "block"; | |
document.body.style.backgroundImage = ""; | |
} else { | |
better.style.display = "none"; | |
} | |
if (myVideo.currentTime > 36 && myVideo.currentTime < 40) { | |
document.body.style.backgroundImage = "url('http://nicole.pizza/itp/liveweb/week1-selfportrait/dolphin.gif')"; | |
} | |
if (myVideo.currentTime > 40 && myVideo.currentTime < 43) { | |
bye.style.display = "block"; | |
document.body.style.backgroundImage = ""; | |
} | |
myVideo.onended = function() { | |
fleetwood.pause(); | |
myVideo.load(); | |
bye.style.display = "none"; | |
}; | |
}); | |
} | |
function yesButtonClicked() { | |
fleetwood.play(); | |
} | |
function noButtonClicked() { | |
noMusic.style.display = "block"; | |
} | |
window.addEventListener('load', init); | |
</script> | |
</head> | |
<body> | |
<div class="left" id="sick" style="display:none"> | |
this week has been hard because i got sick | |
</div> | |
<div class="video"> | |
<video id="theVideo" width="500" height="333" controls> | |
<source src="http://nicole.pizza/itp/liveweb/week1-selfportrait/video.mp4" type="video/mp4"> | |
</video> | |
</div> | |
<div class="bottom" id="hello" style="display:none"> | |
hello. | |
</div> | |
<div class="bottom" id="hello2" style="display:none"> | |
hello. this is my self portrait | |
</div> | |
<div class="bottom" id="music" style="display:none"> | |
how about some fleetwood?? | |
<button id="yesButton">Yea!</button> | |
<button id="noButton">Nah</button> | |
<audio id="fleetwood" src="http://nicole.pizza/itp/liveweb/week1-selfportrait/dreams.mp3"> | |
</div> | |
<div class="bottom" id="noMusic" style="display:none"> | |
ok :( | |
</div> | |
<div class="bottom" id="typing" style="display:none"> | |
<img src="http://nicole.pizza/itp/liveweb/week1-selfportrait/typing.gif"> | |
</div> | |
<div class="bottom" id="learning" style="display:none"> | |
i'm trying to learn javascript | |
</div> | |
<div class="bottom" id="better" style="display:none"> | |
but i feel better now | |
</div> | |
<div class="bottom" id="bye" style="display:none"> | |
ok bye | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment