* Sunda Cyber Army 2k17 *
Indonesia Defacer ~
title = ["Moby Dick", "War and Peace", "Seven Pillars of Wisdom", "The Metamorphosis"];
author = ["Herman Melville", "Leo Tolstoy", "T. E. Lawrence", "Franz Kafka"];
year = ["1851", "1869", "1922", "1915"];
//Add Book
let results = document.querySelector("#results").innerHTML;
const addtitle = function (bookdata) {
title.push(bookdata);
}
const addauthor = function (bookdata) {
author.push(bookdata);
}
const addyear = function (bookdata) {
year.push(bookdata);
}
document.querySelector("#addbook").addEventListener("click", function () {
addtitle(document.querySelector("#newtitle").value);
addauthor(document.querySelector("#newauthor").value);
addyear(document.querySelector("#newyear").value);
})
//List All
let code = "";
document.querySelector("#listall").addEventListener("click", function () {
document.querySelector("#results").innerHTML = results
code = "</br>";
for (let i = 0; i < title.length; i++) {
code += "<strong>" + title[i] + "</strong> by ";
code += "<em>" + author[i] + "</em> ";
code += "(" + year[i] + ")<br/> <br/>";
}
document.querySelector("#results").innerHTML = results + code;
})
//Search by Title
document.querySelector("#searchtitle").addEventListener("click", function () {
document.querySelector("#results").innerHTML = results
searchbook(document.querySelector("#title").value);
})
const searchbook = function (searchterm) {
document.querySelector("#results").innerHTML = results
code = "</br>";
for (let i = 0; i < title.length; i++) {
if (title[i].indexOf(searchterm) > -1) {
code += "<strong>" + title[i] + "</strong> by ";
code += "<em>" + author[i] + "</em> ";
code += "(" + year[i] + ")<br/> <br/>";
}
}
document.querySelector("#results").innerHTML = results + code;
}