From 8f88bdbc4c1b74656cabb01cbf2592fa0274b89c Mon Sep 17 00:00:00 2001 From: nightly Date: Mon, 19 Sep 2022 23:55:23 +0200 Subject: [PATCH] bing --- Components/webserver.js | 16 ++++++- Public/MangoBerry.css | 25 ++++++++++ Public/script.js | 1 + Public/style.css | 4 +- Templates/index.ejs | 46 +++++++++++++++++- testdatabase.json | 101 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 189 insertions(+), 4 deletions(-) create mode 100644 Public/MangoBerry.css create mode 100644 Public/script.js create mode 100644 testdatabase.json diff --git a/Components/webserver.js b/Components/webserver.js index 46d1f29..7902cc0 100644 --- a/Components/webserver.js +++ b/Components/webserver.js @@ -3,6 +3,10 @@ const express = require('express'); const app = express(); const server = require('http').createServer(app); const port = process.env.PORT || 3430; +const test = require('../testdatabase.json'); + +var site; +// TODO: Add stuff for MySQL // Set the templates folder for the thingy app.set('views', __dirname + '/../Templates'); @@ -13,7 +17,17 @@ app.use(express.static(__dirname + '/../Public')); // Main page app.get('/', function(req, res){ - res.render('index'); + console.log('🌐 Client requested ' + req.url); + res.render('index', { test, site: 1 }); + console.log('✅ Client recieved ' + req.url); + // console.log(test.cars.Nissan[1].model) +}); + +app.get('/inventory', function(req, res){ + console.log('🌐 Client requested ' + req.url); + res.render('index', { test, site: 2 }); + console.log('✅ Client recieved ' + req.url); + // console.log(test.cars.Nissan[1].model) }); // Simple way to expose a function diff --git a/Public/MangoBerry.css b/Public/MangoBerry.css new file mode 100644 index 0000000..f72ac51 --- /dev/null +++ b/Public/MangoBerry.css @@ -0,0 +1,25 @@ +body { + margin: 0px; +} + + +.mbNavTop { + background-color: var(--colour-navbar); + overflow: hidden; + height: 65; + padding: 0 .5rem; + width:100vw; +} + +#Logo { + color:white; +} + +.mbNavTop a { + float:left; + color:antiquewhite; + text-align: center; + padding: 14px 16px; + text-decoration: none; + font-size: 17px; +} \ No newline at end of file diff --git a/Public/script.js b/Public/script.js new file mode 100644 index 0000000..d36cd2a --- /dev/null +++ b/Public/script.js @@ -0,0 +1 @@ +console.log('✅ Done') \ No newline at end of file diff --git a/Public/style.css b/Public/style.css index 1e3d829..81cc0fb 100644 --- a/Public/style.css +++ b/Public/style.css @@ -1,3 +1,3 @@ -#cssloaded { - color:deepskyblue; +:root { + --colour-navbar: #303030; } \ No newline at end of file diff --git a/Templates/index.ejs b/Templates/index.ejs index a1f3382..f64a434 100644 --- a/Templates/index.ejs +++ b/Templates/index.ejs @@ -11,7 +11,51 @@ -

Hello world!

+ + +
+ <% if(site == 2) { %> +

Inventory

+ + + + + + + + + + + + <% for (let i = 0; i < test.mangoshelf.Items.length; i++) { %> + + + + + + + + <% } %> + +
#NameLocationAmountTools
<%= i + 1 %><%= test.mangoshelf.Items[i].Name %><%= test.mangoshelf.Items[i].Location %><%= test.mangoshelf.Items[i].Amount %>
+ <% } %> +
+ \ No newline at end of file diff --git a/testdatabase.json b/testdatabase.json new file mode 100644 index 0000000..4ca146f --- /dev/null +++ b/testdatabase.json @@ -0,0 +1,101 @@ +{ + "mangoshelf": { + "Items": [ + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Sentra", "Location":"3B","Amount":4}, + {"Name":"Maxima", "Location":"1B","Amount":4}, + {"Name":"Skyline", "Location":"3A", "Amount":2} + ], + "Ford": [ + {"model":"Taurus", "doors":4}, + {"model":"Escort", "doors":4} + ] + } +} \ No newline at end of file