1 2 3 function update_groups_htmlOKay(f, group_str) { // group_str = "(group-identifier:policy,group-identifier:policy)" 4 if(!group_str) { 5 return; 6 } 7 8 var group_array = group_str.match(/\((.*?)\)/); // extract plicies from parentheses 9 group_array=group_array[1].split(","); // get array of policies 10 11 for(var i=0; i<group_array.length; i++) { // loop through policies 12 var vals = group_array[i].split(":"); // split group identifier from policy 13 var name = "group[" + vals[0] + "]"; // create a complete name for element, .eg. 'group[admin]' 14 var node_list = f[name]; 15 if (typeof(node_list) == "undefined") { continue;} 16 17 for(var j=0; j< node_list.length; j++) { //loop through the chekboxes 18 if(node_list[j].value == vals[1]) { // check off the box which matches saved value 19 node_list[j].checked = true; 20 } 21 } 22 23 } 24 25 } 26 27 28 29 function get_selected_files_htmlOKay(file_str) { 30 var selected_files = new Array(); 31 if(!file_str) { 32 return selected_files; 33 } 34 var files = file_str.match(/\((.*?)\)/); 35 var selected = files[1].split(","); 36 for(var i=0; i < selected.length; i++) { 37 selected_files[selected[i]] = true; 38 } 39 return selected_files; 40 } 41 42 function get_access_array_htmlOKay(access) { 43 var access_array = new Array(); 44 var a_array = access.split(";;"); 45 46 for(var i = 0; i < a_array.length; i++) { 47 var elements = a_array[i].split("=>"); 48 if(a_array[i]) { 49 if(elements) { 50 access_array[elements[0]] = elements[1]; // elements[0] = filespec, group, or user 51 } 52 } 53 } 54 55 return access_array; 56 } 57 58 59 function getNSdata_htmlOKay(f) { 60 var index = f['abs_path'].selectedIndex; 61 var ns = f['abs_path'].options[index].value; 62 update_avail_htmlOKay(ns); 63 document.getElementById('current_ns').innerHTML = f['abs_path'].options[index].text; 64 } 65 66 var scroll_visible_htmlOKay = false; 67 68 function handleHttpResponse_htmlOKay(data) { 69 70 71 var f = window.document['nsdata']; 72 reset_htmlOKay(f); 73 var s = f['filespecs[]']; 74 s.options.length = 0; 75 var data = data.split("%%"); 76 var opts = data[0]; 77 var access = data[1]; 78 79 var access_array = get_access_array_htmlOKay(access); 80 81 var selected_files = get_selected_files_htmlOKay(access_array['filespecs']); 82 var opt_array = opts.split("|"); 83 var selected_default; 84 for(var i=0; i<opt_array.length-1; i++) { 85 var ar = opt_array[i].split(":"); 86 var selected = false; 87 if(ar.length == 3 && !selected_default) selected_default = i; 88 if(selected_files[ar[1]]) { 89 selected = true; 90 selected_default = -1; 91 } 92 93 var o = new Option(ar[0],ar[1]); 94 s.options[i] = o; 95 s.options[i].selected = selected; 96 } 97 if(selected_default && selected_default > -1) { 98 s.options[i].selected = true; 99 } 100 101 update_groups_htmlOKay(f, access_array['group'] ); 102 update_users_htmlOKay(f, access_array['user'] ); 103 104 } 105 106 function update_avail_htmlOKay(qstr) { 107 var url = DOKU_BASE + '/lib/plugins/htmlOKay/directory_scan-3.php'; 108 url = url +"?path=" + JSINFO['path'] + '&'; 109 qstr = 'abs_path=' + encodeURIComponent(qstr); 110 url = url + qstr; 111 112 jQuery.post( 113 url, 114 "", 115 function (data) { 116 handleHttpResponse_htmlOKay(data); 117 }, 118 'html' 119 ); 120 121 } 122 123 124 /* function update_avail_htmlOKay(qstr) { 125 var url = DOKU_BASE + 'lib/exe/ajax.php'; 126 url = url +"?path=" + JSINFO['path'] + '&'; 127 qstr = 'abs_path=' + encodeURIComponent(qstr); 128 129 var params = 'call=htmlokay&path=' + encodeURIComponent(JSINFO['path']); 130 params += '&abs_path='+encodeURIComponent(qstr); 131 132 jQuery.post( 133 DOKU_BASE + 'lib/exe/ajax.php', 134 params, 135 function (data) { 136 alert(data); 137 handleHttpResponse_htmlOKay(data) ; 138 139 }, 140 'html' 141 ); 142 } 143 */ 144 function user_table_size_htmlOKay(entries) { 145 var dom = document.getElementById('htmlOK_user_table'); 146 entries += 2; // allow for table headers 147 var height = 2*entries; 148 if(height > 32) { 149 height = 32; 150 } 151 dom.style.height=height + "em"; 152 153 scrollbars_htmlOKay(); 154 } 155 156 function scrollbars_htmlOKay() { 157 var dom = document.getElementById('htmlOK_user_table'); 158 var scrollbut = document.getElementById('htmlOK_scrollbutton'); 159 if(!scroll_visible_htmlOKay) { 160 dom.style.overflow="scroll"; 161 scroll_visible_htmlOKay = true; 162 scrollbut.value = 'Scroll Off'; 163 return; 164 } 165 dom.style.overflow="visible"; 166 scroll_visible_htmlOKay = false; 167 scrollbut.value = 'Scroll'; 168 } 169 170 171 function reset_htmlOKay(f) { 172 e = f.elements; 173 for(var i=0; i<e.length; i++) { 174 if(e[i].type == "radio") { 175 e[i].checked = false; 176 } 177 } 178 } 179 180 function show_this(radio) { 181 var f = window.document['nsdata']; 182 var node_list = f[radio]; 183 for(var i=0; i < node_list.length; i++) { 184 node_list[i].checked = false; 185 } 186 187 } 188 189 function update_users_htmlOKay(f, user_str) { 190 if(!user_str) return; 191 192 193 var user_array = user_str.match(/\((.*?)\)/); // extract plicies from parentheses 194 user_array=user_array[1].split(","); // get array of policies 195 196 for(var i=0; i<user_array.length; i++) { // loop through policies 197 var vals = user_array[i].split(":"); // split user identifier from policy 198 var name = "user[" + vals[0] + "]"; // create a complete name for element, .eg. 'user[smith]' 199 var node_list = f[name]; 200 201 for(var j=0; j< node_list.length; j++) { //loop through the checkboxes 202 if(node_list[j].value == vals[1]) { // check off the box which matches saved value 203 node_list[j].checked = true; 204 } 205 } 206 207 } 208 } 209 210