Update
This commit is contained in:
parent
ee93cd0679
commit
fda5a76d12
@ -88,8 +88,19 @@ footer a {
|
|||||||
font-family: osl;
|
font-family: osl;
|
||||||
font-size: 23px;
|
font-size: 23px;
|
||||||
color: #898989;
|
color: #898989;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: 0.3s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.user-name:hover {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
.user-name:active {
|
||||||
|
transition: 0.1s;
|
||||||
|
color: #F0F0F0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
.logon-crumbs button {
|
.logon-crumbs button {
|
||||||
float: left;
|
float: left;
|
||||||
position: relative;
|
position: relative;
|
||||||
@ -511,6 +522,7 @@ footer a {
|
|||||||
.my-product-container img {
|
.my-product-container img {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-height: 100%;
|
max-height: 100%;
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
.my-product-details-container {
|
.my-product-details-container {
|
||||||
display: block;
|
display: block;
|
||||||
|
|||||||
@ -67,7 +67,7 @@
|
|||||||
<div class="space"></div>
|
<div class="space"></div>
|
||||||
|
|
||||||
<div class="products">
|
<div class="products">
|
||||||
<p>Popular:</p>
|
<p>Recent:</p>
|
||||||
<div class="product-list-container">
|
<div class="product-list-container">
|
||||||
<% var keys = Object.keys(products) %>
|
<% var keys = Object.keys(products) %>
|
||||||
<% keys.forEach(function(key){ %>
|
<% keys.forEach(function(key){ %>
|
||||||
|
|||||||
@ -143,6 +143,14 @@ function purchaseItem() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function my_product(productID) {
|
||||||
|
firebase.auth().currentUser.getIdToken().then(function(idToken) {
|
||||||
|
console.log("my-products?uToken=" + idToken + '&productid=' + productID)
|
||||||
|
window.location.replace("my-product?uToken=" + idToken + '&productid=' + productID)
|
||||||
|
})
|
||||||
|
.catch(e => {console.log(e)})
|
||||||
|
}
|
||||||
|
|
||||||
function my_products() {
|
function my_products() {
|
||||||
firebase.auth().currentUser.getIdToken().then(function(idToken) {
|
firebase.auth().currentUser.getIdToken().then(function(idToken) {
|
||||||
window.location.replace("my-products?uToken=" + idToken)
|
window.location.replace("my-products?uToken=" + idToken)
|
||||||
|
|||||||
105
functions/views/my-product.ejs
Normal file
105
functions/views/my-product.ejs
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
<!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" onclick="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">➤</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">
|
||||||
|
🔔 | <%= 0%>
|
||||||
|
</div>
|
||||||
|
<div class="cart">
|
||||||
|
🛒 | <%= 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 id="productID" style="display: none;" product_id="<%= key%>"></div>
|
||||||
|
<div class="product-page-container">
|
||||||
|
<div class="product-page-info-container">
|
||||||
|
<div class="product-page-img"><img class="dyn-img" src="media/noimage.png" title="<%= item.img %>"></div>
|
||||||
|
<div class="product-page-info">
|
||||||
|
<h2><%= item.name %> </h2>
|
||||||
|
<p>Seller <%= item.owner %></p>
|
||||||
|
<p>Location: <%= item.location %></p>
|
||||||
|
<p>In stock: <%= item.stock %></p>
|
||||||
|
<p>Price: £<%= item.price %></p>
|
||||||
|
<button onclick={x()} id="xbtn">Smth</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="product-page-description"><p><%= item.desc %></p></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>
|
||||||
@ -66,8 +66,8 @@
|
|||||||
<% var keys = Object.keys(products) %>
|
<% var keys = Object.keys(products) %>
|
||||||
<% keys.forEach(function(key){ %>
|
<% keys.forEach(function(key){ %>
|
||||||
<div class="my-product-container">
|
<div class="my-product-container">
|
||||||
<a href="product?productid=<%=key%>">
|
<a>
|
||||||
<img class="dyn-img" title="<%= products[key].img %>" alt="img" src="media/var.png">
|
<img class="dyn-img" onclick={my_product("<%= key%>")} title="<%= products[key].img %>" alt="img" src="media/var.png">
|
||||||
</a>
|
</a>
|
||||||
<div class="my-product-details-container">
|
<div class="my-product-details-container">
|
||||||
<p class="top"><%= products[key].name%></p>
|
<p class="top"><%= products[key].name%></p>
|
||||||
|
|||||||
@ -24,7 +24,7 @@
|
|||||||
<div class="navbar">
|
<div class="navbar">
|
||||||
<div class="logon-crumbs">
|
<div class="logon-crumbs">
|
||||||
<div id="uname-field" style="display: none;">
|
<div id="uname-field" style="display: none;">
|
||||||
<a id="uname-dom" class="user-name" href="javascript:;" onclick="my_products();">Unregistered user</a>
|
<a id="uname-dom" class="user-name" onclick="my_products();">Unregistered user</a>
|
||||||
<div class="user-logout">
|
<div class="user-logout">
|
||||||
<a onclick={signout()}>Log out</a>
|
<a onclick={signout()}>Log out</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
25
server.js
25
server.js
@ -32,7 +32,7 @@ app.get("/home", function(request, responce) {
|
|||||||
|
|
||||||
function homePage(request, responce) {
|
function homePage(request, responce) {
|
||||||
var dbRef = database.ref("/products")
|
var dbRef = database.ref("/products")
|
||||||
dbRef.limitToLast(5).once('value', function(snapshot){
|
dbRef.orderByChild("public").equalTo("").limitToLast(5).once('value', function(snapshot){
|
||||||
var data = {}
|
var data = {}
|
||||||
data = snapshot.val()
|
data = snapshot.val()
|
||||||
var x = "none"
|
var x = "none"
|
||||||
@ -93,6 +93,27 @@ app.get('/my-products', function(request, responce){
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
app.get('/my-product', function(request, responce){
|
||||||
|
if (request.query.uToken && request.query.productid) {
|
||||||
|
admin.auth().verifyIdToken(request.query.uToken)
|
||||||
|
.then(function(decodedToken) {
|
||||||
|
let uid = decodedToken.uid;
|
||||||
|
var dbRef = database.ref("/products/"+request.query.productid)
|
||||||
|
dbRef.once('value', function(snapshot){
|
||||||
|
data = snapshot.val()
|
||||||
|
responce.render('my-product.ejs', {item:data, key:request.query.productid})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.catch(function(error) {
|
||||||
|
console.log(error)
|
||||||
|
responce.send("<h1>Bad Auth Token</h1><a href='home'>Home</a>")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
responce.send("<h1>No Auth Token Provided</h1><a href='home'>Home</a>")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
app.get('/product', function(request, responce){
|
app.get('/product', function(request, responce){
|
||||||
if (request.query.productid) {
|
if (request.query.productid) {
|
||||||
var dbRef = database.ref("/products/"+request.query.productid)
|
var dbRef = database.ref("/products/"+request.query.productid)
|
||||||
@ -118,7 +139,7 @@ app.post('/purchase-api', function(request, responce){
|
|||||||
let uid = decodedToken.uid;
|
let uid = decodedToken.uid;
|
||||||
let product = request.body.item
|
let product = request.body.item
|
||||||
var productRef = database.ref("/products/"+product)
|
var productRef = database.ref("/products/"+product)
|
||||||
productRef.update({owner:uid})
|
productRef.update({owner:uid, public:"no"})
|
||||||
responce.send({success:true, error:null})
|
responce.send({success:true, error:null})
|
||||||
})
|
})
|
||||||
.catch(function(error) {
|
.catch(function(error) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user