diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..83ada0e2fe07f8ac7ee4413ade8a2b49a42aeaed --- /dev/null +++ b/.gitignore @@ -0,0 +1,31 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Dependency directories +#node_modules/ + +# Optional npm cache directory +.npm + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# Database File +CLCBooks.db diff --git a/CLCBooksSQL.sql b/CLCBooksSQL.sql index 39aeb124ecacb7e1d20a0c07f496c6091ac0d400..47ad905cea21bce383b41ec3a92f10cf4d4fe6f8 100644 --- a/CLCBooksSQL.sql +++ b/CLCBooksSQL.sql @@ -1,5 +1,5 @@ CREATE TABLE [Books] ( - [Order] INTEGER PRIMARY KEY AUTOINCREMENT, + [Order] INTEGER PRIMARY KEY AUTOINCREMENT, [ISBN] INTEGER NOT NULL, [Title] VARCHAR(50) NOT NULL, [Author] VARCHAR(50) NOT NULL @@ -9,7 +9,7 @@ INSERT INTO Books (ISBN, Title, Author) Values ('9781514828144', 'A Byte of Python', 'Swaroop C H'), ('9781108171021', 'Artificial Intelligence: Foundations of Computational Agents', 'David Poole and Alan Mackworth'), -('9781441419057', 'How to Think Like a Computer Scientist: C ++', 'Allen B. Downey'), +('9781441419057', 'How to Think Like a Computer Scientist: C++', 'Allen B. Downey'), ('9787308040365', 'How to Think Like a Computer Scientist: Java', 'Allen B. Downey'), ('9781563249914', 'Philosophy of Computer Science', 'William J. Rapaport'); diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..ca620edc0b425fb3646fde93f3cc1fdb573afdfc --- /dev/null +++ b/LICENSE @@ -0,0 +1,7 @@ +Copyright 2019 trp74 + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/index.js b/index.js index 21818a6c97b197999b30d2967b493f010c04c77e..a51f8535a9ed5ea074489e788dd7c6d6b9e06975 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,5 @@ function goToCCI() { - //window.open('https://drexel.edu/cci/'); + window.open('https://drexel.edu/cci/'); } @@ -18,7 +18,7 @@ function getBooks() { function myCallBack(xhr) { if (xhr.readyState==4 && xhr.status==200) { let table = document.getElementById('book-list'); - table.innerHTML = `<tr> + table.innerHTML = `<tr id="header-row"> <th>Title</th> <th>Author</th> <th>ISBN</th> diff --git a/logos/drexel.png b/logos/drexel.png index 340a20d356aa1dd114711fa43b37c8438037aa16..e9aa327cadc99c35cea89a2f6261eeb8311bd974 100644 Binary files a/logos/drexel.png and b/logos/drexel.png differ diff --git a/package.json b/package.json index 7252cb160a164002f521ed2a3d3420cccffdbc88..6bb07236a7db1932f338ad1aeba1cfd683e31f38 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ci101lab5", - "version": "0.0.1", - "description": "lab for ci 101", + "version": "0.0.2", + "description": "Lab for CI 101", "license": "MIT", "repository": { "type": "git", @@ -11,5 +11,9 @@ "bootstrap": "^4.3.1", "express": "^4.17.1", "sqlite3": "^4.1.0" + }, + "main": "server.js", + "scripts": { + "start": "node server.js" } } diff --git a/server.js b/server.js index b7e51a23bd03f53f84e2d2acb1316b644ae36a3e..4bcbb368d6959365792c1060b461daeabaee5bb1 100644 --- a/server.js +++ b/server.js @@ -1,33 +1,40 @@ const express = require("express"); const app = express(); -const sqlite3 = require('sqlite3').verbose(); +const sqlite3 = require("sqlite3").verbose(); -app.use(express.static('.')); +app.use(express.static(".")); app.use(express.json()); -app.get("/getBooks", function(req, res){ - const db = new sqlite3.Database('./CLCBooks.db'); - console.log('recieved'); - let output = ''; - db.serialize(function() { - db.each("SELECT Books.ISBN, Books.Title, Books.Author, Availability.Available FROM Books, Availability WHERE Books.ISBN = Availability.ISBN", function(err, row) { - if (row) { - if (row.Available == 'Y') { - row.Available = "Yes"; - } else { - row.Available = "No"; - } - output += `<tr> <td>` + row.Title + `</td><td>` + row.Author + `</td><td>` + row.ISBN + `</td> <td>` + row.Available + `</td></tr>`; - } - }); - }); - setTimeout(function(){ - db.close(); - res.send(output); - }, 500); +app.get("/getBooks", function(req, res) { + const db = new sqlite3.Database("./CLCBooks.db"); + console.log("recieved"); + let output = ""; + db.serialize(function() { + db.each( + "SELECT Books.ISBN, Books.Title, Books.Author, Availability.Available FROM Books, Availability WHERE Books.ISBN = Availability.ISBN", + function(err, row) { + if (row) { + if (row.Available == "Y") { + row.Available = "Yes"; + } else { + row.Available = "No"; + } + output += `<tr class="rows"> + <td>${row.Title}</td> + <td>${row.Author}</td> + <td>${row.ISBN}</td> + <td>${row.Available}</td> + </tr>`; + } + } + ); + }); + setTimeout(function() { + db.close(); + res.send(output); + }, 500); }); -app.listen('8080', function(){ - console.log("listening at port 8080..."); -}); \ No newline at end of file +const port = "8080"; +app.listen(port, () => console.log(`Listening at 127.0.0.1:${port}...`));