forked from ioalpha/dropdeadbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
87 lines (71 loc) · 2.1 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Drop Dead Box - Data Sacrifation</title>
<meta name="description" content="Drop Dead Box">
<meta name="author" content="Olaf Nowacki, Daniel Kranz, ">
<script src="js/jquery-2.1.4.min.js" type="text/javascript"></script>
<script src="js/sacrifice.js" type="text/javascript"></script>
<link rel="stylesheet" href="css/styles.css"/>
<!--link rel="stylesheet" href="css/styles.css"-->
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<h1>Sacrifice your data <br> to please the internet gods</h1>
<input type='file' id="fileUpload" />
<div id="prey">
<canvas id="canvas" width="900" height="600">
Browser missing HTML5 support.
</canvas>
</div>
<div id="balken"></div>
<script type="text/javascript">
var w = 900
var h = 600;
var canvas = document.getElementById("canvas");
var context = canvas.getContext("2d");
function centerCanvas() {
var docWidth = document.body.clientWidth;
var left = Math.round((docWidth - w) / 2);
$("#prey").css("left", left);
}
centerCanvas();
var ligeti = new Audio("audio/ligeti.mp3");
var noise = new Audio("audio/noise.mp3");
function el(id) {
return document.getElementById(id);
} // Get elem by ID
function readImage() {
if ( this.files && this.files[0] ) {
var FR = new FileReader();
FR.onload = function(e) {
var img = new Image();
img.onload = function() {
context.drawImage(img, Math.round((w - img.width) / 2), 0);
};
img.src = e.target.result;
};
FR.readAsDataURL( this.files[0] );
sacrifice();
}
}
function sacrifice() {
ligeti.play();
$("#prey").animate({
top: 600,
}, 25000, function() {
reset();
});
}
function reset() {
ligeti.pause();
$("#prey").css("top", "-600px");
context.clearRect(0, 0, canvas.width, canvas.height);
}
el("fileUpload").addEventListener("change", readImage, false);
</script>
</body>
</html>