mirror of
https://github.com/TrentSPalmer/hugo_themes_report.git
synced 2024-12-04 16:41:31 -08:00
lint buildPage.js
This commit is contained in:
parent
36880bd056
commit
5c3d0a661d
@ -1,32 +1,34 @@
|
||||
function getSortBy() {
|
||||
let sortByLastCommitInput = document.getElementById('sortByDate');
|
||||
let sortByLastCommitInput = document.getElementById("sortByDate");
|
||||
if (sortByLastCommitInput === null) {
|
||||
return 'date';
|
||||
return "date";
|
||||
} else {
|
||||
return sortByLastCommitInput.checked ? 'date' : 'stars';
|
||||
return sortByLastCommitInput.checked ? "date" : "stars";
|
||||
}
|
||||
}
|
||||
|
||||
function getTagSortBy() {
|
||||
let tagSortByNumThemes = document.getElementById('tagSortByNumThemes');
|
||||
let tagSortByNumThemes = document.getElementById("tagSortByNumThemes");
|
||||
if (tagSortByNumThemes === null) {
|
||||
return 'numThemes';
|
||||
return "numThemes";
|
||||
} else {
|
||||
return tagSortByNumThemes.checked ? 'numThemes' : 'name';
|
||||
return tagSortByNumThemes.checked ? "numThemes" : "name";
|
||||
}
|
||||
}
|
||||
|
||||
function getFeatureSortBy() {
|
||||
let featureSortByNumThemes = document.getElementById('featureSortByNumThemes');
|
||||
let featureSortByNumThemes = document.getElementById(
|
||||
"featureSortByNumThemes"
|
||||
);
|
||||
if (featureSortByNumThemes === null) {
|
||||
return 'numThemes';
|
||||
return "numThemes";
|
||||
} else {
|
||||
return featureSortByNumThemes.checked ? 'numThemes' : 'name';
|
||||
return featureSortByNumThemes.checked ? "numThemes" : "name";
|
||||
}
|
||||
}
|
||||
|
||||
function getSortedThemes(themeList, sortedBy) {
|
||||
if (sortedBy === 'date') {
|
||||
if (sortedBy === "date") {
|
||||
return themeList.sort((a, b) => b.date_in_seconds - a.date_in_seconds);
|
||||
} else {
|
||||
return themeList.sort((a, b) => b.num_stars - a.num_stars);
|
||||
@ -34,7 +36,7 @@ function getSortedThemes(themeList, sortedBy) {
|
||||
}
|
||||
|
||||
function getSelectedTags() {
|
||||
let tagSelectionInputs = document.getElementsByClassName('tagSelectionInput');
|
||||
let tagSelectionInputs = document.getElementsByClassName("tagSelectionInput");
|
||||
if (tagSelectionInputs.length > 0) {
|
||||
return [...tagSelectionInputs].filter((x) => x.checked).map((y) => y.value);
|
||||
} else {
|
||||
@ -43,31 +45,35 @@ function getSelectedTags() {
|
||||
}
|
||||
|
||||
function getSelectedFeatures() {
|
||||
let featureSelectionInputs = document.getElementsByClassName('featureSelectionInput');
|
||||
let featureSelectionInputs = document.getElementsByClassName(
|
||||
"featureSelectionInput"
|
||||
);
|
||||
if (featureSelectionInputs.length > 0) {
|
||||
return [...featureSelectionInputs].filter((x) => x.checked).map((y) => y.value);
|
||||
return [...featureSelectionInputs]
|
||||
.filter((x) => x.checked)
|
||||
.map((y) => y.value);
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
function getFilteredThemes(selectedTags, selectedFeatures) {
|
||||
if ((selectedTags.length === 0) && selectedFeatures.length === 0) {
|
||||
if (selectedTags.length === 0 && selectedFeatures.length === 0) {
|
||||
return themes;
|
||||
} else {
|
||||
return themes
|
||||
.filter((x) => selectedTags.every((y) => x.tags.includes(y)) )
|
||||
.filter((z) => selectedFeatures.every((w) => z.features.includes(w)) );
|
||||
.filter((x) => selectedTags.every((y) => x.tags.includes(y)))
|
||||
.filter((z) => selectedFeatures.every((w) => z.features.includes(w)));
|
||||
}
|
||||
}
|
||||
|
||||
function buildResults() {
|
||||
let resultsDiv = document.getElementById('results');
|
||||
resultsDiv.innerHTML = '';
|
||||
let resultsDiv = document.getElementById("results");
|
||||
resultsDiv.innerHTML = "";
|
||||
let resultsTable = document.createElement("table");
|
||||
resultsTable.id = 'resultsTable';
|
||||
resultsTable.style.border = '1px solid black';
|
||||
resultsTable.style.fontSize = '.9rem';
|
||||
resultsTable.id = "resultsTable";
|
||||
resultsTable.style.border = "1px solid black";
|
||||
resultsTable.style.fontSize = ".9rem";
|
||||
|
||||
let resultsTableHeadRow = document.createElement("tr");
|
||||
resultsDiv.appendChild(resultsTable);
|
||||
@ -94,9 +100,9 @@ function buildResults() {
|
||||
let sortedBy = getSortBy();
|
||||
let filtered_themes = getFilteredThemes(selectedTags, selectedFeatures);
|
||||
let sorted_themes = getSortedThemes(filtered_themes, sortedBy);
|
||||
sorted_themes.forEach(theme => addThemeTableRow(theme));
|
||||
sorted_themes.forEach((theme) => addThemeTableRow(theme));
|
||||
|
||||
buildSelectionMenu(sorted_themes, sortedBy, selectedTags, selectedFeatures);
|
||||
};
|
||||
}
|
||||
|
||||
buildResults();
|
||||
|
Loading…
Reference in New Issue
Block a user