hugo_themes_report/templates/js/buildSortByDiv.js

127 lines
3.6 KiB
JavaScript
Raw Normal View History

2021-08-14 17:42:01 -07:00
// called from buildSelectionMenu.js
2021-08-16 10:35:36 -07:00
function buildSortByDiv(sortBy, 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";
2021-08-16 10:35:36 -07:00
// sortByRow.style.width = "500px";
2021-08-12 17:23:42 -07:00
sortByRow.style.maxWidth = "100%";
2021-08-14 07:21:26 -07:00
sortByRow.style.display = sortByRowDisplay;
2021-08-16 10:35:36 -07:00
sortByRow.style.flexWrap = "wrap";
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-16 10:35:36 -07:00
// from buildButton.js
2021-08-12 17:23:42 -07:00
let sortByStarsButton = buildRadioButton(
(inputID = "sortByStars"),
(inputName = "sortBy"),
(inputValue = "stars"),
2021-08-16 10:35:36 -07:00
(sortedBy = sortBy[0]),
2021-08-12 17:23:42 -07:00
(sortedBySelector = "stars"),
(labelText = "Stars")
);
2021-08-16 10:35:36 -07:00
// from buildButton.js
2021-08-12 17:23:42 -07:00
let sortByLastCommitButton = buildRadioButton(
(inputID = "sortByDate"),
(inputName = "sortBy"),
(inputValue = "date"),
2021-08-16 10:35:36 -07:00
(sortedBy = sortBy[0]),
2021-08-12 17:23:42 -07:00
(sortedBySelector = "date"),
(labelText = "Latest Commit Date")
);
2021-08-16 10:35:36 -07:00
// 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);
}
});
2021-08-11 11:58:10 -07:00
menuDiv.appendChild(sortByRow);
2021-08-12 17:23:42 -07:00
2021-08-16 10:35:36 -07:00
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();
}
};
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-16 10:35:36 -07:00
let sortByNameInput = document.getElementById("sortByName");
sortByNameButton.onclick = function () {
if (!sortByNameInput.checked) {
sortByNameInput.checked = true;
buildResults();
}
};
2021-08-11 11:58:10 -07:00
}