diff --git a/public/js/little-library.js b/public/js/little-library.js index c278707..a5aa418 100644 --- a/public/js/little-library.js +++ b/public/js/little-library.js @@ -15,5 +15,10 @@ $(document).ready(function() { fileName = fileName.substr(lastIndexOfSlash + 1); } $('#bookFileName').text(fileName ? fileName : 'None Selected'); - }) + }); + + $('.book').click(function() { + var modal = $(this).data('modal'); + $('#' + modal).addClass('is-active'); + }); }); \ No newline at end of file diff --git a/server.js b/server.js index 02aec43..d234a06 100644 --- a/server.js +++ b/server.js @@ -19,6 +19,8 @@ function Server () { this.fileLocation = path.resolve(settings.fileLocation); this.historyLocation = path.resolve(settings.historyLocation); + this.templateCache = {}; + this.takenBooks = []; this.server.use(helmet()); @@ -42,7 +44,20 @@ function Server () { this.server.use('/css', express.static(path.join(__dirname, './public/css/'))); this.server.get('/', (req, res) => { - const body = this.fillTemplate('./templates/pages/uploadForm.html'); + const files = fs.readdirSync(this.fileLocation).filter(fileName => fileName.includes('.json')); + const books = files.map(fileName => { + const bookData = JSON.parse(fs.readFileSync(path.resolve(this.fileLocation, fileName), 'utf8')); + const id = fileName.replace('.json', ''); + const content = '