blob: 13eb58233c70c1bc47d2c3bc737ea066c05db38f (
plain) (
blame)
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
|
/* This script accompanies the /setup_uedit web page. Its job is to keep
** the check-boxes with user capabilities up-to-date with the capability
** string.
**
** The capability string is stored in #usetupEditCapability
*/
function updateCapabilityString(){
try {
var inputs = document.getElementsByTagName('input');
if( inputs && inputs.length ){
var output = document.getElementById('usetupEditCapability');
if( output ){
var permsIds = [], x = 0;
for(var i = 0; i < inputs.length; i++){
var e = inputs[i];
if( !e.name || !e.type ) continue;
if( e.type.toLowerCase()!=='checkbox' ) continue;
if( e.name.length===2 && e.name[0]==='a' ){
// looks like a capability checkbox
e.onchange = updateCapabilityString;
if( e.checked ){
// grab the second character of the element
// name, which is the textual flag for this
// capability, and then add it to the result
// array.
permsIds[x++] = e.name[1];
}
}
}
permsIds.sort();
output.innerHTML = permsIds.join('');
}
}
} catch (e) {
/* ignore errors */
}
}
updateCapabilityString();
|