Skip to content

Commit

Permalink
Update ui/ui.js
Browse files Browse the repository at this point in the history
Refactor VRF drop down options to function.
Fixes #9
  • Loading branch information
knewell committed Mar 11, 2020
1 parent bb1a62a commit 2e54b7b
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions ui/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,8 @@ $(document).ready(function () {

var return_data = new Array();

selectVrf = document.getElementById('selectVrf');
selectModVrf = document.getElementById('selectModVrf');

$.each( response[2], function( index, value ) {
var opt = document.createElement('option');
opt.text = value;
opt.value = value;
selectVrf.appendChild(opt);
});

$.each( response[2], function( index, value ) {
var opt = document.createElement('option');
opt.text = value;
opt.value = value;
selectModVrf.appendChild(opt);
});
addVrfOptions('selectVrf', response[2]);
addVrfOptions('selectModVrf', response[2]);

$.each( response[1], function( name, flow ) {

Expand Down Expand Up @@ -636,3 +622,19 @@ function getActiveFlowFilter(pollInterval){
}
setTimeout(poll, pollInterval);
}

function addVrfOptions(elementID, vrf){

var select = document.getElementById(elementID);
var length = select.options.length;
for (i = length-1; i >= 0; i--) {
select.options[i] = null;
}

$.each( vrf, function( index, value ) {
var opt = document.createElement('option');
opt.text = value;
opt.value = value;
select.appendChild(opt);
});
}

0 comments on commit 2e54b7b

Please sign in to comment.