123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- // Licensed Materials - Property of IBM
- //
- // IBM Cognos Products: ps
- //
- // (C) Copyright IBM Corp. 2005, 2011
- //
- // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- // Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
- // Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
- function select(p, v) {
- for (var i=0;i<document.pform.elements.length;i++)
- {
- var e = document.pform.elements[i];
- if (e.name.substring(0, p.length)==p)
- {
- e.checked = v;
- }
- }
- event_onclick();
- }
- function event_onclick(chkPrefix, hidPrefix)
- {
- var newpv = "";
- var newmv = "";
-
- // scan all checkboxes using a well known prefix
- for (i=0; i<document.pform.elements.length; i++)
- {
- var e = document.pform.elements[i];
- if (e.name.substring(0, chkPrefix.length) == chkPrefix)
- {
- if (e.checked)
- {
- // get its hidden input equivalent
- p = document.pform.elements[hidPrefix + e.name.substring(chkPrefix.length)];
- pv = p.value;
- if (newpv == "")
- {
- // first state
- newpv = pv;
- }
- else if (newpv != pv)
- {
- // mixed state
- for (j = 0; j < newpv.length; j++)
- {
- permission = newpv.substr(j, 1);
- if ((-1 == pv.indexOf(permission)) && (-1 == newmv.indexOf(permission)))
- newmv += permission;
- }
- for (j=0; j<pv.length; j++)
- {
- permission = pv.substr(j, 1);
- if ((-1 == newpv.indexOf(permission)) && (-1 == newmv.indexOf(permission)))
- newmv += permission;
- }
- }
- }
- }
- }
- // for each 'permission' in 'mixed' if 'pattern' has it, remove it from 'pattern'
- for (i = 0; i < newmv.length; i++)
- {
- permission = newmv.substr(i, 1);
- newpv = newpv.replace(new RegExp(permission,""), "");
- }
- // set the values
- document.pform.elements['privileges_pattern'].value = newpv;
- document.pform.elements['privileges_mixed'].value = newmv;
- // update all checkboxes images
- all = "rRwWxXpPtT";
- for (i=0; i<all.length; i++)
- {
- permission = all.substr(i, 1);
- if (newmv.indexOf(permission) != -1)
- state = 2;
- else
- state = (newpv.indexOf(permission) != -1) ? 1 : 0;
- setImage(permission, state);
- }
- }
- function checkboxKeyHandler(rwxp)
- {
- var Key;
- Key = window.event.keyCode;
- if (Key==32) //space bar
- {
- document.pform.uncommitted_permissions.value='1';
- check(rwxp);
- }
- }
- function check(permission)
- {
- otherPermission = (permission == permission.toLowerCase()) ? permission.toUpperCase() : permission.toLowerCase();
- p = document.pform.elements['privileges_pattern'];
- m = document.pform.elements['privileges_mixed'];
- pv = p.value; // get values for pattern and mixed
- mv = m.value;
- ppos = pv.indexOf(permission);
- if (-1 == ppos) // is it unchecked or third state?
- {
- // add 'permission' to 'pv', remove 'otherPermission' from 'pv' and
- // remove both ('permission' and 'otherPermission') from 'mv'
- pv += permission;
- re = RegExp(otherPermission,"");
- pv = pv.replace(re, "");
- mv = mv.replace(re, "");
- mv = mv.replace(new RegExp(permission,""), "");
- state = 1; // checked
- }
- else
- {
- // just remove 'permission' from 'pv'
- pv = pv.replace(new RegExp(permission,""), "");
- state = 0; // unchecked
- }
- setImage(permission, state); // new checkbox state
- setImage(otherPermission, 0); // reset other to unchecked
- p.value = pv; // reassign values
- m.value = mv;
- if (window.on_uncommitted_permissions_changed)
- {
- on_uncommitted_permissions_changed();
- }
- return;
- }
- function setImage(permission, state)
- {
- obj = document.images[permission];
- if (obj)
- {
- img = obj.src;
- ipos = img.lastIndexOf('checkbox_');
- path = img.substr(0, ipos);
- switch (state)
- {
- case 1:
- gif = "checked";
- obj.alt=checkbox_checked_message;
- break;
- case 2:
- gif = "mixed";
- obj.alt=checkbox_mixed_message;
- break;
- default:
- gif = "unchecked";
- obj.alt=checkbox_unchecked_message;
- break;
- }
- obj.src = path + 'checkbox_' + gif + '.gif';
- }
- }
|