notherbase-fs 3.2.21 → 3.3.0
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/creation.js +8 -11
- package/controllers/spirit-world.js +24 -10
- package/controllers/user.js +8 -31
- package/models/index.js +0 -2
- package/models/spirit.js +56 -19
- package/models/user.js +93 -0
- package/notherbase-fs.js +3 -10
- package/package.json +1 -1
- package/public/js/base.js +237 -32
- package/public/js/chat-box.js +0 -13
- package/public/styles/account.css +45 -0
- package/public/styles/inventory.css +76 -0
- package/public/styles/main.css +143 -288
- package/public/styles/menu.css +135 -0
- package/public/styles/more.css +17 -0
- package/public/styles/player.css +36 -0
- package/test/coast/tall-beach/nono-cove/index.ejs +0 -1
- package/test/pages/void/index.ejs +1 -32
- package/test/the-front/add-gold.js +23 -0
- package/test/the-front/check/add-more-gold.js +3 -0
- package/test/the-front/check/emailTime.js +2 -0
- package/test/the-front/check/index.ejs +1 -1
- package/test/the-front/check/subtract-gold.js +3 -0
- package/test/the-front/checks.js +11 -0
- package/test/the-front/incTranslation.js +9 -0
- package/test/the-front/index.ejs +1 -1
- package/views/basic-footer.ejs +2 -0
- package/views/explorer.ejs +8 -6
- package/views/footer.ejs +1 -1
- package/views/head.ejs +6 -0
- package/views/menu/account.ejs +39 -0
- package/views/menu/inventory.ejs +8 -0
- package/views/menu/more.ejs +2 -0
- package/views/menu/player.ejs +3 -0
- package/views/menu.ejs +43 -0
- package/test/pages/check/index-old.ejs +0 -105
package/public/js/base.js
CHANGED
|
@@ -13,6 +13,108 @@ class Base {
|
|
|
13
13
|
return response;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* The player's inventory.
|
|
18
|
+
*/
|
|
19
|
+
#Inventory = class Inventory {
|
|
20
|
+
constructor() {
|
|
21
|
+
this.items = [];
|
|
22
|
+
this.lastUpdate = 0;
|
|
23
|
+
|
|
24
|
+
this.refresh();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Reloads the inventory.
|
|
29
|
+
*/
|
|
30
|
+
async refresh() {
|
|
31
|
+
let $list = $(".inventory .item-list");
|
|
32
|
+
|
|
33
|
+
let response = await Base.commune("getInventory", { _lastUpdate: this.lastUpdate });
|
|
34
|
+
|
|
35
|
+
if (response.status === "success") {
|
|
36
|
+
this.items = response.data;
|
|
37
|
+
this.lastUpdate = response.lastUpdate;
|
|
38
|
+
$list.empty();
|
|
39
|
+
|
|
40
|
+
for (let i = 0; i < this.items.length; i++) {
|
|
41
|
+
let $new = $list.append(
|
|
42
|
+
`<div class="item-card">
|
|
43
|
+
<h5>${this.items[i].name}</h5>
|
|
44
|
+
<button id="${i}">X</button>
|
|
45
|
+
<hr>
|
|
46
|
+
<p>${this.items[i].amount}</p>
|
|
47
|
+
</div>`
|
|
48
|
+
).children().last();
|
|
49
|
+
|
|
50
|
+
$new.find("button").on("click", this.reduceItem);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
this.clearError();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Clears the error on screen.
|
|
59
|
+
*/
|
|
60
|
+
clearError() {
|
|
61
|
+
let $error = $("#inventory #error");
|
|
62
|
+
|
|
63
|
+
$error.addClass("invisible");
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Shows an error on screen.
|
|
68
|
+
* @param {String} text The error message.
|
|
69
|
+
*/
|
|
70
|
+
setError(text) {
|
|
71
|
+
let $error = $("#inventory #error");
|
|
72
|
+
|
|
73
|
+
$error.text(text);
|
|
74
|
+
$error.removeClass("invisible");
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The player's attributes.
|
|
80
|
+
*/
|
|
81
|
+
#PlayerAttributes = class PlayerAttributes {
|
|
82
|
+
constructor() {
|
|
83
|
+
this.attributes = [];
|
|
84
|
+
this.lastUpdate = 0;
|
|
85
|
+
|
|
86
|
+
this.refresh();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Reloads the player's attributes.
|
|
91
|
+
*/
|
|
92
|
+
async refresh() {
|
|
93
|
+
let response = await Base.commune("getAttributes", { _lastUpdate: this.lastUpdate });
|
|
94
|
+
if (response.status === "success") {
|
|
95
|
+
this.lastUpdate = response.lastUpdate;
|
|
96
|
+
this.attributes = response.data;
|
|
97
|
+
|
|
98
|
+
this.render();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Renders the attributes.
|
|
104
|
+
*/
|
|
105
|
+
render() {
|
|
106
|
+
let $content = $(".menu .content#player");
|
|
107
|
+
|
|
108
|
+
$content.empty();
|
|
109
|
+
|
|
110
|
+
if (this.attributes) {
|
|
111
|
+
for (const [key, value] of Object.entries(this.attributes)) {
|
|
112
|
+
$content.append(`<h3 id="${key}">${key}: ${value}</h3>`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
16
118
|
/**
|
|
17
119
|
* Services for the player's account.
|
|
18
120
|
*/
|
|
@@ -21,6 +123,58 @@ class Base {
|
|
|
21
123
|
this.username = "";
|
|
22
124
|
this.email = "";
|
|
23
125
|
this.lastUpdate = 0;
|
|
126
|
+
|
|
127
|
+
this.refresh();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Reloads the player's basic info.
|
|
132
|
+
*/
|
|
133
|
+
async refresh() {
|
|
134
|
+
let response = await Base.commune("getInfo", { _lastUpdate: this.lastUpdate });
|
|
135
|
+
if (response.status === "success") {
|
|
136
|
+
this.lastUpdate = response.lastUpdate;
|
|
137
|
+
this.email = response.data.email;
|
|
138
|
+
this.username = response.data.username;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
let $email = $(".content#account .setting#email p");
|
|
142
|
+
let $emailInput = $(".content#account .edit#email input");
|
|
143
|
+
let $username = $(".content#account .setting#username p");
|
|
144
|
+
let $usernameInput = $(".content#account .edit#username input");
|
|
145
|
+
|
|
146
|
+
$email.text(this.email);
|
|
147
|
+
$emailInput.val(this.email);
|
|
148
|
+
$username.text(this.username);
|
|
149
|
+
$usernameInput.val(this.username);
|
|
150
|
+
|
|
151
|
+
$(".content#account .settings").removeClass("invisible");
|
|
152
|
+
$(".content#account #please-login").addClass("invisible");
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Initiates email editing.
|
|
157
|
+
*/
|
|
158
|
+
editEmail() {
|
|
159
|
+
let $emailSetting = $(".content#account .setting#email");
|
|
160
|
+
let $emailEdit = $(".content#account .edit#email");
|
|
161
|
+
|
|
162
|
+
$emailSetting.addClass("invisible");
|
|
163
|
+
$emailEdit.removeClass("invisible");
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Cancels editing the email.
|
|
168
|
+
*/
|
|
169
|
+
cancelEmail() {
|
|
170
|
+
let $email = $(".content#account .setting#email p");
|
|
171
|
+
let $emailSetting = $(".content#account .setting#email");
|
|
172
|
+
let $emailEdit = $(".content#account .edit#email");
|
|
173
|
+
let $emailInput = $(".content#account .edit#email input");
|
|
174
|
+
|
|
175
|
+
$emailSetting.removeClass("invisible");
|
|
176
|
+
$emailEdit.addClass("invisible");
|
|
177
|
+
$emailInput.val($email.text());
|
|
24
178
|
}
|
|
25
179
|
|
|
26
180
|
/**
|
|
@@ -44,6 +198,31 @@ class Base {
|
|
|
44
198
|
this.cancelEmail();
|
|
45
199
|
}
|
|
46
200
|
|
|
201
|
+
/**
|
|
202
|
+
* Initiates username editing.
|
|
203
|
+
*/
|
|
204
|
+
editUsername() {
|
|
205
|
+
let $usernameSetting = $(".content#account .setting#username");
|
|
206
|
+
let $usernameEdit = $(".content#account .edit#username");
|
|
207
|
+
|
|
208
|
+
$usernameSetting.addClass("invisible");
|
|
209
|
+
$usernameEdit.removeClass("invisible");
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Cancels username editing.
|
|
214
|
+
*/
|
|
215
|
+
cancelUsername() {
|
|
216
|
+
let $usernameSetting = $(".content#account .setting#username");
|
|
217
|
+
let $usernameEdit = $(".content#account .edit#username");
|
|
218
|
+
let $usernameInput = $(".content#account .edit#username input");
|
|
219
|
+
let $username = $(".content#account .setting#username p");
|
|
220
|
+
|
|
221
|
+
$usernameSetting.removeClass("invisible");
|
|
222
|
+
$usernameEdit.addClass("invisible");
|
|
223
|
+
$usernameInput.val($username.text());
|
|
224
|
+
}
|
|
225
|
+
|
|
47
226
|
/**
|
|
48
227
|
* Confirms and submits a username edit.
|
|
49
228
|
*/
|
|
@@ -67,9 +246,56 @@ class Base {
|
|
|
67
246
|
}
|
|
68
247
|
|
|
69
248
|
constructor() {
|
|
249
|
+
this.playerInventory = new this.#Inventory();
|
|
250
|
+
this.playerAttributes = new this.#PlayerAttributes();
|
|
70
251
|
this.playerAccount = new this.#AccountServices();
|
|
252
|
+
this.menuClosing = false;
|
|
253
|
+
|
|
254
|
+
this.switchTab("inventory");
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Closes the menu.
|
|
259
|
+
*/
|
|
260
|
+
closeMenu = () => {
|
|
261
|
+
let $menu = $(".ui .menu");
|
|
262
|
+
let $fade = $(".ui .fade");
|
|
263
|
+
|
|
264
|
+
if (!this.menuClosing) {
|
|
265
|
+
this.menuClosing = true;
|
|
266
|
+
$fade.addClass("camo");
|
|
267
|
+
|
|
268
|
+
setTimeout(() => {
|
|
269
|
+
$menu.addClass("invisible");
|
|
270
|
+
$fade.addClass("invisible");
|
|
271
|
+
this.menuClosing = false;
|
|
272
|
+
}, 100);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Opens the menu.
|
|
278
|
+
*/
|
|
279
|
+
openMenu = () => {
|
|
280
|
+
let $menu = $(".ui .menu");
|
|
281
|
+
let $fade = $(".ui .fade");
|
|
282
|
+
|
|
283
|
+
$menu.removeClass("invisible");
|
|
284
|
+
$fade.removeClass("camo");
|
|
285
|
+
$fade.removeClass("invisible");
|
|
71
286
|
}
|
|
72
287
|
|
|
288
|
+
/**
|
|
289
|
+
* Switches tabs in the menu.
|
|
290
|
+
* @param {String} id The name of the tab to switch to.
|
|
291
|
+
*/
|
|
292
|
+
switchTab = function switchTab(id) {
|
|
293
|
+
$("#content-window .content").addClass("invisible");
|
|
294
|
+
$(".menu .tabs button").removeClass("selected");
|
|
295
|
+
$(`#content-window #${id}`).removeClass("invisible");
|
|
296
|
+
$(`.menu .tabs #${id}`).addClass("selected");
|
|
297
|
+
}
|
|
298
|
+
|
|
73
299
|
/**
|
|
74
300
|
* Communes to logout.
|
|
75
301
|
* @returns Communion response.
|
|
@@ -77,8 +303,7 @@ class Base {
|
|
|
77
303
|
logout = async () => {
|
|
78
304
|
let response = await Base.commune("logout");
|
|
79
305
|
|
|
80
|
-
|
|
81
|
-
//return response;
|
|
306
|
+
return response;
|
|
82
307
|
}
|
|
83
308
|
|
|
84
309
|
/**
|
|
@@ -109,8 +334,11 @@ class Base {
|
|
|
109
334
|
});
|
|
110
335
|
|
|
111
336
|
if (response.status === "success") {
|
|
337
|
+
this.playerInventory.refresh();
|
|
112
338
|
this.playerAccount.username = response.data;
|
|
113
339
|
this.playerAccount.email = email;
|
|
340
|
+
this.playerAccount.refresh();
|
|
341
|
+
this.playerAttributes.refresh();
|
|
114
342
|
}
|
|
115
343
|
|
|
116
344
|
return response;
|
|
@@ -156,45 +384,22 @@ class Base {
|
|
|
156
384
|
}));
|
|
157
385
|
|
|
158
386
|
if (response.status != "success") console.log(`${window.location.pathname} - ${response.message}`);
|
|
387
|
+
|
|
388
|
+
this.playerInventory.refresh();
|
|
389
|
+
this.playerAttributes.refresh();
|
|
159
390
|
|
|
160
391
|
return response;
|
|
161
392
|
}
|
|
162
393
|
|
|
163
394
|
/**
|
|
164
|
-
* Loads a certain
|
|
165
|
-
* @param {String} service The name of the
|
|
395
|
+
* Loads all spirits of a certain service.
|
|
396
|
+
* @param {String} service The name of the spirits to load.
|
|
166
397
|
* @param {String} scope Defaults to local, else global.
|
|
167
398
|
* @returns Spirit world response.
|
|
168
399
|
*/
|
|
169
|
-
|
|
170
|
-
let response = await $.post("/s/
|
|
400
|
+
loadAll = async (service, scope = "local", data = {}, id = null) => {
|
|
401
|
+
let response = await $.post("/s/loadAll", JSON.stringify({ service, scope, data, id }));
|
|
171
402
|
|
|
172
403
|
return response;
|
|
173
404
|
}
|
|
174
|
-
|
|
175
|
-
createToggleViewButton = async () => {
|
|
176
|
-
Base.commune("getView").then((res) => {
|
|
177
|
-
// add a button to the footer for toggling between compact and full view
|
|
178
|
-
this.$viewToggle = $("<button>").addClass("view-toggle").text(">");
|
|
179
|
-
this.$viewToggle.on("click", () => {
|
|
180
|
-
this.toggleView();
|
|
181
|
-
});
|
|
182
|
-
$("footer").append(this.$viewToggle);
|
|
183
|
-
|
|
184
|
-
if (res.data === "full") this.toggleView(false);
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
toggleView = async (save = true) => {
|
|
189
|
-
if (this.$viewToggle.text() === ">") {
|
|
190
|
-
this.$viewToggle.text("<");
|
|
191
|
-
$("main").addClass("full-view");
|
|
192
|
-
if (save) Base.commune("setView", { view: "full" });
|
|
193
|
-
}
|
|
194
|
-
else {
|
|
195
|
-
this.$viewToggle.text(">");
|
|
196
|
-
$("main").removeClass("full-view");
|
|
197
|
-
if (save) Base.commune("setView", { view: "compact" });
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
405
|
}
|
package/public/js/chat-box.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
class ChatBox {
|
|
5
5
|
constructor(username, room) {
|
|
6
|
-
ChatBox.attemptStyle();
|
|
7
6
|
this.socket = null;
|
|
8
7
|
this.username = username;
|
|
9
8
|
this.room = room;
|
|
@@ -24,18 +23,6 @@ class ChatBox {
|
|
|
24
23
|
this.render();
|
|
25
24
|
}
|
|
26
25
|
|
|
27
|
-
static styled = false;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Adds the chat box styles if needed.
|
|
31
|
-
*/
|
|
32
|
-
static attemptStyle() {
|
|
33
|
-
if (!ChatBox.styled) {
|
|
34
|
-
$("head").append(`<link href='/styles/chat.css' rel='stylesheet' />`);
|
|
35
|
-
ChatBox.styled = true;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
26
|
/**
|
|
40
27
|
* Renders a new message in the chat.
|
|
41
28
|
* @param {Object} msg An object including the text to render.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
.content#account {
|
|
2
|
+
padding: 20px;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.content#account h3 {
|
|
6
|
+
padding: 10px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.content#account hr {
|
|
10
|
+
margin: 10px 0;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.content#account #info {
|
|
14
|
+
text-align: center;
|
|
15
|
+
width: 100%;
|
|
16
|
+
margin-top: 40px;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.content#account .setting {
|
|
20
|
+
background: var(--darkBgColor);
|
|
21
|
+
padding: 25px;
|
|
22
|
+
border-radius: 5px;
|
|
23
|
+
display: flex;
|
|
24
|
+
justify-content: center;
|
|
25
|
+
text-align: center;
|
|
26
|
+
flex-wrap: wrap;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.content#account p {
|
|
30
|
+
width: 100%;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.content#account button {
|
|
34
|
+
width: 40%;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.content#account .edit {
|
|
38
|
+
background: var(--darkWoodColor);
|
|
39
|
+
padding: 25px;
|
|
40
|
+
border-radius: 5px;
|
|
41
|
+
display: flex;
|
|
42
|
+
justify-content: center;
|
|
43
|
+
text-align: center;
|
|
44
|
+
flex-wrap: wrap;
|
|
45
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
.inventory .item-list {
|
|
2
|
+
width: 100%;
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-wrap: wrap;
|
|
5
|
+
border: none;
|
|
6
|
+
align-content: flex-start;
|
|
7
|
+
justify-content: center;
|
|
8
|
+
padding: 0;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.inventory .item-spawner {
|
|
12
|
+
width: 100%;
|
|
13
|
+
border: 1px solid var(--textColor);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.item-spawner .search-results {
|
|
17
|
+
width: 100%;
|
|
18
|
+
border: 1px solid var(--textColor);
|
|
19
|
+
overflow: auto;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.search-results p {
|
|
23
|
+
width: 100%;
|
|
24
|
+
cursor: pointer;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.search-results p:hover {
|
|
28
|
+
background-color: var(--woodColor);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.item-card {
|
|
32
|
+
margin: var(--margin);
|
|
33
|
+
width: var(--fillFromMargin);
|
|
34
|
+
height: 70px;
|
|
35
|
+
border: var(--standardBorder);
|
|
36
|
+
background-color: var(--bgColor);
|
|
37
|
+
display: flex;
|
|
38
|
+
align-items: center;
|
|
39
|
+
flex-wrap: nowrap;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.item-card h5 {
|
|
43
|
+
width: 70%;
|
|
44
|
+
text-align: left;
|
|
45
|
+
padding: 5px;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.item-card p {
|
|
49
|
+
width: 27%;
|
|
50
|
+
text-align: right;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.item-card hr {
|
|
54
|
+
border: none;
|
|
55
|
+
border-right: var(--standardBorder);
|
|
56
|
+
height: 100%;
|
|
57
|
+
width: 1px;
|
|
58
|
+
margin: 0;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.item-card button {
|
|
62
|
+
margin: 0;
|
|
63
|
+
padding: 0 3px;
|
|
64
|
+
border-radius: 0;
|
|
65
|
+
border-bottom: none;
|
|
66
|
+
height: 50%;
|
|
67
|
+
width: 75px;
|
|
68
|
+
position: absolute;
|
|
69
|
+
right: 0;
|
|
70
|
+
bottom: 0;
|
|
71
|
+
display: none;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@media only screen and (max-width: 1000px) {
|
|
75
|
+
|
|
76
|
+
}
|