hugo_themes_report/templates/js/buildSortByDiv.js

127 lines
3.1 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(
2021-08-17 17:23:51 -07:00
"sortByStars",
"sortBy",
"stars",
sortBy[0],
"stars",
"Stars"
2021-08-12 17:23:42 -07:00
);
2021-08-16 10:35:36 -07:00
// from buildButton.js
2021-08-12 17:23:42 -07:00
let sortByLastCommitButton = buildRadioButton(
2021-08-17 17:23:51 -07:00
"sortByDate",
"sortBy",
"date",
sortBy[0],
"date",
"Latest Commit Date"
2021-08-12 17:23:42 -07:00
);
2021-08-16 10:35:36 -07:00
// from buildButton.js
let sortByMinVerButton = buildRadioButton(
2021-08-17 17:23:51 -07:00
"sortByMinVer",
"sortBy",
"minVer",
sortBy[0],
"minVer",
"Min Hugo Version"
2021-08-16 10:35:36 -07:00
);
// from buildButton.js
let sortByLicenseButton = buildRadioButton(
2021-08-17 17:23:51 -07:00
"sortByLicense",
"sortBy",
"license",
sortBy[0],
"license",
"License"
2021-08-16 10:35:36 -07:00
);
// from buildButton.js
let sortByNameButton = buildRadioButton(
2021-08-17 17:23:51 -07:00
"sortByName",
"sortBy",
"name",
sortBy[0],
"name",
"Name"
2021-08-16 10:35:36 -07:00
);
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
}