-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenergy_sensing.html
170 lines (142 loc) · 4.34 KB
/
energy_sensing.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
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
<!DOCTYPE html>
<html>
<head>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-119557099-2"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-119557099-2');
</script>
<link rel="stylesheet" type="text/css" href="static/css/app.css">
<link href='https://fonts.googleapis.com/css?family=Aladin' rel='stylesheet'>
<meta charset="utf-8" />
<title>Energy Sensing</title>
<style type="text/css">
body {
font-family: 'Aladin';font-size: 22px;
}
button {
height: 30px;
}
#img-display {
margin-bottom: 50px;
}
.left-img {
margin-right: 400px;
display: inline-block;
}
.right-img {
display: inline-block;
}
.above-img {
margin-bottom: 150px;
}
.button-group {
text-align: center;
margin-bottom: 130px;
}
</style>
</head>
<body class="container">
<h4>Energy Sensing</h4>
<p>Hello, young man, among these four pictures, two of them featuring positive things, two of them featuring negative, horror things. Their opacity are decreased to 0 so you cannot discern with your eyes. But, you can still feel their energy, try to feel it and point out which are positive and which are negative</p>
<br>
<br>
<div class="button-group">
<div id="img-display" style="display: inline-block;"></div>
<br>
<button onclick="showImage()">Show Image</button>
<button onclick="showDesc()">Show Description</button>
<button onclick="reset()">Reset</button>
</div>
<script type="text/javascript">
/*** Declare data ***/
var data = {
image_path: "static/energy_sensing",
images: [
{
origin_name: "positive_1.jpg",
name: "positive_1_processed.jpg",
alt: "mother and her newborn child",
state: "positive"
},
{
origin_name: "positive_2.jpg",
name: "positive_2_processed.jpg",
alt: "Happy exciting running puppy",
state: "positive"
},
{
origin_name: "negative_1.jpg",
name: "negative_1_processed.jpg",
alt: "A man being stab my a demon-like furious-deer",
state: "negative"
},
{
origin_name: "negative_2.jpg",
name: "negative_2_processed.jpg",
alt: "Man stabbing demon-deer",
state: "negative"
}
]
}
var display = function() {
var displayDiv = document.getElementById("img-display");
shuffleArray(data.images);
data.images.forEach((img, index) => {
index += 1;
var imgTag = document.createElement("img");
imgTag.setAttribute("src", data.image_path + "/" + img.name);
imgTag.setAttribute("height", "250px");
imgTag.setAttribute("width", "300px");
imgTag.setAttribute("data-origin-src", data.image_path + "/" + img.origin_name);
imgTag.setAttribute("data-src", data.image_path + "/" + img.name);
var caption = document.createElement("figcaption");
caption.setAttribute("data-desc", img.state + " - " + img.alt);
caption.innerHTML = "Image " + index;
var div = document.createElement("div");
if (index == 1 || index == 3) {
div.setAttribute("class", div.getAttribute("class") + " " + "left-img");
}
if (index == 2 || index == 4) {
div.setAttribute("class", div.getAttribute("class") + " " + "right-img");
}
if (index == 1 || index == 2) {
div.setAttribute("class", div.getAttribute("class") + " " + "above-img");
}
div.appendChild(imgTag);
div.appendChild(caption);
displayDiv.appendChild(div);
if (index === 2) {
displayDiv.appendChild(document.createElement("br"));
}
});
}
var showImage = function() {
var images = document.getElementsByTagName("img");
Array.from(images).forEach((img) => {
img.setAttribute("src", img.getAttribute("data-origin-src"));
});
};
var showDesc = function() {
var captions = document.getElementsByTagName("figcaption");
Array.from(captions).forEach((caption) => {
caption.innerHTML = caption.getAttribute("data-desc");
});
}
var reset = function() {
document.getElementById("img-display").innerHTML = "";
display();
}
function shuffleArray(array) {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
}
display();
</script>
</body>
</html>