remove jquery
This commit is contained in:
parent
b3ccda7885
commit
f800e4c718
@ -2,7 +2,6 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Library</title>
|
||||
<script type="text/javascript" src="js/jquery.js"></script>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
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
|
||||
|
||||
// rendering
|
||||
document.getElementById("books").innerHTML = TableTemplate(books);
|
||||
$("#books tbody tr")
|
||||
.not(":first") // ignore the headers
|
||||
.on("click", (e) => {
|
||||
document.getElementById("current").innerHTML = BookTemplate(
|
||||
books[e.currentTarget.id]
|
||||
);
|
||||
var bookElement = document.getElementById("books");
|
||||
bookElement.innerHTML = TableTemplate(books);
|
||||
|
||||
// add listeners for selecting book to view
|
||||
Array.from(bookElement.querySelectorAll("tbody tr"))
|
||||
.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(
|
||||
sortState.sortOrder
|
||||
);
|
||||
// mark currently active column
|
||||
bookElement
|
||||
.querySelector("tbody tr th[data-sort-by=" + sortState.sortBy + "]")
|
||||
.classList.add(sortState.sortOrder);
|
||||
}
|
||||
|
||||
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