notherbase-fs 1.1.32 → 1.1.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,26 +1,32 @@
1
- const User = require("../models/user.js");
1
+ const { user, connectionSuccess } = require("../models");
2
2
 
3
3
  const authCheck = async function authCheck(req, res, next){
4
- try {
5
- if (req.session.currentUser) {
6
- const foundAccount = await User.findById(req.session.currentUser);
7
-
8
- if (foundAccount) {
9
- req.session.currentUserFull = foundAccount;
10
- next();
4
+ if (connectionSuccess) {
5
+ try {
6
+ if (req.session.currentUser) {
7
+ const foundAccount = await user.findById(req.session.currentUser);
8
+
9
+ if (foundAccount) {
10
+ req.session.currentUserFull = foundAccount;
11
+ next();
12
+ }
13
+ else {
14
+ req.session.currentUserFull = null;
15
+ res.redirect("/the-front");
16
+ }
11
17
  }
12
- else {
13
- req.session.currentUserFull = null;
18
+ else{
14
19
  res.redirect("/the-front");
15
20
  }
16
21
  }
17
- else{
18
- res.redirect("/the-front");
22
+ catch(err) {
23
+ console.log("database error");
24
+ console.log(err);
19
25
  }
20
26
  }
21
- catch(err) {
22
- console.log("database error");
23
- console.log(err);
27
+ else {
28
+ console.log("AuthCheck failed: not connected to db");
29
+ res.redirect("/the-front");
24
30
  }
25
31
  }
26
32
 
@@ -2,101 +2,111 @@ const express = require("express");
2
2
  const router = express.Router();
3
3
 
4
4
  // Import my Data
5
- const inventory = require("../models/inventory");
6
- const item = require("../models/item");
5
+ const { inventory, item, connectionSuccess } = require("../models");
7
6
 
8
7
  router.get("/", async function(req, res) {
9
- try {
10
- if (req.session.currentUserFull) {
11
- let foundInventory = await inventory.findOne({user: req.session.currentUser}).populate("items.item");
12
-
13
- res.status(200).send({ foundInventory: foundInventory });
8
+ if (connectionSuccess) {
9
+ try {
10
+ if (req.session.currentUserFull) {
11
+ let foundInventory = await inventory.findOne({user: req.session.currentUser}).populate("items.item");
12
+
13
+ res.status(200).send({ foundInventory: foundInventory });
14
+ }
15
+ else {
16
+ res.status(401).end();
17
+ }
14
18
  }
15
- else {
16
- res.status(401).end();
19
+ catch(err) {
20
+ console.log(err);
21
+ res.status(500).end();
17
22
  }
18
23
  }
19
- catch(err) {
20
- console.log(err);
24
+ else {
25
+ res.status(500).end();
21
26
  }
22
27
  });
23
28
 
24
29
  router.post("/", async function(req, res) {
25
- try {
26
- if (req.session.currentUserFull) {
27
- let foundInventory = await inventory.findOne({user: req.session.currentUser}).populate("items.item");
28
-
29
- let holding = false;
30
-
31
- for (let j = 0; j < foundInventory.items.length; j++) {
32
- if (foundInventory.items[j].item._id.equals(req.body.change.item)) {
33
- holding = true;
34
-
35
- if (foundInventory.items[j].amount >= -Math.floor(req.body.change.amount)) {
36
- foundInventory.items[j].amount += Math.floor(req.body.change.amount);
37
-
38
- if (foundInventory.items[j].amount === 0) {
39
- let itemToEmpty = foundInventory.items[j].item._id;
40
-
41
- foundInventory.items.splice(j, 1);
42
- await foundInventory.save();
30
+ if (connectionSuccess) {
31
+ try {
32
+ if (req.session.currentUserFull) {
33
+ let foundInventory = await inventory.findOne({user: req.session.currentUser}).populate("items.item");
34
+
35
+ let holding = false;
36
+
37
+ for (let j = 0; j < foundInventory.items.length; j++) {
38
+ if (foundInventory.items[j].item._id.equals(req.body.change.item)) {
39
+ holding = true;
43
40
 
44
- res.status(200).send({
45
- item: {
46
- _id: itemToEmpty
47
- },
48
- amount: 0
49
- });
41
+ if (foundInventory.items[j].amount >= -Math.floor(req.body.change.amount)) {
42
+ foundInventory.items[j].amount += Math.floor(req.body.change.amount);
43
+
44
+ if (foundInventory.items[j].amount === 0) {
45
+ let itemToEmpty = foundInventory.items[j].item._id;
46
+
47
+ foundInventory.items.splice(j, 1);
48
+ await foundInventory.save();
49
+
50
+ res.status(200).send({
51
+ item: {
52
+ _id: itemToEmpty
53
+ },
54
+ amount: 0
55
+ });
56
+ }
57
+ else {
58
+ await foundInventory.save();
59
+
60
+ res.status(200).send(foundInventory.items[j]);
61
+ }
50
62
  }
51
63
  else {
52
- await foundInventory.save();
53
-
54
- res.status(200).send(foundInventory.items[j]);
64
+ console.log("subtract from too few", req.body.change);
65
+ res.status(304).send(
66
+ `Unable to remove ${req.body.change.amount} ${req.body.change.item}
67
+ from inventory because the inventory has only ${foundInventory.items[j].amount}.`
68
+ );
55
69
  }
70
+
71
+ break;
72
+ }
73
+ }
74
+
75
+ if (!holding) {
76
+ if (req.body.change.amount > 0) {
77
+ let foundItem = await item.findById(req.body.change.item);
78
+
79
+ foundInventory.items.push({
80
+ item: foundItem._id,
81
+ amount: req.body.change.amount
82
+ });
83
+
84
+ await foundInventory.save();
85
+
86
+ await inventory.populate(foundInventory, "items.item");
87
+
88
+ res.status(200).send(foundInventory.items[foundInventory.items.length - 1]);
56
89
  }
57
90
  else {
58
- console.log("subtract from too few", req.body.change);
91
+ console.log("subtract from none", req.body.change);
59
92
  res.status(304).send(
60
93
  `Unable to remove ${req.body.change.amount} ${req.body.change.item}
61
- from inventory because the inventory has only ${foundInventory.items[j].amount}.`
94
+ from inventory because the inventory has none.`
62
95
  );
63
96
  }
64
-
65
- break;
66
- }
97
+ };
98
+ }
99
+ else {
100
+ res.status(401).send("User not logged in!");
67
101
  }
68
-
69
- if (!holding) {
70
- if (req.body.change.amount > 0) {
71
- let foundItem = await item.findById(req.body.change.item);
72
-
73
- foundInventory.items.push({
74
- item: foundItem._id,
75
- amount: req.body.change.amount
76
- });
77
-
78
- await foundInventory.save();
79
-
80
- await inventory.populate(foundInventory, "items.item");
81
-
82
- res.status(200).send(foundInventory.items[foundInventory.items.length - 1]);
83
- }
84
- else {
85
- console.log("subtract from none", req.body.change);
86
- res.status(304).send(
87
- `Unable to remove ${req.body.change.amount} ${req.body.change.item}
88
- from inventory because the inventory has none.`
89
- );
90
- }
91
- };
92
102
  }
93
- else {
94
- res.status(401).send("User not logged in!");
103
+ catch(err) {
104
+ res.status(500).end();
105
+ console.log(err);
95
106
  }
96
107
  }
97
- catch(err) {
108
+ else {
98
109
  res.status(500).end();
99
- console.log(err);
100
110
  }
101
111
  });
102
112
 
@@ -1,4 +1,4 @@
1
- const inventory = require("../models/inventory");
1
+ const { inventory, connectionSuccess } = require("../models");
2
2
 
3
3
  let router = require("express").Router();
4
4
  let dir = "";
@@ -33,17 +33,30 @@ let front = function front(detail) {
33
33
  detail.options.main = `${dir}/views/${detail.options.main}`;
34
34
 
35
35
  router.get(`/${detail.name}`, async function(req, res) {
36
- try {
37
- const foundInventory = await inventory.findOne({ user: req.session.currentUser }).populate("items.item");
38
-
39
- if (detail.options.needsKey !== "" && foundInventory) {
40
- let hasKey = false;
41
-
42
- for (let i = 0; i < foundInventory.items.length; i++) {
43
- if (foundInventory.items[i].item.name === detail.options.needsKey) hasKey = true;
36
+ if (connectionSuccess) {
37
+ try {
38
+ const foundInventory = await inventory.findOne({ user: req.session.currentUser }).populate("items.item");
39
+
40
+ if (detail.options.needsKey !== "" && foundInventory) {
41
+ let hasKey = false;
42
+
43
+ for (let i = 0; i < foundInventory.items.length; i++) {
44
+ if (foundInventory.items[i].item.name === detail.options.needsKey) hasKey = true;
45
+ }
46
+
47
+ if (!hasKey) res.redirect(detail.options.dropOff);
48
+ else res.render(`explorer`,
49
+ {
50
+ siteTitle: "NotherBase | The Front",
51
+ user: req.session.currentUserFull,
52
+ styles: detail.options.styles,
53
+ externalStyles: detail.options.externalStyles,
54
+ main: detail.options.main,
55
+ scripts: detail.options.scripts,
56
+ inventory: foundInventory,
57
+ query: req.query
58
+ });
44
59
  }
45
-
46
- if (!hasKey) res.redirect(detail.options.dropOff);
47
60
  else res.render(`explorer`,
48
61
  {
49
62
  siteTitle: "NotherBase | The Front",
@@ -56,21 +69,25 @@ let front = function front(detail) {
56
69
  query: req.query
57
70
  });
58
71
  }
59
- else res.render(`explorer`,
72
+ catch(err) {
73
+ console.log(err);
74
+ }
75
+ }
76
+ else {
77
+ console.log("no db connection");
78
+
79
+ res.render(`explorer`,
60
80
  {
61
81
  siteTitle: "NotherBase | The Front",
62
- user: req.session.currentUserFull,
82
+ user: null,
63
83
  styles: detail.options.styles,
64
84
  externalStyles: detail.options.externalStyles,
65
85
  main: detail.options.main,
66
86
  scripts: detail.options.scripts,
67
- inventory: foundInventory,
87
+ inventory: null,
68
88
  query: req.query
69
89
  });
70
90
  }
71
- catch(err) {
72
- console.log(err);
73
- }
74
91
  });
75
92
  }
76
93
 
package/index.js CHANGED
@@ -1,10 +1,12 @@
1
1
  require("dotenv").config();
2
2
 
3
+ let db = require("./models");
4
+
3
5
  module.exports = {
4
6
  explore: function explore(path) {
5
7
  return `./${path}/${path}.js`;
6
8
  },
7
- data: require("./models"),
9
+ data: db,
8
10
  chat: null,
9
11
  start: function start(world) {
10
12
  let theFront = require("./controllers/the-front");
@@ -13,6 +15,6 @@ module.exports = {
13
15
  explorer.complete(world.explorer);
14
16
  theFront.complete(world.theFront);
15
17
 
16
- require("./server")(theFront.router, explorer.router);
18
+ require("./server")(theFront.router, explorer.router, db.connectionSuccess);
17
19
  }
18
20
  }
package/models/index.js CHANGED
@@ -1,9 +1,8 @@
1
1
  module.exports = {
2
+ connectionSuccess: require("./start-mongoose"),
2
3
  chat: require("./chat"),
3
4
  item: require("./item"),
4
5
  user: require("./user"),
5
6
  contact: require("./contact"),
6
7
  inventory: require("./inventory"),
7
8
  }
8
-
9
- require("./start-mongoose");
@@ -1,21 +1,40 @@
1
1
  require("dotenv").config();
2
2
  const mongoose = require("mongoose");
3
3
 
4
+ let success = false;
5
+
4
6
  //connect mongoose and mongo
5
- mongoose.connect(process.env.MONGODB_URI, {
6
- useNewUrlParser: true,
7
- useUnifiedTopology: true
8
- });
7
+ let init = async function init() {
8
+ try {
9
+ await mongoose.connect(process.env.MONGODB_URI, {
10
+ useNewUrlParser: true,
11
+ useUnifiedTopology: true
12
+ });
13
+
14
+ success = true;
15
+
16
+ //handlers
17
+ mongoose.connection.on('connected', (err) => {
18
+ console.log(`Mongoose connected to db`);
19
+ success = true;
20
+ });
21
+
22
+ mongoose.connection.on('error', (err) => {
23
+ console.log(`Mongoose ${err}`);
24
+ success = false;
25
+ });
9
26
 
10
- //handlers
11
- mongoose.connection.on('connected', () => {
12
- console.log(`Mongoose connected to db`);
13
- });
27
+ mongoose.connection.on('disconnected', () => {
28
+ console.log('Mongoose disconnected');
29
+ success = false;
30
+ });
31
+ }
32
+ catch (err) {
33
+ console.log(`Mongoose on connect: ${err}`);
34
+ success = false;
35
+ }
36
+ }
14
37
 
15
- mongoose.connection.on('error', (err) => {
16
- console.log(`Mongoose connected error ${err}`);
17
- });
38
+ init();
18
39
 
19
- mongoose.connection.on('disconnected', () => {
20
- console.log('Mongoose disconnected');
21
- });
40
+ module.exports = success;
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "notherbase-fs",
3
- "version": "1.1.32",
3
+ "version": "1.1.35",
4
4
  "description": "Functions to help make developing for NotherBase easier.",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
7
+ "test": "nodemon test.js"
8
8
  },
9
9
  "repository": {
10
10
  "type": "git",
@@ -0,0 +1,75 @@
1
+ .inventory {
2
+ border: 1px solid var(--textColor);
3
+ color: var(--textColor);
4
+ position: fixed;
5
+ width: 90%;
6
+ height: 30%;
7
+ left: 5%;
8
+ bottom: 105px;
9
+ background-color: var(--bgColor);
10
+ padding: 5px;
11
+ border-radius: 5px;
12
+ z-index: 500;
13
+ display: flex;
14
+ flex-wrap: wrap;
15
+ overflow: auto;
16
+ }
17
+
18
+ .inventory .item-list {
19
+ width: 100%;
20
+ display: flex;
21
+ flex-wrap: wrap;
22
+ overflow: auto;
23
+ border: 1px solid var(--textColor);
24
+ }
25
+
26
+ .inventory .item-spawner {
27
+ width: 100%;
28
+ border: 1px solid var(--textColor);
29
+ }
30
+
31
+ .item-spawner .search-results {
32
+ width: 100%;
33
+ border: 1px solid var(--textColor);
34
+ overflow: auto;
35
+ }
36
+
37
+ .search-results p {
38
+ width: 100%;
39
+ cursor: pointer;
40
+ }
41
+
42
+ .search-results p:hover {
43
+ background-color: var(--woodColor);
44
+ }
45
+
46
+ button#inventory {
47
+ position: fixed;
48
+ bottom: 30px;
49
+ right: 75px;
50
+ width: 64px;
51
+ height: 64px;
52
+ }
53
+
54
+ .item-card {
55
+ width: 100px;
56
+ height: 100px;
57
+ border-radius: 5px;
58
+ border: 1px solid var(--textColor);
59
+ padding: 10px;
60
+ margin: 5px;
61
+ position: relative;
62
+ }
63
+
64
+ .item-card button {
65
+ position: absolute;
66
+ right: 0;
67
+ top: 0;
68
+ margin: 0;
69
+ padding: 0;
70
+ }
71
+
72
+ .item-card hr {
73
+ margin: 5px -10px;
74
+ width: calc(100% + 20px);
75
+ }
@@ -163,7 +163,6 @@ ul {
163
163
  margin: 10px;
164
164
  }
165
165
 
166
-
167
166
  #contact {
168
167
  position: fixed;
169
168
  bottom: 30px;
@@ -190,83 +189,6 @@ ul {
190
189
  overflow: auto;
191
190
  }
192
191
 
193
- .inventory {
194
- width: 100%;
195
- border: 1px solid var(--textColor);
196
- color: var(--textColor);
197
- position: fixed;
198
- width: 90%;
199
- height: 30%;
200
- left: 5%;
201
- bottom: 105px;
202
- background-color: var(--bgColor);
203
- padding: 5px;
204
- border-radius: 5px;
205
- z-index: 500;
206
- display: flex;
207
- flex-wrap: wrap;
208
- overflow: auto;
209
- }
210
-
211
- .inventory .item-list {
212
- width: 100%;
213
- display: flex;
214
- flex-wrap: wrap;
215
- overflow: auto;
216
- border: 1px solid var(--textColor);
217
- }
218
-
219
- .inventory .item-spawner {
220
- width: 100%;
221
- border: 1px solid var(--textColor);
222
- }
223
-
224
- .item-spawner .search-results {
225
- width: 100%;
226
- border: 1px solid var(--textColor);
227
- overflow: auto;
228
- }
229
-
230
- .search-results p {
231
- width: 100%;
232
- cursor: pointer;
233
- }
234
-
235
- .search-results p:hover {
236
- background-color: var(--woodColor);
237
- }
238
-
239
- #inventory-button {
240
- position: fixed;
241
- bottom: 30px;
242
- right: 5px;
243
- width: 64px;
244
- height: 64px;
245
- }
246
-
247
- .item-card {
248
- width: 100px;
249
- height: 100px;
250
- border-radius: 5px;
251
- border: 1px solid var(--textColor);
252
- padding: 10px;
253
- margin: 5px;
254
- position: relative;
255
- }
256
-
257
- .item-card button {
258
- position: absolute;
259
- right: 0;
260
- top: 0;
261
- margin: 0;
262
- padding: 0;
263
- }
264
-
265
- .item-card hr {
266
- margin: 5px -10px;
267
- width: calc(100% + 20px);
268
- }
269
-
270
192
  .door {
271
193
  border: 1px solid var(--darkWoodColor);
272
194
  width: 100px;
@@ -299,7 +221,6 @@ iframe {
299
221
  flex-wrap: wrap;
300
222
  }
301
223
 
302
-
303
224
  .auth-form h3 {
304
225
  width: calc(100% - 20px);
305
226
  text-align: center;
@@ -321,6 +242,10 @@ iframe {
321
242
  font-size: 12px;
322
243
  }
323
244
 
245
+ .ui {
246
+ position: relative;
247
+ }
248
+
324
249
  @media only screen and (max-width: 500px) {
325
250
  main {
326
251
  width: 100%;
@@ -0,0 +1,47 @@
1
+ .menu {
2
+ width: 75%;
3
+ height: 50%;
4
+ margin: 5% 12.5%;
5
+ border: 1px solid var(--textColor);
6
+ color: var(--textColor);
7
+ position: fixed;
8
+ left: 0;
9
+ top: 0;
10
+ background-color: var(--bgColor);
11
+ border-radius: 5px;
12
+ z-index: 500;
13
+ }
14
+
15
+ .ui button#menu {
16
+ position: fixed;
17
+ bottom: 30px;
18
+ right: 5px;
19
+ width: 64px;
20
+ height: 64px;
21
+ }
22
+
23
+ .menu button#close {
24
+ top: 5px;
25
+ right: 5px;
26
+ width: 32px;
27
+ height: 32px;
28
+ position: absolute;
29
+ }
30
+
31
+ .menu .tabs {
32
+ width: 100%;
33
+ height: 10%;
34
+ border: 1px solid var(--textColor);
35
+ }
36
+
37
+ .menu .content {
38
+ width: 100%;
39
+ height: 90%;
40
+ border: 1px solid var(--textColor);
41
+ }
42
+
43
+ .menu a {
44
+ margin: 0;
45
+ padding: 5px;
46
+ margin: 5px;
47
+ }
package/server.js CHANGED
@@ -1,6 +1,6 @@
1
1
  let started = false;
2
2
 
3
- module.exports = function start(frontRouter, exploreRouter) {
3
+ module.exports = function start(frontRouter, exploreRouter, dbConnected) {
4
4
  if (!started) {
5
5
  // Setup for Express
6
6
  const express = require("express");
@@ -37,12 +37,14 @@ module.exports = function start(frontRouter, exploreRouter) {
37
37
  const controllers = require("./controllers");
38
38
 
39
39
  //enable cookies
40
- app.use(session({
41
- store: MongoStore.create({ mongoUrl: process.env.MONGODB_URI }),
42
- secret: process.env.SECRET || "won",
43
- resave: false,
44
- saveUninitialized: false
45
- }));
40
+ if (dbConnected) {
41
+ app.use(session({
42
+ store: MongoStore.create({ mongoUrl: process.env.MONGODB_URI }),
43
+ secret: process.env.SECRET || "won",
44
+ resave: false,
45
+ saveUninitialized: false
46
+ }));
47
+ }
46
48
 
47
49
  io.on('connection', (socket) => {
48
50
  socket.join(socket.handshake.query.room);
@@ -66,12 +68,11 @@ module.exports = function start(frontRouter, exploreRouter) {
66
68
 
67
69
  app.use("/", controllers.authCheck, exploreRouter);
68
70
 
69
- // Go Off (On)
70
71
  server.listen(process.env.PORT, function () {
71
72
  console.log(`Server started at ${process.env.PORT}`);
73
+ started = true;
72
74
  });
73
75
 
74
- started = true;
75
76
  }
76
77
  else console.log("Server already started!");
77
78
  }
@@ -4,6 +4,35 @@
4
4
 
5
5
  <hr>
6
6
 
7
- <a class="return" href="/forest/pond/tower">
8
- Back to the Wizard's Tower
9
- </a>
7
+ <div class="auth-form" id="login-form">
8
+ <h1>NotherBase</h1>
9
+ <h3>Login to Your Account</h3>
10
+ <input type="text" name="username" placeholder="username" id="login-user">
11
+ <input type="password" name="password" placeholder="password" id="login-pass">
12
+ <button id="login-button">Login</button>
13
+ <p id="login-info"></p>
14
+ </div>
15
+
16
+ <script>
17
+ let $loginButton = $("#login-button");
18
+ let $loginInfo = $("#login-info");
19
+
20
+ $loginButton.on("click", async function () {
21
+ try {
22
+ await $.post("/user/login", {
23
+ username: $("#login-user").val(),
24
+ password: $("#login-pass").val()
25
+ }, (data) => {
26
+ $loginInfo.text("To your right you hear the sound of a bang against a chain-link fence. You've logged in.");
27
+ });
28
+ } catch (error) {
29
+ //console.log(error);
30
+ if (error.status === 401) {
31
+ $loginInfo.text("Login Error: Username or password incorrect!");
32
+ }
33
+ else if (error.status === 500) {
34
+ $loginInfo.text("Server Error: Try again later!");
35
+ }
36
+ }
37
+ });
38
+ </script>
package/test.js ADDED
@@ -0,0 +1 @@
1
+ require("./test/test-index");
package/views/contact.ejs CHANGED
@@ -4,8 +4,6 @@
4
4
  <button id="send">Send Message</button>
5
5
  </div>
6
6
 
7
- <button id="contact">Msg Nother</button>
8
-
9
7
  <script>
10
8
  $("#contact").on("click", (e) => {
11
9
  $("#contact-form").toggleClass("invisible");
@@ -11,12 +11,13 @@
11
11
 
12
12
  <main class="override">
13
13
  <%- include(`${main}.ejs`); %>
14
-
15
- <%- include("./inventory.ejs", {inventory: inventory}); %>
16
-
17
- <%- include("./contact.ejs"); %>
18
14
  </main>
19
15
 
16
+ <div class="ui">
17
+ <%- include("./inventory.ejs", {inventory: inventory}); %>
18
+ <%- include("./menu.ejs", {user: user}); %>
19
+ </div>
20
+
20
21
  <script>
21
22
  <% for (let i = 0; i < scripts.length; i++) { %>
22
23
  <%- include(`${scripts[i]}.js`); %>
package/views/footer.ejs CHANGED
@@ -1,8 +1,6 @@
1
1
 
2
2
  <footer>
3
- <% if (user) { %>
4
- <a href="/user/logout">Logout</a>
5
- <% } %>
3
+
6
4
  </footer>
7
5
 
8
6
  </body>
package/views/head.ejs CHANGED
@@ -14,6 +14,8 @@
14
14
  <link href="https://fonts.googleapis.com/css2?family=Redacted+Script:wght@300&display=swap" rel="stylesheet">
15
15
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
16
16
  <link rel="stylesheet" href="/styles/main.css">
17
+ <link rel="stylesheet" href="/styles/inventory.css">
18
+ <link rel="stylesheet" href="/styles/menu.css">
17
19
  </head>
18
20
 
19
21
  <body>
@@ -21,11 +21,11 @@
21
21
  </div>
22
22
  </div>
23
23
 
24
- <button id="inventory-button">
24
+ <button id="inventory">
25
25
  <i class="fas fa-database"></i>
26
26
  </button>
27
27
  <% } else { %>
28
- <button id="inventory-button">
28
+ <button id="inventory">
29
29
  ERR
30
30
  </button>
31
31
  <% } %>
@@ -39,7 +39,7 @@
39
39
  this.$search = $(".search");
40
40
  this.$searchResults = $(".search-results");
41
41
  this.searchResults = [];
42
- this.$button = $("#inventory-button");
42
+ this.$button = $("button#inventory");
43
43
  this.items = [];
44
44
 
45
45
  this.$button.on("click", () => {
package/views/menu.ejs ADDED
@@ -0,0 +1,42 @@
1
+ <div class="menu invisible">
2
+
3
+
4
+ <div class="tabs">
5
+ <button id="inventory">
6
+ Inventory
7
+ </button>
8
+ <button id="player">
9
+ Player
10
+ </button>
11
+ <button id="contact">
12
+ Contact
13
+ </button>
14
+
15
+ <button id="close">
16
+ X
17
+ </button>
18
+ </div>
19
+
20
+ <div class="content">
21
+ <%- include("./contact.ejs"); %>
22
+
23
+ </div>
24
+
25
+ <% if (user) { %>
26
+ <a href="/user/logout">Logout</a>
27
+ <% } %>
28
+ </div>
29
+
30
+ <button id="menu"><i class="fas fa-cog"></i></button>
31
+
32
+ <script>
33
+ let $menu = $(".menu");
34
+
35
+ $("button#menu").on("click", function () {
36
+ $menu.toggleClass("invisible");
37
+ });
38
+
39
+ $("button#close").on("click", function () {
40
+ $menu.toggleClass("invisible");
41
+ });
42
+ </script>