-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
99 lines (90 loc) · 3.18 KB
/
Copy pathscript.js
File metadata and controls
99 lines (90 loc) · 3.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
jQuery(function () {
/**
* admin interface: autocomplete users
*/
function adminAutocomplete($form) {
$form.find('input[name="user"]')
.autocomplete({
source: function (request, response) {
jQuery.getJSON(DOKU_BASE + 'lib/exe/ajax.php?call=plugin_acknowledge_autocomplete', {
user: request.term,
sectok: $form.find('input[name="sectok"]').val()
}, response);
},
minLength: 1
});
$form.find('input[name="pg"]')
.autocomplete({
source: function (request, response) {
jQuery.getJSON(DOKU_BASE + 'lib/exe/ajax.php?call=plugin_acknowledge_autocomplete', {
pg: request.term,
sectok: $form.find('input[name="sectok"]').val()
}, response);
},
minLength: 3
});
}
const $form = jQuery('.dokuwiki.mode_admin div.plugin_acknowledgement_admin form#acknowledge__user-autocomplete');
if ($form.length) {
adminAutocomplete($form);
}
/*
* Handle assignments
*/
let $aContainer = jQuery('.plugin-acknowledge-banner');
// if no container is found, create one in the last section
if ($aContainer.length === 0) {
const section = jQuery('.dokuwiki.mode_show')
.find('div.level1, div.level2, div.level3, div.level4, div.level5')
.filter(function (idx, el) {
return jQuery(el).parents('ul, ol, aside, nav, footer, header').length === 0;
})
.last();
if (section.length === 0) {
return;
}
$aContainer = jQuery('<div class="plugin-acknowledge-banner"></div>');
section.append($aContainer);
}
// on-page report: load the full user list when a count is clicked
$aContainer.on('click', 'a.plugin-acknowledge-loadusers', function (event) {
event.preventDefault();
const $link = jQuery(this);
const $target = jQuery('<div class="plugin-acknowledge-userlist"></div>');
$link.replaceWith($target);
$target.load(
DOKU_BASE + 'lib/exe/ajax.php',
{
call: 'plugin_acknowledge_userlist',
id: $link.data('id'),
status: $link.data('status')
}
);
});
$aContainer.on('submit', function (event) {
event.preventDefault();
const $form = jQuery(event.target),
ack = $form.find("input[name='ack']")[0];
$aContainer.load(
DOKU_BASE + "lib/exe/ajax.php",
{
call: "plugin_acknowledge_acknowledge",
id: JSINFO.id,
ack: ack.checked === true ? 1 : 0
}
);
});
$aContainer.load(
DOKU_BASE + 'lib/exe/ajax.php',
{
call: 'plugin_acknowledge_acknowledge',
id: JSINFO.id
},
response => {
// remove container if no data to show
if (response === '') {
$aContainer.remove();
}
}
);
});