[Netpass-devel] NetPass/www/htdocs/OSSTemplate/js common.js,NONE,1.1 lockcfg.js,NONE,1.1 netgroups.j
Brought to you by:
jeffmurphy
From: jeff m. <jef...@us...> - 2005-05-04 03:09:56
|
Update of /cvsroot/netpass/NetPass/www/htdocs/OSSTemplate/js In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11419/www/htdocs/OSSTemplate/js Modified Files: userform.js Added Files: common.js lockcfg.js netgroups.js Log Message: netgroup UI --- NEW FILE: netgroups.js --- function netgroup_onchange_netgroups() { var o = document.getElementById("netgroups"); if (!o) return; if (o.options[0].selected == true) { //IE o.options[0].selected == false; return; } document.forms[0].submit(); } Index: userform.js =================================================================== RCS file: /cvsroot/netpass/NetPass/www/htdocs/OSSTemplate/js/userform.js,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- userform.js 23 Apr 2005 15:32:06 -0000 1.8 +++ userform.js 4 May 2005 03:09:45 -0000 1.9 @@ -80,8 +80,8 @@ } } } - userform_sortList("GroupList"); - userform_sortList("AvailableGroupList"); + sortList("GroupList"); + sortList("AvailableGroupList"); if (usingAuthDB) { var pwd = document.getElementById('passwdDialog'); @@ -421,8 +421,8 @@ userform_enableList("AccessControlList"); DBG_objDump(userhash, "userhash"); userform_setAclHash(); - userform_sortList("GroupList"); - userform_sortList("AvailableGroupList"); + sortList("GroupList"); + sortList("AvailableGroupList"); } else { dbg (1, RN + ": cant find AvailableGroupList and/or GroupList object"); } @@ -448,8 +448,8 @@ userform_disableList("AccessControlList"); DBG_objDump(userhash, "userhash"); userform_setAclHash(); - userform_sortList("GroupList"); - userform_sortList("AvailableGroupList"); + sortList("GroupList"); + sortList("AvailableGroupList"); } else { dbg (1, RN + ": cant find AvailableGroupList and/or GroupList object"); } @@ -470,33 +470,6 @@ } -function userform_sortList(ln) { - - if (ln) { - var l = document.getElementById(ln); - if (l && l.options.length) { - var oa = new Array(); - for (var i = 1 ; i < l.options.length ; i++) { - oa[oa.length] = new Option( l.options[i].text, - l.options[i].value, - l.options[i].defaultSelected, - l.options[i].selected); - oa = oa.sort( function(a,b) { - if ((a.value+"") < (b.value+"")) { return -1; } - if ((a.value+"") > (b.value+"")) { return 1; } - return 0; } - ); - for ( i = 0 ; i < oa.length ; i++) { - l.options[i+1] = new Option(oa[i].text, - oa[i].value, - oa[i].defaultSelected, - oa[i].selected) - ; - } - } - } - } -} function userform_onblur_addUser(o) { var RN = "userform_onblur_addUser"; @@ -524,5 +497,5 @@ ul.options[ul.options.length-1].selected = true; if(o) o.value = "Add user..."; - userform_sortList("UserList"); + sortList("UserList"); } --- NEW FILE: lockcfg.js --- function lockConfig_results(r) { var b = document.getElementById('lockButton'); if (b) { b.disabled = ''; b.innerHTML = "Lock Config"; } lockOpPending = false; var ra = r.split(/\s+/); var i = 0; while (i < ra.length && ra[i] != "OK" && ra[i] != "NOK") { i++ } if (ra[i] == "OK") { // something succeeded if (ra[i+1] == "lock") { // we got the lock, change button to // green and text to 'unlock' b.style.backgroundColor = '#77FF77'; b.innerHTML = 'Config is Locked (by you)<BR>Unlock Config'; adjust_onClick(b, "return lockConfig(0, 0);"); lockConfig_enableElements(); } else { // we got the unlock, button -> yellow // text -> 'lock' b.style.backgroundColor = '#FFFF77'; b.innerHTML = 'Config is Unlocked<BR>Lock Config'; adjust_onClick(b, "return lockConfig(1, 0);"); lockConfig_disableElements(); } } else { // something failed if (ra[i+1] == "lock") { // we didnt get the lock, change button to // red and text to 'force lock' b.style.backgroundColor = '#FF7777'; b.innerHTML = 'Config is Locked by '+ra[i+2]+'<BR>Force Lock Config'; adjust_onClick(b, "return lockConfig(1, 1);"); lockConfig_disableElements(); } else { // we didnt get the unlock, // button -> red // text -> 'force unlock' b.style.backgroundColor = '#FF7777'; b.innerHTML = 'Config is Locked by '+ra[i+2]+'<BR>Force Unlock Config'; adjust_onClick(b, "return lockConfig(0, 1);"); lockConfig_disableElements(); } } } function lockConfig(lock, force) { // lock: 0 = unlock, 1 = lock // force: 0 = no, 1 = yes if (lockOpPending) return; var b = document.getElementById('lockButton'); if (b) { b.innerHTML = "Wait ..."; adjust_onClick(b, "return false;"); b.disabled = true; } lockOpPending = true; var url = "cmd/lockcfg.mhtml?printable=2&lock="+lock +"&force="+force; xmlhttp.open("GET", url , true); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState == 4) { lockConfig_results(xmlhttp.responseText); } }; xmlhttp.send(null); return false; } function lockConfig_enableElements() { if (lockConfig_EE.length) { for (var i = 0 ; i < lockConfig_EE.length ; i++) { enable_element(lockConfig_EE[i]); } } } function lockConfig_disableElements() { if (lockConfig_EE.length) { for (var i = 0 ; i < lockConfig_EE.length ; i++) { disable_element(lockConfig_EE[i]); } } } function lockConfig_show_unlock() { var b = document.getElementById('lockButton'); } --- NEW FILE: common.js --- function adjust_onClick(obj, fn) { if (browserType_IE) { obj.onclick = eval("x=function(e){"+fn+"}"); } else { obj.setAttribute('ONCLICK', fn); } } function enable_element(o) { if (!o) return; var o2; if (typeof o == "string") { o2 = document.getElementById(o); if (!o2) return; } else { o2 = o; } o2.disabled = false; } function disable_element(o) { if (!o) return; var o2; if (typeof o == "string") { o2 = document.getElementById(o); if (!o2) return; } else { o2 = o; } o2.disabled = true; } function sortList(ln) { if (ln) { var l = document.getElementById(ln); if (l && l.options.length) { var oa = new Array(); for (var i = 1 ; i < l.options.length ; i++) { oa[oa.length] = new Option( l.options[i].text, l.options[i].value, l.options[i].defaultSelected, l.options[i].selected); oa = oa.sort( function(a,b) { if ((a.value+"") < (b.value+"")) { return -1; } if ((a.value+"") > (b.value+"")) { return 1; } return 0; } ); for ( i = 0 ; i < oa.length ; i++) { l.options[i+1] = new Option(oa[i].text, oa[i].value, oa[i].defaultSelected, oa[i].selected) ; } } } } } |