2021-08-14 17:42:01 -07:00
|
|
|
// called from buildSelectionMenu.js
|
2021-08-14 07:21:26 -07:00
|
|
|
function buildSortByDiv(sortedBy, sortByRowDisplay) {
|
2021-08-12 17:23:42 -07:00
|
|
|
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.maxWidth = "100%";
|
2021-08-14 07:21:26 -07:00
|
|
|
sortByRow.style.display = sortByRowDisplay;
|
2021-08-12 17:23:42 -07:00
|
|
|
sortByRow.style.justifyContent = "space-around";
|
|
|
|
sortByRow.style.margin = "1rem auto 1rem auto";
|
|
|
|
|
|
|
|
let sortByPrompt = document.createElement("div");
|
|
|
|
sortByPrompt.style.display = "flex";
|
|
|
|
sortByPrompt.style.alignItems = "center";
|
2021-08-11 11:58:10 -07:00
|
|
|
sortByPrompt.innerHTML = "Sort By:";
|
|
|
|
sortByRow.appendChild(sortByPrompt);
|
|
|
|
|
2021-08-12 17:23:42 -07:00
|
|
|
let sortByStarsButton = buildRadioButton(
|
|
|
|
(inputID = "sortByStars"),
|
|
|
|
(inputName = "sortBy"),
|
|
|
|
(inputValue = "stars"),
|
|
|
|
(sortedBy = sortedBy),
|
|
|
|
(sortedBySelector = "stars"),
|
|
|
|
(labelText = "Stars")
|
|
|
|
);
|
|
|
|
|
|
|
|
let sortByLastCommitButton = buildRadioButton(
|
|
|
|
(inputID = "sortByDate"),
|
|
|
|
(inputName = "sortBy"),
|
|
|
|
(inputValue = "date"),
|
|
|
|
(sortedBy = sortedBy),
|
|
|
|
(sortedBySelector = "date"),
|
|
|
|
(labelText = "Latest Commit Date")
|
|
|
|
);
|
|
|
|
|
|
|
|
sortByRow.appendChild(sortByStarsButton);
|
|
|
|
sortByRow.appendChild(sortByLastCommitButton);
|
2021-08-11 11:58:10 -07:00
|
|
|
menuDiv.appendChild(sortByRow);
|
2021-08-12 17:23:42 -07:00
|
|
|
|
|
|
|
let sortByStarsInput = document.getElementById("sortByStars");
|
|
|
|
sortByStarsButton.onclick = function () {
|
|
|
|
if (!sortByStarsInput.checked) {
|
|
|
|
sortByStarsInput.checked = true;
|
|
|
|
buildResults();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
let sortByLastCommitInput = document.getElementById("sortByDate");
|
|
|
|
sortByLastCommitButton.onclick = function () {
|
|
|
|
if (!sortByLastCommitInput.checked) {
|
|
|
|
sortByLastCommitInput.checked = true;
|
|
|
|
buildResults();
|
|
|
|
}
|
|
|
|
};
|
2021-08-11 11:58:10 -07:00
|
|
|
}
|