isite 2023.12.21 → 2024.1.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/lib/parser.js +2 -2
- package/lib/session.js +0 -1
- package/lib/words.js +33 -7
- package/package.json +1 -1
package/lib/parser.js
CHANGED
|
@@ -436,7 +436,7 @@ module.exports = function init(req, res, ____0, route) {
|
|
|
436
436
|
out = out[property[5]];
|
|
437
437
|
}
|
|
438
438
|
}
|
|
439
|
-
if (out
|
|
439
|
+
if (!out) {
|
|
440
440
|
$(this).remove();
|
|
441
441
|
} else {
|
|
442
442
|
$(this).removeAttr('x-show-item1');
|
|
@@ -522,7 +522,7 @@ module.exports = function init(req, res, ____0, route) {
|
|
|
522
522
|
out = out[property[5]];
|
|
523
523
|
}
|
|
524
524
|
}
|
|
525
|
-
if (out
|
|
525
|
+
if (!out) {
|
|
526
526
|
$(this).remove();
|
|
527
527
|
} else {
|
|
528
528
|
$(this).removeAttr('x-show-item2');
|
package/lib/session.js
CHANGED
package/lib/words.js
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
module.exports = function init(____0) {
|
|
2
2
|
let app = function () {};
|
|
3
|
+
app.$collection = ____0.connectCollection('words');
|
|
3
4
|
app.list = [];
|
|
4
|
-
app.userWordsPath = process.cwd() + '/.words.json';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
app.$collection.findAll({}, (err, docs) => {
|
|
7
|
+
if (!err && docs) {
|
|
8
|
+
docs.forEach((doc) => {
|
|
9
|
+
let index = app.list.findIndex((w) => w.name === doc.name);
|
|
10
|
+
if (index === -1) {
|
|
11
|
+
app.list.unshift(doc);
|
|
12
|
+
} else {
|
|
13
|
+
app.list[index] = doc;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
10
16
|
}
|
|
11
|
-
}
|
|
17
|
+
});
|
|
12
18
|
|
|
13
19
|
app.word = function (obj) {
|
|
14
20
|
if (typeof obj === 'string') {
|
|
@@ -31,6 +37,8 @@ module.exports = function init(____0) {
|
|
|
31
37
|
let index = app.list.findIndex((w) => w.name === word.name);
|
|
32
38
|
if (index === -1) {
|
|
33
39
|
app.list.push(word);
|
|
40
|
+
} else {
|
|
41
|
+
return app.list[index];
|
|
34
42
|
}
|
|
35
43
|
return word;
|
|
36
44
|
};
|
|
@@ -64,6 +72,24 @@ module.exports = function init(____0) {
|
|
|
64
72
|
});
|
|
65
73
|
};
|
|
66
74
|
|
|
75
|
+
app.save = function () {
|
|
76
|
+
app.list.forEach((w, i) => {
|
|
77
|
+
if (w.id) {
|
|
78
|
+
app.$collection.update(w, (err, result) => {
|
|
79
|
+
if (!err && result.doc) {
|
|
80
|
+
app.list[i] = result.doc;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
} else {
|
|
84
|
+
app.$collection.add(w, (err, doc) => {
|
|
85
|
+
if (!err && doc) {
|
|
86
|
+
app.list[i] = doc;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
|
|
67
93
|
____0.on(____0.strings[9], () => {
|
|
68
94
|
____0.get({ name: '/x-api/words' }, (req, res) => {
|
|
69
95
|
res.json({ done: !0, words: app.list });
|
|
@@ -71,7 +97,7 @@ module.exports = function init(____0) {
|
|
|
71
97
|
|
|
72
98
|
____0.post({ name: '/x-api/words/save' }, (req, res) => {
|
|
73
99
|
app.list = req.data;
|
|
74
|
-
|
|
100
|
+
app.save();
|
|
75
101
|
res.json({ done: !0, count: app.list.length });
|
|
76
102
|
});
|
|
77
103
|
|