notherbase-fs 1.1.42 → 1.2.2
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 +5 -20
- package/controllers/explorer.js +11 -1
- package/controllers/inventory.js +2 -4
- package/controllers/the-front.js +18 -10
- package/controllers/user.js +314 -20
- package/models/index.js +2 -1
- package/models/send-mail.js +26 -0
- package/models/user.js +11 -1
- package/package.json +6 -2
- package/public/styles/account.css +41 -0
- package/public/styles/inventory.css +12 -24
- package/public/styles/main.css +8 -30
- package/public/styles/menu.css +61 -9
- package/public/styles/more.css +3 -0
- package/public/styles/player.css +12 -0
- package/test/coast/tall-beach/nono-cove/local-scripts/nono.js +211 -0
- package/test/coast/tall-beach/nono-cove/styles/index.css +18 -0
- package/test/coast/tall-beach/nono-cove/styles/nono.css +89 -0
- package/test/coast/tall-beach/nono-cove/views/index.ejs +5 -1
- package/test/coast/tall-beach/nono-cove/views/nono-og.ejs +37 -0
- package/test/test-index.js +10 -0
- package/test/views/index.ejs +94 -4
- package/views/account.ejs +161 -0
- package/views/explorer.ejs +7 -1
- package/views/head.ejs +4 -1
- package/views/inventory.ejs +68 -59
- package/views/menu.ejs +51 -14
- package/views/{contact.ejs → more.ejs} +2 -2
- package/views/player.ejs +47 -0
package/test/views/index.ejs
CHANGED
|
@@ -4,15 +4,35 @@
|
|
|
4
4
|
|
|
5
5
|
<hr>
|
|
6
6
|
|
|
7
|
+
<h3>Register Account</h3>
|
|
8
|
+
<input type="email" placeholder="email" id="register-email">
|
|
9
|
+
<input type="text" placeholder="username" id="register-user">
|
|
10
|
+
<input type="password" placeholder="password" id="register-pass">
|
|
11
|
+
<button id="register-button">register</button>
|
|
12
|
+
<p id="register-info"></p>
|
|
13
|
+
|
|
14
|
+
<hr>
|
|
15
|
+
|
|
7
16
|
<div class="auth-form" id="login-form">
|
|
8
17
|
<h1>NotherBase</h1>
|
|
9
18
|
<h3>Login to Your Account</h3>
|
|
10
|
-
<input type="
|
|
19
|
+
<input type="email" name="email" placeholder="user@email.com" id="login-email">
|
|
11
20
|
<input type="password" name="password" placeholder="password" id="login-pass">
|
|
12
21
|
<button id="login-button">Login</button>
|
|
22
|
+
<button id="reset-password">Reset Password</button>
|
|
13
23
|
<p id="login-info"></p>
|
|
14
24
|
</div>
|
|
15
25
|
|
|
26
|
+
<div class="auth-form" id="reset-form">
|
|
27
|
+
<h1>NotherBase</h1>
|
|
28
|
+
<h3>Login to Your Account</h3>
|
|
29
|
+
<input type="number" name="token" placeholder="Your Reset Code" id="token">
|
|
30
|
+
<input type="password" name="password" placeholder="Type Your New Password Here" minlength="8" required id="password">
|
|
31
|
+
<input type="password" name="confirmation" placeholder="Type Your New Password Here Again" minlength="8" required id="confirmation">
|
|
32
|
+
<button id="change-password">Change Password</button>
|
|
33
|
+
<p id="change-info"></p>
|
|
34
|
+
</div>
|
|
35
|
+
|
|
16
36
|
<hr>
|
|
17
37
|
|
|
18
38
|
<div class="locked to nother-base">
|
|
@@ -20,12 +40,17 @@
|
|
|
20
40
|
</div>
|
|
21
41
|
|
|
22
42
|
<a href="/coast/tall-beach/nono-cove" class="invisible to nother-base">
|
|
23
|
-
Go
|
|
43
|
+
Go inside
|
|
24
44
|
</a>
|
|
25
45
|
|
|
26
46
|
<script>
|
|
47
|
+
let $resetPassword = $("#reset-password");
|
|
27
48
|
let $loginButton = $("#login-button");
|
|
28
49
|
let $loginInfo = $("#login-info");
|
|
50
|
+
let $registerButton = $("#register-button");
|
|
51
|
+
let $registerInfo = $("#register-info");
|
|
52
|
+
let $changePasswordButton = $("button#change-password");
|
|
53
|
+
let $changeInfo = $("#change-info");
|
|
29
54
|
let $toNonoButton = $(".locked.to.nother-base");
|
|
30
55
|
let $toNonoLink = $(".invisible.to.nother-base");
|
|
31
56
|
|
|
@@ -37,21 +62,86 @@
|
|
|
37
62
|
$loginButton.on("click", async function () {
|
|
38
63
|
try {
|
|
39
64
|
await $.post("/user/login", {
|
|
40
|
-
|
|
65
|
+
email: $("#login-email").val(),
|
|
41
66
|
password: $("#login-pass").val()
|
|
42
67
|
}, (data) => {
|
|
43
68
|
$loginInfo.text("To your right you hear the sound of a bang against a chain-link fence. You've logged in.");
|
|
44
69
|
$toNonoButton.addClass("invisible");
|
|
45
70
|
$toNonoLink.removeClass("invisible");
|
|
71
|
+
|
|
72
|
+
playerInventory.refresh();
|
|
73
|
+
playerAttributes.refresh();
|
|
74
|
+
accountServices.refresh();
|
|
75
|
+
});
|
|
76
|
+
} catch (error) {
|
|
77
|
+
if (error.status === 401) {
|
|
78
|
+
$loginInfo.text("Login Error: Email or password incorrect!");
|
|
79
|
+
}
|
|
80
|
+
else if (error.status === 500) {
|
|
81
|
+
$loginInfo.text("Server Error: Try again later!");
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
$registerButton.on("click", async function () {
|
|
87
|
+
try {
|
|
88
|
+
await $.post("/user/register", {
|
|
89
|
+
username: $("#register-user").val(),
|
|
90
|
+
password: $("#register-pass").val(),
|
|
91
|
+
email: $("#register-email").val()
|
|
92
|
+
}, (data) => {
|
|
93
|
+
$registerInfo.text("Account registered.");
|
|
46
94
|
});
|
|
47
95
|
} catch (error) {
|
|
48
96
|
//console.log(error);
|
|
97
|
+
if (error.status === 400) {
|
|
98
|
+
$registerInfo.text("Login Error: Username already taken!");
|
|
99
|
+
}
|
|
100
|
+
else if (error.status === 500) {
|
|
101
|
+
$registerInfo.text("Server Error: Try again later!");
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
$resetPassword.on("click", async function () {
|
|
107
|
+
try {
|
|
108
|
+
await $.get("/user/password-reset", { email: $("#login-email").val() });
|
|
109
|
+
$loginInfo.text("Reset link sent to your email.");
|
|
110
|
+
}
|
|
111
|
+
catch(err) {
|
|
49
112
|
if (error.status === 401) {
|
|
50
|
-
$loginInfo.text("
|
|
113
|
+
$loginInfo.text("Reset Error: Email not found!");
|
|
51
114
|
}
|
|
52
115
|
else if (error.status === 500) {
|
|
53
116
|
$loginInfo.text("Server Error: Try again later!");
|
|
54
117
|
}
|
|
55
118
|
}
|
|
56
119
|
});
|
|
120
|
+
|
|
121
|
+
$changePasswordButton.on("click", async function () {
|
|
122
|
+
try {
|
|
123
|
+
let token = $("#reset-form #token").val();
|
|
124
|
+
|
|
125
|
+
await $.post(`/user/password-reset/${token}`, {
|
|
126
|
+
token: token,
|
|
127
|
+
password: $("#reset-form #password").val(),
|
|
128
|
+
confirmation: $("#reset-form #confirmation").val()
|
|
129
|
+
}, (data) => {
|
|
130
|
+
$changeInfo.text("Password changed.");
|
|
131
|
+
});
|
|
132
|
+
} catch (error) {
|
|
133
|
+
if (error.status === 498) {
|
|
134
|
+
$changeInfo.text("Change Error: Your reset code expired! Please request a new one.");
|
|
135
|
+
}
|
|
136
|
+
else if (error.status === 400) {
|
|
137
|
+
$changeInfo.text("Change Error: Passwords must match!");
|
|
138
|
+
}
|
|
139
|
+
else if (error.status === 404) {
|
|
140
|
+
$changeInfo.text("Change Error: Reset code not valid!");
|
|
141
|
+
}
|
|
142
|
+
else if (error.status === 500) {
|
|
143
|
+
$changeInfo.text("Server Error: Try again later!");
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
});
|
|
57
147
|
</script>
|
|
@@ -0,0 +1,161 @@
|
|
|
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="accountServices.editEmail()">Change Email</button>
|
|
9
|
+
</div>
|
|
10
|
+
<div class="edit invisible" id="email">
|
|
11
|
+
<input type="email" name="email">
|
|
12
|
+
<button onclick="accountServices.updateEmail()">Update</button>
|
|
13
|
+
<button onclick="accountServices.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="accountServices.editUsername()">Change Username</button>
|
|
22
|
+
</div>
|
|
23
|
+
<div class="edit invisible" id="username">
|
|
24
|
+
<input type="text" name="username">
|
|
25
|
+
<button onclick="accountServices.updateUsername()">Update</button>
|
|
26
|
+
<button onclick="accountServices.cancelUsername()">Cancel</button>
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
<hr>
|
|
30
|
+
|
|
31
|
+
<h3>Password:</h3>
|
|
32
|
+
<div class="setting" id="password">
|
|
33
|
+
<p>*********</p>
|
|
34
|
+
<button onclick="accountServices.editPassword()">Change Password</button>
|
|
35
|
+
</div>
|
|
36
|
+
<div class="edit invisible" id="password">
|
|
37
|
+
<input type="password" name="password">
|
|
38
|
+
<button onclick="accountServices.updatePassword()">Update</button>
|
|
39
|
+
<button onclick="accountServices.cancelPassword()">Cancel</button>
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
<p id="info"></p>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
<script>
|
|
47
|
+
class AccountServices {
|
|
48
|
+
constructor() {
|
|
49
|
+
this.$emailSetting = $(".content#account .setting#email");
|
|
50
|
+
this.$email = this.$emailSetting.find("p");
|
|
51
|
+
this.$emailEdit = $(".content#account .edit#email");
|
|
52
|
+
this.$emailInput = this.$emailEdit.find("input");
|
|
53
|
+
|
|
54
|
+
this.$usernameSetting = $(".content#account .setting#username");
|
|
55
|
+
this.$username = this.$usernameSetting.find("p");
|
|
56
|
+
this.$usernameEdit = $(".content#account .edit#username");
|
|
57
|
+
this.$usernameInput = this.$usernameEdit.find("input");
|
|
58
|
+
|
|
59
|
+
this.$passwordSetting = $(".content#account .setting#password");
|
|
60
|
+
this.$passwordEdit = $(".content#account .edit#password");
|
|
61
|
+
this.$passwordInput = this.$passwordEdit.find("input");
|
|
62
|
+
|
|
63
|
+
this.$info = $(".content#account #info");
|
|
64
|
+
|
|
65
|
+
<% if (user) { %>
|
|
66
|
+
this.refresh();
|
|
67
|
+
<% } %>
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async refresh() {
|
|
71
|
+
try {
|
|
72
|
+
$.get("/user/basic", (data) => {
|
|
73
|
+
this.$email.text(data.email);
|
|
74
|
+
this.$emailInput.val(data.email);
|
|
75
|
+
this.$username.text(data.username);
|
|
76
|
+
this.$usernameInput.val(data.username);
|
|
77
|
+
|
|
78
|
+
$(".content#account .settings").removeClass("invisible");
|
|
79
|
+
$(".content#account #please-login").addClass("invisible");
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
catch(err) {
|
|
83
|
+
this.$info.text(err);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
editEmail() {
|
|
88
|
+
this.$emailSetting.addClass("invisible");
|
|
89
|
+
this.$emailEdit.removeClass("invisible");
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
cancelEmail() {
|
|
93
|
+
this.$emailSetting.removeClass("invisible");
|
|
94
|
+
this.$emailEdit.addClass("invisible");
|
|
95
|
+
this.$emailInput.val(this.$email.text());
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async updateEmail() {
|
|
99
|
+
try {
|
|
100
|
+
await $.post("/user/email", { email: this.$emailInput.val() }, (data) => {
|
|
101
|
+
this.$email.text(this.$emailInput.val());
|
|
102
|
+
this.cancelEmail();
|
|
103
|
+
this.$info.text("Email Updated!");
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
catch(err) {
|
|
107
|
+
this.$info.text(err);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
editUsername() {
|
|
112
|
+
this.$usernameSetting.addClass("invisible");
|
|
113
|
+
this.$usernameEdit.removeClass("invisible");
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
cancelUsername() {
|
|
117
|
+
this.$usernameSetting.removeClass("invisible");
|
|
118
|
+
this.$usernameEdit.addClass("invisible");
|
|
119
|
+
this.$usernameInput.val(this.$username.text());
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
async updateUsername() {
|
|
123
|
+
try {
|
|
124
|
+
await $.post("/user/username", { username: this.$usernameInput.val() }, (data) => {
|
|
125
|
+
this.$username.text(this.$usernameInput.val());
|
|
126
|
+
this.cancelUsername();
|
|
127
|
+
this.$info.text("Username Updated!");
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
catch(err) {
|
|
131
|
+
if (err.status === 401) this.$info.text("Username already taken!");
|
|
132
|
+
else this.$info.text("Server Error");
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
editPassword() {
|
|
137
|
+
this.$passwordSetting.addClass("invisible");
|
|
138
|
+
this.$passwordEdit.removeClass("invisible");
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
cancelPassword() {
|
|
142
|
+
this.$passwordSetting.removeClass("invisible");
|
|
143
|
+
this.$passwordEdit.addClass("invisible");
|
|
144
|
+
this.$passwordInput.val("");
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
async updatePassword() {
|
|
148
|
+
try {
|
|
149
|
+
await $.post("/user/password", { password: this.$passwordInput.val() }, (data) => {
|
|
150
|
+
this.cancelPassword();
|
|
151
|
+
this.$info.text("Password Updated!");
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
catch(err) {
|
|
155
|
+
this.$info.text(err);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
let accountServices = new AccountServices();
|
|
161
|
+
</script>
|
package/views/explorer.ejs
CHANGED
|
@@ -9,12 +9,18 @@
|
|
|
9
9
|
<% } %>
|
|
10
10
|
</style>
|
|
11
11
|
|
|
12
|
+
<script>
|
|
13
|
+
let itemIDs = [];
|
|
14
|
+
<% for (let i = 0; i < itemIDs.length; i++) { %>
|
|
15
|
+
itemIDs.push("<%= itemIDs[i] %>");
|
|
16
|
+
<% } %>
|
|
17
|
+
</script>
|
|
18
|
+
|
|
12
19
|
<main class="override">
|
|
13
20
|
<%- include(`${main}.ejs`); %>
|
|
14
21
|
</main>
|
|
15
22
|
|
|
16
23
|
<div class="ui">
|
|
17
|
-
<%- include("./inventory.ejs", {inventory: inventory}); %>
|
|
18
24
|
<%- include("./menu.ejs", {user: user}); %>
|
|
19
25
|
</div>
|
|
20
26
|
|
package/views/head.ejs
CHANGED
|
@@ -14,8 +14,11 @@
|
|
|
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
17
|
<link rel="stylesheet" href="/styles/menu.css">
|
|
18
|
+
<link rel="stylesheet" href="/styles/inventory.css">
|
|
19
|
+
<link rel="stylesheet" href="/styles/player.css">
|
|
20
|
+
<link rel="stylesheet" href="/styles/account.css">
|
|
21
|
+
<link rel="stylesheet" href="/styles/more.css">
|
|
19
22
|
</head>
|
|
20
23
|
|
|
21
24
|
<body>
|
package/views/inventory.ejs
CHANGED
|
@@ -1,51 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
<div class="search-results">
|
|
11
|
-
|
|
12
|
-
</div>
|
|
13
|
-
</div>
|
|
14
|
-
|
|
15
|
-
<% break;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
} %>
|
|
19
|
-
|
|
20
|
-
<div class="item-list">
|
|
21
|
-
</div>
|
|
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-spawner invisible">
|
|
7
|
+
<input type="text" class="search">
|
|
8
|
+
<div class="search-results">
|
|
9
|
+
|
|
22
10
|
</div>
|
|
11
|
+
</div>
|
|
23
12
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
<% } else { %>
|
|
28
|
-
<button id="inventory">
|
|
29
|
-
ERR
|
|
30
|
-
</button>
|
|
31
|
-
<% } %>
|
|
32
|
-
<% } %>
|
|
13
|
+
<div class="item-list">
|
|
14
|
+
</div>
|
|
15
|
+
</div>
|
|
33
16
|
|
|
34
17
|
<script>
|
|
35
18
|
class Inventory {
|
|
36
19
|
constructor() {
|
|
37
20
|
this.$div = $(".inventory");
|
|
38
|
-
this.$list = $(".item-list");
|
|
21
|
+
this.$list = $(".inventory .item-list");
|
|
39
22
|
this.$search = $(".search");
|
|
40
23
|
this.$searchResults = $(".search-results");
|
|
41
24
|
this.searchResults = [];
|
|
42
|
-
this.$
|
|
25
|
+
this.$error = $("#inventory #error");
|
|
43
26
|
this.items = [];
|
|
44
27
|
|
|
45
|
-
this.$button.on("click", () => {
|
|
46
|
-
this.$div.toggleClass("invisible");
|
|
47
|
-
});
|
|
48
|
-
|
|
49
28
|
this.$search.on("keyup", () => {
|
|
50
29
|
let searchString = this.$search.val();
|
|
51
30
|
|
|
@@ -54,17 +33,13 @@
|
|
|
54
33
|
});
|
|
55
34
|
});
|
|
56
35
|
|
|
57
|
-
|
|
58
|
-
this.items = data.foundInventory.items;
|
|
59
|
-
|
|
60
|
-
this.render();
|
|
61
|
-
});
|
|
36
|
+
this.refresh();
|
|
62
37
|
|
|
63
38
|
setInterval(this.update, this.updateCooldown);
|
|
64
39
|
}
|
|
65
40
|
|
|
66
|
-
change(change) {
|
|
67
|
-
$.post("/inventory", { change: change }, (data, status) => {
|
|
41
|
+
async change(change) {
|
|
42
|
+
await $.post("/inventory", { change: change }, (data, status) => {
|
|
68
43
|
if (status === "success") {
|
|
69
44
|
let holding = false;
|
|
70
45
|
|
|
@@ -87,28 +62,62 @@
|
|
|
87
62
|
});
|
|
88
63
|
}
|
|
89
64
|
|
|
65
|
+
async getData() {
|
|
66
|
+
try {
|
|
67
|
+
await $.get("/inventory", (data) => {
|
|
68
|
+
if (data.foundInventory) this.items = data.foundInventory.items;
|
|
69
|
+
|
|
70
|
+
this.clearError();
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
catch(err) {
|
|
74
|
+
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
90
78
|
render() {
|
|
91
79
|
this.$list.empty();
|
|
92
|
-
|
|
80
|
+
|
|
93
81
|
for (let i = 0; i < this.items.length; i++) {
|
|
94
82
|
let $new = this.$list.append(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
83
|
+
`<div class="item-card">
|
|
84
|
+
<h5>${this.items[i].item.name}</h5>
|
|
85
|
+
<button id="${i}">X</button>
|
|
86
|
+
<hr>
|
|
87
|
+
<p>${this.items[i].amount}</p>
|
|
88
|
+
</div>`
|
|
89
|
+
).children().last();
|
|
90
|
+
|
|
91
|
+
$new.find("button").on("click", (e) => {
|
|
92
|
+
let which = parseInt(e.currentTarget.id);
|
|
93
|
+
|
|
94
|
+
this.change({
|
|
95
|
+
item: this.items[which].item._id,
|
|
96
|
+
amount: -1
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
this.clearError();
|
|
109
100
|
});
|
|
110
|
-
}
|
|
101
|
+
}
|
|
111
102
|
}
|
|
103
|
+
|
|
104
|
+
async refresh() {
|
|
105
|
+
try {
|
|
106
|
+
await this.getData();
|
|
107
|
+
this.render();
|
|
108
|
+
}
|
|
109
|
+
catch(err) {
|
|
110
|
+
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
clearError() {
|
|
115
|
+
this.$error.addClass("invisible");
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
setError(text) {
|
|
119
|
+
this.$error.text(text);
|
|
120
|
+
this.$error.removeClass("invisible");
|
|
112
121
|
}
|
|
113
122
|
|
|
114
123
|
renderSearchResults(results) {
|
package/views/menu.ejs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
<div class="
|
|
2
|
-
|
|
1
|
+
<div class="fade invisible">
|
|
2
|
+
|
|
3
|
+
</div>
|
|
3
4
|
|
|
5
|
+
<div class="menu invisible">
|
|
4
6
|
<div class="tabs">
|
|
5
7
|
<button id="inventory">
|
|
6
8
|
Inventory
|
|
@@ -8,35 +10,70 @@
|
|
|
8
10
|
<button id="player">
|
|
9
11
|
Player
|
|
10
12
|
</button>
|
|
11
|
-
<button id="
|
|
12
|
-
|
|
13
|
+
<button id="account">
|
|
14
|
+
Account
|
|
13
15
|
</button>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
X
|
|
16
|
+
<button id="more">
|
|
17
|
+
More
|
|
17
18
|
</button>
|
|
18
19
|
</div>
|
|
19
20
|
|
|
20
|
-
<
|
|
21
|
-
|
|
21
|
+
<button id="close">
|
|
22
|
+
X
|
|
23
|
+
</button>
|
|
22
24
|
|
|
25
|
+
<div id="content-window">
|
|
26
|
+
<%- include("./inventory.ejs"); %>
|
|
27
|
+
<%- include("./player.ejs"); %>
|
|
28
|
+
<%- include("./account.ejs"); %>
|
|
29
|
+
<%- include("./more.ejs"); %>
|
|
23
30
|
</div>
|
|
24
31
|
|
|
25
|
-
|
|
26
|
-
<a href="/user/logout">Logout</a>
|
|
27
|
-
<% } %>
|
|
32
|
+
<a href="/user/logout" id="logout">Logout</a>
|
|
28
33
|
</div>
|
|
29
34
|
|
|
30
35
|
<button id="menu"><i class="fas fa-cog"></i></button>
|
|
31
36
|
|
|
32
37
|
<script>
|
|
33
38
|
let $menu = $(".menu");
|
|
39
|
+
let $fade = $(".ui .fade");
|
|
40
|
+
let menuClosing = false;
|
|
41
|
+
|
|
42
|
+
let closeMenu = function closeMenu() {
|
|
43
|
+
menuClosing = true;
|
|
44
|
+
$fade.addClass("camo");
|
|
45
|
+
|
|
46
|
+
setTimeout(() => {
|
|
47
|
+
$menu.addClass("invisible");
|
|
48
|
+
$fade.addClass("invisible");
|
|
49
|
+
menuClosing = false;
|
|
50
|
+
}, 100);
|
|
51
|
+
}
|
|
34
52
|
|
|
35
53
|
$("button#menu").on("click", function () {
|
|
36
54
|
$menu.toggleClass("invisible");
|
|
55
|
+
$fade.removeClass("camo");
|
|
56
|
+
$fade.removeClass("invisible");
|
|
37
57
|
});
|
|
38
58
|
|
|
39
|
-
$
|
|
40
|
-
|
|
59
|
+
$fade.on("click", function () {
|
|
60
|
+
if (!menuClosing) closeMenu();
|
|
41
61
|
});
|
|
62
|
+
|
|
63
|
+
$(".menu button#close").on("click", function () {
|
|
64
|
+
closeMenu();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
$(".menu .tabs button").on("click", function (e) {
|
|
68
|
+
switchTab(e.currentTarget.id);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
let switchTab = function switchTab(id) {
|
|
72
|
+
$("#content-window .content").addClass("invisible");
|
|
73
|
+
$(".menu .tabs button").removeClass("selected");
|
|
74
|
+
$(`#content-window #${id}`).removeClass("invisible");
|
|
75
|
+
$(`.menu .tabs #${id}`).addClass("selected");
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
switchTab("inventory");
|
|
42
79
|
</script>
|
package/views/player.ejs
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<div class="content invisible" id="player">
|
|
2
|
+
<p id="please-login">Please login to view your player stats.</p>
|
|
3
|
+
</div>
|
|
4
|
+
|
|
5
|
+
<script>
|
|
6
|
+
class PlayerAttributes {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.$content = $(".content#player");
|
|
9
|
+
|
|
10
|
+
<% if (user) { %>
|
|
11
|
+
this.refresh();
|
|
12
|
+
<% } %>
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async setAtt(change, to) {
|
|
16
|
+
await $.post("/user/attributes", { change: change, to: to }, async (data) => {
|
|
17
|
+
await this.refresh();
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async refresh() {
|
|
22
|
+
try {
|
|
23
|
+
await $.get("/user/attributes", (data) => {
|
|
24
|
+
this.$content.empty();
|
|
25
|
+
for (const [key, value] of Object.entries(data)) {
|
|
26
|
+
<% if (user) {
|
|
27
|
+
if (user.authLevels.includes("Creator")) { %>
|
|
28
|
+
this.$content.append(`<h3 id="${key}">
|
|
29
|
+
${key}: ${value}
|
|
30
|
+
<input type="number"></input>
|
|
31
|
+
<button onclick="playerAttributes.setAtt('${key}', $('.content#player h3#${key} input').val())">Set</button>
|
|
32
|
+
</h3>`);
|
|
33
|
+
<% }
|
|
34
|
+
} else { %>
|
|
35
|
+
this.$content.append(`<h3 id="${key}">${key}: ${value}</h3>`);
|
|
36
|
+
<% } %>
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
catch(err) {
|
|
41
|
+
console.log(err);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
let playerAttributes = new PlayerAttributes();
|
|
47
|
+
</script>
|