[LON-CAPA-cvs] cvs: rat /client parameter.html
raeburn
raeburn at source.lon-capa.org
Sat May 21 12:58:08 EDT 2016
raeburn Sat May 21 16:58:08 2016 EDT
Modified files:
/rat/client parameter.html
Log:
- Modal parameter setting window for Client IP/Name Access Control includes
individual textboxes for each IP or Name, with separate boxes for
"allow from" and "deny from".
Index: rat/client/parameter.html
diff -u rat/client/parameter.html:1.72 rat/client/parameter.html:1.73
--- rat/client/parameter.html:1.72 Sun May 15 17:40:34 2016
+++ rat/client/parameter.html Sat May 21 16:58:07 2016
@@ -5,7 +5,7 @@
The LearningOnline Network with CAPA
Parameter Input Window
//
-// $Id: parameter.html,v 1.72 2016/05/15 17:40:34 raeburn Exp $
+// $Id: parameter.html,v 1.73 2016/05/21 16:58:07 raeburn Exp $
//
// Copyright Michigan State University Board of Trustees
//
@@ -440,6 +440,62 @@
draw();
}
+function ipstringeval() {
+ var patternIp = /^([\[\]a-zA-Z\.\d\*\-]+)$/;
+ var acctypes = new Array;
+ acctypes = ['allow','deny'];
+ svalue = '';
+ for (var i=0; i<acctypes.length; i++) {
+ var items = choices.document.getElementsByName('setip'+acctypes[i]);
+ if (items.length) {
+ for (var j=0; j<items.length; j++) {
+ if (items[j].type == "text") {
+ var possip = items[j].value
+ possip = possip.replace(/^\s+|\s+$/g,'');
+ if (patternIp.test(possip)) {
+ if (acctypes[i] == 'deny') {
+ possip = '!'+possip;
+ }
+ if (svalue == '') {
+ svalue = possip;
+ } else {
+ svalue += ','+possip;
+ }
+ }
+ }
+ }
+ }
+ }
+ draw();
+}
+
+function addIpRule(iptype) {
+ var frame = window.frames["choices"];
+ if (frame.document.getElementById('LC_string_ipacc_inner_'+iptype)) {
+ var innerDiv = frame.document.getElementById('LC_string_ipacc_inner_'+iptype);
+ var count = innerDiv.childNodes.length
+ var ipDiv = frame.document.createElement('div');
+ ipDiv.innerHTML = '<input type="text" size="10" name="setip'+iptype+'" onblur="parent.ipstringeval();" />'+
+ '<a href="#" onclick="parent.removeIpRule(\''+iptype+'\',\''+count+'\')">Remove</a>';
+ frame.document.getElementById('LC_string_ipacc_inner_'+iptype).appendChild(ipDiv);
+ }
+ return false;
+}
+
+function removeIpRule(iptype,num) {
+ var frame = window.frames["choices"];
+ if (frame.document.getElementById('LC_string_ipacc_inner_'+iptype)) {
+ var innerDiv = frame.document.getElementById('LC_string_ipacc_inner_'+iptype);
+ for (var i=0; i<innerDiv.childNodes.length; i++) {
+ if (i==num) {
+ innerDiv.removeChild(innerDiv.childNodes[i]);
+ ipstringeval();
+ break;
+ }
+ }
+ }
+}
+
function radiostringeval(newval) {
svalue=newval;
draw();
@@ -480,7 +536,7 @@
document.getElementById('lenientweighteddiv').style.display='none';
}
svalue=newval;
- }
+ }
draw();
}
@@ -529,7 +585,11 @@
choicewrite(' action="javascript:floateval();"');
}
if (ptype=='string') {
- choicewrite(' action="javascript:stringeval();"');
+ if (pscat == 'ip') {
+ choicewrite(' action="javascript:ipstringeval();"');
+ } else {
+ choicewrite(' action="javascript:stringeval();"');
+ }
}
if (ptype != 'int' && ptype != 'float' && ptype != 'string') {
choicewrite(' action=""');
@@ -910,10 +970,55 @@
choicewrite(' /> No</label><br />');
}
if (pscat=='ip') {
- tablestart('IP Number/Name');
- choicewrite('<tr><td>Value:</td><td colspan="2">');
- choicewrite('<input name="stringval" size="20" value="'+escapeHTML(svalue)+
- '" onchange="parent.stringeval()" />');
+ var currallow = new Array;
+ var currdeny = new Array;
+ if ((svalue != '') && (svalue != null)) {
+ var patternComma = /,/;
+ var patternAllow = /^([\[\]a-zA-Z\.\d\*\-]+)$/;
+ var patternDeny = /^\!([\[\]a-zA-Z\.\d\*\-]+)$/;
+ var current = new Array;
+ if (patternComma.test(svalue)) {
+ current = svalue.split(',');
+ } else {
+ current = (svalue);
+ }
+ for (var i=0; i<current.length; i++) {
+ if (patternDeny.test(current[i])) {
+ var denied = current[i].replace(/^!/,'');
+ currdeny.push(denied);
+ } else {
+ if (patternAllow.test(current[i])) {
+ currallow.push(current[i]);
+ }
+ }
+ }
+ }
+ if (currdeny.length == 0) {
+ currdeny = ('');
+ }
+ if (currallow.length == 0) {
+ currallow = ('');
+ }
+ var curripaccess = [currallow,currdeny];
+ tablestart('IP Number/Name');
+ choicewrite('<tr><th>Allow from</th><th>Deny from</th></tr><tr>');
+ var acctypes = ['allow','deny'];
+ for (var i=0; i<acctypes.length; i++) {
+ choicewrite('<td valign="top">'+
+ '<div class="LC_string_ipacc_wrap" id="LC_string_ipacc_'+acctypes[i]+'">'+
+ '<div class="LC_string_ipacc_inner" id="LC_string_ipacc_inner_'+acctypes[i]+'">');
+ var num=0;
+ for (var j=0; j<curripaccess[i].length; j++) {
+ choicewrite('<div><input type="text" size="10" name="setip'+acctypes[i]+'" value="'+curripaccess[i][j]+'" onblur="parent.ipstringeval();" />');
+ if (num > 0) {
+ choicewrite('<a href="#" onclick="parent.removeIpRule(\''+acctypes[i]+'\',\''+j+'\')">Remove</a>');
+ }
+ choicewrite('</div>');
+ num ++;
+ }
+ choicewrite('</div><button onclick="parent.addIpRule(\''+acctypes[i]+'\');">Add more</button>');
+ }
+ choicewrite('</div></td></tr></table>');
}
if (pscat=='fileext') {
tablestart('Allowed File Extensions');
More information about the LON-CAPA-cvs
mailing list