2021-08-11 11:58:10 -07:00
|
|
|
function getSortBy() {
|
2021-08-16 10:35:36 -07:00
|
|
|
let a = document.getElementsByClassName("sortBy");
|
|
|
|
if (a.length > 0) {
|
|
|
|
return [
|
|
|
|
...[...a].filter((y) => y.checked).map((x) => x.value),
|
|
|
|
...[...a].filter((y) => !y.checked).map((x) => x.value),
|
|
|
|
];
|
2021-08-11 11:58:10 -07:00
|
|
|
} else {
|
2021-08-16 10:35:36 -07:00
|
|
|
return ["date", "stars", "name", "minVer", "license"];
|
2021-08-11 11:58:10 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-17 17:23:51 -07:00
|
|
|
function getSelected(filterCategory) {
|
|
|
|
let selectionInputs = document.getElementsByClassName(
|
|
|
|
`${filterCategory}SelectionInput`
|
|
|
|
);
|
|
|
|
if (selectionInputs.length > 0) {
|
|
|
|
return [...selectionInputs].filter((x) => x.checked).map((y) => y.value);
|
2021-08-11 11:58:10 -07:00
|
|
|
} else {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-14 17:42:01 -07:00
|
|
|
function getSelectedColumns() {
|
|
|
|
let columnSelectionInputs = document.getElementsByClassName(
|
|
|
|
"columnSelectionInput"
|
|
|
|
);
|
|
|
|
if (columnSelectionInputs.length > 0) {
|
|
|
|
let checked = [...columnSelectionInputs].filter((x) => x.checked);
|
|
|
|
if (checked.length > 0) {
|
|
|
|
return checked.map((y) => y.id.slice(0, -23));
|
|
|
|
} else {
|
|
|
|
return ["cname", "date", "num_stars", "commit"];
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return ["cname", "date", "num_stars", "commit"];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-18 15:09:33 -07:00
|
|
|
function getTagAndFeatureFilteredThemes(
|
|
|
|
minVerFilteredThemes,
|
|
|
|
selectedTags,
|
|
|
|
selectedFeatures
|
|
|
|
) {
|
2021-08-11 20:33:28 -07:00
|
|
|
if (selectedTags.length === 0 && selectedFeatures.length === 0) {
|
2021-08-18 15:09:33 -07:00
|
|
|
return minVerFilteredThemes;
|
2021-08-11 11:58:10 -07:00
|
|
|
} else {
|
2021-08-18 15:09:33 -07:00
|
|
|
return minVerFilteredThemes
|
2021-08-11 20:33:28 -07:00
|
|
|
.filter((x) => selectedTags.every((y) => x.tags.includes(y)))
|
|
|
|
.filter((z) => selectedFeatures.every((w) => z.features.includes(w)));
|
2021-08-11 11:58:10 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-18 15:09:33 -07:00
|
|
|
function getMinVerFilteredThemes(selectedMinVer) {
|
|
|
|
if (selectedMinVer.length === 0 || selectedMinVer[0] === "none") {
|
|
|
|
return themes;
|
|
|
|
} else {
|
|
|
|
// return licenseFilteredThemes;
|
|
|
|
return themes
|
|
|
|
.filter((x) => x.min_ver !== "")
|
|
|
|
.filter((x) => semVerCompare(x.min_ver, selectedMinVer[0]) > -1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function getLicenseFilteredThemes(
|
|
|
|
tagAndFeatureFilteredThemes,
|
|
|
|
selectedLicenses
|
|
|
|
) {
|
2021-08-17 17:23:51 -07:00
|
|
|
if (selectedLicenses.length === 0) {
|
|
|
|
return tagAndFeatureFilteredThemes;
|
|
|
|
} else {
|
|
|
|
return tagAndFeatureFilteredThemes.filter((x) =>
|
|
|
|
selectedLicenses.includes(x.license)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-14 07:21:26 -07:00
|
|
|
function getDState(x) {
|
|
|
|
let e = document.getElementById(x);
|
|
|
|
return e !== null ? e.style.display : "none";
|
|
|
|
}
|
|
|
|
|
|
|
|
function getDiplayState() {
|
|
|
|
let dState = {};
|
|
|
|
[
|
|
|
|
"sortByRow",
|
2021-08-14 17:42:01 -07:00
|
|
|
"columnSelectionHeadingRow",
|
|
|
|
"columnSelectionRow",
|
2021-08-17 17:23:51 -07:00
|
|
|
"licenseSelectionHeadingRow",
|
|
|
|
"licenseSelectionRow",
|
2021-08-18 15:09:33 -07:00
|
|
|
"minVerSelectionHeadingRow",
|
|
|
|
"minVerSelectionRow",
|
2021-08-14 07:21:26 -07:00
|
|
|
"tagSelectionHeadingRow",
|
|
|
|
"tagSelectionRow",
|
|
|
|
"featureSelectionHeadingRow",
|
|
|
|
"featureSelectionRow",
|
2021-08-18 15:09:33 -07:00
|
|
|
"minVerSelectionHeadingRow",
|
|
|
|
"minVerSelectionRow",
|
2021-08-14 07:21:26 -07:00
|
|
|
].forEach((x) => (dState[x] = getDState(x)));
|
|
|
|
return dState;
|
|
|
|
}
|
|
|
|
|
2021-08-14 17:42:01 -07:00
|
|
|
let tableColumns = [
|
2021-08-19 12:28:22 -07:00
|
|
|
{ headingName: "cname", headingText: "themes" },
|
2021-08-14 17:42:01 -07:00
|
|
|
{ headingName: "date", headingText: "date" },
|
|
|
|
{ headingName: "num_stars", headingText: "stars" },
|
|
|
|
{ headingName: "commit", headingText: "commit" },
|
|
|
|
{ headingName: "min_ver", headingText: "minVer" },
|
|
|
|
{ headingName: "license", headingText: "license" },
|
|
|
|
{ headingName: "desc", headingText: "desc" },
|
|
|
|
{ headingName: "tags", headingText: "tags" },
|
|
|
|
{ headingName: "features", headingText: "features" },
|
|
|
|
];
|
|
|
|
|
2021-08-11 11:58:10 -07:00
|
|
|
function buildResults() {
|
2021-08-11 20:33:28 -07:00
|
|
|
let resultsDiv = document.getElementById("results");
|
|
|
|
resultsDiv.innerHTML = "";
|
2021-08-11 11:58:10 -07:00
|
|
|
let resultsTable = document.createElement("table");
|
2021-08-11 20:33:28 -07:00
|
|
|
resultsTable.id = "resultsTable";
|
|
|
|
resultsTable.style.border = "1px solid black";
|
|
|
|
resultsTable.style.fontSize = ".9rem";
|
2021-08-11 11:58:10 -07:00
|
|
|
|
|
|
|
let resultsTableHeadRow = document.createElement("tr");
|
|
|
|
resultsDiv.appendChild(resultsTable);
|
|
|
|
resultsTable.appendChild(resultsTableHeadRow);
|
2021-08-14 17:42:01 -07:00
|
|
|
let selectedColumns = getSelectedColumns();
|
2021-08-11 11:58:10 -07:00
|
|
|
|
2021-08-22 15:50:58 -07:00
|
|
|
let selectedTags = getSelected("tag").map(x => x.slice(0,-4));
|
|
|
|
let selectedFeatures = getSelected("feature").map(x => x.slice(0,-8));
|
|
|
|
let selectedLicenses = getSelected("license").map(x => x.slice(0,-8));
|
2021-08-18 15:09:33 -07:00
|
|
|
let selectedMinVer = getSelected("minVerRadioButton");
|
2021-08-11 11:58:10 -07:00
|
|
|
let sortedBy = getSortBy();
|
2021-08-18 15:09:33 -07:00
|
|
|
let minVerFilteredThemes = getMinVerFilteredThemes(selectedMinVer);
|
2021-08-17 17:23:51 -07:00
|
|
|
let tagAndFeatureFilteredThemes = getTagAndFeatureFilteredThemes(
|
2021-08-18 15:09:33 -07:00
|
|
|
minVerFilteredThemes,
|
2021-08-17 17:23:51 -07:00
|
|
|
selectedTags,
|
|
|
|
selectedFeatures
|
|
|
|
);
|
2021-08-18 15:09:33 -07:00
|
|
|
let filteredThemes = getLicenseFilteredThemes(
|
2021-08-17 17:23:51 -07:00
|
|
|
tagAndFeatureFilteredThemes,
|
|
|
|
selectedLicenses
|
|
|
|
);
|
2021-08-18 15:09:33 -07:00
|
|
|
sortThemes(filteredThemes, sortedBy);
|
2021-08-19 11:53:24 -07:00
|
|
|
// from buildThemeTableRow.js
|
|
|
|
filteredThemes.forEach((theme) =>
|
2021-08-19 12:01:44 -07:00
|
|
|
addThemeTableRow(theme, selectedColumns, selectedTags, selectedFeatures)
|
2021-08-19 11:53:24 -07:00
|
|
|
);
|
2021-08-11 11:58:10 -07:00
|
|
|
|
2021-08-19 12:28:22 -07:00
|
|
|
tableColumns
|
|
|
|
.filter((y) => selectedColumns.includes(y.headingName))
|
|
|
|
.forEach((x) => {
|
|
|
|
let xTH = document.createElement("th");
|
|
|
|
if (x.headingText === "themes") {
|
|
|
|
xTH.innerHTML = `${filteredThemes.length}/${themes.length} ${x.headingText}`;
|
|
|
|
} else {
|
|
|
|
xTH.innerHTML = x.headingText;
|
|
|
|
}
|
|
|
|
resultsTableHeadRow.appendChild(xTH);
|
|
|
|
});
|
|
|
|
|
2021-08-14 17:42:01 -07:00
|
|
|
// from buildSelectionMenu.js
|
2021-08-14 07:21:26 -07:00
|
|
|
buildSelectionMenu(
|
2021-08-17 17:23:51 -07:00
|
|
|
tagAndFeatureFilteredThemes,
|
2021-08-18 15:09:33 -07:00
|
|
|
filteredThemes,
|
2021-08-17 17:23:51 -07:00
|
|
|
sortedBy,
|
|
|
|
selectedTags,
|
|
|
|
selectedFeatures,
|
|
|
|
selectedLicenses,
|
|
|
|
selectedColumns,
|
2021-08-18 15:09:33 -07:00
|
|
|
selectedMinVer,
|
2021-08-17 17:23:51 -07:00
|
|
|
getDiplayState()
|
2021-08-14 07:21:26 -07:00
|
|
|
);
|
2021-08-19 10:48:40 -07:00
|
|
|
|
|
|
|
buildDescription(
|
|
|
|
selectedColumns,
|
|
|
|
sortedBy,
|
|
|
|
selectedMinVer,
|
|
|
|
selectedLicenses,
|
|
|
|
selectedTags,
|
|
|
|
selectedFeatures
|
|
|
|
);
|
2021-08-11 20:33:28 -07:00
|
|
|
}
|
2021-08-11 11:58:10 -07:00
|
|
|
|
|
|
|
buildResults();
|