diff options
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(); |
