Fossil SCM

fossil-scm / src / useredit.js
Blame History Raw 39 lines
1
/* This script accompanies the /setup_uedit web page. Its job is to keep
2
** the check-boxes with user capabilities up-to-date with the capability
3
** string.
4
**
5
** The capability string is stored in #usetupEditCapability
6
*/
7
function updateCapabilityString(){
8
try {
9
var inputs = document.getElementsByTagName('input');
10
if( inputs && inputs.length ){
11
var output = document.getElementById('usetupEditCapability');
12
if( output ){
13
var permsIds = [], x = 0;
14
for(var i = 0; i < inputs.length; i++){
15
var e = inputs[i];
16
if( !e.name || !e.type ) continue;
17
if( e.type.toLowerCase()!=='checkbox' ) continue;
18
if( e.name.length===2 && e.name[0]==='a' ){
19
// looks like a capability checkbox
20
e.onchange = updateCapabilityString;
21
if( e.checked ){
22
// grab the second character of the element
23
// name, which is the textual flag for this
24
// capability, and then add it to the result
25
// array.
26
permsIds[x++] = e.name[1];
27
}
28
}
29
}
30
permsIds.sort();
31
output.innerHTML = permsIds.join('');
32
}
33
}
34
} catch (e) {
35
/* ignore errors */
36
}
37
}
38
updateCapabilityString();
39

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button