Update
This commit is contained in:
parent
7a6e211d2e
commit
995250d60a
@ -51,7 +51,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="sbar">
|
<div class="sbar">
|
||||||
<img src="media/gg_logo.png" alt="img">
|
<img src="media/gg_logo.png" onclick={window.location.replace('home')} alt="img">
|
||||||
<input id="sfield" type="text" placeholder="I Want...">
|
<input id="sfield" type="text" placeholder="I Want...">
|
||||||
<button id="sbutton">Go!</button>
|
<button id="sbutton">Go!</button>
|
||||||
<a href="#">Extras</a>
|
<a href="#">Extras</a>
|
||||||
|
|||||||
@ -215,7 +215,8 @@ footer a {
|
|||||||
height: 35px;
|
height: 35px;
|
||||||
float: left;
|
float: left;
|
||||||
padding-left: 7%;
|
padding-left: 7%;
|
||||||
padding-right: 20px;
|
margin-right: 20px;
|
||||||
|
cursor: pointer;
|
||||||
/*left: 5%;*/
|
/*left: 5%;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -320,6 +320,10 @@ function addShippingAddress(){
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function search(keywords){
|
||||||
|
window.location.replace('search?search='+keywords)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var addressField = document.getElementById("shippingaddressinput")
|
var addressField = document.getElementById("shippingaddressinput")
|
||||||
@ -338,3 +342,20 @@ try {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
catch(error) {console.log(error)}
|
catch(error) {console.log(error)}
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
var searchField = document.getElementById("sfield")
|
||||||
|
searchField.addEventListener("keyup", function(event) {
|
||||||
|
if (event.keyCode === 13) {
|
||||||
|
event.preventDefault()
|
||||||
|
if (searchField.value == ""){
|
||||||
|
searchField.blur()
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
search(searchField.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
catch(error) {console.log(error)}
|
||||||
@ -51,7 +51,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="sbar">
|
<div class="sbar">
|
||||||
<img src="media/gg_logo.png" alt="img">
|
<img src="media/gg_logo.png" onclick={window.location.replace('home')} alt="img">
|
||||||
<input id="sfield" type="text" placeholder="I Want...">
|
<input id="sfield" type="text" placeholder="I Want...">
|
||||||
<button id="sbutton">Go!</button>
|
<button id="sbutton">Go!</button>
|
||||||
<a href="#">Extras</a>
|
<a href="#">Extras</a>
|
||||||
|
|||||||
@ -52,7 +52,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<div class="sbar">
|
<div class="sbar">
|
||||||
<img src="media/gg_logo.png" alt="img">
|
<img src="media/gg_logo.png" onclick={window.location.replace('home')} alt="img">
|
||||||
<input id="sfield" type="text" placeholder="I Want...">
|
<input id="sfield" type="text" placeholder="I Want...">
|
||||||
<button id="sbutton">Go!</button>
|
<button id="sbutton">Go!</button>
|
||||||
<a href="#">Extras</a>
|
<a href="#">Extras</a>
|
||||||
|
|||||||
@ -51,7 +51,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="sbar">
|
<div class="sbar">
|
||||||
<img src="media/gg_logo.png" alt="img">
|
<img src="media/gg_logo.png" onclick={window.location.replace('home')} alt="img">
|
||||||
<input id="sfield" type="text" placeholder="I Want...">
|
<input id="sfield" type="text" placeholder="I Want...">
|
||||||
<button id="sbutton">Go!</button>
|
<button id="sbutton">Go!</button>
|
||||||
<a href="#">Extras</a>
|
<a href="#">Extras</a>
|
||||||
|
|||||||
109
functions/views/search.ejs
Normal file
109
functions/views/search.ejs
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
<!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="home">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" onclick={window.location.replace('home')} 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>Search results:</p>
|
||||||
|
<div class="my-products-container">
|
||||||
|
<% var keys = Object.keys(products) %>
|
||||||
|
<% keys.forEach(function(key){ %>
|
||||||
|
<div class="my-product-container">
|
||||||
|
<img class="dyn-img" onclick={window.location.replace('product?productid=<%=key%>')} title="<%= products[key].img %>" alt="img" src="media/var.png">
|
||||||
|
<div class="my-product-details-container">
|
||||||
|
<p class="top"><%= products[key].name%></p>
|
||||||
|
<p class="middle-top"> </p>
|
||||||
|
<p class="middle-bottom"> </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>
|
||||||
41
server.js
41
server.js
@ -47,10 +47,51 @@ function homePage(request, responce) {
|
|||||||
if (request.query.itemAdded == "true") {
|
if (request.query.itemAdded == "true") {
|
||||||
x = 'block'
|
x = 'block'
|
||||||
}
|
}
|
||||||
|
console.log(data)
|
||||||
responce.render('home.ejs', {products: data, message: x})
|
responce.render('home.ejs', {products: data, message: x})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app.get('/search', function(request, responce){
|
||||||
|
var dbRef = database.ref("/products")
|
||||||
|
if (request.query.search) {
|
||||||
|
let sQuery = request.query.search.toLowerCase()
|
||||||
|
dbRef.orderByChild("status").equalTo("on-sale").once('value', function(snapshot){
|
||||||
|
var data = {
|
||||||
|
'x': {desc: '',holder: '',id: 999,img: '',location: '',name: 'Nothing found 😢',owner: '',price: '',public: '',stock: ''},
|
||||||
|
}
|
||||||
|
if (snapshot.val()) {
|
||||||
|
data = snapshot.val()
|
||||||
|
var sResults = [{desc: '',holder: '',id: 999,img: '',location: '',name: 'Nothing found 😢',owner: '',price: '',public: '',stock: ''}]
|
||||||
|
|
||||||
|
var keys = Object.keys(data)
|
||||||
|
|
||||||
|
keys.forEach(key => {
|
||||||
|
if (data[key].name.toLowerCase().includes(sQuery) || data[key].desc.toLowerCase().includes(sQuery)) {
|
||||||
|
sResults[key] = data[key]
|
||||||
|
console.log(sResults)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (Object.keys(sResults).length > 1) {
|
||||||
|
delete sResults[0]
|
||||||
|
}
|
||||||
|
console.log(sResults)
|
||||||
|
responce.render('search.ejs', {products: sResults})
|
||||||
|
}
|
||||||
|
else {responce.render('search.ejs', {products: data})}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
dbRef.orderByChild("status").equalTo("on-sale").once('value', function(snapshot){
|
||||||
|
var data = {
|
||||||
|
'x': {desc: '',holder: '',id: 999,img: '',location: '',name: 'Nothing found 😢',owner: '',price: '',public: '',stock: ''},
|
||||||
|
}
|
||||||
|
if (snapshot.val()) {data = snapshot.val()}
|
||||||
|
responce.render('search.ejs', {products: data})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
app.get('/additmpage', function(request, responce){
|
app.get('/additmpage', function(request, responce){
|
||||||
responce.render('add-item.ejs')
|
responce.render('add-item.ejs')
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user