Compare commits

..

No commits in common. "397626e98bf244f2353a86f36102e5c0e98cb557" and "bb181363a1d5e5990ce24f6782ae7128e81901a9" have entirely different histories.

31 changed files with 1501 additions and 12004 deletions

0
.dockerignore Executable file → Normal file
View File

10
Dockerfile Executable file → Normal file
View File

@ -1,15 +1,15 @@
FROM node:16.15.1-buster-slim
FROM node:latest
WORKDIR /app
COPY . .
# RUN apt update
# RUN apt install htop
RUN apt update
RUN apt install htop
RUN npm install
RUN npm install pm2 -g
EXPOSE 5001
EXPOSE 5000
CMD ["pm2-runtime", "server.js"]
CMD ["pm2-runtime", "app.js"]

0
functions/index.js Executable file → Normal file
View File

0
functions/views/404.ejs Executable file → Normal file
View File

0
functions/views/add-item.ejs Executable file → Normal file
View File

0
functions/views/admin-review.ejs Executable file → Normal file
View File

429
functions/views/css/style.css Executable file → Normal file
View File

@ -19,85 +19,8 @@
src: url(../fonts/Nunito-Bold.ttf);
}
:root {
--white: #FFFFFF;
--light-gray: #F0F0F0;
--whitesmoke: whitesmoke;
--gray: gray;
--black: black;
--violet: violet;
--green: green;
--footer-background: #D8D8D8;
--footer-shadow-background: #8A8A8A;
--footer-a: #737373;
--placeholder: #aaaaaa;
--input-border: #979797;
--input-shadow: #A5A5A5;
--input-shadow-alt: #E5E5E5;
--uname: #898989;
--red: red;
--login-btn: #3D10FF;
--login-hover: whitesmoke;
--login-active: #00df90;
--google-login-btn: #cacaca;
--google-login-btn-hover: #A5A5A5;
--add-item-btn: #ff6619;
--add-item-btn-hover: #c41000;
--add-item-btn-active: #BBBBBB;
--notifications: #898989;
--notifications-hover: tomato;
--notifications-active: cyan;
--search-btn-background: #5359FF;
--search-btn: #C4C4C4;
--search-extra: #7F7F7F;
--product-container-p: #CA5555;
--user-logout: #393939;
--new-product-field-p: #898989;
--new-product-field-btn: #30a8ff;
--new-product-field-btn-hover: #ff7700;
--new-product-field-btn-active: #ffaf69;
--new-product-field-btn-disabled: #b9b9b9;
--product-page-info-container: #5E5E5E;
--product-page-info-btn: #30a8ff;
--product-page-info-hover: #ffc04b;
--product-page-info-active: #ffaf69;
--product-page-info-disabled: #b9b9b9;
--my-product-details-container: #CA5555;
--purchase-msg: #00df90;
--error-msg: #df0000;
--edit-btn: #A562FF;
--edit-btn-hover: #ea62ff;
--edit-btn-active: pink;
--sell-btn: #0FDD00;
--sell-btn-hover: #AAFF00;
--sell-btn-active: #00FF00;
--ship-btn: #CB0070;
--ship-btn-hover: cyan;
--ship-btn-active: #00CCEE;
--change-address-btn: salmon;
--change-address-btn-hover: pink;
--change-address-btn-active: white;
--shipping-address-input: #EEEEEE;
--user-registration-box: #d8d8d8;
--user-registration-btn: #A2FF9B;
--user-registration-btn-hover: #rgb(0, 255, 221);
--user-registration-btn-active: #11FF00;
--dropzone-border: #CCCCCC;
--dropzone-background: #F5F5F5;
--dropzone-svg: #AAAAAA;
--dropzone-dragover-border: #737373;
--admin-approve-btn: #52FF5B;
--admin-approve-btn-hover: aqua;
--admin-approve-btn-active: whitesmoke;
--admin-reject-btn: #F43030;
--admin-reject-btn-hover: violet;
--admin-reject-btn-active: black;
--heading: #7C7C7C;
}
body {
background: var(--white);
background: #FFFFFF;
margin-left: auto;
margin-right: auto;
font-family: os;
@ -107,7 +30,7 @@ body {
main {
min-height: calc(100vh - 200px);
min-height: 79.7vh;
/*padding-bottom: 200px;*/
}
@ -115,20 +38,20 @@ footer {
position: absolute;
left: 0;
right: 0;
background-color: var(--footer-background);
background-color: #D8D8D8;
text-align: center;
height: 200px;
font-family: osl;
font-size: 25px;
box-shadow: inset 0px 3px 10px var(--footer-shadow-background);
box-shadow: inset 0px 3px 10px #8A8A8A;
}
footer a {
color: var(--footer-a);
color: #737373;
}
::placeholder {
color: var(--placeholder);
color: #aaaaaa;
font-family: osl;
}
@ -137,137 +60,22 @@ input:focus, textarea:focus, select:focus{
}
.page {
background-color: var(--white);
background-color: white;
}
.navbar {
background-color: var(--white);
height: 60px;
}
.login-prompt a{
float: left;
position: relative;
font-family: osl;
font-size: 23px;
color: var(--uname);
cursor: pointer;
transition: 0.3s;
}
.login-prompt a:hover{
color: var(--red);
}
.login-prompt a:active{
color: var(--violet);
transition: 0.1s;
}
.login-form {
position: absolute;
height: 230px;
width: 230px;
z-index: 3;
top: 45px;
margin-left: 2%;
padding: 10px;
display: block;
border: 0.5px solid var(--input-border);
background-color: var(--white);
box-shadow: 0px 1px 2px var(--input-shadow);
}
.login-form p {
color: var(--search-extra);
font-family: osl;
}
.login-form .login-row {
position: relative;
width: 100%;
display: inline-flex;
height: 30px;
margin-top: 6px;
margin-bottom: 6px;
}
.login-row input {
position: relative;
width: 100%;
padding-left: 5px;
font-family: osl;
font-size: 15px;
border: 0.5px solid var(--input-border);
box-shadow: 0px 2px 3px var(--input-shadow-alt);
}
.login-row button {
margin-left: 7px;
width: 40px;
background-color: var(--login-btn);
border: none;
font-size: 22px;
color: var(--white);
box-shadow: 0px 2px 3px var(--input-shadow);
}
.a-login-btn {
background-image: url("/media/a_big_logon.png") !important;
background-repeat: no-repeat;
background-size: cover;
border: none;
background-position: 50% 50%;
border-radius: 0;
box-shadow: 0px 2px 3px var(--input-shadow);
cursor: pointer;
transition: 0.3s;
}
.a-login-btn:hover {
box-shadow: 0px 2px 3px var(--login-hover);
}
.a-login-btn:active {
box-shadow: 0px 2px 3px var(--red);
transition: 0.1s;
}
.g-login-btn {
background-image: url("/media/g_big_logon.png") !important;
background-repeat: no-repeat;
background-size: cover;
border: none;
border-radius: 5px;
box-shadow: 0px 2px 3px var(--input-shadow);
cursor: pointer;
transition: 0.3s;
}
.g-login-btn:hover {
box-shadow: 0px 2px 3px var(--login-hover);
}
.g-login-btn:active {
box-shadow: 0px 2px 3px var(--login-active);
transition: 0.1s;
}
.fb-login-btn {
background-image: url("/media/fb_big_logon.png") !important;
background-repeat: no-repeat;
background-size: cover;
background-position: 50% 50%;
border: none;
box-shadow: 0px 2px 3px var(--input-shadow);
cursor: pointer;
transition: 0.3s;
}
.fb-login-btn:hover {
box-shadow: 0px 2px 3px var(--login-hover);
}
.fb-login-btn:active {
box-shadow: 0px 2px 3px var(--login-active);
transition: 0.1s;
background-color: white;
height: 55px;
}
.logon-crumbs {
padding-top: 17px;
padding-top: 10px;
padding-bottom: 10px;
display: inline-flex;
}
.logon-crumbs input {
/*display: inline-flex;*/
border: 0.5px solid var(--input-border);
border: 0.5px solid #979797;
float: left;
position: relative;
height: 34px;
@ -277,7 +85,7 @@ input:focus, textarea:focus, select:focus{
/*border: none;*/
font-family: osl;
font-size: 17px;
box-shadow: 0px 2px 3px var(--input-shadow);
box-shadow: 0px 2px 3px #A5A5A5;
}
.user-name {
@ -285,17 +93,17 @@ input:focus, textarea:focus, select:focus{
position: relative;
font-family: osl;
font-size: 23px;
color: var(--uname);
color: #898989;
cursor: pointer;
transition: 0.3s;
}
.user-name:hover {
color: var(--red);
color: red;
}
.user-name:active {
transition: 0.1s;
color: var(--light-gray);
color: #F0F0F0;
}
@ -309,14 +117,14 @@ input:focus, textarea:focus, select:focus{
}
.btn-login {
background-color: var(--login-btn);
background-color: #3D10FF;
font-size: 30px;
color: var(--white);
box-shadow: 0px 2px 3px var(--input-shadow);
color: white;
box-shadow: 0px 2px 3px #A5A5A5;
}
.btn-g-login {
background-color: var(--google-login-btn);
background-color: #cacaca;
border-radius: 5px;
}
@ -326,13 +134,13 @@ input:focus, textarea:focus, select:focus{
}
.btn-login:hover {
color: var(--red);
color: red;
transition: 0.3s;
cursor: pointer;
}
.btn-g-login:hover {
box-shadow: 0px 2px 3px var(--google-login-btn-hover);
box-shadow: 0px 2px 3px #A5A5A5;
transition: 0.3s;
cursor: pointer;
}
@ -340,28 +148,28 @@ input:focus, textarea:focus, select:focus{
.btn-fb-login {
transition: 0.3s;
cursor: pointer;
background-color: var(--white);
background-color: white;
border-radius: 20px;
}
.btn-fb-login:hover {
box-shadow: 0px 2px 3px var(--google-login-btn-hover);
box-shadow: 0px 2px 3px #A5A5A5;
transition: 0.3s;
cursor: pointer;
}
.btn-fb-login:active {
box-shadow: 0px 2px 3px var(--red);
box-shadow: 0px 2px 3px red;
transition: 0.1s;
}
.btn-login:active {
color: var(--white);
color: white;
transition: 0.1s;
}
.btn-g-login:active {
box-shadow: 0px 2px 3px var(--red);
box-shadow: 0px 2px 3px red;
transition: 0.1s;
}
@ -369,14 +177,12 @@ input:focus, textarea:focus, select:focus{
float: right;
position: relative;
display: inline-flex;
padding-top: 20px;
padding-bottom: 10px;
/* bottom: 10%; */
bottom: 10%;
font-family: osl
}
.add-item a {
color: var(--add-item-btn);
color: #ff6619;
font-family: osl;
font-size: 30px;
padding-left: 10px;
@ -385,38 +191,38 @@ input:focus, textarea:focus, select:focus{
}
.add-item a:hover {
color: var(--add-item-btn-hover);
color: #c41000;
transition: 0.3s;
}
.add-item a:active {
color: var(--add-item-btn-active);
color: #BBBBBB;
transition: 0.1s;
}
.notifications {
padding-right: 15px;
color: var(--notifications);
color: #898989;
transition: 0.3s;
}
.notifications:hover {
color: var(--notifications-hover);
color: tomato;
}
.notifications:active {
transition: 0.1s;
color: var(--notifications-active);
color: cyan;
}
.cart {
color: var(--notifications);
color: #898989;
transition: 0.3s;
}
.cart:hover {
color: var(--notifications-hover);
color: tomato;
}
.cart:active {
transition: 0.1s;
color: var(--notifications-active);
color: cyan;
}
.sbar {
@ -436,7 +242,8 @@ input:focus, textarea:focus, select:focus{
}
.sbar input {
border: 0.5px solid var(--input-border);
border: 0.5px solid gray;
display: inline-flex;
position: relative;
float: left;
height: 34px;
@ -444,16 +251,20 @@ input:focus, textarea:focus, select:focus{
padding-left: 10px;
font-family: osl;
font-size: 17px;
box-shadow: 0px 3px 4px var(--input-shadow);
box-shadow: 0px 3px 4px #A5A5A5;
/*position: absolute;
left: 50%;
transform: translate(-50%, 0);*/
}
.sbar button {
position: relative;
float: left;
background-color: var(--search-btn-background);
background-color: #5359FF;
border: none;
box-shadow: 0px 2px 3px var(--input-shadow);
color: var(--search-btn);
box-shadow: 0px 2px 3px #A5A5A5;
color: #C4C4C4;
height: 35px;
width: 100px;
margin-left: 20px;
@ -463,19 +274,19 @@ input:focus, textarea:focus, select:focus{
}
.sbar button:hover {
background-color: var(--violet);
background-color: violet;
transition: 0.2s;
}
.sbar button:active {
background-color: var(--whitesmoke);
background-color: whitesmoke;
transition: 0.2s;
}
.sbar a {
position: relative;
float: left;
color: var(--search-extra);
color: #7F7F7F;
font-family: osl;
font-size: 14px;
margin-left: 15px;
@ -483,7 +294,7 @@ input:focus, textarea:focus, select:focus{
}
.space {
height: 25px;
height: 15px;
}
.welcome img {
@ -493,30 +304,11 @@ input:focus, textarea:focus, select:focus{
.products p {
font-family: osl;
font-size: 25px;
color: var(--heading);
color: #7C7C7C;
margin-bottom: 10px;
margin-top: 10px;
}
.profile a {
font-family: osl;
font-size: 25px;
color: var(--product-page-info-btn);
margin-bottom: 20px;
margin-top: 20px;
cursor: pointer;
transition: 0.3s;
}
.profile a:hover {
color: var(--violet);
}
.profile a:active {
color: var(--white);
transition: 0.1s;
}
.product-list-container {
display: flex;
justify-content: space-between;
@ -536,7 +328,7 @@ input:focus, textarea:focus, select:focus{
.product-container p {
font-family: nunito;
color: var(--product-container-p);
color: #CA5555;
font-size: 17px;
}
@ -568,7 +360,7 @@ input:focus, textarea:focus, select:focus{
margin-right: 10%;
margin-top: 5px;
font-size: 19px;
color: var(--footer-a);
color: #737373;
}
.user-logout {
@ -578,12 +370,12 @@ input:focus, textarea:focus, select:focus{
position: relative;
font-family: osl;
font-size: 13px;
color: var(--user-logout);
color: #393939;
cursor: pointer;
}
.user-logout:hover {
color: var(--red);
color: red;
transition: 0.3s;
}
@ -594,7 +386,7 @@ input:focus, textarea:focus, select:focus{
}
.user-auth-message p {
color: var(--red);
color: red;
font-size: 30px;
}
@ -608,13 +400,13 @@ input:focus, textarea:focus, select:focus{
.new-product-field p {
font-size: 25px;
color: var(--new-product-field-p);
color: #898989;
padding-bottom: 20px;
}
.new-product-field label {
font-size: 20px;
color: var(--new-product-field-p);
color: #898989;
display: inline-block;
}
@ -626,7 +418,7 @@ input:focus, textarea:focus, select:focus{
padding-left: 10px;
margin-bottom: 15px;
border-radius: 0;
border: 0.5px solid var(--gray);
border: 0.5px solid grey;
cursor: text;
}
@ -639,7 +431,7 @@ input:focus, textarea:focus, select:focus{
padding-top: 10px;
margin-bottom: 15px;
border-radius: 0;
border: 0.5px solid var(--gray);
border: 0.5px solid grey;
cursor: text;
}
@ -649,26 +441,26 @@ input:focus, textarea:focus, select:focus{
display: block;
font-size: 19px;
font-family: osl;
box-shadow: 0px 2px 3px var(--input-shadow);
box-shadow: 0px 2px 3px #A5A5A5;
margin-bottom: 15px;
border-radius: 0;
border: none;
background-color: var(--new-product-field-btn);
background-color: #30a8ff;
transition: 0.3s;
}
.new-product-field button:hover {
transition: 0.3s;
background-color: var(--new-product-field-btn-hover);
background-color: #ff7700;
}
.new-product-field button:active {
transition: 0.1s;
background-color: var(--new-product-field-btn-active);
background-color: #ffaf69;
}
.new-product-field button:disabled {
background-color: var(--new-product-field-btn-disabled);
background-color: #b9b9b9;
}
.n-p-left {
@ -693,7 +485,7 @@ input:focus, textarea:focus, select:focus{
position: relative;
font-family: osl;
font-size: 20px;
color: var(--green);
color: green;
left: 50%;
transform: translate(-10%, 0);
}
@ -706,7 +498,7 @@ input:focus, textarea:focus, select:focus{
position: relative;
width: 100%;
font-family: osl;
color: var(--product-page-info-container);
color: #5E5E5E;
display: inline-flex;
}
.product-page-img {
@ -730,22 +522,22 @@ input:focus, textarea:focus, select:focus{
display: block;
font-size: 19px;
font-family: osl;
box-shadow: 0px 2px 3px var(--input-shadow);
box-shadow: 0px 2px 3px #A5A5A5;
border-radius: 0;
border: none;
background-color: var(--product-page-info-btn);
background-color: #30a8ff;
transition: 0.3s;
}
.product-page-info button:hover {
transition: 0.3s;
background-color: var(--product-page-info-hover);
background-color: #ffc04b;
}
.product-page-info button:active {
transition: 0.1s;
background-color: var(--product-page-info-active);
background-color: #ffaf69;
}
.product-page-info button:disabled {
background-color: var(--product-page-info-disabled);
background-color: #b9b9b9;
}
.product-page-info h2 {
font-size: 30px;
@ -764,7 +556,7 @@ input:focus, textarea:focus, select:focus{
margin-bottom: -10px;
font-family: osl;
border-radius: 0;
border: 0.5px solid var(--gray);
border: 0.5px solid grey;
}
.product-page-description {
@ -773,7 +565,7 @@ input:focus, textarea:focus, select:focus{
.product-page-description p {
font-family: osl;
font-size: 20px;
color: var(--product-page-info-container);
color: #5E5E5E;
}
.my-products-container {
@ -801,7 +593,7 @@ input:focus, textarea:focus, select:focus{
}
.my-product-details-container p {
font-family: nunito;
color: var(--my-product-details-container);
color: #CA5555;
font-size: 25px;
width: 100%;
}
@ -819,7 +611,7 @@ input:focus, textarea:focus, select:focus{
}
.purchase-message {
color: var(--purchase-msg);
color: #00df90;
text-align: center;
font-size: 25px;
font-family: osl;
@ -827,7 +619,7 @@ input:focus, textarea:focus, select:focus{
}
.error-message {
color: var(--error-msg);
color: #df0000;
text-align: center;
font-size: 25px;
font-family: osl;
@ -844,7 +636,7 @@ input:focus, textarea:focus, select:focus{
display: block;
font-size: 19px;
font-family: osl;
box-shadow: 0px 2px 3px var(--input-shadow);
box-shadow: 0px 2px 3px #A5A5A5;
border-radius: 0;
border: none;
transition: 0.3s;
@ -902,41 +694,41 @@ input:focus, textarea:focus, select:focus{
border: 0;
height: 40px;
width: 350px;
background-color: var(--change-address-btn);
background-color: salmon;
font-family: osl;
font-size: 20px;
left: 50%;
transform: translate(-50%, 0);
transition: 0.3s;
color: white;
box-shadow: 0px 2px 3px var(--input-shadow);
box-shadow: 0px 2px 3px #A5A5A5;
}
.ship-adress button:hover {
background-color: var(--change-address-btn-hover);
background-color: pink;
color: black;
}
.ship-adress button:active {
transition: 0.1s;
background-color: var(--change-address-btn-active);
background-color: white;
}
.ship-adress input {
position: relative;
border: 0;
height: 40px;
width: 600px;
background-color: var(--shipping-address-input);
background-color: #EEEEEE;
font-family: osl;
font-size: 20px;
left: 50%;
transform: translate(-50%, 0);
color: var(--black);
box-shadow: 0px 2px 3px var(--input-border);
color: black;
box-shadow: 0px 2px 3px #A5A5A5;
padding-left: 10px;
}
.big-box {
height: 35px;
background-color: var(--user-registration-box);
background-color: #d8d8d8d8;
margin-top: 10px;
width: 100%;
}
@ -948,7 +740,7 @@ input:focus, textarea:focus, select:focus{
.small-box {
height: 35px;
background-color: var(--user-registration-box);
background-color: #d8d8d8d8;
}
.u-r-title {
@ -980,7 +772,7 @@ input:focus, textarea:focus, select:focus{
padding-left: 10px;
margin: 15px 0;
border-radius: 0;
border: 0.5px solid var(--input-border);
border: 0.5px solid grey;
}
.u-r-i-location input {
width: 90%;
@ -1008,21 +800,21 @@ input:focus, textarea:focus, select:focus{
display: block;
font-size: 19px;
font-family: osl;
box-shadow: 0px 2px 3px var(--input-shadow);
box-shadow: 0px 2px 3px #A5A5A5;
border-radius: 0;
transition: 0.3s;
margin: 10px auto;
background-color: var(--user-registration-btn-background);
color: var(--input);
background-color: #A2FF9B;
color: #727272;
}
.u-r-btn button:hover {
background-color: var(--user-registration-btn-hover);
background-color: rgb(0, 255, 221);
}
.u-r-btn button:active {
background-color: var(--user-registration-btn-active);
color: var(--input);
background-color: #11FF00;
color: white;
transition: 0.1s;
}
@ -1031,8 +823,8 @@ input:focus, textarea:focus, select:focus{
height: 70%;
margin-left: auto;
margin-right: 0;
border: 2px dashed var(--dropzone-border);
background: var(--dropzone-background);
border: 2px dashed #CCCCCC;
background: #F5F5F5;
transition: 0.2s;
}
.dropzone svg{
@ -1040,14 +832,14 @@ input:focus, textarea:focus, select:focus{
left: 50%;
top: 40%;
transform: translate(-50%);
fill: var(--dropzone-svg);
fill: #AAAAAA;
}
.dropzone.dragover {
border: 2px dashed var(--dropzone-dragover-border);
background-color: var(--dropzone-svg);
border: 2px dashed #737373;
background-color: #AAAAAA;
}
.dropzone.dragover svg{
fill: var(--whitesmoke);
fill: whitesmoke;
}
.dropzone img {
position: relative;
@ -1061,19 +853,19 @@ input:focus, textarea:focus, select:focus{
display: block;
font-size: 19px;
font-family: osl;
box-shadow: 0px 2px 3px var(--input-shadow);
box-shadow: 0px 2px 3px #A5A5A5;
margin-bottom: 0;
margin-top: -13px;
border-radius: 0;
border: none;
background-color: var(--admin-approve-btn);
background-color: #52FF5B;
transition: 0.3s;
}
.admin-approve:hover {
background-color: var(--admin-approve-btn-hover);
background-color: aqua;
}
.admin-approve:active {
background-color: var(--admin-approve-btn-active);
background-color: whitesmoke;
transition: 0.1s;
}
@ -1083,20 +875,20 @@ input:focus, textarea:focus, select:focus{
display: block;
font-size: 19px;
font-family: osl;
box-shadow: 0px 2px 3px var(--input-shadow);
box-shadow: 0px 2px 3px #A5A5A5;
margin-bottom: 0;
margin-top: -13px;
border-radius: 0;
border: none;
background-color: var(--admin-reject-btn);
background-color: #F43030;
transition: 0.3s;
}
.admin-reject:hover {
background-color: var(--admin-reject-btn-hover);
background-color: violet;
}
.admin-reject:active {
background-color: var(--admin-reject-btn-active);
color: var(--white);
background-color: black;
color: white;
transition: 0.1s;
}
@ -1122,5 +914,4 @@ input:focus, textarea:focus, select:focus{
background: rgb(20, 20, 20);
box-shadow: none;
}
} */
} */

0
functions/views/edit-item.ejs Executable file → Normal file
View File

101
functions/views/home.ejs Executable file → Normal file
View File

@ -6,36 +6,85 @@
<div class="space"></div>
<div class="products">
<p>Recently Added:</p>
<!-- GET LIST OF LISTS -->
<%
let productKeys = Object.keys(products)
let p1 = productKeys.slice(0,5)
let p2 = productKeys.slice(5,10)
let p3 = productKeys.slice(10,15)
let p4 = productKeys.slice(15,20)
let p5 = productKeys.slice(20,25)
let productListArray = [p1, p2, p3, p4, p5]
%>
<% productListArray.forEach(rowKeys=>{%>
<div class="product-list-container">
<% rowKeys.forEach(function(key){ %>
<div class="product-container">
<a href="product?productid=<%=key%>">
<img class="dyn-img" title="<%= products[key].img %>" alt="img" src="media/var.png">
</a>
<p class="l"><%= products[key].name%></p>
<p class="r">£ <%= products[key].price%></p>
</div>
<% }) %>
<p>Recent:</p>
<div class="product-list-container">
<% var keys = Object.keys(products) %>
<% keys.forEach(function(key){ %>
<div class="product-container">
<a href="product?productid=<%=key%>">
<img class="dyn-img" title="<%= products[key].img %>" alt="img" src="media/var.png">
</a>
<p class="l"><%= products[key].name%></p>
<p class="r">£ <%= products[key].price%></p>
</div>
<div class="space"></div>
<% }) %>
</div>
</div>
<div class="products">
<p>Personalised 1:</p>
<div class="product-list-container">
<div class="product-container">
<a href="#"><img src="media/var.png" alt="img"></a>
<p class="l"><%= "Item name"%></p>
<p class="r">£ <%= "20.99"%></p>
</div>
<div class="product-container">
<a href="#"><img src="media/var.png" alt="img"></a>
<p class="l"><%= "Item name"%></p>
<p class="r">£ <%= "20.99"%></p>
</div>
<div class="product-container">
<a href="#"><img src="media/var.png" alt="img"></a>
<p class="l"><%= "Item name"%></p>
<p class="r">£ <%= "20.99"%></p>
</div>
<div class="product-container">
<a href="#"><img src="media/var.png" alt="img"></a>
<p class="l"><%= "Item name"%></p>
<p class="r">£ <%= "20.99"%></p>
</div>
<div class="product-container">
<a href="#"><img src="media/var.png" alt="img"></a>
<p class="l"><%= "Item name"%></p>
<p class="r">£ <%= "20.99"%></p>
</div>
</div>
</div>
<div class="products">
<p>Personalised 2:</p>
<div class="product-list-container">
<div class="product-container">
<a href="#"><img src="media/var.png" alt="img"></a>
<p class="l"><%= "Item name"%></p>
<p class="r">£ <%= "20.99"%></p>
</div>
</div>
</div>
<div class="products">
<p>Personalised 3:</p>
<div class="product-list-container">
<div class="product-container">
<a href="#"><img src="media/var.png" alt="img"></a>
<p class="l"><%= "Item name"%></p>
<p class="r">£ <%= "20.99"%></p>
</div>
</div>
</div>
<div class="products">
<p>Recent:</p>
<div class="product-list-container">
<div class="product-container">
<a href="#"><img src="media/var.png" alt="img"></a>
<p class="l"><%= "Item name"%></p>
<p class="r">£ <%= "20.99"%></p>
</div>
</div>
</div>
<div class="space"></div>
</div>

2
functions/views/js/fAuth.js Executable file → Normal file
View File

@ -1 +1 @@
function checkAuth(){firebase.auth().onAuthStateChanged(function(e){if(e){if("dev@dev.dev"==e.email)try{document.getElementById("admin").setAttribute("style","display: block;")}catch(e){}try{document.getElementById("uname-dom").innerHTML="Loading...",document.getElementById("login-form").setAttribute("style","display: none;")}catch(e){}firebase.auth().currentUser.getIdToken().then(function(e){let t={uToken:e},n={method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json"}};fetch("login-user-api",n).then(e=>e.json()).then(function(e){if(1==e.success)if(e.registered)document.getElementById("uname-dom").innerHTML="Hello, "+e.name;else{try{document.getElementById("uname-dom").innerHTML="Unregistered!",document.getElementById("notifications").innerHTML="🔔 | Register your account",document.getElementById("notifications").setAttribute("href","registration"),document.getElementById("notifications").setAttribute("style","color: red;")}catch(e){}"registration"!=window.location.href.split("/").pop()&&window.location.replace("registration")}else console.log(e.error),document.getElementById("notifications").innerHTML="🔔 | What the fuck just happened.....",document.getElementById("notifications").setAttribute("style","color: pink;")})});try{document.getElementById("uname-field").setAttribute("style","display: block;"),document.getElementById("login-field").setAttribute("style","display: none;")}catch(e){}try{document.getElementById("uAuthMsg").setAttribute("style","display: none;")}catch(e){}try{document.getElementById("authField").setAttribute("style","display: block;")}catch(e){}}else{document.getElementById("uname-field").setAttribute("style","display: none;"),document.getElementById("login-field").setAttribute("style","display: block;"),document.getElementById("uname-dom").innerHTML="Unregistered";try{document.getElementById("uAuthMsg").setAttribute("style","display: block;")}catch(e){}try{document.getElementById("authField").setAttribute("style","display: none;")}catch(e){}}})}function loginFormListener(){let e=document.getElementById("login-form");document.addEventListener("click",function(t){try{var n=e.contains(t.target);"login-form-btn"==t.target.id||n||document.getElementById("login-form").setAttribute("style","display: none;")}catch(e){}},!1)}function login_form(){document.getElementById("login-form").setAttribute("style","display: block;"),document.getElementById("fuid").focus()}function admin_review(){firebase.auth().currentUser.getIdToken().then(function(e){window.location.replace("admin-review?authToken="+e)})}function signinwithgoogle(){var e=new firebase.auth.GoogleAuthProvider;firebase.auth().signInWithPopup(e).then(function(e){console.log("User signed in...")}).catch(function(e){console.log(e)})}function signinwithapple(){console.log("Coming later!")}function signinwithfb(){var e=new firebase.auth.FacebookAuthProvider;firebase.auth().signInWithPopup(e).then(function(e){console.log("User signed in...")}).catch(function(e){console.log(e)})}function signinwithemail(){const e=document.getElementById("fuid"),t=document.getElementById("fpwd");var n=e.value,i=t.value;firebase.auth().signInWithEmailAndPassword(n,i).catch(e=>console.log(e.message)).then(function(n){t.value="",e.value=""})}function signout(){firebase.auth().signOut(),window.location.replace("home")}checkAuth(),loginFormListener();try{var pwField=document.getElementById("fpwd");pwField.addEventListener("keyup",function(e){13===e.keyCode&&(e.preventDefault(),document.getElementById("blogin").click())})}catch(e){}
function checkAuth(){firebase.auth().onAuthStateChanged(function(e){if(e){if("dev@dev.dev"==e.email)try{document.getElementById("admin").setAttribute("style","display: block;")}catch(e){}try{document.getElementById("uname-dom").innerHTML="Loading..."}catch(e){}firebase.auth().currentUser.getIdToken().then(function(e){let t={uToken:e},n={method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json"}};fetch("login-user-api",n).then(e=>e.json()).then(function(e){if(1==e.success)if(e.registered)document.getElementById("uname-dom").innerHTML="Hello, "+e.name;else{try{document.getElementById("uname-dom").innerHTML="Unregistered!",document.getElementById("notifications").innerHTML="🔔 | Register your account",document.getElementById("notifications").setAttribute("href","registration"),document.getElementById("notifications").setAttribute("style","color: red;")}catch(e){}"registration"!=window.location.href.split("/").pop()&&window.location.replace("registration")}else console.log(e.error),document.getElementById("notifications").innerHTML="🔔 | What the fuck just happened.....",document.getElementById("notifications").setAttribute("style","color: pink;")})});try{document.getElementById("uname-field").setAttribute("style","display: block;"),document.getElementById("login-field").setAttribute("style","display: none;"),document.getElementById("uname-field").setAttribute("style","display: block;"),document.getElementById("login-field").setAttribute("style","display: none;")}catch(e){}try{document.getElementById("uAuthMsg").setAttribute("style","display: none;")}catch(e){}try{document.getElementById("authField").setAttribute("style","display: block;")}catch(e){}}else{document.getElementById("uname-field").setAttribute("style","display: none;"),document.getElementById("login-field").setAttribute("style","display: block;"),document.getElementById("uname-dom").innerHTML="Unregistered";try{document.getElementById("uAuthMsg").setAttribute("style","display: block;")}catch(e){}try{document.getElementById("authField").setAttribute("style","display: none;")}catch(e){}}})}function admin_review(){firebase.auth().currentUser.getIdToken().then(function(e){window.location.replace("admin-review?authToken="+e)})}function signinwithgoogle(){var e=new firebase.auth.GoogleAuthProvider;firebase.auth().signInWithPopup(e).then(function(e){console.log("User signed in...")}).catch(function(e){console.log(e)})}function signinwithfb(){var e=new firebase.auth.FacebookAuthProvider;firebase.auth().signInWithPopup(e).then(function(e){console.log("User signed in...")}).catch(function(e){console.log(e)})}function signinwithemail(){const e=document.getElementById("fuid"),t=document.getElementById("fpwd");var n=e.value,i=t.value;firebase.auth().signInWithEmailAndPassword(n,i).catch(e=>console.log(e.message)).then(function(n){t.value="",e.value=""})}function signout(){firebase.auth().signOut(),window.location.replace("home")}checkAuth();try{var pwField=document.getElementById("fpwd");pwField.addEventListener("keyup",function(e){13===e.keyCode&&(e.preventDefault(),document.getElementById("blogin").click())})}catch(e){}

38
functions/views/js/fAuth.src.js Executable file → Normal file
View File

@ -1,15 +1,15 @@
// @ts-nocheck
function checkAuth(){
firebase.auth().onAuthStateChanged(function(user){
if (user) {
if (user.email == "dev@dev.dev") {
try {document.getElementById('admin').setAttribute('style', 'display: block;')}
try {
document.getElementById('admin').setAttribute('style', 'display: block;')
}
catch(error){}
}
try {
document.getElementById('uname-dom').innerHTML = "Loading..."
document.getElementById('login-form').setAttribute("style", "display: none;")
}catch(error){}
try {document.getElementById('uname-dom').innerHTML = "Loading..."}
catch(error){}
firebase.auth().currentUser.getIdToken().then(function(idToken) {
let url = 'login-user-api'
@ -44,6 +44,9 @@ function checkAuth(){
try {
document.getElementById('uname-field').setAttribute("style", "display: block;")
document.getElementById('login-field').setAttribute("style", "display: none;")
document.getElementById('uname-field').setAttribute("style", "display: block;")
document.getElementById('login-field').setAttribute("style", "display: none;")
}
catch(error) {}
try {document.getElementById('uAuthMsg').setAttribute("style", "display: none;")}
@ -62,26 +65,9 @@ function checkAuth(){
}
})
}
checkAuth()
function loginFormListener() {
let loginForm = document.getElementById('login-form');
document.addEventListener('click', function (event) {
try{
var isClickInside = loginForm.contains(event.target);
if (event.target.id != "login-form-btn" && !isClickInside) {
document.getElementById('login-form').setAttribute("style", "display: none;")
}
}catch(err){}
}, false)
}
loginFormListener()
function login_form() {
document.getElementById('login-form').setAttribute("style", "display: block;")
document.getElementById("fuid").focus()
}
function admin_review() {
firebase.auth().currentUser.getIdToken().then(function(idToken) {
window.location.replace("admin-review?authToken="+idToken)
@ -100,10 +86,6 @@ function signinwithgoogle(){
})
}
function signinwithapple(){
console.log("Coming later!")
}
function signinwithfb(){
var fbAuthProvider = new firebase.auth.FacebookAuthProvider()
firebase.auth().signInWithPopup(fbAuthProvider)

0
functions/views/js/fdb.js Executable file → Normal file
View File

1
functions/views/js/fdb.src.js Executable file → Normal file
View File

@ -1,5 +1,4 @@
// https://javascript-minifier.com
// @ts-nocheck
function checkFields() {
if (document.getElementById('pName').value && document.getElementById('pDesc').value
&& document.getElementById('pLoc').value && document.getElementById('pPrice').value

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

0
functions/views/media/gg_logo.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

0
functions/views/media/noimage.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 29 KiB

0
functions/views/media/profile.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 40 KiB

0
functions/views/media/welcome.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

6
functions/views/my-product.ejs Executable file → Normal file
View File

@ -14,15 +14,15 @@
<p>Price: £<%= item.price %></p>
<div class="product-mgmt-buttons">
<% var editbtnStyle = ""%>
<% if (item.status == "on-sale" || item.status == "off-sale") {editbtnStyle = "visibility:all;"} else {editbtnStyle = "visibility:hidden;"}%>
<% if (item.status == "sold") {editbtnStyle = "visibility:hidden;"} else {editbtnStyle = "visibility:all;"}%>
<div class="edit-btn" style=<%= editbtnStyle%>><button onclick={edit_item()} id="editBtn">Edit</button> </div>
<% var sellbtnText = "Place On Sale"%>
<% var salebtnStyle = "visibility:hidden"%>
<% if (item.status == "on-sale" || item.status == "off-sale") {salebtnStyle = "visibility:all;"}%>
<% if (item.status != "sold") {salebtnStyle = "visibility:all;"}%>
<% if (item.status == "on-sale") {sellbtnText = "Take Off Sale"}%>
<div class="sell-btn" style="<%= salebtnStyle%>"><button onclick={toggle_sale()} id="toggleSaleBtn"><%= sellbtnText%></button> </div>
<% var shipbtnStyle = ""%>
<% if (item.status != "on-sale") {shipbtnStyle = "visibility:hidden;"} else {shipbtnStyle = "visibility:all;"}%>
<% if (item.status == "sold") {shipbtnStyle = "visibility:hidden;"} else {shipbtnStyle = "visibility:all;"}%>
<div class="ship-btn" style=<%= shipbtnStyle%>><button onclick={mark_as_sold()} id="soldBtn">Mark Sold</button> </div>
</div>
</div>

4
functions/views/my-products.ejs Executable file → Normal file
View File

@ -8,10 +8,6 @@
<div class="space"></div>
<div class="profile">
<a href="user-profile?dbid=<%= dbid %>">My Profile</a>
</div>
<div class="products">
<p>My products:</p>
<div class="my-products-container">

2
functions/views/partials/footer.ejs Executable file → Normal file
View File

@ -13,7 +13,7 @@
<a class="link" href="#">Cookies</a>
</div>
<div class="location">
GG Sales UK 🇬🇧
GG Sales US 🇺🇸
</div>
</footer>
<script src="js/fAuth.js"></script>

35
functions/views/partials/header.ejs Executable file → Normal file
View File

@ -16,43 +16,25 @@
<script src="https://www.gstatic.com/firebasejs/7.14.1/firebase-storage.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.14.1/firebase-database.js"></script>
<script src="js/fInit.js"></script>
<script async src="https://www.googletagmanager.com/gtag/js?id=G-6PZS01KZYB"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-6PZS01KZYB');
</script>
</head>
<body>
<main>
<div class="page">
<div class="navbar">
<div class="login-form" id="login-form" style="display:none;">
<p>Login:</p>
<button id="blogin_a" onclick={signinwithapple()} class="a-login-btn login-row"></button>
<button id="blogin_g" onclick={signinwithgoogle()} class="g-login-btn login-row"></button>
<button id="blogin_f" onclick={signinwithfb()} class="fb-login-btn login-row"></button>
<div class="login-row">
<input id="fuid" type="text" placeholder="Username">
</div>
<div class="login-row">
<input id="fpwd" type="password" placeholder="Password">
<button id="blogin" onclick={signinwithemail()} class="login-btn">&#x27a4;</button>
</div>
</div>
<div class="logon-crumbs">
<div id="uname-field" style="display: block;">
<div id="uname-field" style="display: none;">
<a id="uname-dom" class="user-name" href="javascript:;" onclick="my_products();">Unregistered user</a>
<div class="user-logout">
<a onclick={signout()}>Log out</a>
</div>
</div>
<div id="login-field" class="login-prompt" style="display: none;">
<a href="javascript:;" id="login-form-btn" onclick="login_form();">Hi There, Login?</a>
<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">
@ -76,11 +58,10 @@
</div>
</div>
</div>
<div class="sbar">
<img src="media/gg_logo.png" onclick={window.location.replace('home')} alt="img">
<input id="sfield" type="text" name="search" placeholder="I Want...">
<input id="sfield" type="text" placeholder="I Want...">
<button id="sbutton" onclick={bSearch()}>Go!</button>
<a href="#">Extras</a>
</div>

0
functions/views/product.ejs Executable file → Normal file
View File

0
functions/views/search.ejs Executable file → Normal file
View File

0
functions/views/user-profile.ejs Executable file → Normal file
View File

0
functions/views/user-registration.ejs Executable file → Normal file
View File

12841
package-lock.json generated Executable file → Normal file

File diff suppressed because it is too large Load Diff

1
package.json Executable file → Normal file
View File

@ -14,7 +14,6 @@
"license": "ISC",
"dependencies": {
"body-parser": "^1.19.0",
"cookie-parser": "^1.4.5",
"ejs": "^3.1.2",
"express": "^4.17.1",
"firebase": "^7.14.3",

35
server.js Executable file → Normal file
View File

@ -16,10 +16,6 @@ app.use(bodyParser.json())
app.use(logger('dev'))
app.use(express.static('views'))
const cookieParser = require('cookie-parser')();
app.use(cookieParser);
app.set('view engine', 'ejs')
app.set('views', __dirname + '/views')
@ -33,15 +29,6 @@ let transporter = nodemailer.createTransport({
})
const validateFirebaseIdToken = (req, res, next) => {
console.log("Running pre-function")
console.log(req.cookies); //// <----- issue this is empty {} why??
console.log("Finished pre function")
next();
};
app.use(validateFirebaseIdToken)
app.get("/", function(request, responce) {
homePage(request, responce)
})
@ -52,7 +39,7 @@ app.get("/home", function(request, responce) {
function homePage(request, responce) {
var dbRef = database.ref("/products")
dbRef.orderByChild("status").equalTo("on-sale").limitToLast(25).once('value', function(snapshot){
dbRef.orderByChild("status").equalTo("on-sale").limitToLast(5).once('value', function(snapshot){
var data = {}
if (snapshot.val()) {data = snapshot.val()}
responce.render('home.ejs', {products: data})
@ -128,16 +115,10 @@ app.get('/my-products', function(request, responce){
})
}
else {
let usersRef = database.ref("/users")
usersRef.orderByChild("UID").equalTo(uid).once('value', function(snapshot){
vals = snapshot.val()
var keys = Object.keys(vals)
sellerDBID = keys[0]
dbRef.orderByChild('owner').equalTo(uid).once('value', function(snapshot){
var data = {'x': {holder: '',id: 999,img: '',location: '',name: 'No products listed 😢',owner: '',price: '',stock: ''}}
if (snapshot.val()) {data = snapshot.val()}
responce.render('my-products.ejs', {products: data, dbid:sellerDBID})
})
dbRef.orderByChild('owner').equalTo(uid).once('value', function(snapshot){
var data = {'x': {holder: '',id: 999,img: '',location: '',name: 'No products listed 😢',owner: '',price: '',stock: ''}}
if (snapshot.val()) {data = snapshot.val()}
responce.render('my-products.ejs', {products: data})
})
}
})
@ -268,7 +249,7 @@ app.get('/user-profile', function(request, responce){
return allProductsDict[obj].status == 'on-sale';
})
let filteredProducts = {"0":{img: '',name: 'Nothing listed 😢',price: ''}}
filteredKeys.forEach(function(key){filteredProducts[key] = allProductsDict[key]})
if (Object.keys(filteredProducts).length > 1) {delete filteredProducts["0"]}
@ -755,8 +736,8 @@ app.post('*', function(request, responce){
responce.status(404).send({success:false, error:"404"})
})
var port = 5001
var port = 5000
app.listen(port, function() {
console.log('Server running on port ' + port)
})
})