1 <& /elements/header-popup.html &>
2 <DIV STYLE="visibility: hidden; position: absolute" ID="measurebox"></DIV>
5 <TD WIDTH="30%" ALIGN="right">Module:</TD>
6 <TD><SELECT ID="select_module"></SELECT></TD>
9 <TD ALIGN="right">Object:</TD>
10 <TD><INPUT TYPE="text" NAME="path" ID="input_path" SIZE=50 WIDTH="100%"></TD>
14 <SELECT STYLE="width:100%" SIZE=12 ID="select_path"></SELECT>
18 <TH ALIGN="center" COLSPAN=2 ID="mib_objectID"></TH>
21 <TD ALIGN="right">Module: </TD><TD ID="mib_moduleID"></TD>
24 <TD ALIGN="right">Data type: </TD><TD ID="mib_type"></TD>
28 <BUTTON ID="submit_button" onclick="submit()" DISABLED=1>Continue</BUTTON>
32 <& /elements/xmlhttp.html,
33 url => $p.'misc/xmlhttp-mib-browse.html',
34 subs => [qw( search get_module_list )],
36 <SCRIPT TYPE="text/javascript">
40 function show_info(state) {
41 document.getElementById('mib_objectID').style.display =
42 document.getElementById('mib_moduleID').style.display =
43 document.getElementById('mib_type').style.display =
47 function clear_list() {
48 var select_path = document.getElementById('select_path');
49 select_path.options.length = 0;
52 var measurebox = document.getElementById('measurebox');
53 function add_item(value) {
54 var select_path = document.getElementById('select_path');
55 var input_path = document.getElementById('input_path');
56 var opt = document.createElement('option');
58 if ( v.match(/-$/) ) {
59 opt.className = 'leaf';
60 v = v.substring(0, v.length - 1);
62 var optvalue = v; // may not be the name we display
63 // shorten these if they don't fit in the box
64 if ( v.length > 30 ) { // unless they're already really short
65 measurebox.innerHTML = v;
66 while ( measurebox.clientWidth > select_path.clientWidth - 10
67 && v.match(/^\..*\./) ) {
68 v = v.replace(/^\.[^\.]+/, '');
69 measurebox.innerHTML = v;
71 if ( optvalue != v ) {
77 opt.selected = (input_path.value == v);
78 select_path.add(opt, null);
83 function populate(json_result) {
84 var result = JSON.parse(json_result);
86 for (var x in result['choices']) {
87 opt = document.createElement('option');
88 add_item(result['choices'][x]);
90 if ( result['objectID'] ) {
91 selected_mib = result;
93 // show details on the selected node
94 document.getElementById('mib_objectID').innerHTML = result.objectID;
95 document.getElementById('mib_moduleID').innerHTML = result.moduleID;
96 document.getElementById('mib_type').innerHTML = result.type;
97 document.getElementById('submit_button').disabled = !result.type;
99 selected_mib = undefined;
104 function populate_modules(json_result) {
105 var result = JSON.parse(json_result);
106 var select_module = document.getElementById('select_module');
107 var opt = document.createElement('option');
110 select_module.add(opt, null);
111 for (var x in result['modules']) {
112 opt = document.createElement('option');
113 opt.value = opt.text = result['modules'][x];
114 select_module.add(opt, null);
118 function dispatch_search() {
119 // called from the interval timer
120 var search_string = document.getElementById('select_module').value + ':' +
121 document.getElementById('input_path').value;
123 search(search_string, populate);
126 function delayed_search() {
127 // onkeyup handler for the text input
128 // 500ms after the user stops typing, send the search request
130 clearTimeout(timerID);
132 timerID = setTimeout(dispatch_search, 500);
135 function handle_choose_object() {
136 // onchange handler for the selector
137 // when the user picks an option, set the text input to that, and then
138 // search for it as though it was entered
139 var input_path = document.getElementById('input_path');
140 input_path.value = this.value;
144 function handle_choose_module() {
145 input_path.value = ''; // just to avoid confusion
152 parent.nd(1); // close popup
154 alert(document.getElementById('input_path').value);
158 var input_path = document.getElementById('input_path');
159 input_path.onkeyup = delayed_search;
160 var select_path = document.getElementById('select_path');
161 select_path.onchange = handle_choose_object;
162 var select_module = document.getElementById('select_module');
163 select_module.onchange = handle_choose_module;
164 % if ( $cgi->param('curr_value') ) {
165 input_path.value = <% $cgi->param('curr_value') |js_string %>;
168 get_module_list('', populate_modules);
171 <& /elements/footer.html &>
173 my $callback = 'alert("(no callback defined)" + selected_mib.stringify)';
174 $cgi->param('callback') =~ /^(\w+)$/;
176 # construct the JS function call expresssion
177 $callback = 'window.parent.' . $1 . '(selected_mib';
178 foreach ($cgi->param('arg')) {
179 # pass-through arguments
181 $callback .= ",'$1'";