This commit is contained in:
Max Hunt 2020-04-26 00:04:41 +01:00
parent 9c105c7904
commit d90b948049
7 changed files with 168 additions and 8 deletions

View File

@ -25,7 +25,7 @@
<div class="navbar">
<div class="logon-crumbs">
<div id="uname-field" style="display: none;">
<a id="uname-dom" class="user-name" href="home">Unregistered user</a>
<a id="uname-dom" class="user-name" href="my-products">Unregistered user</a>
<div class="user-logout">
<a onclick={signout()}>Log out</a>
</div>

View File

@ -496,5 +496,35 @@ footer a {
color: #5E5E5E;
}
.my-products-container {
}
.my-product-container {
padding-top: 15px;
width: 300px;
display: inline-flex;
}
.my-product-container img {
width: 100%;
max-height: 100%;
}
.my-product-details-container {
display: block;
line-height: 0;
padding-left: 10px;
width: 100%;
}
.my-product-details-container p {
font-family: nunito;
color: #CA5555;
font-size: 25px;
}
.top {
padding-top: 5px;
}
.middle {
padding-top: 50px;
}
.bottom {
padding-top: 50px;
}

View File

@ -24,7 +24,7 @@
<div class="navbar">
<div class="logon-crumbs">
<div id="uname-field" style="display: none;">
<a id="uname-dom" class="user-name" href="home">Unregistered user</a>
<a id="uname-dom" class="user-name" href="my-products">Unregistered user</a>
<div class="user-logout">
<a onclick={signout()}>Log out</a>
</div>

View File

@ -6,15 +6,19 @@ function checkAuth(){
document.getElementById('uname-dom').innerHTML = "Hello, " + user.displayName
document.getElementById('uname-field').setAttribute("style", "display: block;")
document.getElementById('login-field').setAttribute("style", "display: none;")
document.getElementById('uAuthMsg').setAttribute("style", "display: none;")
document.getElementById('npf').setAttribute("style", "display: block;")
try {document.getElementById('uAuthMsg').setAttribute("style", "display: none;")}
catch(error) {console.log(error)}
try{document.getElementById('npf').setAttribute("style", "display: block;")}
catch(error) {console.log(error)}
}
else {
document.getElementById('uname-field').setAttribute("style", "display: none;")
document.getElementById('login-field').setAttribute("style", "display: block;")
document.getElementById('uname-dom').innerHTML = "Unregistered"
document.getElementById('uAuthMsg').setAttribute("style", "display: block;")
document.getElementById('npf').setAttribute("style", "display: none;")
try{document.getElementById('uAuthMsg').setAttribute("style", "display: block;")}
catch(error) {console.log(error)}
try{document.getElementById('npf').setAttribute("style", "display: none;")}
catch(error) {console.log(error)}
}
})
}

View File

@ -0,0 +1,110 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>GG Prototype</title>
<meta name="description" content="GG Prototype Web">
<meta name="author" content="Max">
<link rel="stylesheet" href="css/style.css">
<script src="https://www.gstatic.com/firebasejs/7.14.1/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.14.1/firebase-analytics.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.14.1/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.14.1/firebase-storage.js"></script>
<script defer src="https://www.gstatic.com/firebasejs/7.14.1/firebase-database.js"></script>
<script src="js/fInit.js"></script>
</head>
<body>
<main>
<div class="page">
<div class="navbar">
<div class="logon-crumbs">
<div id="uname-field" style="display: none;">
<a id="uname-dom" class="user-name" href="my-products">Unregistered user</a>
<div class="user-logout">
<a onclick={signout()}>Log out</a>
</div>
</div>
<div id="login-field" style="display: block;">
<input id="fuid" type="text" placeholder="Username">
<input id="fpwd" type="password" placeholder="Password">
<button id="blogin" onclick={signinwithemail()} class="btn-login">&#x27a4;</button>
<button id="blogin_g" onclick={signinwithgoogle()} class="btn-g-login"><img src="media/g_logon.png" class="img-g-login" alt="img"></button>
<button id="blogin_g" onclick={signinwithfb()} class="btn-fb-login"><img src="media/fb_logon.png" class="img-g-login" alt="img"></button>
</div>
</div>
<div class="user-info">
<div class="notifications">
&#x1F514; | <%= 0%>
</div>
<div class="cart">
&#x1F6d2; | <%= 0%>
</div>
<div class="add-item">
<a href="additmpage">⊕</a>
</div>
</div>
</div>
<div class="sbar">
<img src="media/gg_logo.png" alt="img">
<input id="sfield" type="text" placeholder="I Want...">
<button id="sbutton">Go!</button>
<a href="#">Extras</a>
</div>
<div class="space"></div>
<div class="products">
<p>My products:</p>
<div class="my-products-container">
<% var keys = Object.keys(products) %>
<% keys.forEach(function(key){ %>
<div class="my-product-container">
<a href="product?productid=<%=key%>">
<img class="dyn-img" title="<%= products[key].img %>" alt="img" src="media/var.png">
</a>
<div class="my-product-details-container">
<p class="top"><%= products[key].name%></p>
<p class="middle"><%= products[key].location%></p>
<p class="bottom">£ <%= products[key].price%></p>
</div>
</div>
<% }) %>
</div>
</div>
<div class="space"></div>
</div>
</main>
<footer>
<div class="links">
<a href="#">Help</a>
<a href="#">Contact</a>
<a href="#">Legal</a>
</div>
<div class="legal">
<a>© GG Sales 2019-2020. All Rights Reserved. </a>
<a class="link" href="#">User Agreement</a>
<a> ,</a>
<a class="link" href="#">Privacy</a>
<a> ,</a>
<a class="link" href="#">Cookies</a>
</div>
<div class="location">
GG Sales US 🇺🇸
</div>
</footer>
<script src="js/fAuth.js"></script>
<script src="js/fdb.js"></script>
</body>
</html>

View File

@ -24,7 +24,7 @@
<div class="navbar">
<div class="logon-crumbs">
<div id="uname-field" style="display: none;">
<a id="uname-dom" class="user-name" href="home">Unregistered user</a>
<a id="uname-dom" class="user-name" href="my-products">Unregistered user</a>
<div class="user-logout">
<a onclick={signout()}>Log out</a>
</div>

View File

@ -53,6 +53,22 @@ app.get('/additmpage', function(request, responce){
responce.render('add-item.ejs')
})
app.get('/my-products', function(request, responce){
request.query.userid = "FhZpTE7ZYzgDDwBBl2MYkc243Se2"
if (request.query.userid) {
var dbRef = database.ref("/products")
dbRef.orderByChild('owner').equalTo(request.query.userid).once('value', function(snapshot){
var data = {}
data = snapshot.val()
responce.render('my-products.ejs', {products: data})
})
}
else {
responce.render('404.ejs')
}
})
app.get('/product', function(request, responce){
if (request.query.productid) {
var dbRef = database.ref("/products/"+request.query.productid)