diff options
| author | cashmere <cashmere@autistici.org> | 2026-09-04 09:05:24 +0200 |
|---|---|---|
| committer | cashmere <cashmere@autistici.org> | 2026-09-04 09:05:24 +0200 |
| commit | 4f49b16079b27d7ce633619e4cddfdf2bffbc952 (patch) | |
| tree | c296c1e7f3c3e2f6859c6d3a1b1b208779b89679 /src/useredit.js | |
| download | relic-master.tar.gz | |
Diffstat (limited to 'src/useredit.js')
| -rw-r--r-- | src/useredit.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/useredit.js b/src/useredit.js new file mode 100644 index 0000000..13eb582 --- /dev/null +++ b/src/useredit.js @@ -0,0 +1,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(); |
