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
|
||||||
|
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(
|
document.getElementById("current").innerHTML = BookTemplate(
|
||||||
books[e.currentTarget.id]
|
books[e.currentTarget.id]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
$("#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(
|
// add sorting callbacks
|
||||||
sortState.sortOrder
|
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
|
||||||
|
});
|
||||||
|
});
|
||||||
|
// mark currently active column
|
||||||
|
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