remove jquery
This commit is contained in:
parent
b3ccda7885
commit
f800e4c718
@ -2,7 +2,6 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Library</title>
|
<title>Library</title>
|
||||||
<script type="text/javascript" src="js/jquery.js"></script>
|
|
||||||
<link
|
<link
|
||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"
|
href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"
|
||||||
@ -87,21 +86,32 @@
|
|||||||
books.forEach((e, i) => (e.rowNumber = i)); // re-key
|
books.forEach((e, i) => (e.rowNumber = i)); // re-key
|
||||||
|
|
||||||
// rendering
|
// rendering
|
||||||
document.getElementById("books").innerHTML = TableTemplate(books);
|
var bookElement = document.getElementById("books");
|
||||||
$("#books tbody tr")
|
bookElement.innerHTML = TableTemplate(books);
|
||||||
.not(":first") // ignore the headers
|
|
||||||
.on("click", (e) => {
|
// add listeners for selecting book to view
|
||||||
document.getElementById("current").innerHTML = BookTemplate(
|
Array.from(bookElement.querySelectorAll("tbody tr"))
|
||||||
books[e.currentTarget.id]
|
.slice(1) // remove header from Array
|
||||||
);
|
.forEach((row) => {
|
||||||
|
row.addEventListener("click", (e) => {
|
||||||
|
// add listener to swap current book
|
||||||
|
document.getElementById("current").innerHTML = BookTemplate(
|
||||||
|
books[e.currentTarget.id]
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
// add sorting callbacks
|
||||||
|
Array.from(
|
||||||
|
bookElement.querySelectorAll("tbody tr th[data-sort-by]")
|
||||||
|
).forEach((row) => {
|
||||||
|
row.addEventListener("click", function (e) {
|
||||||
|
renderTable(books, e.target.dataset.sortBy); // only add callback when there's a sortBy attribute
|
||||||
});
|
});
|
||||||
$("#books tbody tr th[data-sort-by]").on("click", function (e) {
|
|
||||||
console.log(e);
|
|
||||||
renderTable(books, $(this).data("sortBy")); // only add callback when there's a sortBy attribute
|
|
||||||
});
|
});
|
||||||
$("#books tbody tr th[data-sort-by=" + sortState.sortBy + "]").addClass(
|
// mark currently active column
|
||||||
sortState.sortOrder
|
bookElement
|
||||||
);
|
.querySelector("tbody tr th[data-sort-by=" + sortState.sortBy + "]")
|
||||||
|
.classList.add(sortState.sortOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
function titleCleaner(title) {
|
function titleCleaner(title) {
|
||||||
|
4
frontend/files/js/jquery.js
vendored
4
frontend/files/js/jquery.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user