-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
229 lines (190 loc) · 5.28 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
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
<!doctype html>
<html>
<head>
<title>web-Image-Viewer</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="logo.png" rel="icon">
<link href="logo.png" rel="apple-touch-icon">
<style>
* {
box-sizing: border-box;
margin: 0;
}
.row {
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
padding: 0px 5px;
flex-wrap: wrap;
}
/* Create four equal columns that sits next to each other */
.column {
-ms-flex: 25%;
/* IE10 */
flex: 25%;
}
.column img {
vertical-align: middle;
width: 100%;
}
.header_main {
margin: 20px 10px 20px 13px;
width: 98%;
background-color: #F5F5F5;
padding: 20px;
text-align: center;
border-radius: 60px 60px 15px 15px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
.header_main h1 {
font-style: normal !important;
background-image: linear-gradient(90deg, #7209d4, #2832d4 33%, #00a5b2);
-webkit-background-clip: text;
background-clip: text;
color: transparent;
font-size: 36px;
font-weight: bold;
margin-bottom: 20px;
margin-top: -10px;
}
.header_main h2 {
font-size: 24px;
color: #333;
margin-bottom: 20px;
}
.section_menu {
margin-top: 20px;
display: inline-block;
text-align: start;
}
.section_menu input[type="checkbox"] {
width: 20px;
height: 20px;
margin-right: 10px;
}
.section_menu label {
font-size: 18px;
color: #333;
}
.section_menu input[type="checkbox"]:checked+label {
color: #4CAF50;
font-weight: bold;
}
/* Responsive layout - makes a two column-layout instead of four columns */
@media screen and (max-width: 800px) {
.column {
-ms-flex: 50%;
flex: 50%;
max-width: 50%;
}
}
/* Responsive layout - makes the two columns stack on top of each other instead of next to each other */
@media screen and (max-width: 600px) {
.column {
-ms-flex: 100%;
flex: 100%;
max-width: 100%;
}
}
</style>
<script type="text/javascript">
function changeBackgroundColor() {
if (document.getElementById("dark_background").checked) {
document.querySelector("body").style.backgroundColor = '#404040';
document.querySelector(".header_main").style.backgroundColor = '#b3b3b3';
} else {
document.querySelector("body").style.backgroundColor = 'white';
document.querySelector(".header_main").style.backgroundColor = '#F5F5F5';
}
}
function roundedCorners() {
let images = document.getElementsByTagName("img");
if (document.getElementById("rounded_corners").checked) {
for (image of images) {
image.style.borderRadius = '10px';
}
} else {
for (image of images){
image.style.borderRadius = '0px';
}
}
}
function paddingImages() {
let images = document.getElementsByTagName("img");
if (document.getElementById("padding_images").checked) {
for (image of images) {
image.style.padding = '5px 5px';
document.querySelector(".row").style.padding = '0px 5px';
}
} else {
for (image of images){
image.style.padding = '0px';
document.getElementById("rounded_corners").checked = false;
roundedCorners();
document.querySelector(".row").style.padding = '0px 0px';
}
}
}
// http://stackoverflow.com/questions/805107/creating-multiline-strings-in-javascript
function mlString(f) {
return f.toString().
replace(/^[^\/]+\/\*!?/, '').
replace(/\*\/[^\/]+$/, '');
}
var columns = ["column0", "column1", "column2", "column3"];
var indexColumn = 0;
function main() {
var filenames = g_FOLDER_CONTENTS.match(/\S+/g);
var fragment = document.createDocumentFragment();
for (var i = 0; i < filenames.length; ++i) {
task(i);
}
function task(i) {
setTimeout(function () {
console.log(filenames[i]);
var image = document.createElement("img");
image.src = "album/" + filenames[i];
image.style.borderRadius = '10px';
//image.style.width = '100%';
image.style.padding = '5px 5px';
fragment.appendChild(image);
console.log(columns[indexColumn]);
document.getElementById(columns[indexColumn]).appendChild(fragment);
indexColumn++;
if (indexColumn == 4) {
indexColumn = 0;
}
}, 0 * i)
}
}
</script>
<script type="text/javascript" src="folder_contents.js"></script>
</head>
<body onload="main()">
<header class="header_main">
<h1>A simple & responsive web image album viewer</h1>
<section class="section_menu">
<input type="checkbox" onchange="roundedCorners()" id="rounded_corners" name="rounded_corners"
value="corners" checked>
<label for="rounded_corners">Rounded corners</label><br>
<input type="checkbox" onchange="changeBackgroundColor()" id="dark_background" name="dark_background"
value="background">
<label for="dark_background">Dark background</label><br>
<input type="checkbox" onchange="paddingImages()" id="padding_images" name="padding_images"
value="padding" checked>
<label for="padding_images">Image padding</label><br>
</section>
</header>
<div class="row">
<div class="column" id="column0">
</div>
<div class="column" id="column1">
</div>
<div class="column" id="column2">
</div>
<div class="column" id="column3">
</div>
</div>
</body>
</html>