notherbase-fs 1.0.35 → 1.0.39
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.
- package/controllers/authCheck.js +27 -0
- package/controllers/chat.js +30 -0
- package/controllers/contact.js +22 -0
- package/controllers/explorer.js +122 -0
- package/controllers/index.js +11 -0
- package/controllers/inventory.js +104 -0
- package/controllers/item.js +61 -0
- package/controllers/portfolio/models/projects.js +16 -0
- package/controllers/portfolio/portfolio-controller.js +10 -0
- package/controllers/portfolio/views/index.ejs +234 -0
- package/controllers/portfolio/views/parts/tamago.ejs +534 -0
- package/controllers/the-front.js +88 -0
- package/controllers/user.js +111 -0
- package/index.js +16 -0
- package/models/chat.js +13 -0
- package/models/contact.js +17 -0
- package/models/index.js +11 -0
- package/models/inventory.js +22 -0
- package/models/item.js +12 -0
- package/models/start-mongoose.js +22 -0
- package/models/user.js +16 -0
- package/package.json +12 -3
- package/public/img/logo.png +0 -0
- package/public/styles/chat.css +60 -0
- package/public/styles/main.css +328 -0
- package/public/styles/portfolio.css +468 -0
- package/public/styles/void.css +37 -0
- package/server.js +83 -0
- package/views/basic-footer.ejs +2 -0
- package/views/chat-box.ejs +47 -0
- package/views/contact.ejs +24 -0
- package/views/explorer.ejs +26 -0
- package/views/footer.ejs +9 -0
- package/views/head.ejs +19 -0
- package/views/inventory.ejs +134 -0
- package/main.js +0 -83
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
<% if (inventory.items) { %>
|
|
2
|
+
<div class="inventory invisible">
|
|
3
|
+
<% if (user.authLevels.length > 0) {
|
|
4
|
+
for (let i = 0; i < user.authLevels.length; i++) {
|
|
5
|
+
if (user.authLevels[i] === "Creator") { %>
|
|
6
|
+
|
|
7
|
+
<div class="item-spawner">
|
|
8
|
+
<input type="text" class="search">
|
|
9
|
+
<div class="search-results">
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
<% break;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
} %>
|
|
18
|
+
|
|
19
|
+
<div class="item-list">
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
<button id="inventory-button">
|
|
24
|
+
<i class="fas fa-database"></i>
|
|
25
|
+
</button>
|
|
26
|
+
<% } else { %>
|
|
27
|
+
<button id="inventory-button">
|
|
28
|
+
ERR
|
|
29
|
+
</button>
|
|
30
|
+
<% } %>
|
|
31
|
+
|
|
32
|
+
<script>
|
|
33
|
+
class Inventory {
|
|
34
|
+
constructor() {
|
|
35
|
+
this.$div = $(".inventory");
|
|
36
|
+
this.$list = $(".item-list");
|
|
37
|
+
this.$search = $(".search");
|
|
38
|
+
this.$searchResults = $(".search-results");
|
|
39
|
+
this.searchResults = [];
|
|
40
|
+
this.$button = $("#inventory-button");
|
|
41
|
+
this.items = [];
|
|
42
|
+
|
|
43
|
+
this.$button.on("click", () => {
|
|
44
|
+
this.$div.toggleClass("invisible");
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
this.$search.on("keyup", () => {
|
|
48
|
+
let searchString = this.$search.val();
|
|
49
|
+
|
|
50
|
+
$.get(`/item`, { name: searchString }, (data) => {
|
|
51
|
+
this.renderSearchResults(data.foundItems);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
$.get("/inventory", (data) => {
|
|
56
|
+
this.items = data.foundInventory.items;
|
|
57
|
+
|
|
58
|
+
this.render();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
setInterval(this.update, this.updateCooldown);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
change(change) {
|
|
65
|
+
$.post("/inventory", { change: change }, (data, status) => {
|
|
66
|
+
if (status === "success") {
|
|
67
|
+
let holding = false;
|
|
68
|
+
|
|
69
|
+
for (let i = 0; i < this.items.length; i++) {
|
|
70
|
+
if (this.items[i].item._id === data.item._id) {
|
|
71
|
+
this.items[i].amount = data.amount;
|
|
72
|
+
holding = true;
|
|
73
|
+
|
|
74
|
+
if (this.items[i].amount === 0) this.items.splice(i, 1);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (!holding) {
|
|
79
|
+
this.items.push(data);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
this.render();
|
|
83
|
+
}
|
|
84
|
+
else console.log(status);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
render() {
|
|
89
|
+
this.$list.empty();
|
|
90
|
+
|
|
91
|
+
for (let i = 0; i < this.items.length; i++) {
|
|
92
|
+
let $new = this.$list.append(
|
|
93
|
+
`<div class="item-card">
|
|
94
|
+
<h5>${this.items[i].item.name}</h5>
|
|
95
|
+
<button id="${i}">X</button>
|
|
96
|
+
<hr>
|
|
97
|
+
<p>${this.items[i].amount}</p>
|
|
98
|
+
</div>`
|
|
99
|
+
).children().last();
|
|
100
|
+
|
|
101
|
+
$new.find("button").on("click", (e) => {
|
|
102
|
+
let which = parseInt(e.currentTarget.id);
|
|
103
|
+
|
|
104
|
+
this.change({
|
|
105
|
+
item: this.items[which].item._id,
|
|
106
|
+
amount: -1
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
renderSearchResults(results) {
|
|
113
|
+
this.$searchResults.empty();
|
|
114
|
+
this.searchResults = results;
|
|
115
|
+
|
|
116
|
+
for (let i = 0; i < this.searchResults.length; i++) {
|
|
117
|
+
let $new = this.$searchResults.append(
|
|
118
|
+
`<p id="${i}">${this.searchResults[i].name}</p>`
|
|
119
|
+
).children().last();
|
|
120
|
+
|
|
121
|
+
$new.on("click", (e) => {
|
|
122
|
+
let which = parseInt(e.currentTarget.id);
|
|
123
|
+
|
|
124
|
+
this.change({
|
|
125
|
+
item: this.searchResults[which]._id,
|
|
126
|
+
amount: 1
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
let playerInventory = new Inventory();
|
|
134
|
+
</script>
|
package/main.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
const inventory = require(process.cwd() + "/models/inventory").inventory;
|
|
2
|
-
|
|
3
|
-
let router;
|
|
4
|
-
let dir;
|
|
5
|
-
|
|
6
|
-
let explore = function explore(route, options) {
|
|
7
|
-
options = {
|
|
8
|
-
styles: [],
|
|
9
|
-
scripts: [],
|
|
10
|
-
needsKey: "",
|
|
11
|
-
dropOff: "",
|
|
12
|
-
...options
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
options.styles = options.styles.map(style => {
|
|
16
|
-
style = `${dir}/styles/${style}`;
|
|
17
|
-
return style;
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
options.scripts = options.scripts.map(script => {
|
|
21
|
-
script = `${dir}/local-scripts/${script}`;
|
|
22
|
-
return script;
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
options.main = "index";
|
|
26
|
-
if (route !== "") options.main = route;
|
|
27
|
-
options.main = `${dir}/views/${options.main}`;
|
|
28
|
-
|
|
29
|
-
router.get(`/${route}`, async function(req, res) {
|
|
30
|
-
try {
|
|
31
|
-
const foundInventory = await inventory.findOne({ user: req.session.currentUser }).populate("items.item");
|
|
32
|
-
|
|
33
|
-
if (options.needsKey !== "" && foundInventory) {
|
|
34
|
-
let hasKey = false;
|
|
35
|
-
|
|
36
|
-
for (let i = 0; i < foundInventory.items.length; i++) {
|
|
37
|
-
if (foundInventory.items[i].item.name === options.needsKey) hasKey = true;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (!hasKey) res.redirect(options.dropOff);
|
|
41
|
-
else res.render(`explorer`,
|
|
42
|
-
{
|
|
43
|
-
siteTitle: "NotherBase",
|
|
44
|
-
user: req.session.currentUserFull,
|
|
45
|
-
styles: options.styles,
|
|
46
|
-
main: options.main,
|
|
47
|
-
scripts: options.scripts,
|
|
48
|
-
pov: req.query.pov,
|
|
49
|
-
inventory: foundInventory,
|
|
50
|
-
query: req.query
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
else res.render(`explorer`,
|
|
54
|
-
{
|
|
55
|
-
siteTitle: "NotherBase",
|
|
56
|
-
user: req.session.currentUserFull,
|
|
57
|
-
styles: options.styles,
|
|
58
|
-
main: options.main,
|
|
59
|
-
scripts: options.scripts,
|
|
60
|
-
pov: req.query.pov,
|
|
61
|
-
inventory: foundInventory,
|
|
62
|
-
query: req.query
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
catch(err) {
|
|
66
|
-
console.log(err);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
let from = function from(currentDirectory) {
|
|
72
|
-
dir = currentDirectory;
|
|
73
|
-
router = require("express").Router();
|
|
74
|
-
|
|
75
|
-
return {
|
|
76
|
-
explore: explore,
|
|
77
|
-
router: router
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
module.exports = {
|
|
82
|
-
from: from
|
|
83
|
-
}
|