added sorting by date
refined main.js/vote()
This commit is contained in:
parent
7e3f191910
commit
e9e825eb42
@ -103,7 +103,7 @@ function search(searchString) {
|
||||
|
||||
function sort(sortString) {
|
||||
let query = sortString.toLowerCase().split(" ");
|
||||
if (query[1] === "a-z" || query[1] === "↑") {
|
||||
if (query[1] === "a-z" || query[1] === "↑" || query[1] === "oldest-newest") {
|
||||
query[1] = "asc";
|
||||
} else {
|
||||
query[1] = "desc";
|
||||
@ -121,16 +121,14 @@ export function vote(entryID, up) {
|
||||
baseURL,
|
||||
);
|
||||
console.log(fetchURL); // TODO: remove
|
||||
fetch(fetchURL)
|
||||
fetch(fetchURL, {
|
||||
method: "post"
|
||||
})
|
||||
.then(resp => resp.json())
|
||||
.then((data) => {
|
||||
console.log(data.content); // TODO: remove
|
||||
let dataset = document.querySelector('[data-id= ' + CSS.escape(entryID) + ']')
|
||||
if (Number.isInteger(data.content)) { // TODO: remove and do parsing instead
|
||||
dataset.querySelector("span").innerText = data.content; // TODO: remove
|
||||
} else { // TODO: remove
|
||||
dataset.querySelector("span").innerText = -1;
|
||||
} // TODO: remove
|
||||
dataset.querySelector("span").innerText = -1; // TODO: replace by parsed vote
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,8 @@
|
||||
|
||||
<section id="tool-bar">
|
||||
<select id="sort-btn" class="btn flat" title="Sort entries">Sort by
|
||||
<option>Date newest-oldest</option>
|
||||
<option>Date oldest-newest</option>
|
||||
<option>Author A-Z</option>
|
||||
<option>Author Z-A</option>
|
||||
<option>Title A-Z</option>
|
||||
|
Loading…
Reference in New Issue
Block a user