add more sorting for results

This commit is contained in:
2021-08-16 10:35:36 -07:00
parent e75c83d9b8
commit d40b8c218a
7 changed files with 188 additions and 24 deletions

View File

@@ -1,14 +1,15 @@
// called from buildSelectionMenu.js
function buildSortByDiv(sortedBy, sortByRowDisplay) {
function buildSortByDiv(sortBy, sortByRowDisplay) {
let menuDiv = document.getElementById("selection-menu");
menuDiv.innerHTML = "";
menuDiv.style.maxWidth = "100%";
let sortByRow = document.createElement("div");
sortByRow.id = "sortByRow";
sortByRow.style.width = "500px";
// sortByRow.style.width = "500px";
sortByRow.style.maxWidth = "100%";
sortByRow.style.display = sortByRowDisplay;
sortByRow.style.flexWrap = "wrap";
sortByRow.style.justifyContent = "space-around";
sortByRow.style.margin = "1rem auto 1rem auto";
@@ -18,28 +19,88 @@ function buildSortByDiv(sortedBy, sortByRowDisplay) {
sortByPrompt.innerHTML = "Sort By:";
sortByRow.appendChild(sortByPrompt);
// from buildButton.js
let sortByStarsButton = buildRadioButton(
(inputID = "sortByStars"),
(inputName = "sortBy"),
(inputValue = "stars"),
(sortedBy = sortedBy),
(sortedBy = sortBy[0]),
(sortedBySelector = "stars"),
(labelText = "Stars")
);
// from buildButton.js
let sortByLastCommitButton = buildRadioButton(
(inputID = "sortByDate"),
(inputName = "sortBy"),
(inputValue = "date"),
(sortedBy = sortedBy),
(sortedBy = sortBy[0]),
(sortedBySelector = "date"),
(labelText = "Latest Commit Date")
);
sortByRow.appendChild(sortByStarsButton);
sortByRow.appendChild(sortByLastCommitButton);
// from buildButton.js
let sortByMinVerButton = buildRadioButton(
(inputID = "sortByMinVer"),
(inputName = "sortBy"),
(inputValue = "minVer"),
(sortedBy = sortBy[0]),
(sortedBySelector = "minVer"),
(labelText = "Min Hugo Version")
);
// from buildButton.js
let sortByLicenseButton = buildRadioButton(
(inputID = "sortByLicense"),
(inputName = "sortBy"),
(inputValue = "license"),
(sortedBy = sortBy[0]),
(sortedBySelector = "license"),
(labelText = "License")
);
// from buildButton.js
let sortByNameButton = buildRadioButton(
(inputID = "sortByName"),
(inputName = "sortBy"),
(inputValue = "name"),
(sortedBy = sortBy[0]),
(sortedBySelector = "name"),
(labelText = "Name")
);
sortBy.forEach((x) => {
if (x === "date") {
sortByRow.appendChild(sortByLastCommitButton);
} else if (x === "name") {
sortByRow.appendChild(sortByNameButton);
} else if (x === "minVer") {
sortByRow.appendChild(sortByMinVerButton);
} else if (x === "license") {
sortByRow.appendChild(sortByLicenseButton);
} else if (x === "stars") {
sortByRow.appendChild(sortByStarsButton);
}
});
menuDiv.appendChild(sortByRow);
let sortByMinVerInput = document.getElementById("sortByMinVer");
sortByMinVerButton.onclick = function () {
if (!sortByMinVerInput.checked) {
sortByMinVerInput.checked = true;
buildResults();
}
};
let sortByLicenseInput = document.getElementById("sortByLicense");
sortByLicenseButton.onclick = function () {
if (!sortByLicenseInput.checked) {
sortByLicenseInput.checked = true;
buildResults();
}
};
let sortByStarsInput = document.getElementById("sortByStars");
sortByStarsButton.onclick = function () {
if (!sortByStarsInput.checked) {
@@ -54,4 +115,12 @@ function buildSortByDiv(sortedBy, sortByRowDisplay) {
buildResults();
}
};
let sortByNameInput = document.getElementById("sortByName");
sortByNameButton.onclick = function () {
if (!sortByNameInput.checked) {
sortByNameInput.checked = true;
buildResults();
}
};
}