diff --git a/server.js b/server.js index c98cd83..ec997a0 100644 --- a/server.js +++ b/server.js @@ -20,12 +20,10 @@ app.set('views', __dirname + '/views') app.get("/", function(request, responce) { - dbRef = database.ref("/products") + var dbRef = database.ref("/products") dbRef.limitToFirst(5).once('value', function(snapshot){ - var data = snapshot.val() - if (!data) { - data = {} - } + var data = {} + data = snapshot.val() var x = "none" if (request.query.itemAdded == "true") { x = 'block' @@ -42,9 +40,20 @@ app.get('/additmpage', function(request, responce){ app.get('/product', function(request, responce){ if (request.query.productid) { - console.log(request.query.productid) + var dbRef = database.ref("/products/"+request.query.productid) + dbRef.once('value', function(snapshot){ + data = snapshot.val() + if (data){ + responce.render('product.ejs', {item:data}) + } + else { + responce.render('404.ejs') + } + }) + } + else { + responce.render('404.ejs') } - responce.render('product.ejs') }) var port = 5000 diff --git a/views/404.ejs b/views/404.ejs new file mode 100644 index 0000000..414037b --- /dev/null +++ b/views/404.ejs @@ -0,0 +1,94 @@ + + + + + + + 404 + + + + + + + + + + + + + + +
+
+ + +
+ img + + + Extras +
+ +
+ + +
+

It's a 404!

+
+ + +
+
+ +
+ + + + + + \ No newline at end of file diff --git a/views/add-item.ejs b/views/add-item.ejs index e2d0982..2571bbb 100644 --- a/views/add-item.ejs +++ b/views/add-item.ejs @@ -103,7 +103,6 @@ - \ No newline at end of file diff --git a/views/css/style.css b/views/css/style.css index 0479789..f87e3d4 100644 --- a/views/css/style.css +++ b/views/css/style.css @@ -425,4 +425,70 @@ footer a { color: green; left: 50%; transform: translate(-10%, 0); -} \ No newline at end of file +} + +.product-page-container { + width: 100%; + display: block; +} +.product-page-info-container { + position: relative; + width: 100%; + font-family: osl; + color: #5E5E5E; + display: inline-flex; +} +.product-page-img { + position: relative; + width: 42%; + padding-top: 5px; +} +.product-page-img img { + width: 100%; +} +.product-page-info { + position: relative; + padding-left: 20px; + display: block; +} + +.product-page-info button { + margin-top: 38px; + height: 40px; + width: 100px; + display: block; + font-size: 19px; + font-family: osl; + box-shadow: 0px 2px 3px #A5A5A5; + border-radius: 0; + border: none; + background-color: #30a8ff; + transition: 0.3s; +} +.product-page-info button:hover { + transition: 0.3s; + background-color: #ff7700; +} +.product-page-info button:active { + transition: 0.1s; + background-color: #ffaf69; +} + +.product-page-info h2 { + font-size: 30px; +} +.product-page-info p { + font-size: 20px; + padding-top: 38px; +} +.product-page-description { + margin-top: 10px; +} +.product-page-description p { + font-family: osl; + font-size: 20px; + color: #5E5E5E; +} + + + diff --git a/views/home.ejs b/views/home.ejs index b0221c0..236b92e 100644 --- a/views/home.ejs +++ b/views/home.ejs @@ -160,6 +160,6 @@ - + \ No newline at end of file diff --git a/views/js/fStore.js b/views/js/fStore.js deleted file mode 100644 index 3a8dd08..0000000 --- a/views/js/fStore.js +++ /dev/null @@ -1,12 +0,0 @@ -function updateImgs() { - const storage = firebase.storage() - const rootReference = storage.ref('/product-img') - - var images = document.getElementsByClassName('dyn-img') - // console.log(images) - Array.from(images).forEach((image) => { - var pathReference = rootReference.child(image.title) - pathReference.getDownloadURL().then(function(url) {image.src = url}) - }) -} -updateImgs(); \ No newline at end of file diff --git a/views/js/fdb.js b/views/js/fdb.js index 0ae357d..abb0ba6 100644 --- a/views/js/fdb.js +++ b/views/js/fdb.js @@ -52,3 +52,16 @@ function addItem(item){ console.log(error) }) } + +function updateImgs() { + const storage = firebase.storage() + const rootReference = storage.ref('/product-img') + + var images = document.getElementsByClassName('dyn-img') + // console.log(images) + Array.from(images).forEach((image) => { + var pathReference = rootReference.child(image.title) + pathReference.getDownloadURL().then(function(url) {image.src = url}) + }) +} +updateImgs(); \ No newline at end of file diff --git a/views/media/noimage.png b/views/media/noimage.png new file mode 100644 index 0000000..e78160b Binary files /dev/null and b/views/media/noimage.png differ diff --git a/views/product.ejs b/views/product.ejs index 7610ef5..d1c9315 100644 --- a/views/product.ejs +++ b/views/product.ejs @@ -60,6 +60,20 @@
+
+
+
+
+

<%= item.name %>

+

Seller <%= item.owner %>

+

Location: <%= item.location %>

+

In stock: <%= item.stock %>

+

Price: £<%= item.price %>

+ +
+
+

<%= "Description" %>

+
@@ -86,6 +100,6 @@ - + \ No newline at end of file