nodebb-plugin-ezoic-infinite 0.9.12 → 0.9.14
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/package.json +1 -1
- package/public/admin.js +54 -9
package/package.json
CHANGED
package/public/admin.js
CHANGED
|
@@ -19,19 +19,64 @@ $(document).ready(function () {
|
|
|
19
19
|
form.find('[name="messageIntervalPosts"]').val(parseInt(data.messageIntervalPosts, 10) || 3);
|
|
20
20
|
form.find('[name="messagePlaceholderIds"]').val(data.messagePlaceholderIds || '');
|
|
21
21
|
|
|
22
|
-
//
|
|
23
|
-
|
|
22
|
+
// Charger les groupes dynamiquement (NodeBB 4.x) - plusieurs fallbacks selon version
|
|
23
|
+
(function loadGroups() {
|
|
24
24
|
const $select = form.find('[name="excludedGroups"]');
|
|
25
25
|
$select.empty();
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
const selected = (data.excludedGroups || '').split(',').map(s => s.trim()).filter(Boolean);
|
|
28
|
+
|
|
29
|
+
function renderGroups(list) {
|
|
30
|
+
const names = (list || [])
|
|
31
|
+
.map(g => (typeof g === 'string' ? g : (g && g.name)))
|
|
30
32
|
.filter(Boolean)
|
|
31
|
-
.sort((a, b) => a.localeCompare(b, 'fr', { sensitivity: 'base' }))
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
.sort((a, b) => a.localeCompare(b, 'fr', { sensitivity: 'base' }));
|
|
34
|
+
|
|
35
|
+
names.forEach((name) => $select.append($('<option>').val(name).text(name)));
|
|
36
|
+
|
|
37
|
+
$select.find('option').each(function () {
|
|
38
|
+
$(this).prop('selected', selected.includes($(this).val()));
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function normalize(res) {
|
|
43
|
+
if (!res) return null;
|
|
44
|
+
if (Array.isArray(res)) return res;
|
|
45
|
+
if (Array.isArray(res.groups)) return res.groups;
|
|
46
|
+
if (Array.isArray(res.results)) return res.results;
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const events = [
|
|
51
|
+
'groups.getGroups',
|
|
52
|
+
'admin.groups.get',
|
|
53
|
+
'admin.groups.list',
|
|
54
|
+
'groups.list',
|
|
55
|
+
];
|
|
56
|
+
|
|
57
|
+
(function tryNext(i) {
|
|
58
|
+
if (i >= events.length) {
|
|
59
|
+
// REST fallback
|
|
60
|
+
try {
|
|
61
|
+
const base = (window.config && window.config.relative_path) ? window.config.relative_path : '';
|
|
62
|
+
$.get(base + '/api/groups', function (resp) {
|
|
63
|
+
const list = normalize(resp) || normalize(resp && resp.response) || (resp && resp.groups) || [];
|
|
64
|
+
if (Array.isArray(list) && list.length) return renderGroups(list);
|
|
65
|
+
// If still empty, leave blank silently
|
|
66
|
+
});
|
|
67
|
+
} catch (e) {}
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
socket.emit(events[i], {}, function (err2, res) {
|
|
72
|
+
const list = (!err2) ? normalize(res) : null;
|
|
73
|
+
if (Array.isArray(list) && list.length) {
|
|
74
|
+
return renderGroups(list);
|
|
75
|
+
}
|
|
76
|
+
tryNext(i + 1);
|
|
77
|
+
});
|
|
78
|
+
})(0);
|
|
79
|
+
})();
|
|
35
80
|
}
|
|
36
81
|
|
|
37
82
|
const selected = (data.excludedGroups || '').split(',').map(s => s.trim()).filter(Boolean);
|