Skip to content

Commit 0cf7bdb

Browse files
committed
Merge branch 'compact'
2 parents b2f4964 + a7ccce9 commit 0cf7bdb

5 files changed

Lines changed: 120 additions & 41 deletions

File tree

main.css

Lines changed: 64 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ body {
247247
font-weight: bold;
248248
}
249249
.results-navigate {
250-
margin-left: 24px;
250+
margin-left: 1.2rem;
251251
}
252252
.results-per-page {
253253
font-size: 0.7rem;
@@ -256,18 +256,25 @@ body {
256256
width: 2rem !important;
257257
margin-left: 0.5rem;
258258
}
259+
.results-compact {
260+
position: absolute;
261+
top: 2rem; right: 0;
262+
}
259263
.results-bottom {
260264
text-align: right;
261265
margin-top: 0.5rem;
262266
}
263267

264268
.entry {
265-
height: 6rem;
266269
padding: 0.5rem 0;
267270
border-bottom: 0.15rem solid #0002;
268271
display: flex;
269272
}
270-
.entry-logo {
273+
274+
.entry:not([compact]) {
275+
height: 6rem;
276+
}
277+
.entry:not([compact]) .entry-logo {
271278
height: 100%;
272279
background-position: center;
273280
background-repeat: no-repeat;
@@ -276,33 +283,80 @@ body {
276283
flex: 0 0 8rem;
277284
cursor: pointer;
278285
}
279-
.entry-text {
286+
.entry:not([compact]) .entry-text {
280287
min-width: 0;
281288
display: flex;
282289
flex-direction: column;
283290
flex-grow: 1;
284291
white-space: nowrap;
285292
overflow: hidden;
286293
}
287-
.entry-title {
294+
.entry:not([compact]) .entry-title {
288295
font-family: Tahoma, sans-serif;
289296
font-size: 1.5rem;
290297
}
291-
.entry-developer {
298+
.entry:not([compact]) .entry-developer {
292299
font-size: 0.7rem;
293300
margin-left: 0.1rem;
294301
}
295-
.entry-type,
296-
.entry-tags {
302+
.entry:not([compact]) .entry-type,
303+
.entry:not([compact]) .entry-tags {
297304
font-size: 0.9rem;
298305
}
299-
.entry-tags {
306+
.entry:not([compact]) .entry-tags {
300307
color: #000a;
301308
}
302-
.entry-description {
309+
.entry:not([compact]) .entry-description {
303310
margin-top: 0.5rem;
304311
white-space: normal;
305312
}
313+
.entry:not([compact]) .entry-description[empty] {
314+
color: #000a;
315+
font-style: italic;
316+
}
317+
318+
.entry[compact] {
319+
height: 1rem;
320+
overflow: hidden;
321+
align-items: center;
322+
}
323+
.entry[compact] :not(.entry-platform, .entry-library) {
324+
overflow: hidden;
325+
text-overflow: ellipsis;
326+
white-space: nowrap;
327+
}
328+
.entry[compact] :not(.entry-title) {
329+
font-size: 0.7rem;
330+
}
331+
.entry[compact] :not(.entry-description) {
332+
flex-shrink: 0;
333+
}
334+
.entry[compact] .entry-platform,
335+
.entry[compact] .entry-library {
336+
width: 1.2rem;
337+
height: 1.2rem;
338+
background-size: contain;
339+
background-position: center;
340+
background-repeat: no-repeat;
341+
padding-right: 0.2rem;
342+
}
343+
.entry[compact] .entry-title {
344+
font-size: 0.9rem;
345+
padding: 0 0.5rem 0 0.2rem;
346+
max-width: calc(40% - 2.8rem);
347+
}
348+
.entry[compact] .entry-developer {
349+
padding-right: 0.5rem;
350+
max-width: calc(25% - 2.8rem);
351+
}
352+
.entry[compact] .entry-description {
353+
color: #000a;
354+
flex-grow: 1;
355+
}
356+
.entry[compact] .entry-tags {
357+
padding-left: 0.5rem;
358+
max-width: calc(35% - 2.8rem);
359+
}
306360

307361
.viewer {
308362
flex-direction: column;

search/animation.png

355 Bytes
Loading

search/game.png

728 Bytes
Loading

search/index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@
5858
<input type="text" placeholder="#" class="results-input-page">
5959
<button class="results-go-to-page">Go</button>
6060
</div>
61+
<div class="results-compact">
62+
<input type="checkbox" id="compact"> <label for="compact">Compact View</label>
63+
</div>
6164
</div>
6265
<div class="results-list" hidden></div>
6366
<div class="results-bottom results-navigate" hidden>

search/search.js

Lines changed: 53 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
let fpdb = {
22
api: 'https://db-api.unstable.life',
33
images: 'https://infinity.unstable.life/images',
4+
icons: 'https://flashpointproject.github.io/flashpoint-database-logos/',
45
resultsPerPage: 100,
56
metaMap: {
67
title: "Title",
@@ -71,9 +72,6 @@ fetch('fields.json').then(r => r.json()).then(async json => {
7172
fetch('sort.json').then(r => r.json()).then(json => {
7273
fpdb.sortOptions = json;
7374

74-
let options = document.querySelector('.results-sort-options'),
75-
direction = document.querySelector('.results-sort-direction');
76-
7775
for (let sort of json) {
7876
let opt = document.createElement('option');
7977
opt.value = sort.name;
@@ -226,22 +224,12 @@ function loadPage(page) {
226224
});
227225

228226
for (let i = (page - 1) * fpdb.displayedResults; i < Math.min(fpdb.list.length, page * fpdb.displayedResults); i++) {
229-
let entry = document.createElement('div')
227+
let compact = document.querySelector('#compact').checked;
228+
229+
let entry = document.createElement('div');
230230
entry.className = 'entry';
231-
232-
let logo = document.createElement('div');
233-
logo.className = 'entry-logo';
234-
logo.setAttribute('view', i);
235-
logo.setAttribute('lazy-background', `url("${fpdb.images}/Logos/${fpdb.list[i].id.substring(0, 2)}/${fpdb.list[i].id.substring(2, 4)}/${fpdb.list[i].id}.png?type=jpg")`);
236-
logo.addEventListener('click', loadEntry);
237-
logoObserver.observe(logo);
238-
239-
let text = document.createElement('div');
240-
text.className = 'entry-text';
241-
242-
let header = document.createElement('div'),
243-
subHeader = document.createElement('div');
244-
231+
if (compact) entry.setAttribute('compact', 'true');
232+
245233
let title = document.createElement('a');
246234
title.classList.add('entry-title', 'common-activate');
247235
title.setAttribute('view', i);
@@ -256,29 +244,61 @@ function loadPage(page) {
256244
developer.textContent = ' by ' + fpdb.list[i].publisher;
257245
else
258246
developer.hidden = true;
259-
260-
let type = document.createElement('span');
261-
type.className = 'entry-type';
262-
type.textContent = fpdb.list[i].platform.replace(/; /g, '/') + (fpdb.list[i].library == 'arcade' ? ' game' : ' animation');
263-
247+
264248
let tags = document.createElement('span');
265249
tags.className = 'entry-tags';
266-
tags.textContent = ' - ' + fpdb.list[i].tags.join(' - ');
250+
if (compact)
251+
tags.textContent = fpdb.list[i].tags.join(', ');
252+
else
253+
tags.textContent = '\u00A0- ' + fpdb.list[i].tags.join(' - ');
267254

268255
let description = document.createElement('div');
269256
description.className = 'entry-description';
270257
if (fpdb.list[i].originalDescription != '')
271258
description.textContent = fpdb.list[i].originalDescription;
259+
else if (!compact) {
260+
description.textContent = 'No description.';
261+
description.setAttribute('empty', 'true');
262+
}
263+
264+
if (compact) {
265+
let platform = document.createElement('div');
266+
platform.className = 'entry-platform';
267+
let platformName = fpdb.list[i].platform.split('; ')[0];
268+
platform.style.backgroundImage = 'url("' + fpdb.icons + platformName + '.png")';
269+
platform.setAttribute('title', platformName);
270+
271+
let library = document.createElement('div');
272+
library.className = 'entry-library';
273+
library.style.backgroundImage = 'url("' + (fpdb.list[i].library == 'arcade' ? 'game.png' : 'animation.png') + '")';
274+
library.setAttribute('title', fpdb.list[i].library == 'arcade' ? 'Game' : 'Animation');
275+
276+
entry.append(platform, library, title, developer, description, tags);
277+
}
272278
else {
273-
description.textContent = 'No description.'
274-
description.style.color = '#000a';
275-
description.style.fontStyle = 'italic';
279+
let logo = document.createElement('div');
280+
logo.className = 'entry-logo';
281+
logo.setAttribute('view', i);
282+
logo.setAttribute('lazy-background', `url("${fpdb.images}/Logos/${fpdb.list[i].id.substring(0, 2)}/${fpdb.list[i].id.substring(2, 4)}/${fpdb.list[i].id}.png?type=jpg")`);
283+
logo.addEventListener('click', loadEntry);
284+
logoObserver.observe(logo);
285+
286+
let text = document.createElement('div');
287+
text.className = 'entry-text';
288+
289+
let header = document.createElement('div'),
290+
subHeader = document.createElement('div');
291+
292+
let type = document.createElement('span');
293+
type.className = 'entry-type';
294+
type.textContent = fpdb.list[i].platform.replace(/; /g, '/') + (fpdb.list[i].library == 'arcade' ? ' game' : ' animation');
295+
296+
header.append(title, developer);
297+
subHeader.append(type, tags);
298+
text.append(header, subHeader, description);
299+
entry.append(logo, text);
276300
}
277301

278-
header.append(title, developer);
279-
subHeader.append(type, tags);
280-
text.append(header, subHeader, description);
281-
entry.append(logo, text);
282302
htmlList.append(entry);
283303
}
284304
}
@@ -436,6 +456,8 @@ function backToResults() {
436456

437457
document.querySelector('.search-button').addEventListener('click', performSearch);
438458

459+
document.querySelector('#compact').addEventListener('change', () => loadPage(fpdb.currentPage));
460+
439461
document.querySelectorAll('.results-first-page').forEach(elem => elem.addEventListener('click', () => { if (fpdb.currentPage > 1) loadPage(1); }));
440462
document.querySelectorAll('.results-back-page').forEach(elem => elem.addEventListener('click', () => { if (fpdb.currentPage > 1) loadPage(fpdb.currentPage - 1); }));
441463
document.querySelectorAll('.results-forward-page').forEach(elem => elem.addEventListener('click', () => { if (fpdb.currentPage < fpdb.pages) loadPage(fpdb.currentPage + 1); }));

0 commit comments

Comments
 (0)