notherbase-fs 1.3.14 → 1.4.1
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/explorer.js +52 -26
- package/controllers/the-front.js +2 -2
- package/models/{poi.js → detail.js} +5 -4
- package/models/index.js +1 -1
- package/package.json +1 -1
- package/public/js/memories.js +45 -0
- package/test/coast/tall-beach/nono-cove/views/index.ejs +25 -35
- package/views/explorer.ejs +5 -0
- package/views/inventory.ejs +1 -1
package/controllers/explorer.js
CHANGED
|
@@ -38,24 +38,43 @@ const explorer = async function explorer(worldPath, voidPath) {
|
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
40
|
|
|
41
|
-
router.get(
|
|
41
|
+
router.get(`/recall`, async function(req, res) {
|
|
42
42
|
try {
|
|
43
|
-
let
|
|
43
|
+
let exists = await db.detail.exists({
|
|
44
|
+
route: req.query.route,
|
|
45
|
+
service: req.query.service,
|
|
46
|
+
scope: "local",
|
|
47
|
+
user: req.session.currentUser
|
|
48
|
+
});
|
|
44
49
|
|
|
45
|
-
let exists = await db.poi.exists({ route: currentRoute, user: req.session.currentUser });
|
|
46
50
|
if (!exists) {
|
|
47
|
-
await db.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
await db.detail.create({
|
|
52
|
+
_lastUpdate: Date.now(),
|
|
53
|
+
route: req.query.route,
|
|
54
|
+
service: req.query.service,
|
|
55
|
+
scope: "local",
|
|
51
56
|
user: req.session.currentUser,
|
|
52
57
|
data: {}
|
|
53
58
|
});
|
|
54
59
|
}
|
|
55
60
|
|
|
56
|
-
let found = await db.
|
|
57
|
-
|
|
58
|
-
|
|
61
|
+
let found = await db.detail.findOne({
|
|
62
|
+
route: req.query.route,
|
|
63
|
+
service: req.query.service,
|
|
64
|
+
scope: "local",
|
|
65
|
+
user: req.session.currentUser
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
if (new Date(found._lastUpdate) > new Date(req.query._lastUpdate)) {
|
|
69
|
+
res.send({
|
|
70
|
+
isUpToDate: false,
|
|
71
|
+
data: found.data
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
else res.send({
|
|
75
|
+
isUpToDate: true,
|
|
76
|
+
data: null
|
|
77
|
+
});
|
|
59
78
|
}
|
|
60
79
|
catch(err) {
|
|
61
80
|
console.log(err);
|
|
@@ -63,21 +82,25 @@ const explorer = async function explorer(worldPath, voidPath) {
|
|
|
63
82
|
}
|
|
64
83
|
});
|
|
65
84
|
|
|
66
|
-
router.post(
|
|
85
|
+
router.post(`/commit`, async function(req, res) {
|
|
67
86
|
try {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
87
|
+
console.log(req.body);
|
|
88
|
+
await db.detail.updateOne({
|
|
89
|
+
route: req.body.route,
|
|
90
|
+
service: req.body.service,
|
|
91
|
+
scope: "local",
|
|
92
|
+
user: req.session.currentUser
|
|
93
|
+
}, {
|
|
94
|
+
route: req.body.route,
|
|
95
|
+
service: req.body.service,
|
|
96
|
+
scope: "local",
|
|
75
97
|
user: req.session.currentUser,
|
|
76
|
-
|
|
98
|
+
_lastUpdate: req.body.time,
|
|
99
|
+
data: req.body.data
|
|
100
|
+
}, {
|
|
101
|
+
upsert: true
|
|
77
102
|
});
|
|
78
103
|
|
|
79
|
-
await db.poi.updateOne({ route: currentRoute, user: req.session.currentUser }, { data: req.body });
|
|
80
|
-
|
|
81
104
|
res.send("Update successful!");
|
|
82
105
|
}
|
|
83
106
|
catch(err) {
|
|
@@ -102,7 +125,7 @@ const explorer = async function explorer(worldPath, voidPath) {
|
|
|
102
125
|
inventory: foundInventory,
|
|
103
126
|
query: req.query,
|
|
104
127
|
dir: worldPath,
|
|
105
|
-
|
|
128
|
+
route: `/${req.params.region}/${req.params.area}/${req.params.poi}/${req.params.detail}`
|
|
106
129
|
}
|
|
107
130
|
|
|
108
131
|
await res.render(`explorer`, context);
|
|
@@ -113,7 +136,8 @@ const explorer = async function explorer(worldPath, voidPath) {
|
|
|
113
136
|
siteTitle: "NotherBase | The Void",
|
|
114
137
|
user: null,
|
|
115
138
|
inventory: null,
|
|
116
|
-
main: `${voidPath}/index
|
|
139
|
+
main: `${voidPath}/index`,
|
|
140
|
+
route: `/void/index`
|
|
117
141
|
});
|
|
118
142
|
}
|
|
119
143
|
}
|
|
@@ -139,7 +163,7 @@ const explorer = async function explorer(worldPath, voidPath) {
|
|
|
139
163
|
inventory: foundInventory,
|
|
140
164
|
query: req.query,
|
|
141
165
|
dir: worldPath,
|
|
142
|
-
|
|
166
|
+
route: `/${req.params.region}/${req.params.area}/${req.params.poi}/index`
|
|
143
167
|
}
|
|
144
168
|
|
|
145
169
|
await res.render(`explorer`, context);
|
|
@@ -150,7 +174,8 @@ const explorer = async function explorer(worldPath, voidPath) {
|
|
|
150
174
|
siteTitle: "NotherBase | The Void",
|
|
151
175
|
user: null,
|
|
152
176
|
inventory: null,
|
|
153
|
-
main: `${voidPath}/index
|
|
177
|
+
main: `${voidPath}/index`,
|
|
178
|
+
route: `/void/index`
|
|
154
179
|
});
|
|
155
180
|
}
|
|
156
181
|
}
|
|
@@ -172,7 +197,8 @@ const explorer = async function explorer(worldPath, voidPath) {
|
|
|
172
197
|
siteTitle: "NotherBase | The Void",
|
|
173
198
|
user: null,
|
|
174
199
|
inventory: null,
|
|
175
|
-
main: `${voidPath}/index
|
|
200
|
+
main: `${voidPath}/index`,
|
|
201
|
+
route: `/void/index`
|
|
176
202
|
});
|
|
177
203
|
});
|
|
178
204
|
|
package/controllers/the-front.js
CHANGED
|
@@ -43,7 +43,7 @@ const front = async function front(dir) {
|
|
|
43
43
|
inventory: foundInventory,
|
|
44
44
|
query: req.query,
|
|
45
45
|
dir: dir,
|
|
46
|
-
|
|
46
|
+
route: `/the-front/${req.params.detail}`
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
await res.render(`explorer`, context);
|
|
@@ -69,7 +69,7 @@ const front = async function front(dir) {
|
|
|
69
69
|
inventory: foundInventory,
|
|
70
70
|
query: req.query,
|
|
71
71
|
dir: dir,
|
|
72
|
-
|
|
72
|
+
route: `/the-front/${req.params.detail}`
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
await res.render(`explorer`, context);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// This allows us to use Mongoose to connect to MongoDB
|
|
2
2
|
const mongoose = require("mongoose");
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
const detail = new mongoose.Schema({
|
|
5
|
+
_lastUpdate: Number,
|
|
5
6
|
route: String,
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
service: String,
|
|
8
|
+
scope: String,
|
|
8
9
|
user: {
|
|
9
10
|
type: mongoose.Schema.Types.ObjectId,
|
|
10
11
|
ref: "users",
|
|
@@ -15,4 +16,4 @@ const poi = new mongoose.Schema({
|
|
|
15
16
|
|
|
16
17
|
// This tells Mongoose to use the exampleSchema to access the examples collection
|
|
17
18
|
// in our db and then exports the model so we can use it.
|
|
18
|
-
module.exports = mongoose.model('
|
|
19
|
+
module.exports = mongoose.model('details', detail);
|
package/models/index.js
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
class Memories {
|
|
2
|
+
constructor() {
|
|
3
|
+
this._lastUpdate = 0;
|
|
4
|
+
this.data = {};
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
load = async (service, route = currentRoute) => {
|
|
8
|
+
try {
|
|
9
|
+
await $.get(`/recall`, {
|
|
10
|
+
route: route,
|
|
11
|
+
service: service,
|
|
12
|
+
_lastUpdate: this._lastUpdate
|
|
13
|
+
}, (res) => {
|
|
14
|
+
if (!res.isUpToDate && res.data) {
|
|
15
|
+
this.data[service] = JSON.parse(res.data);
|
|
16
|
+
this._lastUpdate = this.data[service]._lastUpdate;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
return this.data[service];
|
|
21
|
+
} catch (error) {
|
|
22
|
+
return error;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
save = async (service, dataToSave, route = currentRoute) => {
|
|
27
|
+
try {
|
|
28
|
+
this._lastUpdate = Date.now();
|
|
29
|
+
|
|
30
|
+
await $.post('/commit', {
|
|
31
|
+
route: route,
|
|
32
|
+
service: service,
|
|
33
|
+
time: this._lastUpdate,
|
|
34
|
+
data: JSON.stringify(dataToSave)
|
|
35
|
+
}, (data) => {
|
|
36
|
+
this.data[service] = dataToSave;
|
|
37
|
+
return "saved";
|
|
38
|
+
});
|
|
39
|
+
} catch (error) {
|
|
40
|
+
return error;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const memories = new Memories();
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
|
|
18
18
|
<hr>
|
|
19
19
|
|
|
20
|
-
<h3>
|
|
20
|
+
<h3>memories Test</h3>
|
|
21
21
|
|
|
22
|
-
<button onclick="
|
|
22
|
+
<button onclick="setTime()">Add</button>
|
|
23
23
|
<p id="timer">0:00</p>
|
|
24
24
|
|
|
25
25
|
<hr>
|
|
@@ -105,44 +105,34 @@
|
|
|
105
105
|
|
|
106
106
|
let time = 0;
|
|
107
107
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
108
|
+
(async () => {
|
|
109
|
+
let load = await memories.load("time", "/void/test");
|
|
110
|
+
console.log(load);
|
|
111
|
+
time = load.time;
|
|
112
|
+
})();
|
|
111
113
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
if (time < 0) time = 0;
|
|
130
|
-
$("#timer").text(Math.floor(time));
|
|
131
|
-
});
|
|
132
|
-
} catch (error) {
|
|
133
|
-
console.log(error);
|
|
134
|
-
}
|
|
114
|
+
let setTime = async function setTime() {
|
|
115
|
+
time = Date.now();
|
|
116
|
+
|
|
117
|
+
await memories.save("time", {
|
|
118
|
+
time: time,
|
|
119
|
+
a: "dabfb",
|
|
120
|
+
bln: false,
|
|
121
|
+
numba: 4236,
|
|
122
|
+
arrray: [32, "sg", 45],
|
|
123
|
+
check: {
|
|
124
|
+
time: time,
|
|
125
|
+
a: "dabfb",
|
|
126
|
+
bln: false,
|
|
127
|
+
numba: 4236,
|
|
128
|
+
arrray: [32, "sg", 45]
|
|
129
|
+
}
|
|
130
|
+
}, "/void/test");
|
|
135
131
|
}
|
|
136
132
|
|
|
137
133
|
let updateTime = function updateTime() {
|
|
138
|
-
|
|
139
|
-
time--;
|
|
140
|
-
if (time < 0) time = 0;
|
|
141
|
-
$("#timer").text(Math.floor(time));
|
|
142
|
-
}
|
|
143
|
-
|
|
134
|
+
$("#timer").text(Math.floor((Date.now() - time) / 1000));
|
|
144
135
|
}
|
|
145
136
|
|
|
146
137
|
setInterval(updateTime, 1000);
|
|
147
|
-
getTime();
|
|
148
138
|
</script>
|
package/views/explorer.ejs
CHANGED
package/views/inventory.ejs
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
constructor() {
|
|
20
20
|
this.$div = $(".inventory");
|
|
21
21
|
this.$list = $(".inventory .item-list");
|
|
22
|
-
this.$search = $(".search");
|
|
22
|
+
this.$search = $(".inventory .search");
|
|
23
23
|
this.$searchResults = $(".search-results");
|
|
24
24
|
this.searchResults = [];
|
|
25
25
|
this.$error = $("#inventory #error");
|