forked from Metroxe/one-html-page-challenge
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
188 lines (168 loc) · 6.76 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>One HTML Page Challenge</title>
<link rel="apple-touch-icon" sizes="180x180" href="./meta/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="./meta/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="./meta/favicon-16x16.png">
<link rel="manifest" href="./meta/site.webmanifest">
<link rel="mask-icon" href="./meta/safari-pinned-tab.svg" color="#ffa500">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff">
<meta property="og:title" content="One HTML Page Challenge">
<meta property="og:image" content="https://repository-images.githubusercontent.com/194445383/571a9000-9cd0-11e9-9a72-2faf76647a01">
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<style>
.jumbotron {
text-align: center;
}
.logo {
max-width: 70%;
}
body {
background: repeating-linear-gradient(
45deg,
#000000,
#1e1e1e 10px,
#15191d 10px,
#15191d 20px
);
}
.card-text:nth-of-type(2)::before {
display: inline-block;
content: 'Supported in:';
margin-right: 0.5em;
}
</style>
</head>
<body>
<div class="container">
<br/>
<div class="card">
<div class="card-body">
<div class="jumbotron">
<img src="./meta/one-html-page-logo.png" alt="One Html Page Challenge" class="logo"/>
<hr class="my-4">
<p>The goal is to create anything you want within 1 single html file. Practice your skills with no assistance from libraries, no separation of files, and no assistance of a modern framework. <b>How creative can you be with such restrictions?</b></p>
<a class="btn btn-primary btn-lg" href="https://github.com/Metroxe/one-html-page-challenge/blob/master/README.md#how-to-submit" role="button">Submit an Entry</a>
<a class="btn btn-primary btn-lg" href="https://github.com/Metroxe/one-html-page-challenge" role="button">Github</a>
</div>
<div class="input-group flex-nowrap">
<input type="text" class="form-control" placeholder="Search" aria-label="Search" aria-describedby="addon-wrapping" id="search" oninput="searchOnInput()">
<div class="input-group-append">
<span class="input-group-text" id="addon-wrapping">🔍</span>
</div>
</div>
<div id="list"></div>
</div>
</div>
</div>
<br/>
<script src="./entries.js"></script>
<script>
// sort based on title
const sortedEntries = entries.sort((a,b) => (a.title > b.title) ? 1 : ((b.title > a.title) ? -1 : 0));
// create initial list
searchOnInput();
function searchOnInput() {
//get elements
const filter = document.getElementById("search").value.toLowerCase();
const list = document.getElementById("list");
// remove children
while (list.firstChild) {
list.removeChild(list.firstChild);
}
// filter list
const filteredEntries = sortedEntries.filter((entry) => {
let key;
for (key in entry) {
if (entry.hasOwnProperty(key)) {
const prop = entry[key];
if (typeof prop === "string" && prop.toLowerCase().includes(filter)) {
return true;
}
}
}
return false;
});
// create list
filteredEntries.forEach(({title, description, filename, github, author, compatibleBrowsers}) => {
// horizontal rule
const hr = document.createElement("hr");
list.appendChild(hr);
const card = document.createElement("div");
card.className = "card";
const body = document.createElement("div");
body.className = "card-body";
card.appendChild(body);
// title
const cardTitle = document.createElement("h5");
const cardTitleNode = document.createTextNode(title);
cardTitle.className = "card-title";
cardTitle.appendChild(cardTitleNode);
body.appendChild(cardTitle);
// author
if (author) {
const authorSubtitle = document.createElement("h6");
const authorSubtitleNode = document.createTextNode(author);
authorSubtitle.className = "card-subtitle mb-2 text-muted";
authorSubtitle.appendChild(authorSubtitleNode);
body.appendChild(authorSubtitle);
}
// description
if (description) {
const cardDescription = document.createElement("p");
const cardDescriptionNode = document.createTextNode(description);
cardDescription.className = "card-text";
cardDescription.appendChild(cardDescriptionNode);
body.appendChild(cardDescription);
}
// browser list
if (compatibleBrowsers) {
const browserList = document.createElement("p");
const browser = compatibleBrowsers.join(", ");
const browserNameNode = document.createTextNode(browser);
browserList.className = "card-text";
browserList.appendChild(browserNameNode);
body.appendChild(browserList);
}
// toolbar
const toolbar = document.createElement("div");
const group1 = document.createElement("div");
const group2 = document.createElement("div");
toolbar.className = "btn-toolbar";
group1.className = "btn-group mr-2";
group2.className = "btn-group mr-2";
toolbar.appendChild(group1);
toolbar.appendChild(group2);
body.appendChild(toolbar);
// HTML Link
const linkButton = document.createElement("a");
const linkButtonNode = document.createTextNode(filename);
linkButton.className = "btn btn-primary btn-md";
linkButton.href = `./entries/${filename}`;
linkButton.appendChild(linkButtonNode);
group1.appendChild(linkButton);
// Source Code Link
const sourceCodeButton = document.createElement("a");
const sourceCodeNode = document.createTextNode("Source");
sourceCodeButton.className = "btn btn-secondary btn-md";
sourceCodeButton.href = `https://github.com/Metroxe/one-html-page-challenge/blob/master/entries/${filename}`;
sourceCodeButton.appendChild(sourceCodeNode);
group1.appendChild(sourceCodeButton);
// github button
if (github) {
const githubButton = document.createElement("a");
const githubButtonNode = document.createTextNode("Github");
githubButton.className = "btn btn-primary btn-md";
githubButton.href = `https://github.com/${github}`;
githubButton.appendChild(githubButtonNode);
group2.appendChild(githubButton);
}
list.appendChild(card);
})
}
</script>
</body>
</html>