Skip to content
Snippets Groups Projects
Commit f043ce8b authored by hosama's avatar hosama
Browse files

The library application, implemented the table and some functions. addBook is BROKEN.

parent dc563ea7
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
<html>
<head>
<title>
Library
</title>
<style>
td {
background-color: #e5eecc;
text-align: center;
border: 3px solid black;
}
#shelves {
background-color: #e5eecc;
text-align: center;
border: 3px solid black;
}
</style>
</head>
<script src = "libraryApplication.js"></script>
<script src = "jquery-3.1.1.js"></script>
<body id = "library">
<div id = "Table">
<table id ="shelves">
<td id "art"> Art </td>
<td id "science"> Science </td>
<td id "sport"> Sport </td>
<td id "Literature"> Literature </td>
<tr></tr>
<td>B0</td>
<td>B1</td>
<td>B2</td>
<td>B3</td>
<tr></tr>
<td>B4</td>
<td>B5</td>
<td>B6</td>
<td>B7</td>
<tr></tr>
<td>B8</td>
<td>B9</td>
<td>B10</td>
<td>B11</td>
<tr></tr>
<td>B12</td>
<td>B13</td>
<td>B14</td>
<td>B15</td>
<tr></tr>
<td>B16</td>
<td>B17</td>
<td>B18</td>
<td>B19</td>
<tr></tr>
<td>B20</td>
<td>B21</td>
<td>B22</td>
<td>B23</td>
<tr></tr>
<td>B24 </td>
<td> </td>
<td> </td>
<td> </td>
<tr> </tr>
</div>
</body>
var id;//Book Id
var bookName; //save the book name
//Generates a 3 digit book ID
function ID_generator(){
id = Math.floor((Math.random() * 999) + 100);
while(id.toString().length != 3){ //Make sure that the id is 3 digits
id = Math.floor((Math.random() * 999) + 100);
}
console.log("Book ID is: " + id);
return id;
};
//Saves the name of the user who borrowed the book.
function borrowedBy(user){
localStorage.setItem("user", user);
};
//Check the availability of the chosen book. take the book as a parameter.
function availability(available){
if(!available){
localStorage.setItem("available", 0);
console.log("The book " + available + " is borrowed by a student.");
return false
}else{
localStorage.setItem("available", 1);
console.log("The book " + available + " is available");
return true;
}
};
/*
addBook("Yastawat", "art");
//Add a book to a specefic shelf. FIX-ME
function addBook(name, category){
if(category.toLowerCase() == "art" ){
$('#shelves').append(name);
}else if(category.toLowerCase() == "science"){
}
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment