notherbase-fs 3.2.5 → 3.2.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notherbase-fs",
3
- "version": "3.2.5",
3
+ "version": "3.2.7",
4
4
  "description": "Functions to help make developing for NotherBase easier.",
5
5
  "exports": "./notherbase-fs.js",
6
6
  "scripts": {
package/public/js/base.js CHANGED
@@ -13,108 +13,6 @@ 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
-
118
16
  /**
119
17
  * Services for the player's account.
120
18
  */
@@ -123,58 +21,6 @@ class Base {
123
21
  this.username = "";
124
22
  this.email = "";
125
23
  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());
178
24
  }
179
25
 
180
26
  /**
@@ -198,31 +44,6 @@ class Base {
198
44
  this.cancelEmail();
199
45
  }
200
46
 
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
-
226
47
  /**
227
48
  * Confirms and submits a username edit.
228
49
  */
@@ -246,56 +67,9 @@ class Base {
246
67
  }
247
68
 
248
69
  constructor() {
249
- this.playerInventory = new this.#Inventory();
250
- this.playerAttributes = new this.#PlayerAttributes();
251
70
  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");
286
71
  }
287
72
 
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
-
299
73
  /**
300
74
  * Communes to logout.
301
75
  * @returns Communion response.
@@ -303,7 +77,8 @@ class Base {
303
77
  logout = async () => {
304
78
  let response = await Base.commune("logout");
305
79
 
306
- return response;
80
+ location.reload();
81
+ //return response;
307
82
  }
308
83
 
309
84
  /**
@@ -334,11 +109,8 @@ class Base {
334
109
  });
335
110
 
336
111
  if (response.status === "success") {
337
- this.playerInventory.refresh();
338
112
  this.playerAccount.username = response.data;
339
113
  this.playerAccount.email = email;
340
- this.playerAccount.refresh();
341
- this.playerAttributes.refresh();
342
114
  }
343
115
 
344
116
  return response;
@@ -384,9 +156,6 @@ class Base {
384
156
  }));
385
157
 
386
158
  if (response.status != "success") console.log(`${window.location.pathname} - ${response.message}`);
387
-
388
- this.playerInventory.refresh();
389
- this.playerAttributes.refresh();
390
159
 
391
160
  return response;
392
161
  }
@@ -20,6 +20,7 @@
20
20
  Go to Nono Cove
21
21
  </a>
22
22
 
23
+ <script src="/js/chat-box.js"></script>
23
24
  <script>
24
25
  let chatTest = new ChatBox("<%= user.username %>", "test-chat");
25
26
  let chatTest2 = new ChatBox("<%= user.username %>", "test-chat-2");
@@ -2,10 +2,6 @@
2
2
 
3
3
  <script src="/socket.io/socket.io.js"></script>
4
4
 
5
- <div class="ui">
6
- <%- include("./menu.ejs", {user: user}); %>
7
- </div>
8
-
9
5
  <script src="/js/base.js"></script>
10
6
  <script>
11
7
  const currentRoute = "<%- route %>";
@@ -13,8 +9,6 @@
13
9
  const base = new Base();
14
10
  </script>
15
11
 
16
-
17
-
18
12
  <main class="override">
19
13
  <% if (requireUser && !user) { %>
20
14
  <div class="login-cover">
package/views/footer.ejs CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  <footer>
3
-
3
+ <%- user ? `<p class="login-status">Logged In: ${user.username}</p><button onclick="base.logout()">Logout</button>` : `<p class="login-status">Not Logged In</p>` %>
4
4
  </footer>
5
5
 
6
6
  </body>
package/views/head.ejs CHANGED
@@ -13,11 +13,6 @@
13
13
  <link href="https://fonts.googleapis.com/css2?family=Redacted+Script:wght@300&display=swap" rel="stylesheet">
14
14
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
15
15
  <link rel="stylesheet" href="/styles/main.css">
16
- <link rel="stylesheet" href="/styles/menu.css">
17
- <link rel="stylesheet" href="/styles/inventory.css">
18
- <link rel="stylesheet" href="/styles/player.css">
19
- <link rel="stylesheet" href="/styles/account.css">
20
- <link rel="stylesheet" href="/styles/more.css">
21
16
  <link rel="stylesheet" href="/styles/chat.css">
22
17
  </head>
23
18
 
@@ -1,45 +0,0 @@
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
- }
@@ -1,76 +0,0 @@
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
- }
@@ -1,135 +0,0 @@
1
- .menu {
2
- width: 75%;
3
- height: 50%;
4
- border: 1px solid var(--textColor);
5
- color: var(--textColor);
6
- position: fixed;
7
- left: 12.5%;
8
- top: 5%;
9
- background-color: var(--bgColor);
10
- backdrop-filter: blur(3px);
11
- border-radius: 5px;
12
- z-index: 500;
13
- padding: 0;
14
- }
15
-
16
- .menu hr {
17
- margin: 0;
18
- }
19
-
20
- .ui .fade {
21
- background-color: var(--veryDarkBgColorTransparent);
22
- backdrop-filter: blur(3px);
23
- width: 100%;
24
- height: 130%;
25
- position: fixed;
26
- left: 0;
27
- top: 0;
28
- z-index: 400;
29
- }
30
-
31
- .ui button {
32
- background-color: var(--bgColor);
33
- border: 1px solid var(--textColor);
34
- margin: 0;
35
-
36
- }
37
-
38
- .ui button:hover {
39
- border: 1px solid var(--textColorBright);
40
- color: var(--textColorBright);
41
- cursor: pointer;
42
- }
43
-
44
- .ui button#menu {
45
- position: fixed;
46
- bottom: 15px;
47
- right: 15px;
48
- width: 64px;
49
- height: 64px;
50
- border-radius: 5px;
51
- z-index: 100;
52
- padding: var(--padding);
53
- }
54
-
55
- .menu button#close {
56
- top: 0;
57
- right: 0;
58
- width: 32px;
59
- height: 30px;
60
- position: fixed;
61
- border-radius: 0;
62
- padding: 0 3px;
63
- }
64
-
65
- .menu .tabs {
66
- width: 100%;
67
- height: 30px;
68
- border: 1px solid var(--textColor);
69
- border-top: none;
70
- padding: 0;
71
- margin: 0;
72
- display: flex;
73
- }
74
-
75
- .menu .tabs button {
76
- height: 30px;
77
- border-radius: 0;
78
- padding: 0 10px;
79
- }
80
-
81
- .menu .tabs .selected {
82
- border: 2px solid var(--textColorBright);
83
- }
84
-
85
- .menu #content-window {
86
- width: var(--fillFromMargin);
87
- margin: var(--margin);
88
- height: calc(100% - 30px - 2 * var(--margin));
89
- border: 1px solid var(--textColor);
90
- overflow: auto;
91
- padding: 0;
92
- }
93
-
94
- .menu .content {
95
- border: none;
96
- color: var(--textColor);
97
- width: 100%;
98
- height: 100%;
99
- padding: 0;
100
- z-index: 500;
101
- overflow: auto;
102
- }
103
-
104
- .menu a {
105
- margin: 0;
106
- padding: 5px;
107
- }
108
-
109
- .menu #logout {
110
- position: absolute;
111
- width: 50%;
112
- height: 40px;
113
- bottom: -40px;
114
- left: calc(25%);
115
- background-color: var(--bgColor);
116
- border: var(--standardBorder);
117
- border-top: none;
118
- border-radius: 0 0 5px 5px;
119
- text-align: center;
120
- padding: 5px;
121
- }
122
-
123
- @media only screen and (max-width: 1300px) {
124
- .menu {
125
- width: 100%;
126
- height: 80vh;
127
- top: 0;
128
- left: 0;
129
- }
130
-
131
- .ui button#menu {
132
- bottom: 5px;
133
- right: 5px;
134
- }
135
- }
@@ -1,17 +0,0 @@
1
- .content#more {
2
- padding: 10px;
3
- position: relative;
4
- height: 100%;
5
- overflow: auto;
6
- }
7
-
8
- .content#more h4 {
9
- padding: 10px;
10
- font-size: xx-large;
11
- }
12
-
13
- .content#more button {
14
- position: absolute;
15
- bottom: 5px;
16
- right: 5px;
17
- }
@@ -1,36 +0,0 @@
1
- .content#player {
2
- padding: 10px;
3
- display: flex;
4
- align-items: center;
5
- flex-wrap: wrap;
6
- justify-content: space-around;
7
- }
8
-
9
- .content#player h3 {
10
- width: 100%;
11
- text-transform: capitalize;
12
- border: 1px solid var(--textColor);
13
- padding: 5px 30px;
14
- height: 100px;
15
- position: relative;
16
- font-size: 25px;
17
- display: flex;
18
- align-items: center;
19
- }
20
-
21
- .content#player input {
22
- width: 100px;
23
- text-transform: capitalize;
24
- position: absolute;
25
- right: 0;
26
- top: 0;
27
- margin: 2px;
28
- }
29
-
30
- .content#player h3 button {
31
- width: 100px;
32
- position: absolute;
33
- right: 0;
34
- bottom: 0;
35
- margin: 2px;
36
- }
@@ -1,39 +0,0 @@
1
- <div id="account" class="invisible content">
2
- <p id="please-login">Please login to view your account settings.</p>
3
-
4
- <div class="invisible settings">
5
- <h3>Email:</h3>
6
- <div class="setting" id="email">
7
- <p></p>
8
- <button onclick="base.playerAccount.editEmail()">Change Email</button>
9
- </div>
10
- <div class="edit invisible" id="email">
11
- <input type="email" name="email">
12
- <button onclick="base.playerAccount.updateEmail()">Update</button>
13
- <button onclick="base.playerAccount.cancelEmail()">Cancel</button>
14
- </div>
15
-
16
- <hr>
17
-
18
- <h3>Username:</h3>
19
- <div class="setting" id="username">
20
- <p></p>
21
- <button onclick="base.playerAccount.editUsername()">Change Username</button>
22
- </div>
23
- <div class="edit invisible" id="username">
24
- <input type="text" name="username">
25
- <button onclick="base.playerAccount.updateUsername()">Update</button>
26
- <button onclick="base.playerAccount.cancelUsername()">Cancel</button>
27
- </div>
28
-
29
- <hr>
30
-
31
- <h3>Password:</h3>
32
- <div class="setting" id="password">
33
- <p>*********</p>
34
- <p>Visit the Keeper to Change Your Password</p>
35
- </div>
36
-
37
- <p id="info"></p>
38
- </div>
39
- </div>
@@ -1,8 +0,0 @@
1
- <div class="inventory content invisible" id="inventory">
2
- <div id="error">
3
- Please login to view your inventory.
4
- </div>
5
-
6
- <div class="item-list">
7
- </div>
8
- </div>
@@ -1,2 +0,0 @@
1
- <div class="content invisible" id="more">
2
- </div>
@@ -1,3 +0,0 @@
1
- <div class="content invisible" id="player">
2
- <p id="please-login">Please login to view your player stats.</p>
3
- </div>