Commit e6b8cc6e authored by Olav Kvittem's avatar Olav Kvittem

separert ut som egen fil

parent f171af3d
var mp_url="https://kind.uninett.no/autoregister/utstyr_mp.json";
var mp_list=[];
function make_select( elm, url){
// var html='<button id=traceroute onclick="traceroute( $(\'#tr_host\').val(), $(\'#tr_times\').val(), $(\'#tr_size\').val(), $(\'#tr_interval\').val() )">Trace route</button> to ';
var html='';
// commented code is to produce a select_menu rather than jquery ui autocomplete
html+= '<form name="traceroute_form" id="traceroute_form">';
html+= '<select name="mp_opt" id="mp_opt" class="btn btn-basic btn-lg" onChange="top.location.href = this.form.mp_opt.options[this.form.mp_opt.selectedIndex].value;return false;">';
html+= '<option value="">Velg Mleple</option>';
var items=[];
var request=$.ajax( {url: url, type: 'GET', dataType: 'json', crossDomain: true } );
request.done( function( mps){
// console.log(mps);
mps.sort( function(a, b) {
var textA = a.navn.toLowerCase();
var textB = b.navn.toLowerCase();
if (textA < textB)
return -1;
if (textA > textB)
return 1;
return 0;
});
$.each(mps, function(mp) {
html+='<option value="http://' + mps[mp].navn + '">' + mps[mp].navn + '</option>';
mp_list.push(mps[mp].navn);
});
document.getElementById(elm).innerHTML += html + '</select></form>';
// $( "#mp_name" ).autocomplete({ source: mp_list });
// $("#"+elm).select2();
$("#mp_opt").select2();
});
request.fail( function( jqXHR, status, error){
console.log('Listing beacons faild from '+ url + ' : ' + status + ', ' + error);
});
/* var rq=$.JSONget(url, function(data){console.log(data)});
rq.fail( function( jqXHR, error){
console.log(error+ url);
});
*/
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment