-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
234 lines (196 loc) · 6.77 KB
/
index.html
File metadata and controls
234 lines (196 loc) · 6.77 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
<html>
<head>
<link href='https://fonts.googleapis.com/css?family=Lobster|Montserrat' rel='stylesheet' type='text/css'>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script>
var backgroundImages =
[
"https://farm8.staticflickr.com/7488/16136447277_f8e3ce6fbd_b.jpg",
"https://farm6.staticflickr.com/5120/5843135951_52c6a140e1_b.jpg",
"https://farm6.staticflickr.com/5035/5903895990_402827cd1e_b.jpg",
"https://farm8.staticflickr.com/7544/16135729300_e48a8e56b6_b.jpg"
];
</script>
<style>
html,body {margin:0; padding:0;}
.background {
position:absolute;
width:100%;
height:100%;
z-index:10;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
background-repeat: no-repeat;
background-position: center center
background-attachment: fixed;
}
#backgroundB {
z-index:11;
opacity: 0;
-moz-transition: opacity 0.5s ease-in-out;
-webkit-transition: opacity 0.5s ease-in-out;
transition: opacity 0.5s ease-in-out;
}
#backgroundB.fade-in {
opacity: 1;
}
.content {
position:absolute;
z-index:100;
width:100%;
color:white;
font-family: 'Montserrat', sans-serif;
}
.progress {
position: fixed;
z-index:99;
bottom:0;
width:100%;
height:3px;
}
.progress #progressBar {
width:0%; height:100%;
background-image: linear-gradient(rgba(255, 0, 0, 0.4), rgba(255, 0, 0, 0.4));
}
h1 {
margin:0;
font-family: 'Lobster', cursive;
}
.topHeader {
text-align: center;
padding: 30px 0 30px 0;
border-bottom: 1px solid rgba(256,256,256,.3);
background: transparent;
background-image: linear-gradient(rgba(0,0,0,0.4) 0%,rgba(0,0,0,0.3) 20%,rgba(0,0,0,0.2) 35%,transparent 97%,transparent 0%);
}
</style>
</head>
<body>
<div id="backgroundA" class="background"></div>
<div id="backgroundB" class="background"></div>
<div class="content">
<div class="topHeader row">
<h1>Sam Ou Photography</h1>
emailsamou@gmail.com
</div>
</div>
<div class="progress">
<div id="progressBar"></div>
</div>
<script>
var backgroundCounter=0;
loadImage(backgroundImages[0]);
function whichTransitionEvent(){
var t;
var el = document.createElement('fakeelement');
var transitions = {
'transition':'transitionend',
'OTransition':'oTransitionEnd',
'MozTransition':'transitionend',
'WebkitTransition':'webkitTransitionEnd'
}
for(t in transitions){
if( el.style[t] !== undefined ){
return transitions[t];
}
}
}
var transitionEvent = whichTransitionEvent();
var request;
var progressBar;
var backgroundTimer;
// add event listener
document.getElementById("backgroundB").addEventListener(transitionEvent, function(event) {
if (document.getElementById("backgroundB").classList.contains("fade-in")) {
document.getElementById("backgroundA").style.backgroundImage = "url(data:image/jpeg;base64," + base64Encode(request.responseText)+")";
document.getElementById("backgroundB").classList.remove("fade-in");
}
}, false );
function loadImage(imageURI)
{
request = new XMLHttpRequest();
request.onloadstart = showProgressBar;
request.onprogress = updateProgressBar;
request.onload = showImage;
request.onloadend = hideProgressBar;
request.open("GET", imageURI, true);
request.overrideMimeType('text/plain; charset=x-user-defined');
request.send(null);
}
function showProgressBar()
{
clearTimeout(backgroundTimer);
document.getElementById("progressBar").style.width = "0%";
}
function updateProgressBar(e)
{
if (e.lengthComputable) {
document.getElementById("progressBar").style.width = String(e.loaded / e.total * 100) + "%";
} else {
document.getElementById("progressBar").style.width = "0%";
}
}
function showImage()
{
document.getElementById("progressBar").style.width = "100%";
document.getElementById("backgroundB").style.backgroundImage = "url(data:image/jpeg;base64," + base64Encode(request.responseText)+")";
document.getElementById("backgroundB").classList.add("fade-in");
}
function hideProgressBar()
{
document.getElementById("progressBar").style.width = "0%";
// download next image
backgroundTimer = setTimeout(function(){
if (++backgroundCounter >= backgroundImages.length) { backgroundCounter=0; }
loadImage(backgroundImages[backgroundCounter]);
}, 8000);
}
// This encoding function is from Philippe Tenenhaus's example at http://www.philten.com/us-xmlhttprequest-image/
function base64Encode(inputStr)
{
var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
var outputStr = "";
var i = 0;
while (i < inputStr.length)
{
//all three "& 0xff" added below are there to fix a known bug
//with bytes returned by xhr.responseText
var byte1 = inputStr.charCodeAt(i++) & 0xff;
var byte2 = inputStr.charCodeAt(i++) & 0xff;
var byte3 = inputStr.charCodeAt(i++) & 0xff;
var enc1 = byte1 >> 2;
var enc2 = ((byte1 & 3) << 4) | (byte2 >> 4);
var enc3, enc4;
if (isNaN(byte2))
{
enc3 = enc4 = 64;
}
else
{
enc3 = ((byte2 & 15) << 2) | (byte3 >> 6);
if (isNaN(byte3))
{
enc4 = 64;
}
else
{
enc4 = byte3 & 63;
}
}
outputStr += b64.charAt(enc1) + b64.charAt(enc2) + b64.charAt(enc3) + b64.charAt(enc4);
}
return outputStr;
}
</script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-45967388-3', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>