notherbase-fs 2.0.3 → 3.0.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.
Files changed (59) hide show
  1. package/controllers/creation.js +57 -59
  2. package/controllers/spirit-world.js +55 -74
  3. package/controllers/spirits/contact.js +17 -10
  4. package/controllers/spirits/user.js +144 -112
  5. package/controllers/spirits/util.js +23 -31
  6. package/models/index.js +54 -117
  7. package/models/item.js +80 -0
  8. package/models/send-mail.js +2 -0
  9. package/models/spirit.js +77 -115
  10. package/models/user.js +189 -0
  11. package/notherbase-fs.js +1 -0
  12. package/package.json +1 -1
  13. package/public/styles/main.css +12 -3
  14. package/test/{explorer/coast/tall-beach/nono-cove/styles → coast/tall-beach/nono-cove}/index.css +0 -0
  15. package/test/coast/tall-beach/nono-cove/index.ejs +29 -0
  16. package/test/{explorer/coast/tall-beach/nono-cove/views/nono-og.ejs → coast/tall-beach/nono-cove/nono-og/index.ejs} +2 -2
  17. package/test/{explorer/coast/tall-beach/nono-cove/styles → coast/tall-beach/nono-cove/nono-og}/nono.css +0 -0
  18. package/test/{explorer/coast/tall-beach/nono-cove/local-scripts → coast/tall-beach/nono-cove/nono-og}/nono.js +1 -1
  19. package/test/{explorer/coast/tall-beach/nono-cove/server-scripts → test-page}/emailTime.js +0 -0
  20. package/test/{pages/test.ejs → test-page/index.ejs} +0 -0
  21. package/test/the-front/add-gold.js +35 -0
  22. package/test/the-front/check/add-more-gold.js +3 -0
  23. package/test/the-front/check/emailTime.js +11 -0
  24. package/test/the-front/check/index.ejs +13 -0
  25. package/test/the-front/check/subtract-gold.js +3 -0
  26. package/test/the-front/checks.js +11 -0
  27. package/test/the-front/incTranslation.js +9 -0
  28. package/test/the-front/index.ejs +107 -0
  29. package/test/void/index.ejs +4 -0
  30. package/test/void/void.css +3 -0
  31. package/views/explorer.ejs +32 -41
  32. package/views/menu/account.ejs +39 -0
  33. package/views/menu/inventory.ejs +8 -0
  34. package/views/menu/more.ejs +5 -0
  35. package/views/menu/player.ejs +3 -0
  36. package/views/menu.ejs +20 -62
  37. package/views/scripts/base.js +314 -0
  38. package/controllers/spirits/attribute.js +0 -47
  39. package/controllers/spirits/inventory.js +0 -71
  40. package/controllers/spirits/item.js +0 -41
  41. package/controllers/spirits/serve.js +0 -33
  42. package/public/js/commune.js +0 -22
  43. package/public/js/establishment.js +0 -44
  44. package/public/js/memories.js +0 -44
  45. package/test/explorer/coast/tall-beach/nono-cove/local-scripts/game.js +0 -7
  46. package/test/explorer/coast/tall-beach/nono-cove/local-scripts/items.js +0 -162
  47. package/test/explorer/coast/tall-beach/nono-cove/server-scripts/getTimer.js +0 -31
  48. package/test/explorer/coast/tall-beach/nono-cove/styles/items-floor.css +0 -92
  49. package/test/explorer/coast/tall-beach/nono-cove/views/index.ejs +0 -130
  50. package/test/pages/server-scripts/emailTime.js +0 -15
  51. package/test/the-front/server-scripts/emailTime.js +0 -15
  52. package/test/the-front/server-scripts/getTimer.js +0 -31
  53. package/test/the-front/views/check.ejs +0 -93
  54. package/test/the-front/views/index.ejs +0 -113
  55. package/test/void/styles/void.css +0 -0
  56. package/views/account.ejs +0 -122
  57. package/views/inventory.ejs +0 -117
  58. package/views/more.ejs +0 -16
  59. package/views/player.ejs +0 -60
