-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
109 lines (94 loc) · 2.4 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<!doctype html>
<meta charset="utf-8">
<title>y-a-v-a.org ❤︎ sol lewitt</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="favicon.png" type="image/x-icon">
<style>
html, body {
padding: 0;
margin: 0;
width:100%;
height: 100%;
}
iframe {
border: none;
width: 100%;
height: 100%;
}
div {
position: fixed;
bottom: 16px;
left: 16px;
background: #222;
height: 64px;
width: 272px;
display: none;
border-radius: 4px;
color: white;
padding: 8px;
font-family: sans-serif;
font-size: 13px;
line-height: 1.5;
box-shadow: 0 0 10px #666;
font-weight: lighter;
text-rendering: optimizeLegibility;
}
a {
color: white;
}
</style>
<iframe></iframe>
<div>
This work is made by <a href="http://www.y-a-v-a.org">y-a-v-a.org</a> under MIT license.
Idea to make Sol LeWitt Wall Drawings for web is from <a href="http://www.solvingsol.com">Brad Bouse</a>.
Code on <a href="https://github.com/y-a-v-a/solving-sol">GitHub</a>.
</div>
<script>
(function() {
var iframe = document.querySelectorAll('iframe')[0];
var url = './';
var drawings = [];
var cache = [];
var req = new XMLHttpRequest();
req.onload = function() {
var data = this.responseText;
var solutions = JSON.parse(data);
for (var i = 0; i < solutions.length; i++) {
drawings.push(solutions[i] + '/index.html');
}
if (drawings.length == 0) {
return;
}
setFrameSrc(drawings);
// average time a museum visitor stand in front of a painting
var interval = 16 * 1000;
window.setInterval(setFrameSrc, interval, drawings);
};
req.open('get', './solutions.json', true);
req.send();
function setFrameSrc(drawings) {
var number = getRandomKey();
iframe.src = url + number;
showMessage();
}
function getRandomKey() {
if (!cache.length) {
cache = drawings.slice(0);
}
var start = Math.floor(Math.random() * cache.length);
return cache.splice(start, 1);
}
function showMessage() {
var el = document.querySelectorAll('div')[0];
window.setTimeout(function() {
el.style.display = 'block';
window.setTimeout(function() {
el.style.display = 'none';
}, 5000);
}, 800);
el.onclick = function() {
el.style.display = 'none';
};
}
})();
</script>