Skip to content
Snippets Groups Projects
Commit 3c486c92 authored by Marco De Donno's avatar Marco De Donno
Browse files

Add the search bar on the trainer exercise search page

parent 0f717ae8
No related branches found
No related tags found
No related merge requests found
......@@ -80,6 +80,28 @@
$( "#new_exercise_confirmation_input" ).focus();
}
var update_search_result = function()
{
var searched = $( "#search_bar" ).val();
searched = searched.toLowerCase();
_.forEach( ex_list, function( ex )
{
var tmp = [];
_.forEach( ex, function( e )
{
tmp.push( e.toLowerCase().indexOf( searched ) );
} );
if( Math.max( ...tmp ) > -1 )
{
$( "#ex_" + ex[ "uuid" ] + "_outer_div" ).show();
} else {
$( "#ex_" + ex[ "uuid" ] + "_outer_div" ).hide();
}
} );
}
var ex_list = {};
{% for ex in ex_list %}
ex_list[ "{{ ex[ 'uuid' ] }}" ] = {
......@@ -89,6 +111,12 @@
}
{% endfor %}
</script>
<style>
.icnml_search_bar {
margin-bottom: 20px;
width: 500px;
}
</style>
</head>
<body class="icnml_main_layout">
{% include "header.html" %}
......@@ -100,9 +128,22 @@
<span class="ui-button-text" id="new_exercise_button_text">Create new exercise</span>
</a>
</div>
<div class="icnml_search_bar">
<input id="search_bar" placeholder="Search a exercise list..."/>
</div>
<div id="ex_list">
{% for ex in ex_list %}
<div id="ex_{{ ex[ 'uuid' ] }}_outer_div">
{{ ex[ 'name' ] }}
</div>
{% endfor %}
</div>
</div>
<script type="text/javascript">
$( "#search_bar" ).on( "keyup", update_search_result );
$( "#search_bar" ).focus();
$( "#new_exercise_button" ).on( "click", create_new_exercise );
$( "#icnml_navigation_trainerexercises" )
.addClass( "activated" );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment