notherbase-fs 3.2.1 → 3.2.3
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/user.js +2 -3
- package/models/send-mail.js +4 -1
- package/package.json +1 -1
- package/public/js/chat-box.js +13 -2
- package/public/styles/chat.css +30 -11
- package/test/coast/tall-beach/nono-cove/index.ejs +0 -2
- package/test/pages/test-page/index.ejs +71 -11
- package/views/explorer.ejs +1 -9
- package/public/styles/chat copy.css +0 -57
- /package/test/{void → pages/void}/index.ejs +0 -0
- /package/test/{void → pages/void}/void.css +0 -0
package/controllers/user.js
CHANGED
|
@@ -44,13 +44,12 @@ export default class User {
|
|
|
44
44
|
if (spirit) {
|
|
45
45
|
let token = Math.floor(Math.random() * 9999);
|
|
46
46
|
|
|
47
|
-
if (req.body.test) console.log("token: " + token);
|
|
48
|
-
|
|
49
47
|
spirit.memory.data.resetToken = token;
|
|
50
48
|
spirit.memory.data.resetExp = Date.now() + (1000 * 60 * 10);
|
|
51
49
|
await spirit.commit();
|
|
52
50
|
|
|
53
|
-
|
|
51
|
+
if (req.body.test) console.log("token: " + token);
|
|
52
|
+
else req.db.SendMail.passwordReset(req.body.email, token);
|
|
54
53
|
|
|
55
54
|
success(res, "Password reset token sent.");
|
|
56
55
|
}
|
package/models/send-mail.js
CHANGED
|
@@ -6,7 +6,10 @@ import nodemailer from "nodemailer";
|
|
|
6
6
|
* @param {Number} resetToken Token to reset by.
|
|
7
7
|
*/
|
|
8
8
|
const passwordReset = async (toEmail, resetToken) => {
|
|
9
|
-
return await send(toEmail, 'Password Reset for NotherBase',
|
|
9
|
+
return await send(toEmail, 'Password Reset for NotherBase',
|
|
10
|
+
`<h1>Your One-Time Password Reset Code:<h1>
|
|
11
|
+
<h2>${resetToken}<h2>
|
|
12
|
+
<p>Visit <a href="https://www.notherbase.com/the-front/keeper">notherbase.com/the-front/keeper</a> to finish changing your password.</p>`);
|
|
10
13
|
};
|
|
11
14
|
|
|
12
15
|
/**
|
package/package.json
CHANGED
package/public/js/chat-box.js
CHANGED
|
@@ -29,7 +29,8 @@ class ChatBox {
|
|
|
29
29
|
*/
|
|
30
30
|
newMessage = (msg) => {
|
|
31
31
|
let time = new Date(msg.time);
|
|
32
|
-
|
|
32
|
+
let times = time.toLocaleTimeString('en-US').split(":");
|
|
33
|
+
this.$chatLog.append(`<p>(${times[0]}:${times[1]}) ${msg.name}: ${msg.text}</p>`);
|
|
33
34
|
this.$chatLog.scrollTop(this.$chatLog.prop("scrollHeight"));
|
|
34
35
|
let msgs = this.$chatLog.find("p");
|
|
35
36
|
if (msgs.length > this.maxMessages) {
|
|
@@ -44,7 +45,11 @@ class ChatBox {
|
|
|
44
45
|
* @param {Object} msg An object including the users in the room.
|
|
45
46
|
*/
|
|
46
47
|
updateInfo = (msg) => {
|
|
48
|
+
this.$usersChatting.text(`${msg.data.users.length} User${msg.data.users.length !== 1 ? "s" : ""} Chatting`);
|
|
49
|
+
|
|
47
50
|
this.$users.empty();
|
|
51
|
+
this.$header = $(`<h4>You are ${this.username}</h4>`).appendTo(this.$users);
|
|
52
|
+
|
|
48
53
|
for (let i = 0; i < msg.data.users.length; i++) {
|
|
49
54
|
this.$users.append(`<li>${msg.data.users[i]}</li>`);
|
|
50
55
|
}
|
|
@@ -72,9 +77,11 @@ class ChatBox {
|
|
|
72
77
|
render() {
|
|
73
78
|
this.$div.empty();
|
|
74
79
|
|
|
75
|
-
this.$
|
|
80
|
+
this.$usersChatting = $(`<button id="chatting">0 Users Chatting</button>`).appendTo(this.$div);
|
|
81
|
+
this.$usersChatting.click(this.toggleUsers);
|
|
76
82
|
this.$chatLog = $(`<div class="chat-log"></div>`).appendTo(this.$div);
|
|
77
83
|
this.$users = $(`<ul class="users"></ul>`).appendTo(this.$div);
|
|
84
|
+
this.$header = $(`<h4>You are ${this.username}</h4>`).appendTo(this.$users);
|
|
78
85
|
this.$entry = $(`<input autocomplete="off" type="text" class="chat-entry">`).appendTo(this.$div);
|
|
79
86
|
this.$send = $(`<button class="chat-send">Send</button>`).appendTo(this.$div);
|
|
80
87
|
|
|
@@ -83,5 +90,9 @@ class ChatBox {
|
|
|
83
90
|
if (e.keyCode == 13) this.sendMessage();
|
|
84
91
|
});
|
|
85
92
|
}
|
|
93
|
+
|
|
94
|
+
toggleUsers = () => {
|
|
95
|
+
this.$users.toggleClass("shown");
|
|
96
|
+
}
|
|
86
97
|
}
|
|
87
98
|
|
package/public/styles/chat.css
CHANGED
|
@@ -2,26 +2,29 @@
|
|
|
2
2
|
position: relative;
|
|
3
3
|
box-shadow: var(--boxShadow);
|
|
4
4
|
width: 100%;
|
|
5
|
-
height:
|
|
5
|
+
height: 50vh;
|
|
6
6
|
display: flex;
|
|
7
7
|
flex-wrap: wrap;
|
|
8
|
+
margin: var(--margin);
|
|
8
9
|
}
|
|
9
10
|
|
|
10
|
-
.chat-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
.chat-box h4 {
|
|
12
|
+
padding: var(--padding);
|
|
13
|
+
border-radius: none;
|
|
14
|
+
border: none;
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
.chat-log {
|
|
16
|
-
width:
|
|
17
|
-
height:
|
|
18
|
+
width: 100%;
|
|
19
|
+
height: calc(100% - 65px);
|
|
18
20
|
background-color: rgba(0, 0, 0, 0.534);
|
|
19
21
|
overflow: auto;
|
|
20
22
|
padding: 5px;
|
|
23
|
+
border-radius: none;
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
.chat-send {
|
|
24
|
-
height:
|
|
27
|
+
height: 35px;
|
|
25
28
|
width: 5em;
|
|
26
29
|
outline: none;
|
|
27
30
|
background-color: var(--bgColor);
|
|
@@ -40,7 +43,7 @@
|
|
|
40
43
|
}
|
|
41
44
|
|
|
42
45
|
.chat-entry {
|
|
43
|
-
height:
|
|
46
|
+
height: 35px;
|
|
44
47
|
width: calc(100% - 5em);
|
|
45
48
|
outline: none;
|
|
46
49
|
background-color: var(--bgColor);
|
|
@@ -58,9 +61,25 @@
|
|
|
58
61
|
text-align: left;
|
|
59
62
|
}
|
|
60
63
|
|
|
61
|
-
.chat-box>ul{
|
|
62
|
-
width:
|
|
63
|
-
height:
|
|
64
|
+
.chat-box>ul {
|
|
65
|
+
width: 100%;
|
|
66
|
+
height: 0;
|
|
64
67
|
border: var(--standardBorder);
|
|
65
68
|
margin: 0;
|
|
69
|
+
position: absolute;
|
|
70
|
+
top: 30px;
|
|
71
|
+
left: 0;
|
|
72
|
+
transition: all .25s ease;
|
|
73
|
+
overflow: hidden;
|
|
74
|
+
background: var(--bgColor);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.chat-box>ul.shown {
|
|
78
|
+
height: calc(100% - 30px);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.chat-box #chatting {
|
|
82
|
+
width: 100%;
|
|
83
|
+
height: 25px;
|
|
84
|
+
padding: var(--padding);
|
|
66
85
|
}
|
|
@@ -21,25 +21,85 @@
|
|
|
21
21
|
<link rel="stylesheet" href="/styles/chat.css">
|
|
22
22
|
<script src="/js/base.js"></script>
|
|
23
23
|
</head>
|
|
24
|
-
|
|
25
24
|
<script>
|
|
26
25
|
const currentRoute = "<%- route %>";
|
|
27
26
|
</script>
|
|
28
27
|
|
|
29
|
-
|
|
30
28
|
<body>
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
<main>
|
|
30
|
+
<div class="chatter" id="adam"></div>
|
|
31
|
+
<input type="text" id="adam">
|
|
32
|
+
<button id="adam">Chat</button>
|
|
33
|
+
</main>
|
|
33
34
|
</body>
|
|
34
35
|
|
|
35
36
|
<script>
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
class Spirit {
|
|
38
|
+
constructor(name) {
|
|
39
|
+
this.name = name;
|
|
40
|
+
this.children = {};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
addChild(child, parent) {
|
|
44
|
+
if (!this.children[child.name]) {
|
|
45
|
+
this.children[child.name] = 1;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
this.children[child.name]++;
|
|
49
|
+
}
|
|
43
50
|
}
|
|
51
|
+
|
|
52
|
+
class Chatter {
|
|
53
|
+
constructor(id) {
|
|
54
|
+
this.name = id;
|
|
55
|
+
this.brain = new Spirit("i");
|
|
56
|
+
this.$div = $(`.chatter#${id}`);
|
|
57
|
+
this.$input = $(`input#${id}`);
|
|
58
|
+
this.$submit = $(`button#${id}`);
|
|
59
|
+
|
|
60
|
+
this.$submit.click(() => {
|
|
61
|
+
this.listen(this.$input.val());
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
register = (word) => {
|
|
66
|
+
if (!this.brain[word]) {
|
|
67
|
+
this.brain[word] = new Spirit(word);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return this.brain[word];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
think = () => {
|
|
74
|
+
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
listen = (message) => {
|
|
78
|
+
message = message.toLowerCase();
|
|
79
|
+
let words = message.split(" ");
|
|
80
|
+
|
|
81
|
+
//add words to the dialogue tree
|
|
82
|
+
this.register(words[0]);
|
|
83
|
+
for (let i = 0; i < words.length; i++) {
|
|
84
|
+
if (i < words.length - 1) {
|
|
85
|
+
let child = this.register(words[i + 1]);
|
|
86
|
+
if (i > 0) this.brain[words[i]].addChild(child, this.brain[words[i - 1]]);
|
|
87
|
+
else this.brain[words[i]].addChild(child, null);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
//think
|
|
92
|
+
|
|
93
|
+
this.respond(message);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
respond(message) {
|
|
97
|
+
this.$div.append(`<p>${this.name}: ${message}</p>`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const adam = new Chatter("adam");
|
|
102
|
+
adam.listen(`In the beginning God created the heavens and the earth`);
|
|
103
|
+
adam.listen("if i have the first two words in a three word relationship can the third word be guessed")
|
|
44
104
|
</script>
|
|
45
105
|
</html>
|
package/views/explorer.ejs
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
<input type="email" placeholder="user@email.com" id="email">
|
|
26
26
|
<input type="password" placeholder="password" id="pass">
|
|
27
27
|
<button id="login" onclick="coverLogin()">Login</button>
|
|
28
|
-
<
|
|
28
|
+
<a href="/the-front/keeper">Reset Password</a>
|
|
29
29
|
<p class="info"></p>
|
|
30
30
|
|
|
31
31
|
<script>
|
|
@@ -38,14 +38,6 @@
|
|
|
38
38
|
if (response.status === "success") location.reload();
|
|
39
39
|
$(".login-cover .info").text(response.data);
|
|
40
40
|
};
|
|
41
|
-
|
|
42
|
-
const coverReset = async () => {
|
|
43
|
-
let response = await base.resetPassword(
|
|
44
|
-
$(".login-cover #email").val()
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
$(".login-cover .info").text(response.data);
|
|
48
|
-
};
|
|
49
41
|
</script>
|
|
50
42
|
</div>
|
|
51
43
|
<% } else { %>
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
.chat-box {
|
|
2
|
-
position: relative;
|
|
3
|
-
box-shadow: var(--boxShadow);
|
|
4
|
-
width: 100%;
|
|
5
|
-
height: 400px;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
.chat-name {
|
|
9
|
-
color: var(--textColor);
|
|
10
|
-
padding: 10px;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.chat-log {
|
|
14
|
-
width: 100%;
|
|
15
|
-
height: calc(100% - (var(--h3Size) + 2 * var(--padding) + 2 * var(--margin)) - (var(--pSize) + 2 * var(--padding)));
|
|
16
|
-
background-color: rgba(0, 0, 0, 0.534);
|
|
17
|
-
overflow: auto;
|
|
18
|
-
padding: 5px;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.chat-send {
|
|
22
|
-
height: calc(var(--pSize) + 2 * var(--padding));
|
|
23
|
-
width: 5em;
|
|
24
|
-
outline: none;
|
|
25
|
-
background-color: var(--bgColor);
|
|
26
|
-
border: var(--standardBorder);
|
|
27
|
-
color: var(--textColor);
|
|
28
|
-
text-align: center;
|
|
29
|
-
padding: 0;
|
|
30
|
-
margin: 0;
|
|
31
|
-
border-radius: 0;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.chat-send:hover {
|
|
35
|
-
border: 1px solid var(--textColorBright);
|
|
36
|
-
color: var(--textColorBright);
|
|
37
|
-
cursor: pointer;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.chat-entry {
|
|
41
|
-
height: calc(var(--pSize) + 2 * var(--padding));
|
|
42
|
-
width: calc(100% - 5em);
|
|
43
|
-
outline: none;
|
|
44
|
-
background-color: var(--bgColor);
|
|
45
|
-
border: var(--standardBorder);
|
|
46
|
-
color: var(--textColor);
|
|
47
|
-
margin: 0;
|
|
48
|
-
padding: var(--padding);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.chat-log > p {
|
|
52
|
-
color: var(--textColor);
|
|
53
|
-
margin: 0;
|
|
54
|
-
padding: 2px;
|
|
55
|
-
line-height: 1em;
|
|
56
|
-
text-align: left;
|
|
57
|
-
}
|
|
File without changes
|
|
File without changes
|