1 <& /elements/header-popup.html &>
4 <TD ALIGN="right">Module:</TD>
5 <TD><SELECT ID="select_module"></SELECT></TD>
8 <TD ALIGN="right">Object:</TD>
9 <TD><INPUT TYPE="text" NAME="path" ID="input_path"></TD>
13 <SELECT STYLE="width:100%" SIZE=12 ID="select_path"></SELECT>
17 <TH COLSPAN=2 ID="mib_objectID"></TH>
20 <TD ALIGN="right">Module: </TD><TD ID="mib_moduleID"></TD>
23 <TD ALIGN="right">Data type: </TD><TD ID="mib_type"></TD>
27 <BUTTON ID="submit_button" onclick="submit()" DISABLED=1>Continue</BUTTON>
31 <& /elements/xmlhttp.html,
32 url => $p.'misc/xmlhttp-mib-browse.html',
33 subs => [qw( search get_module_list )],
35 <SCRIPT TYPE="text/javascript">
39 function show_info(state) {
40 document.getElementById('mib_objectID').style.display =
41 document.getElementById('mib_moduleID').style.display =
42 document.getElementById('mib_type').style.display =
43 state ? 'block' : 'none';
46 function clear_list() {
47 var select_path = document.getElementById('select_path');
48 select_path.options.length = 0;
51 function add_item(value) {
52 var select_path = document.getElementById('select_path');
53 var input_path = document.getElementById('input_path');
54 var opt = document.createElement('option');
56 if ( v.match(/-$/) ) {
57 opt.className = 'leaf';
58 v = v.substring(0, v.length - 1);
60 opt.value = opt.text = v;
61 opt.selected = (input_path.value == v);
62 select_path.add(opt, null);
67 function populate(json_result) {
68 var result = JSON.parse(json_result);
70 for (var x in result['choices']) {
71 opt = document.createElement('option');
72 add_item(result['choices'][x]);
74 if ( result['objectID'] ) {
75 selected_mib = result;
77 // show details on the selected node
78 document.getElementById('mib_objectID').innerHTML = result.objectID;
79 document.getElementById('mib_moduleID').innerHTML = result.moduleID;
80 document.getElementById('mib_type').innerHTML = result.type;
81 document.getElementById('submit_button').disabled = !result.type;
83 selected_mib = undefined;
88 function populate_modules(json_result) {
89 var result = JSON.parse(json_result);
90 var select_module = document.getElementById('select_module');
91 var opt = document.createElement('option');
94 select_module.add(opt, null);
95 for (var x in result['modules']) {
96 opt = document.createElement('option');
97 opt.value = opt.text = result['modules'][x];
98 select_module.add(opt, null);
102 function dispatch_search() {
103 // called from the interval timer
104 var search_string = document.getElementById('select_module').value + ':' +
105 document.getElementById('input_path').value;
107 search(search_string, populate);
110 function delayed_search() {
111 // onkeyup handler for the text input
112 // 500ms after the user stops typing, send the search request
114 clearTimeout(timerID);
116 timerID = setTimeout(dispatch_search, 500);
119 function handle_choose_object() {
120 // onchange handler for the selector
121 // when the user picks an option, set the text input to that, and then
122 // search for it as though it was entered
123 var input_path = document.getElementById('input_path');
124 input_path.value = this.value;
128 function handle_choose_module() {
129 input_path.value = ''; // just to avoid confusion
136 parent.nd(1); // close popup
138 alert(document.getElementById('input_path').value);
142 var input_path = document.getElementById('input_path');
143 input_path.onkeyup = delayed_search;
144 var select_path = document.getElementById('select_path');
145 select_path.onchange = handle_choose_object;
146 var select_module = document.getElementById('select_module');
147 select_module.onchange = handle_choose_module;
148 % if ( $cgi->param('curr_value') ) {
149 input_path.value = <% $cgi->param('curr_value') |js_string %>;
152 get_module_list('', populate_modules);
155 <& /elements/footer.html &>
157 my $callback = 'alert("(no callback defined)" + selected_mib.stringify)';
158 $cgi->param('callback') =~ /^(\w+)$/;
160 # construct the JS function call expresssion
161 $callback = 'window.parent.' . $1 . '(selected_mib';
162 foreach ($cgi->param('arg')) {
163 # pass-through arguments
165 $callback .= ",'$1'";