hugo_themes_report/templates/js/buildSortByDiv.js

57 lines
1.7 KiB
JavaScript
Raw Normal View History

2021-08-11 11:58:10 -07:00
function buildSortByDiv(sortedBy) {
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%";
sortByRow.style.display = "flex";
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
}