@@ -1,44 +0,0 @@
1
- class Memories {
2
- constructor() {
3
- this._lastUpdate = 0;
4
- this.data = {};
5
- }
6
-
7
- load = async (service, route = currentRoute, parent = null) => {
8
- if (!this.data[service]) this.data[service] = { _lastUpdate: 0 };
9
-
10
- let response = await commune("recall", {}, {
11
- service: service,
12
- _lastUpdate: this.data[service]._lastUpdate,
13
- route: route,
14
- scope: "local",
15
- parent: parent
16
- });
17
-
18
- if (!response.isUpToDate) {
19
- this.data[service] = response.data;
20
- this._lastUpdate = this.data[service]._lastUpdate;
21
- }
22
-
23
- return this.data[service];
24
- }
25
-
26
- save = async (service, dataToSave, route = currentRoute, parent = null) => {
27
- this._lastUpdate = Date.now();
28
- dataToSave._lastUpdate = this._lastUpdate;
29
-
30
- let response = await commune("commit", dataToSave, {
31
- service: service,
32
- _lastUpdate: this._lastUpdate,
33
- route: route,
34
- scope: "local",
35
- parent: parent
36
- });
37
-
38
- this.data[service] = dataToSave;
39
-
40
- return response;
41
- }
42
- }
43
-
44
- const memories = new Memories();
@@ -1,7 +0,0 @@
1
- let $game = $(".game");
2
- let $text = $(".game h3");
3
- let $button = $(".game button");
4
-
5
- $button.on("click", function () {
6
- $text.text(`${$text.text()} clicked`);
7
- });
@@ -1,162 +0,0 @@
1
- class ItemFloor {
2
- constructor() {
3
- this.items = [];
4
- this.$itemList = $(".floor#items ul.items");
5
- this.$items = $(".floor#items ul.items li");
6
-
7
- this.$read = $(".floor#items .editor .read");
8
- this.$readName = $(".floor#items .editor .read #name");
9
- this.$readShort = $(".floor#items .editor .read #short");
10
- this.$readFull = $(".floor#items .editor .read #full");
11
-
12
- this.$edit = $(".floor#items .editor .edit");
13
- this.$editName = $(".floor#items .editor .edit #name");
14
- this.$editShort = $(".floor#items .editor .edit #short");
15
- this.$editFull = $(".floor#items .editor .edit #full");
16
-
17
- this.selected = -1;
18
- this.state = "reading";
19
-
20
- this.updateItems();
21
- }
22
-
23
- hasValidSelection() {
24
- return (this.selected > -1 && this.selected < this.items.length);
25
- }
26
-
27
- async updateItems() {
28
- try {
29
- await $.get(`/item/all`, (data) => {
30
- this.items = data.foundItems;
31
- this.renderItemList();
32
- });
33
- }
34
- catch(err) {
35
- console.log(err);
36
- }
37
- };
38
-
39
- renderItemList() {
40
- this.$itemList.empty();
41
-
42
- for (let i = 0; i < this.items.length; i++) {
43
- $(".floor#items ul.items").append(`<li onClick="itemFloor.selectItem(${i})">${this.items[i].name}</li>`);
44
- };
45
-
46
- this.$items = $(".floor#items ul.items li");
47
- this.selectItem(this.selected);
48
- }
49
-
50
- createNewItem() {
51
- if (this.state === "reading") {
52
- this.items.push({
53
- _id: null,
54
- name: "New Item",
55
- shortDescription: "Short Description",
56
- fullDescription: "Full Description"
57
- });
58
-
59
- this.renderItemList();
60
- this.selectItem(this.items.length - 1);
61
- this.editSelectedItem();
62
- }
63
- };
64
-
65
- selectItem(index) {
66
- this.$items.removeClass("selected");
67
- this.selected = index;
68
-
69
- if (index > -1) {
70
- $(this.$items[index]).addClass("selected");
71
- }
72
-
73
- this.readSelectedItem();
74
- }
75
-
76
- readSelectedItem() {
77
- this.cancelEdit();
78
-
79
- if (this.hasValidSelection()) {
80
- this.$readName.text(this.items[this.selected].name);
81
- this.$readShort.text(this.items[this.selected].shortDescription);
82
- this.$readFull.text(this.items[this.selected].fullDescription);
83
- }
84
- else {
85
- this.$readName.text("Please select an item from the list.");
86
- this.$readShort.text("");
87
- this.$readFull.text("");
88
- }
89
- }
90
-
91
- editSelectedItem() {
92
- if (this.hasValidSelection()) {
93
- if (this.state != "editing") {
94
- this.$read.addClass("invisible");
95
- }
96
-
97
- this.state = "editing";
98
- this.$edit.removeClass("invisible");
99
-
100
- this.$editName.val(this.items[this.selected].name);
101
- this.$editShort.val(this.items[this.selected].shortDescription);
102
- this.$editFull.val(this.items[this.selected].fullDescription);
103
- }
104
- }
105
-
106
- async saveSelectedItem() {
107
- if (this.state === "editing") {
108
- try {
109
- await $.post("/item", {
110
- id: this.items[this.selected]._id,
111
- name: this.$editName.val(),
112
- shortDescription: this.$editShort.val(),
113
- fullDescription: this.$editFull.val(),
114
- }, () => {
115
- this.items[this.selected].name = this.$editName.val();
116
- this.items[this.selected].shortDescription = this.$editShort.val();
117
- this.items[this.selected].fullDescription = this.$editFull.val();
118
- this.cancelEdit();
119
- this.updateItems();
120
- });
121
- }
122
- catch(err) {
123
- console.log(err);
124
- }
125
- }
126
- }
127
-
128
- cancelEdit() {
129
- if (this.state === "editing") {
130
- this.$edit.addClass("invisible");
131
- this.$read.removeClass("invisible");
132
- this.state = "reading";
133
- }
134
- }
135
-
136
- async deleteSelectedItem() {
137
- if (this.state === "reading" && this.hasValidSelection()) {
138
- try {
139
- await $.post("/item/delete", {
140
- id: this.items[this.selected]._id
141
- }, () => {
142
- this.selectItem(-1);
143
- this.updateItems();
144
- });
145
- }
146
- catch(err) {
147
- console.log(err);
148
- }
149
- }
150
- }
151
- }
152
-
153
- let itemFloor = new ItemFloor();
154
-
155
-
156
-
157
-
158
-
159
-
160
- $(".floor button#toggle").on("click", function (e) {
161
- $(e.target.parentElement).find(".content").toggleClass("invisible");
162
- });
@@ -1,31 +0,0 @@
1
- export default async function getTimer(db, route, user, params) {
2
- try {
3
- let poi = await db.poi.findOne({ route: route, user: user });
4
-
5
- let now = Date.now();
6
-
7
- if (!poi.data) poi.data = {
8
- timer: 0,
9
- lastTime: now
10
- }
11
- else {
12
- if (!poi.data.lastTime) poi.data.lastTime = now;
13
- if (!poi.data.timer) poi.data.timer = 0;
14
- }
15
-
16
- let difference = (now - poi.data.lastTime) / 1000;
17
-
18
- poi.data.timer -= difference;
19
- if (poi.data.timer < 0) poi.data.timer = 0;
20
- poi.data.lastTime = now;
21
-
22
- poi.markModified("data");
23
- await poi.save();
24
-
25
- return poi.data.timer;
26
- }
27
- catch(err) {
28
- console.log(err);
29
- return false;
30
- }
31
- }
@@ -1,92 +0,0 @@
1
- :root {
2
- --bgColor: rgb(37, 37, 37);
3
- --bgColorBright: rgb(66, 66, 66);
4
- --shadowColor: rgb(26, 26, 26);
5
- --textColor: rgb(185, 135, 69);
6
- --textColorBright: rgb(221, 181, 130);
7
- --standardBorder: 1px solid var(--textColor);
8
- --standardRadius: 5px;
9
- }
10
-
11
- .floor#items ul.items {
12
- width: 40%;
13
- height: 800px;
14
- border: var(--standardBorder);
15
- padding: 5px;
16
- margin: 0;
17
- }
18
-
19
- .floor#items ul.items li {
20
- list-style: none;
21
- cursor: pointer;
22
- }
23
-
24
- .floor#items ul.items li:hover {
25
- background-color: var(--bgColorBright);
26
- }
27
-
28
- .floor#items ul.items li.selected {
29
- background-color: var(--shadowColor);
30
- }
31
-
32
- .floor#items .editor {
33
- width: 55%;
34
- height: 800px;
35
- border: var(--standardBorder);
36
- padding: 10px;
37
- }
38
-
39
- .floor#items .read h5 {
40
- margin: 10px;
41
- }
42
-
43
- .floor#items .read #name {
44
- margin: 20px;
45
- }
46
-
47
- .floor#items .read #short {
48
- width: 100%;
49
- height: 100px;
50
- border: var(--standardBorder);
51
- padding: 2px;
52
- }
53
-
54
- .floor#items .read #full {
55
- width: 100%;
56
- height: 250px;
57
- border: var(--standardBorder);
58
- padding: 2px;
59
- }
60
-
61
- .floor#items .edit h5 {
62
- margin: 10px;
63
- }
64
-
65
-
66
- .floor {
67
- width: 100%;
68
- min-height: 50px;
69
- border: 1px solid var(--shadowColor);
70
- background-color: var(--bgColor);
71
- padding: 10px;
72
- display: flex;
73
- align-items: flex-start;
74
- justify-content: center;
75
- flex-wrap: wrap;
76
- }
77
-
78
- .floor h2 {
79
- width: 90%;
80
- }
81
-
82
- .floor button {
83
- margin: 0;
84
- }
85
-
86
- .floor .content {
87
- width: 100%;
88
- display: flex;
89
- align-items: flex-start;
90
- justify-content: center;
91
- flex-wrap: wrap;
92
- }
@@ -1,130 +0,0 @@
1
- <p>
2
- nono
3
- </p>
4
-
5
- <hr>
6
-
7
- <h3>chat</h3>
8
-
9
- <div class="chat-box" id="test-chat"></div>
10
- <div class="chat-box" id="test-chat-2"></div>
11
- <div class="chat-box" id="test-chat-3"></div>
12
-
13
- <hr>
14
-
15
- <h3>serve, memories and institution Test</h3>
16
-
17
- <button onclick="setTime()">Add</button>
18
- <p id="timer">0:00</p>
19
- <p id="timer-g">0:00</p>
20
- <p id="u">N</p>
21
- <button onclick="emailTime()">email</button>
22
-
23
- <hr>
24
-
25
- <button onclick="tradeForDoll()" id="trade">Trade 5g for a doll</button>
26
-
27
-
28
-
29
- <hr>
30
-
31
- <a href="/the-front" class="to">
32
- Go to The Front
33
- </a>
34
-
35
- <a href="/coast/tall-beach/nono-cove/nono-og" class="to">
36
- Go to Nono Cove
37
- </a>
38
-
39
-
40
- <script src="/js/chat-box.js"></script>
41
- <script>
42
- let chatTest = new ChatBox("<%= user.username %>", "test-chat");
43
- let chatTest2 = new ChatBox("<%= user.username %>", "test-chat-2");
44
- let chatTest3 = new ChatBox("<%= user.username %>", "test-chat-3");
45
-
46
- let bought = false;
47
-
48
- let tradeForDoll = async function tradeForDoll() {
49
- if (!bought) {
50
- $("#trade").addClass("invisible");
51
-
52
- let paid = await playerInventory.change("Gold Coin", -5);
53
-
54
- if (paid) {
55
- bought = true;
56
- let received = await playerInventory.change("Rag Doll", 1);
57
- if (!received) playerInventory.change("Gold Coin", 5);
58
- }
59
- else {
60
- $("#trade").removeClass("invisible");
61
- }
62
- }
63
- }
64
-
65
- let time = 0;
66
- let gtime = 0;
67
-
68
- (async () => {
69
- let load = await memories.load("time", "/void/test");
70
- let loadg = await establishment.load("time", "/void/test");
71
- console.log(load, loadg);
72
- time = load.time;
73
- $("p#u").text(`Last: ${loadg.u}`);
74
- gtime = loadg.time;
75
- })();
76
-
77
- let setTime = async function setTime() {
78
- time = Date.now();
79
- gtime = time;
80
-
81
- await memories.save("time", {
82
- time: time,
83
- a: "dabfb",
84
- bln: false,
85
- numba: 4236,
86
- arrray: [32, "sg", 45],
87
- check: {
88
- time: time,
89
- a: "dabfb",
90
- bln: false,
91
- numba: 4236,
92
- arrray: [32, "sg", 45]
93
- }
94
- }, "/void/test");
95
-
96
- await establishment.save("time", {
97
- time: time,
98
- u: "<%= user.username %>",
99
- a: "dabfb",
100
- bln: false,
101
- numba: 4236,
102
- arrray: [32, "sg", 45],
103
- check: {
104
- time: time,
105
- a: "dabfb",
106
- bln: false,
107
- numba: 4236,
108
- arrray: [32, "sg", 45]
109
- }
110
- }, "/void/test");
111
-
112
- $("p#u").text("Last: <%= user.username %>");
113
- }
114
-
115
- let updateTime = function updateTime() {
116
- $("#timer").text(`Local: ${Math.floor((Date.now() - time) / 1000)}`);
117
- $("#timer-g").text(`Global: ${Math.floor((Date.now() - gtime) / 1000)}`);
118
- }
119
-
120
- let emailTime = async () => {
121
- await commune("serveExplorer", {
122
- script: "emailTime",
123
- toEmail: "wyattsushi@gmail.com",
124
- subject: "New Time Update!",
125
- html: `New Time: ${time}`
126
- }, { route: currentRoute });
127
- }
128
-
129
- setInterval(updateTime, 1000);
130
- </script>
@@ -1,15 +0,0 @@
1
- export default async function emailTime(req, user) {
2
- try {
3
- await req.db.SendMail.send(
4
- req.body.data.toEmail,
5
- req.body.data.subject,
6
- req.body.data.html
7
- );
8
-
9
- return "Sent";
10
- }
11
- catch(err) {
12
- console.log(err);
13
- return false;
14
- }
15
- }
@@ -1,15 +0,0 @@
1
- export default async function emailTime(req, user) {
2
- try {
3
- await req.db.SendMail.send(
4
- req.body.data.toEmail,
5
- req.body.data.subject,
6
- req.body.data.html
7
- );
8
-
9
- return "Sent";
10
- }
11
- catch(err) {
12
- console.log(err);
13
- return false;
14
- }
15
- }
@@ -1,31 +0,0 @@
1
- export default async function getTimer(db, route, user, params) {
2
- try {
3
- let poi = await db.poi.findOne({ route: route, user: user });
4
-
5
- let now = Date.now();
6
-
7
- if (!poi.data) poi.data = {
8
- timer: 0,
9
- lastTime: now
10
- }
11
- else {
12
- if (!poi.data.lastTime) poi.data.lastTime = now;
13
- if (!poi.data.timer) poi.data.timer = 0;
14
- }
15
-
16
- let difference = (now - poi.data.lastTime) / 1000;
17
-
18
- poi.data.timer -= difference;
19
- if (poi.data.timer < 0) poi.data.timer = 0;
20
- poi.data.lastTime = now;
21
-
22
- poi.markModified("data");
23
- await poi.save();
24
-
25
- return poi.data.timer;
26
- }
27
- catch(err) {
28
- console.log(err);
29
- return false;
30
- }
31
- }
@@ -1,93 +0,0 @@
1
- <h1>The Big Check</h1>
2
-
3
- <hr>
4
-
5
- <h4>Creation</h4>
6
-
7
- <p>Page Loaded: True</p>
8
- <% if (user) { %>
9
- <p>User: <%= user.username %></p>
10
- <% } else { %>
11
- <p>User: not logged in</p>
12
- <% } %>
13
-
14
- <hr>
15
-
16
- <h4>Spirit World</h4>
17
-
18
- <p class="info" id="spirit-world"></p>
19
-
20
- <h5>Establishment</h5>
21
-
22
- <p id="establish">not loaded</p>
23
- <input type="text" id="establish" onkeyup="saveEstablishment(event)">
24
-
25
- <h5>Memories</h5>
26
-
27
- <p id="memory">not loaded</p>
28
- <input type="text" id="memory" onkeyup="saveMemories(event)">
29
-
30
- <h5>Serve Scripts</h5>
31
-
32
- <button onclick="emailTime()">Email Wyatt</button>
33
-
34
- <hr>
35
-
36
- <a href="/the-front">
37
- Go to The Front
38
- </a>
39
-
40
- <script>
41
- let saveEstablishment = async (e) => {
42
- let $send = $("input#establish");
43
-
44
- if (e.key === "Enter") {
45
- await establishment.save("test", {
46
- line: $send.val()
47
- });
48
-
49
- $("p#establish").text($send.val());
50
- $send.val("");
51
- }
52
- }
53
-
54
- let loadEstablishment = async () => {
55
- let load = await establishment.load("test");
56
-
57
- $("p#establish").text(load.line);
58
- }
59
-
60
- loadEstablishment();
61
-
62
- let saveMemories = async (e) => {
63
- let $send = $("input#memory");
64
-
65
- if (e.key === "Enter") {
66
- let response = await memories.save("test", {
67
- line: $send.val()
68
- });
69
-
70
- if (response.status === "success") {
71
- $("p#memory").text($send.val());
72
- $send.val("");
73
- }
74
- }
75
- }
76
-
77
- let loadMemories = async () => {
78
- let load = await memories.load("test");
79
-
80
- $("p#memory").text(load.line);
81
- }
82
-
83
- loadMemories();
84
-
85
- let emailTime = async () => {
86
- await commune("serveFront", {
87
- script: "emailTime",
88
- toEmail: "wyattsushi@gmail.com",
89
- subject: "New Time Update!",
90
- html: `New Time: From the Big Check!`
91
- }, { route: currentRoute });
92
- }
93
- </script>