notherbase-fs 1.3.6 → 1.3.9

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.
@@ -23,7 +23,7 @@ const explorer = async function explorer(worldPath, voidPath) {
23
23
  await db.poi.create({
24
24
  route: currentRoute,
25
25
  name: req.params.detail,
26
- type: "local",
26
+ type: "user",
27
27
  user: req.session.currentUser,
28
28
  data: {}
29
29
  });
@@ -37,6 +37,54 @@ const explorer = async function explorer(worldPath, voidPath) {
37
37
  res.status(500).end();
38
38
  }
39
39
  });
40
+
41
+ router.get(`/:region/:area/:poi/:detail/load`, async function(req, res) {
42
+ try {
43
+ let currentRoute = `${req.params.region}/${req.params.area}/${req.params.poi}/${req.params.detail}`;
44
+
45
+ let exists = await db.poi.exists({ route: currentRoute, user: req.session.currentUser });
46
+ if (!exists) {
47
+ await db.poi.create({
48
+ route: currentRoute,
49
+ name: req.params.detail,
50
+ type: "user",
51
+ user: req.session.currentUser,
52
+ data: {}
53
+ });
54
+ }
55
+
56
+ let found = await db.poi.findOne({ route: currentRoute, user: req.session.currentUser });
57
+
58
+ res.send(found.data);
59
+ }
60
+ catch(err) {
61
+ console.log(err);
62
+ res.status(500).end();
63
+ }
64
+ });
65
+
66
+ router.post(`/:region/:area/:poi/:detail/save`, async function(req, res) {
67
+ try {
68
+ let currentRoute = `${req.params.region}/${req.params.area}/${req.params.poi}/${req.params.detail}`;
69
+
70
+ let exists = await db.poi.exists({ route: currentRoute, user: req.session.currentUser });
71
+ if (!exists) await db.poi.create({
72
+ route: currentRoute,
73
+ name: req.params.detail,
74
+ type: "user",
75
+ user: req.session.currentUser,
76
+ data: {}
77
+ });
78
+
79
+ await db.poi.updateOne({ route: currentRoute, user: req.session.currentUser }, { data: req.body });
80
+
81
+ res.send("Update successful!");
82
+ }
83
+ catch(err) {
84
+ console.log(err);
85
+ res.status(500).end();
86
+ }
87
+ });
40
88
 
41
89
  router.get(`/:region/:area/:poi/:detail`, async function(req, res) {
42
90
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notherbase-fs",
3
- "version": "1.3.6",
3
+ "version": "1.3.9",
4
4
  "description": "Functions to help make developing for NotherBase easier.",
5
5
  "main": "notherbase-fs.js",
6
6
  "scripts": {
@@ -90,9 +90,10 @@
90
90
 
91
91
  let addToTime = async function addToTime() {
92
92
  try {
93
- await $.post(`/coast/tall-beach/nono-cove/index/serve/addToTimer`, function (data) {
94
- time = Math.floor(data.scriptResult);
95
- $("#timer").text(time);
93
+ time += 10;
94
+
95
+ await $.post(`/coast/tall-beach/nono-cove/index/save`, { timer: time, lastTime: Date.now() }, function () {
96
+ $("#timer").text(Math.floor(time));
96
97
  });
97
98
  } catch (error) {
98
99
  console.log(error);
@@ -101,9 +102,15 @@
101
102
 
102
103
  let getTime = async function getTime() {
103
104
  try {
104
- await $.post(`/coast/tall-beach/nono-cove/index/serve/getTimer`, function (data) {
105
- time = Math.floor(data.scriptResult);
106
- $("#timer").text(time);
105
+ await $.get(`/coast/tall-beach/nono-cove/index/load`, function (data) {
106
+ console.log(data);
107
+ data.timer = parseFloat(data.timer);
108
+ data.lastTime = parseFloat(data.lastTime);
109
+ console.log(data);
110
+ console.log(Date.now());
111
+ time = data.timer - ((Date.now() - data.lastTime) / 1000);
112
+ if (time < 0) time = 0;
113
+ $("#timer").text(Math.floor(time));
107
114
  });
108
115
  } catch (error) {
109
116
  console.log(error);
@@ -113,8 +120,10 @@
113
120
  let updateTime = function updateTime() {
114
121
  if (time > 0) {
115
122
  time--;
116
- $("#timer").text(time);
123
+ if (time < 0) time = 0;
124
+ $("#timer").text(Math.floor(time));
117
125
  }
126
+
118
127
  }
119
128
 
120
129
  setInterval(updateTime, 1000);
@@ -4,4 +4,14 @@
4
4
 
5
5
  <a href="/the-front">
6
6
  Go to The Front
7
- </a>
7
+ </a>
8
+
9
+ <script>
10
+ // $.post("/forest/eye-of-the-forest/square/test/save", {
11
+ // test: 36
12
+ // });
13
+
14
+ // $.get("/forest/eye-of-the-forest/square/test/load", function (data) {
15
+ // console.log(data);
16
+ // });
17
+ </script>
package/views/head.ejs CHANGED
@@ -7,8 +7,8 @@
7
7
  <script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
8
8
  <link rel="preconnect" href="https://fonts.googleapis.com">
9
9
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
10
- <!-- font-family: 'Roboto', sans-serif; -->
11
- <link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet">
10
+ <!-- font-family: 'Roboto' or 'Roboto Condensed', sans-serif; -->
11
+ <link href="https://fonts.googleapis.com/css2?family=Roboto&family=Roboto+Condensed:wght@700&display=swap" rel="stylesheet">
12
12
  <!-- 'Redacted Script', cursive; -->
13
13
  <link href="https://fonts.googleapis.com/css2?family=Redacted+Script:wght@300&display=swap" rel="stylesheet">
14
14
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">