Skip to content

Commit

Permalink
Added filter to waypoint list.
Browse files Browse the repository at this point in the history
  • Loading branch information
biuti committed May 26, 2021
1 parent 8be3cd5 commit ecbbc51
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions airscore/static/js/task_admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,39 @@ $(document).ready(function() {
$('#multi_start').addClass('show');;
}

// adding waypoint select filter
$('#rwp_id').before('<input class="form-control form-control-sm" type="text" id="rwp_filter" value="" placeholder="Filter..." size="3">');

$('#mod-type').on('change', function() {
['mod-how', 'mod-shape', 'mod-radius'].forEach( el => $('#'+el+'-div').hide() )
let val = $(this).val();
if ( val != 'launch' || $('#check_launch').is(':checked') ) $('#mod-radius-div').show();
if ( val == 'speed' ) $('#mod-how-div').show();
if ( val == 'goal' ) $('#mod-shape-div').show();
});

$('#type').on('change', function() {
['how', 'shape', 'radius'].forEach( el => $('#'+el+'-div').hide() )
let val = $(this).val();
if ( val != 'launch' || $('#check_launch').is(':checked') ) $('#radius-div').show();
if ( val == 'speed' ) $('#how-div').show();
if ( val == 'goal' ) $('#shape-div').show();
});

$('#rwp_filter').keyup( function() {
let choices = $('#rwp_id option');
let filter = $(this).val().toLowerCase();
if( !filter ) {
choices.each( (idx, el) => $(el).show() );
}
else {
choices.each( (idx, el) => {
if ( $(el).text().toLowerCase().includes(filter) ) $(el).show();
else $(el).hide();
});
}
});

});

function get_turnpoints(){
Expand Down

0 comments on commit ecbbc51

Please sign in to comment.