notherbase-fs 4.0.22 → 4.0.23
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/README.md +6 -6
- package/controllers/creation.js +147 -147
- package/controllers/spirit-world.js +174 -174
- package/controllers/user.js +240 -240
- package/controllers/util.js +64 -64
- package/models/index.js +33 -33
- package/models/send-mail.js +58 -58
- package/models/spirit.js +234 -234
- package/notherbase-fs.js +112 -112
- package/package.json +40 -40
- package/public/js/base.js +222 -227
- package/public/js/chat-box.js +120 -120
- package/test/coast/tall-beach/nono-cove/index.css +17 -17
- package/test/coast/tall-beach/nono-cove/index.ejs +29 -29
- package/test/coast/tall-beach/nono-cove/nono-og/add-gold.js +15 -15
- package/test/coast/tall-beach/nono-cove/nono-og/index.ejs +46 -46
- package/test/coast/tall-beach/nono-cove/nono-og/nono.css +88 -88
- package/test/coast/tall-beach/nono-cove/nono-og/nono.js +207 -207
- package/test/pages/test-page/emailTime.js +8 -8
- package/test/pages/test-page/index.ejs +104 -104
- package/test/pages/void/index.ejs +35 -35
- package/test/pages/void/void.css +2 -2
- package/test/public/styles/main.css +792 -792
- package/test/the-front/add-gold.js +13 -13
- package/test/the-front/check/check.css +2 -2
- package/test/the-front/check/emailTime.js +9 -9
- package/test/the-front/check/flip.js +9 -9
- package/test/the-front/check/index.ejs +54 -54
- package/test/the-front/check/save-input.js +7 -7
- package/test/the-front/index.ejs +116 -99
- package/test/the-front/keeper/clipboards.js +133 -133
- package/test/the-front/keeper/index.ejs +80 -80
- package/test/the-front/keeper/keeper.css +157 -157
- package/test/the-front/keeper/keeper.js +140 -140
- package/test-index.js +19 -19
- package/test2/pages/test-page/emailTime.js +8 -8
- package/test2/pages/test-page/index.ejs +104 -104
- package/test2/pages/void/index.ejs +35 -35
- package/test2/pages/void/void.css +2 -2
- package/test2/public/styles/main.css +792 -792
- package/test2/the-front/add-gold.js +13 -13
- package/test2/the-front/check/check.css +2 -2
- package/test2/the-front/check/emailTime.js +9 -9
- package/test2/the-front/check/flip.js +9 -9
- package/test2/the-front/check/index.ejs +54 -54
- package/test2/the-front/check/save-input.js +7 -7
- package/test2/the-front/index.ejs +99 -99
- package/test2/the-front/keeper/clipboards.js +133 -133
- package/test2/the-front/keeper/index.ejs +80 -80
- package/test2/the-front/keeper/keeper.css +157 -157
- package/test2/the-front/keeper/keeper.js +140 -140
- package/views/explorer.ejs +82 -82
- package/views/footer.ejs +9 -9
- package/views/head.ejs +17 -17
package/public/js/base.js
CHANGED
|
@@ -1,228 +1,223 @@
|
|
|
1
|
-
class Base {
|
|
2
|
-
/**
|
|
3
|
-
* Communes with the user spirit for easy access to those functions.
|
|
4
|
-
* @param {String} route /s/user/[route]
|
|
5
|
-
* @param {Object} data Data to send with the communion.
|
|
6
|
-
* @returns Communion response.
|
|
7
|
-
*/
|
|
8
|
-
static commune = async (route, data = {}) => {
|
|
9
|
-
let response = await $.post("/s/user/" + route, JSON.stringify(data));
|
|
10
|
-
|
|
11
|
-
if (response.status != "success") console.log(`${"/s/user/" + route} - ${response.message}`);
|
|
12
|
-
|
|
13
|
-
return response;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
constructor() {
|
|
17
|
-
this.playerAccount = {
|
|
18
|
-
username: null
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
this.$viewToggle = null;
|
|
22
|
-
this.viewState = "compact";
|
|
23
|
-
|
|
24
|
-
Base.commune("getView").then((res) => {
|
|
25
|
-
if (res.data === "full") this.toggleView(false);
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Communes to logout.
|
|
31
|
-
* @returns Communion response.
|
|
32
|
-
*/
|
|
33
|
-
logout = async (test = false) => {
|
|
34
|
-
let response = await Base.commune("logout");
|
|
35
|
-
|
|
36
|
-
if (!test) location.reload();
|
|
37
|
-
else {
|
|
38
|
-
this.playerAccount.username = null;
|
|
39
|
-
this.updateLoginStatus();
|
|
40
|
-
return response;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Communes to register a new account.
|
|
46
|
-
* @param {String} email The user's email address.
|
|
47
|
-
* @param {String} username The user's display name.
|
|
48
|
-
* @param {String} password The user's ****.
|
|
49
|
-
* @returns Communion response.
|
|
50
|
-
*/
|
|
51
|
-
attemptRegister = async (username, password) => {
|
|
52
|
-
let response = await Base.commune("register", {
|
|
53
|
-
username, password
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
return response;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Communes to login.
|
|
61
|
-
* @param {String} email The user's email address.
|
|
62
|
-
* @param {String} password The user's password.
|
|
63
|
-
* @returns Communion response.
|
|
64
|
-
*/
|
|
65
|
-
attemptLogin = async (username, password) => {
|
|
66
|
-
let response = await Base.commune("login", {
|
|
67
|
-
username, password
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
if (response.status === "success") {
|
|
71
|
-
this.playerAccount.username = response.data;
|
|
72
|
-
this.updateLoginStatus(response.data);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return response;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Communes to finalize a password change.
|
|
80
|
-
* @param {Number} token The password reset token.
|
|
81
|
-
* @param {String} email The user's email address.
|
|
82
|
-
* @param {String} password The user's new password.
|
|
83
|
-
* @param {String} confirmation Confirmation of the user's new password.
|
|
84
|
-
* @returns Communion response.
|
|
85
|
-
*/
|
|
86
|
-
changePassword = async (oldPassword, newPassword, confirmation) => {
|
|
87
|
-
let response = await Base.commune("changePassword", { oldPassword, newPassword, confirmation });
|
|
88
|
-
|
|
89
|
-
return response;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Runs a script on the server.
|
|
94
|
-
* @param {String} what The script to run.
|
|
95
|
-
* @param {Object} data Data to send as input for the script.
|
|
96
|
-
* @returns Communion response.
|
|
97
|
-
*/
|
|
98
|
-
do = async (what, data = null) => {
|
|
99
|
-
let response = await $.post("/s/serve", JSON.stringify({
|
|
100
|
-
script: what,
|
|
101
|
-
route: window.location.pathname,
|
|
102
|
-
...data
|
|
103
|
-
}));
|
|
104
|
-
|
|
105
|
-
if (response.status != "success") console.log(`${window.location.pathname} - ${response.message}`);
|
|
106
|
-
|
|
107
|
-
return response;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Loads all spirits of a certain service.
|
|
112
|
-
* @param {String} service The name of the spirits to load.
|
|
113
|
-
* @param {String} scope Defaults to local, else global.
|
|
114
|
-
* @param {Object} data Data to filter the spirits by.
|
|
115
|
-
* @param {ObjectID} id The id of the spirit to load.
|
|
116
|
-
* @returns Spirit world response.
|
|
117
|
-
*/
|
|
118
|
-
loadAll = async (service, scope = "local", data = {}, id = null) => {
|
|
119
|
-
let response = await $.post("/s/loadAll", JSON.stringify({ service, scope, data, id }));
|
|
120
|
-
|
|
121
|
-
return response;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Loads a single spirit of a certain service.
|
|
126
|
-
* @param {String} service The name of the spirit to load.
|
|
127
|
-
* @param {String} scope Defaults to local, else global.
|
|
128
|
-
* @param {Object} data Data to filter the spirits by.
|
|
129
|
-
* @param {ObjectID} id The id of the spirit to load.
|
|
130
|
-
* @returns Spirit world response.
|
|
131
|
-
*/
|
|
132
|
-
load = async (service, scope = "local", data = {}, id = null) => {
|
|
133
|
-
let response = await $.post("/s/load", JSON.stringify({ service, scope, data, id }));
|
|
134
|
-
|
|
135
|
-
return response;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Creates the toggle view button.
|
|
140
|
-
*/
|
|
141
|
-
createToggleViewButton = async () => {
|
|
142
|
-
// add a button to the footer for toggling between compact and full view
|
|
143
|
-
this.$viewToggle = $("<button>").addClass("view-toggle").text(">");
|
|
144
|
-
this.$viewToggle.on("click", () => {
|
|
145
|
-
this.toggleView();
|
|
146
|
-
});
|
|
147
|
-
$("footer").append(this.$viewToggle);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Toggles the view between compact and full.
|
|
152
|
-
* @param {Boolean} save Whether or not to save the view state.
|
|
153
|
-
*/
|
|
154
|
-
toggleView = async (save = true) => {
|
|
155
|
-
if (this.viewState === "compact") {
|
|
156
|
-
this.viewState = "full";
|
|
157
|
-
if (this.$viewToggle) this.$viewToggle.text("<");
|
|
158
|
-
$("main").addClass("full-view");
|
|
159
|
-
}
|
|
160
|
-
else {
|
|
161
|
-
this.viewState = "compact";
|
|
162
|
-
if (this.$viewToggle) this.$viewToggle.text(">");
|
|
163
|
-
$("main").removeClass("full-view");
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
if (save) Base.commune("setView", { view: this.viewState });
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Appends html to the head.
|
|
171
|
-
* @param {String} html The html to append.
|
|
172
|
-
*/
|
|
173
|
-
appendToHead = (html) => {
|
|
174
|
-
$("head").append($(html));
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
//update login status
|
|
178
|
-
updateLoginStatus = (name = null) => {
|
|
179
|
-
let $status = $("footer .login-status");
|
|
180
|
-
let $logout = $("footer .logout");
|
|
181
|
-
|
|
182
|
-
if (name) {
|
|
183
|
-
$status.text(`Logged In: ${name}`);
|
|
184
|
-
$logout.removeClass("invisible");
|
|
185
|
-
}
|
|
186
|
-
else {
|
|
187
|
-
$status.text("Not Logged In");
|
|
188
|
-
$logout.addClass("invisible");
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// download your data
|
|
193
|
-
downloadData = async () => {
|
|
194
|
-
let response = await Base.commune("downloadData");
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
let
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
a
|
|
203
|
-
a.
|
|
204
|
-
|
|
205
|
-
a.
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
deleteData = async (password) => {
|
|
212
|
-
let response = await Base.commune("deleteAlldata", { password });
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
importData = async (password, data) => {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
let response = await Base.commune("importData", { password, data: parsed });
|
|
224
|
-
console.log("Imported: ", response.status === "success" ? response.data : "no");
|
|
225
|
-
});
|
|
226
|
-
reader.readAsText(data);
|
|
227
|
-
}
|
|
1
|
+
class Base {
|
|
2
|
+
/**
|
|
3
|
+
* Communes with the user spirit for easy access to those functions.
|
|
4
|
+
* @param {String} route /s/user/[route]
|
|
5
|
+
* @param {Object} data Data to send with the communion.
|
|
6
|
+
* @returns Communion response.
|
|
7
|
+
*/
|
|
8
|
+
static commune = async (route, data = {}) => {
|
|
9
|
+
let response = await $.post("/s/user/" + route, JSON.stringify(data));
|
|
10
|
+
|
|
11
|
+
if (response.status != "success") console.log(`${"/s/user/" + route} - ${response.message}`);
|
|
12
|
+
|
|
13
|
+
return response;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
constructor() {
|
|
17
|
+
this.playerAccount = {
|
|
18
|
+
username: null
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
this.$viewToggle = null;
|
|
22
|
+
this.viewState = "compact";
|
|
23
|
+
|
|
24
|
+
Base.commune("getView").then((res) => {
|
|
25
|
+
if (res.data === "full") this.toggleView(false);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Communes to logout.
|
|
31
|
+
* @returns Communion response.
|
|
32
|
+
*/
|
|
33
|
+
logout = async (test = false) => {
|
|
34
|
+
let response = await Base.commune("logout");
|
|
35
|
+
|
|
36
|
+
if (!test) location.reload();
|
|
37
|
+
else {
|
|
38
|
+
this.playerAccount.username = null;
|
|
39
|
+
this.updateLoginStatus();
|
|
40
|
+
return response;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Communes to register a new account.
|
|
46
|
+
* @param {String} email The user's email address.
|
|
47
|
+
* @param {String} username The user's display name.
|
|
48
|
+
* @param {String} password The user's ****.
|
|
49
|
+
* @returns Communion response.
|
|
50
|
+
*/
|
|
51
|
+
attemptRegister = async (username, password) => {
|
|
52
|
+
let response = await Base.commune("register", {
|
|
53
|
+
username, password
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
return response;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Communes to login.
|
|
61
|
+
* @param {String} email The user's email address.
|
|
62
|
+
* @param {String} password The user's password.
|
|
63
|
+
* @returns Communion response.
|
|
64
|
+
*/
|
|
65
|
+
attemptLogin = async (username, password) => {
|
|
66
|
+
let response = await Base.commune("login", {
|
|
67
|
+
username, password
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
if (response.status === "success") {
|
|
71
|
+
this.playerAccount.username = response.data;
|
|
72
|
+
this.updateLoginStatus(response.data);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return response;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Communes to finalize a password change.
|
|
80
|
+
* @param {Number} token The password reset token.
|
|
81
|
+
* @param {String} email The user's email address.
|
|
82
|
+
* @param {String} password The user's new password.
|
|
83
|
+
* @param {String} confirmation Confirmation of the user's new password.
|
|
84
|
+
* @returns Communion response.
|
|
85
|
+
*/
|
|
86
|
+
changePassword = async (oldPassword, newPassword, confirmation) => {
|
|
87
|
+
let response = await Base.commune("changePassword", { oldPassword, newPassword, confirmation });
|
|
88
|
+
|
|
89
|
+
return response;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Runs a script on the server.
|
|
94
|
+
* @param {String} what The script to run.
|
|
95
|
+
* @param {Object} data Data to send as input for the script.
|
|
96
|
+
* @returns Communion response.
|
|
97
|
+
*/
|
|
98
|
+
do = async (what, data = null) => {
|
|
99
|
+
let response = await $.post("/s/serve", JSON.stringify({
|
|
100
|
+
script: what,
|
|
101
|
+
route: window.location.pathname,
|
|
102
|
+
...data
|
|
103
|
+
}));
|
|
104
|
+
|
|
105
|
+
if (response.status != "success") console.log(`${window.location.pathname} - ${response.message}`);
|
|
106
|
+
|
|
107
|
+
return response;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Loads all spirits of a certain service.
|
|
112
|
+
* @param {String} service The name of the spirits to load.
|
|
113
|
+
* @param {String} scope Defaults to local, else global.
|
|
114
|
+
* @param {Object} data Data to filter the spirits by.
|
|
115
|
+
* @param {ObjectID} id The id of the spirit to load.
|
|
116
|
+
* @returns Spirit world response.
|
|
117
|
+
*/
|
|
118
|
+
loadAll = async (service, scope = "local", data = {}, id = null) => {
|
|
119
|
+
let response = await $.post("/s/loadAll", JSON.stringify({ service, scope, data, id }));
|
|
120
|
+
|
|
121
|
+
return response;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Loads a single spirit of a certain service.
|
|
126
|
+
* @param {String} service The name of the spirit to load.
|
|
127
|
+
* @param {String} scope Defaults to local, else global.
|
|
128
|
+
* @param {Object} data Data to filter the spirits by.
|
|
129
|
+
* @param {ObjectID} id The id of the spirit to load.
|
|
130
|
+
* @returns Spirit world response.
|
|
131
|
+
*/
|
|
132
|
+
load = async (service, scope = "local", data = {}, id = null) => {
|
|
133
|
+
let response = await $.post("/s/load", JSON.stringify({ service, scope, data, id }));
|
|
134
|
+
|
|
135
|
+
return response;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Creates the toggle view button.
|
|
140
|
+
*/
|
|
141
|
+
createToggleViewButton = async () => {
|
|
142
|
+
// add a button to the footer for toggling between compact and full view
|
|
143
|
+
this.$viewToggle = $("<button>").addClass("view-toggle").text(">");
|
|
144
|
+
this.$viewToggle.on("click", () => {
|
|
145
|
+
this.toggleView();
|
|
146
|
+
});
|
|
147
|
+
$("footer").append(this.$viewToggle);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Toggles the view between compact and full.
|
|
152
|
+
* @param {Boolean} save Whether or not to save the view state.
|
|
153
|
+
*/
|
|
154
|
+
toggleView = async (save = true) => {
|
|
155
|
+
if (this.viewState === "compact") {
|
|
156
|
+
this.viewState = "full";
|
|
157
|
+
if (this.$viewToggle) this.$viewToggle.text("<");
|
|
158
|
+
$("main").addClass("full-view");
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
this.viewState = "compact";
|
|
162
|
+
if (this.$viewToggle) this.$viewToggle.text(">");
|
|
163
|
+
$("main").removeClass("full-view");
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (save) Base.commune("setView", { view: this.viewState });
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Appends html to the head.
|
|
171
|
+
* @param {String} html The html to append.
|
|
172
|
+
*/
|
|
173
|
+
appendToHead = (html) => {
|
|
174
|
+
$("head").append($(html));
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
//update login status
|
|
178
|
+
updateLoginStatus = (name = null) => {
|
|
179
|
+
let $status = $("footer .login-status");
|
|
180
|
+
let $logout = $("footer .logout");
|
|
181
|
+
|
|
182
|
+
if (name) {
|
|
183
|
+
$status.text(`Logged In: ${name}`);
|
|
184
|
+
$logout.removeClass("invisible");
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
$status.text("Not Logged In");
|
|
188
|
+
$logout.addClass("invisible");
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// download your data
|
|
193
|
+
downloadData = async () => {
|
|
194
|
+
let response = await Base.commune("downloadData");
|
|
195
|
+
|
|
196
|
+
if (response.status === "success") {
|
|
197
|
+
let blob = new Blob([JSON.stringify(response.data)], { type: "application/json" });
|
|
198
|
+
let url = URL.createObjectURL(blob);
|
|
199
|
+
let a = document.createElement("a");
|
|
200
|
+
a.href = url;
|
|
201
|
+
a.download = "data.json";
|
|
202
|
+
document.body.appendChild(a);
|
|
203
|
+
a.click();
|
|
204
|
+
URL.revokeObjectURL(url);
|
|
205
|
+
a.remove();
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return response;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
deleteData = async (password) => {
|
|
212
|
+
let response = await Base.commune("deleteAlldata", { password });
|
|
213
|
+
|
|
214
|
+
return response;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
importData = async (password, data) => {
|
|
218
|
+
let text = await data.text(data);
|
|
219
|
+
|
|
220
|
+
let response = await Base.commune("importData", { password, data: text });
|
|
221
|
+
return response;
|
|
222
|
+
}
|
|
228
223
|
}
|