-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
595 lines (537 loc) · 20.7 KB
/
index.js
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
// globals
window._globals = {
allRepos: undefined,
sortFilterSearchRepos: undefined,
ignoreNextHashChange: undefined,
templates: {}
};
// register events for updating the UI state based on the hash
window.addEventListener("hashchange", updateUI);
// creates a readable project name from the (technical) GitHub repository name
function readableRepoName (sName) {
// split by - by default
let aWords = sName.split("-");
// try splitting with _ instead
if (aWords.length === 1) {
aWords = sName.split("_");
}
// uppercase words
aWords = aWords.map(
(sWord) => sWord.charAt(0).toUpperCase() + sWord.slice(1)
);
// replace minus with space
return aWords.join(" ");
}
// creates all items to be displayed
function createContent (aItems) {
// extract display mode
let oURL = new URL("https://dummy.com");
oURL.search = window.location.hash.substring(1);
const sDisplay = oURL.searchParams.get("display") || "card";
// generate and show HTML
const sResult = aItems.map((oItem) => generateItem(sDisplay, oItem)).join ("");
updateContent(sDisplay, sResult, aItems);
}
// updates the content area
function updateContent (sDisplay, sResult, aItems) {
// flush html
window.document.getElementById((sDisplay === "card" ? "card" : "row") + "s").innerHTML = sResult;
// update result count in search placeholder
window.document.getElementById("search").labels[0].innerText = `Search ${aItems.length} employees...`;
// replace broken images with a default image
registerFallbackImage(window.document);
// initialize tooltips
M.Tooltip.init(window.document.querySelectorAll(".tooltipped"));
}
// updates UI state based on Hash
function updateUI () {
if (window._globals.ignoreNextHashChange) {
return;
}
window._globals.sortFilterSearchRepos = window._globals.allRepos;
let oURL = new URL("https://dummy.com");
oURL.search = window.location.hash.substring(1);
// apply filters
oURL.searchParams.get("sort") && sort(oURL.searchParams.get("sort"));
oURL.searchParams.get("filter") && filter(oURL.searchParams.get("filter"));
oURL.searchParams.get("search") && search(oURL.searchParams.get("search"));
// open details dialog
oURL.searchParams.get("details") && showModal(parseInt(oURL.searchParams.get("details")) || oURL.searchParams.get("details"));
// set display mode
display(oURL.searchParams.get("display") || "card");
}
// updates hash based on UI state (note: does not work on IE11, needs URL Polyfill)
function updateHash (sKey, sValue) {
let oURL = new URL("https://dummy.com");
oURL.search = window.location.hash.substring(1);
sValue ? oURL.searchParams.set(sKey, sValue) : oURL.searchParams.delete(sKey);
window._globals.ignoreNextHashChange = true;
window.location.hash = oURL.searchParams.toString().replace("%21=", "!");
// ignore hash change events for the next second to avoid redundant content update
setTimeout(function () {
window._globals.ignoreNextHashChange = false;
}, 1000);
}
// replace broken images with a default image
function registerFallbackImage (oNode) {
let aImages = oNode.getElementsByTagName("img");
for (let i = 0; i < aImages.length; i++) {
aImages[i].addEventListener("error", function () {
Math.seedrandom(this.src);
this.src = "images/default" + (Math.floor(Math.random() * 3) + 1) + ".png";
Math.seedrandom();
});
}
}
// helper function to display each language in a different static color
function stringToColor (sString) {
Math.seedrandom(sString);
const rand = Math.random() * Math.pow(255,3);
Math.seedrandom();
let sColor = "#";
for (let i = 0; i < 3; sColor += ("00" + ((rand >> i++ * 8) & 0xFF).toString(16)).slice(-2));
return sColor;
}
// fetches an image for the detected programming language
function getRepoLanguage (sLanguage) {
let sLanguageShort = "N/A";
let sFontSize;
if (sLanguage) {
sLanguageShort = sLanguage;
if(sLanguageShort.length > 4) {
// smart length reduction
if (sLanguageShort.match(/[A-Z][a-z]+/g) && sLanguageShort.match(/[A-Z][a-z]+/g).length > 1) {
// abbreviate by capital letters and cut off at 4 letters
sLanguageShort = sLanguageShort.match(/[A-Z][a-z]+/g).reduce((x, y) => x.substr(0,1) + y.substr(0, 1));
} else if (sLanguageShort.match(/[auoie]+/g)) {
// remove vowels
while(sLanguageShort.match(/[auoie]+/g) && sLanguageShort.length > 4) {
sLanguageShort = sLanguageShort.replace(/[auoie]{1}/, "");
}
}
// shorten to 4 letters
sLanguageShort = sLanguageShort.substr(0, 4);
} else {
// short enough
sLanguageShort = sLanguage;
}
// scale down size with length of string
if (sLanguageShort.length > 2) {
sFontSize = 100 - (sLanguageShort.length - 2) * 10 + "%";
}
} else {
sLanguage = "not available";
}
// a pseudo-random color coding and the shortened text
return window._globals.templates.language({
color: (sLanguageShort !== "N/A" ? stringToColor(sLanguage) : ""),
fontSize: sFontSize,
language: sLanguage,
languageShort: sLanguageShort
});
}
// get a visual representation of the Activity Score of the repo.
// - if Activity Score exists: an image representing how active the repo is
// - if Activity Score doesn't exist: a placeholder
function getRepoActivity (oRepo) {
let sScoreIndicator = "<div class=\"tooltipped score\" data-position=\"top\" data-tooltip=\"\"></div>",
vScoreNumeric = "";
if (oRepo._InnerSourceMetadata && typeof oRepo._InnerSourceMetadata.score === "number") {
sScoreIndicator = getActivityLogo(oRepo._InnerSourceMetadata.score);
vScoreNumeric = oRepo._InnerSourceMetadata.score;
}
return [sScoreIndicator, vScoreNumeric];
}
// fetches the corresponding image for the activity score
function getActivityLogo (iScore) {
let sLogo = "images/activity/0.png",
sActivityLevel = "None";
if (iScore > 2500) {
sLogo = "images/activity/5.png";
sActivityLevel = "Extremely High";
} else if (iScore > 1000) {
sLogo = "images/activity/4.png";
sActivityLevel = "Very High";
} else if (iScore > 300) {
sLogo = "images/activity/3.png";
sActivityLevel = "High";
} else if (iScore > 150) {
sLogo = "images/activity/2.png";
sActivityLevel = "Moderate";
} else if (iScore > 50) {
sLogo = "images/activity/1.png";
sActivityLevel = "Low";
} else if (iScore > 5) {
sLogo = "images/activity/0.png";
sActivityLevel = "Very Low";
}
return window._globals.templates.score({
"logo": sLogo,
"level": sActivityLevel
});
}
// calculations a color for the participation value
function getParticipationColor (iValue) {
let iOpacity;
if (!iValue) {
return false;
}
if (iValue === 0) {
iOpacity = 0;
} else {
iOpacity = Math.log(iValue)/4 + 0.03; // 50 = 1, scale logarithmically below
}
iOpacity = Math.min(1, iOpacity);
return "rgba(50, 205, 50, " + iOpacity + ")";
}
// creates an HTMl-based heatmap for the current week and the previous 12 weeks from participation stats
function createParticipationChart (oRepo) {
let aParticipation = oRepo._InnerSourceMetadata && oRepo._InnerSourceMetadata.participation;
if (!aParticipation) {
return "N/A";
}
const aPrevious12Weeks = aParticipation.slice(aParticipation.length - 13, aParticipation.length - 1).reverse();
// this week
let iValue = aParticipation[aParticipation.length - 1];
let oContext = {
thisWeek: {
"commits": iValue,
"color": getParticipationColor(iValue)
},
"weeksPreviousLabel": undefined,
"weeksPrevious": [],
"weeksBeforeLabel": undefined,
"weeksBefore": []
};
// previous 12 weeks
const iCreatedWeeksAgo = Math.ceil((Date.now() - new Date(oRepo.created_at).getTime()) / 1000 / 86400 / 7) - 1;
let iCommitsWeeksBefore = 0;
aPrevious12Weeks.forEach((iValue, iIndex) => {
// don't print boxes for new repos
if (iIndex >= iCreatedWeeksAgo) {
return;
}
iCommitsWeeksBefore += iValue;
oContext.weeksPrevious.push({
"commits": iValue,
"color": getParticipationColor(iValue)
});
});
oContext.weeksPreviousLabel = Math.min(12, iCreatedWeeksAgo) + " weeks: " + iCommitsWeeksBefore;
// 9 months before in weeks
const aPrevious9months = aParticipation.slice(1, aParticipation.length - 13).reverse();
let iWeeksBefore = 0;
let iCommitsMonthBefore = 0;
aPrevious9months.forEach((iValue, iIndex) => {
// don't print boxes for new repos
if (iIndex >= iCreatedWeeksAgo - 13) {
return;
}
iCommitsMonthBefore += iValue;
iWeeksBefore++;
oContext.weeksBefore.push({
"commits": iValue,
"color": getParticipationColor(iValue)
});
});
oContext.weeksBeforeLabel = (Math.floor(iWeeksBefore / 4) <= 1 ? iWeeksBefore + " weeks before: " : Math.floor(iWeeksBefore / 4) + " months before: ") + iCommitsMonthBefore;
return window._globals.templates.participation(oContext);
}
// creates HTML for and displays a project details modal
function showModal (vRepoId, oEvent) {
// don't open modal when clicking on direct links
if (oEvent && oEvent.target.href) {
return;
}
const oRepo = window._globals.allRepos.filter(oRepo => oRepo.id === vRepoId).pop();
let sLogoURL = oRepo._InnerSourceMetadata && oRepo._InnerSourceMetadata.logo
? oRepo._InnerSourceMetadata.logo.startsWith("http") || oRepo._InnerSourceMetadata.logo.startsWith("./")
? oRepo._InnerSourceMetadata.logo
: "data/" + oRepo._InnerSourceMetadata.logo + (oRepo._InnerSourceMetadata.logo.split(".").pop() === "svg" ? "?sanitize=true" : "")
: oRepo.owner.avatar_url;
let sTitle = oRepo._InnerSourceMetadata && oRepo._InnerSourceMetadata.title
? oRepo._InnerSourceMetadata.title
: readableRepoName(oRepo.name);
let sDescription = oRepo._InnerSourceMetadata && oRepo._InnerSourceMetadata.motivation
? oRepo._InnerSourceMetadata.motivation
: oRepo.description !== null
? oRepo.description
: "";
let [sScoreIndicator, vScoreNumeric] = getRepoActivity(oRepo);
let aSkills = oRepo._InnerSourceMetadata && oRepo._InnerSourceMetadata.skills
? oRepo._InnerSourceMetadata.skills
: oRepo.language ?
[oRepo.language] :
[];
let aContributions = oRepo._InnerSourceMetadata && oRepo._InnerSourceMetadata.contributions && oRepo._InnerSourceMetadata.contributions.length
? oRepo._InnerSourceMetadata.contributions
: ["Any"];
let sContributeURL = oRepo._InnerSourceMetadata && oRepo._InnerSourceMetadata.docs
? oRepo._InnerSourceMetadata.docs
: oRepo._InnerSourceMetadata && oRepo._InnerSourceMetadata.guidelines
? `${oRepo.html_url}/blob/${oRepo.default_branch}/${oRepo._InnerSourceMetadata.guidelines}`
: oRepo.html_url;
let oContext = {
"id" : (typeof oRepo.id === "string" ? "'" + oRepo.id + "'" : oRepo.id),
"mediaURL": sLogoURL,
"title": sTitle,
"repoURL": oRepo.html_url,
"repoTitle": oRepo.owner.login + "/" + oRepo.name,
"description": sDescription,
"topics": oRepo._InnerSourceMetadata && oRepo._InnerSourceMetadata.topics,
"stars": oRepo.stargazers_count,
"Views": oRepo.open_issues_count,
"Shares": oRepo.forks_count,
"score": sScoreIndicator,
"scoreNumeric": vScoreNumeric,
"language": getRepoLanguage(oRepo.language),
"skills": aSkills,
"contributions": aContributions,
"documentationURL": oRepo._InnerSourceMetadata && oRepo._InnerSourceMetadata.docs,
"createdAt": moment(oRepo.created_at).format("MMMM Do YYYY"),
"lastUpdate": moment(oRepo.updated_at).fromNow(),
"contributeURL": sContributeURL
};
// fill & init modal
const oModalWrapper = window.document.getElementById("modal-details");
oModalWrapper.innerHTML = window._globals.templates.details(oContext);
// register close handler
M.Modal.init(oModalWrapper, {
onCloseEnd: () => {
updateHash("details", undefined);
}
});
// initialize tooltips
M.Tooltip.init(oModalWrapper.querySelectorAll(".tooltipped"));
// replace broken images with a default image
registerFallbackImage(oModalWrapper);
// open dialog
M.Modal.getInstance(oModalWrapper).open();
oModalWrapper.getElementsByClassName("participationChart")[0].innerHTML = createParticipationChart(oRepo);
updateHash("details", vRepoId);
}
// fills the HTML template for a project item
function generateItem (sDisplay, oRepo) {
let sLogoURL = oRepo._InnerSourceMetadata && oRepo._InnerSourceMetadata.logo
? oRepo._InnerSourceMetadata.logo.startsWith("http") || oRepo._InnerSourceMetadata.logo.startsWith("./")
? oRepo._InnerSourceMetadata.logo
: "data/" + oRepo._InnerSourceMetadata.logo + (oRepo._InnerSourceMetadata.logo.split(".").pop() === "svg" ? "?sanitize=true" : "")
: oRepo.owner.avatar_url;
let sTitle = oRepo._InnerSourceMetadata && oRepo._InnerSourceMetadata.title
? oRepo._InnerSourceMetadata.title
: readableRepoName(oRepo.name);
let sDescription = oRepo._InnerSourceMetadata && oRepo._InnerSourceMetadata.motivation
? oRepo._InnerSourceMetadata.motivation
: oRepo.description !== null
? oRepo.description
: "";
let sContributeURL = oRepo._InnerSourceMetadata && oRepo._InnerSourceMetadata.docs
? oRepo._InnerSourceMetadata.docs
: oRepo._InnerSourceMetadata && oRepo._InnerSourceMetadata.guidelines
? `${oRepo.html_url}/blob/${oRepo.default_branch}/${oRepo._InnerSourceMetadata.guidelines}`
: oRepo.html_url;
let oContext = {
"id" : (typeof oRepo.id === "string" ? "'" + oRepo.id + "'" : oRepo.id),
"mediaURL": sLogoURL,
"title": sTitle,
"repoURL": oRepo.html_url,
"repoTitle": oRepo.owner.login + "/" + oRepo.name,
"description": sDescription,
"stars": oRepo.stargazers_count,
"Views": oRepo.open_issues_count,
"Shares": oRepo.forks_count,
"score": getRepoActivity(oRepo)[0],
"language": getRepoLanguage(oRepo.language),
"contributeURL": sContributeURL
};
// execute pre-compiled template function
return window._globals.templates[sDisplay](oContext);
}
// load repos.json file and display the list of projects from it
window.document.addEventListener("DOMContentLoaded", function() {
// load data
let oXHR = new XMLHttpRequest();
oXHR.open("GET", "repos.json");
oXHR.onload = () => {
if (oXHR.status === 200) {
window._globals.allRepos = JSON.parse(oXHR.responseText);
fillLanguageFilter();
updateUI();
// show number of projects in header
window.document.getElementById("count").innerText = window._globals.allRepos.length;
} else {
console.log("Request failed. Returned status of " + oXHR.status);
}
};
oXHR.send();
// init templates
window._globals.templates.card = Handlebars.compile(window.document.getElementById("card-template").innerHTML);
window._globals.templates.list = Handlebars.compile(window.document.getElementById("list-template").innerHTML);
window._globals.templates.score = Handlebars.compile(window.document.getElementById("score-template").innerHTML);
window._globals.templates.language = Handlebars.compile(window.document.getElementById("language-template").innerHTML);
window._globals.templates.details = Handlebars.compile(window.document.getElementById("details-template").innerHTML);
window._globals.templates.participation = Handlebars.compile(window.document.getElementById("participation-template").innerHTML);
// init filters
window.document.getElementById("sort").addEventListener("change", function () {
sort(this.value);
});
window.document.getElementById("filter").addEventListener("change", function () {
filter(this.value);
});
window.document.getElementById("search").addEventListener("keyup", function () {
search(this.value);
});
window.document.getElementById("display").addEventListener("change", function () {
display(this.checked ? "card" : "list");
});
});
// fill language filter list based on detected languages
function fillLanguageFilter () {
let aAllLanguages = [];
// create a unique list of languages
window._globals.allRepos.map(repo => {
if (repo.language && !aAllLanguages.includes(repo.language)) {
aAllLanguages.push(repo.language);
}
});
// sort alphabetically and reverse
aAllLanguages = aAllLanguages.sort().reverse();
// insert new items backwards between "All" and "Other"
let oFilter = window.document.getElementById("filter");
aAllLanguages.forEach(language => {
let oOption = window.document.createElement("option");
oOption.text = oOption.value = language;
oFilter.add(oOption, 1);
});
// initialize all filters
M.FormSelect.init(document.querySelectorAll("select"));
addLanguageIconsToFilter();
}
// sneak in language icons
function addLanguageIconsToFilter() {
let aItems = window.document.getElementById("filter").parentNode.getElementsByTagName("li");
for (let i = 0; i < aItems.length; i++) {
if (aItems[i].innerText !== "All" && aItems[i].innerText !== "Other") {
aItems[i].innerHTML = getRepoLanguage(aItems[i].innerText) + aItems[i].innerHTML;
}
}
}
// sort the cards by chosen parameter (additive, combines filter or search)
function sort (sParam) {
let aResult;
if (["name", "full_name"].includes(sParam)) {
// sort alphabetically
aResult = window._globals.sortFilterSearchRepos.sort((a, b) => (b[sParam] < a[sParam] ? 1 : -1));
} else if (sParam === "score" && window._globals.sortFilterSearchRepos[0]["_InnerSourceMetadata"]) {
// sort by InnerSource score
aResult = window._globals.sortFilterSearchRepos.sort(
(a, b) =>
b["_InnerSourceMetadata"]["score"] - a["_InnerSourceMetadata"]["score"]
);
} else {
// sort numerically
aResult = window._globals.sortFilterSearchRepos.sort((a, b) => b[sParam] - a[sParam]);
}
createContent(aResult);
// update hash
updateHash("sort", sParam);
// update select
let oSelect = window.document.getElementById("sort");
for (let i = 0; i < oSelect.options.length; i++) {
if (oSelect.options[i].value === sParam) {
oSelect.selectedIndex = i;
}
}
M.FormSelect.init(oSelect);
}
// filter the cards by chosen parameter (resets search)
function filter (sParam) {
let aResult;
if (sParam !== "All") {
if (sParam === "N/A") { // other
aResult = window._globals.allRepos.filter((repo) => repo.language === null || repo.language === undefined);
} else {
aResult = window._globals.allRepos.filter((repo) => repo.language === sParam);
}
} else {
aResult = window._globals.allRepos;
}
createContent(aResult);
window._globals.sortFilterSearchRepos = aResult;
// update hash
updateHash("search", undefined);
updateHash("filter", sParam);
// update select
let oSelect = window.document.getElementById("filter");
for (let i = 0; i < oSelect.options.length; i++) {
if (oSelect.options[i].value === sParam) {
oSelect.selectedIndex = i;
}
}
M.FormSelect.init(oSelect);
addLanguageIconsToFilter();
// reset search
window.document.getElementById("search").value = "";
}
// search the cards by chosen parameter (resets filter)
function search(sParam) {
let sLowerCaseParam = sParam.toLowerCase();
let oResult = window._globals.allRepos.filter(
(repo) =>
// name
repo.full_name.toLowerCase().includes(sLowerCaseParam) ||
// description
(repo.description && repo.description.toLowerCase().includes(sLowerCaseParam)) ||
// InnerSource metadata
repo._InnerSourceMetadata && (
// topics
repo._InnerSourceMetadata.topics &&
repo._InnerSourceMetadata.topics.join(" ").toLowerCase().includes(sLowerCaseParam) ||
// custom title
repo._InnerSourceMetadata.title &&
repo._InnerSourceMetadata.title.toLowerCase().includes(sLowerCaseParam) ||
// motivation
repo._InnerSourceMetadata.motivation &&
repo._InnerSourceMetadata.motivation.toLowerCase().includes(sLowerCaseParam) ||
// skills
repo._InnerSourceMetadata.skills &&
repo._InnerSourceMetadata.skills.join(" ").toLowerCase().includes(sLowerCaseParam) ||
// contributions
repo._InnerSourceMetadata.contributions &&
repo._InnerSourceMetadata.contributions.join(" ").toLowerCase().includes(sLowerCaseParam)
)
);
window._globals.sortFilterSearchRepos = oResult;
createContent(oResult);
// update hash
updateHash("search", sParam);
updateHash("filter", undefined);
// set search
const oSearch = window.document.getElementById("search");
oSearch.value = sParam;
M.updateTextFields();
// reset filter
const oSelect = window.document.getElementById("filter");
oSelect.selectedIndex = 0;
M.FormSelect.init(oSelect);
addLanguageIconsToFilter();
}
// toggles the display between card and table view
function display (sParam) {
// update UI
window.document.getElementById("display").checked = (sParam !== "list");
// toggle active icon
window.document.getElementsByClassName("switch")[0].getElementsByTagName("i")[sParam !== "list" ? 1 : 0].classList.add("active");
window.document.getElementsByClassName("switch")[0].getElementsByTagName("i")[sParam !== "list" ? 0 : 1].classList.remove("active");
// only create content when mode has changed
if (!document.getElementById(sParam !== "list" ? "cards" : "rows").innerHTML) {
// store context
updateHash("display", sParam);
// create content
createContent(window._globals.sortFilterSearchRepos);
}
// toggle content
window.document.getElementById(sParam !== "list" ? "rows" : "cards").innerHTML = "";
window.document.getElementById(sParam !== "list" ? "cards" : "list").style.display = "block";
window.document.getElementById(sParam !== "list" ? "list" : "cards").style.setProperty("display", "none", "important");
}