Private
Public Access
1
0

smooth time slider

This commit is contained in:
Sander Roosendaal
2022-10-31 19:29:39 +01:00
parent 9eb65f5b26
commit 79204c0b5b
4 changed files with 23 additions and 13 deletions

View File

@@ -83,22 +83,29 @@ $( function() {
});
</script>
<script>
function secondsToHMS(s) {
var h = Math.floor(s/3600); // Hours
s -= h*3600;
var m = Math.floor(s/60); // Minutes
s -= m*60;
return h+":"+(m < 10 ? '0'+m : m)+":"+(s < 10 ? '0'+s : s); //zero padding on minutes and seconds
}
$( function() {
console.log({{ activeminutesmin }}, {{ activeminutesmax}}, 'active range');
$( "#slider-timerange" ).slider({
range: true,
min: 0,
max: {{ maxminutes }},
step: 0.1,
values: [ {{ activeminutesmin }}, {{ activeminutesmax }} ],
max: {{ maxminutes|times60 }},
step: 1,
values: [ {{ activeminutesmin|times60 }}, {{ activeminutesmax|times60 }} ],
slide: function( event, ui ) {
$( "#amount" ).val(ui.values[ 0 ] + " min - " + ui.values[ 1 ] + " min " );
$("#id_activeminutesmin").val(ui.values[0]);
$("#id_activeminutesmax").val(ui.values[1]);
$( "#amount" ).val(secondsToHMS(ui.values[ 0 ]) + " - " + secondsToHMS(ui.values[ 1 ]) );
$("#id_activeminutesmin").val(ui.values[0]/60);
$("#id_activeminutesmax").val(ui.values[1]/60);
}
});
$( "#amount" ).val($( "#slider-timerange" ).slider( "values", 0 ) +
" min - " + $( "#slider-timerange" ).slider( "values", 1 ) + " min ");
$( "#amount" ).val(secondsToHMS($( "#slider-timerange" ).slider( "values", 0 )) +
" min - " + secondsToHMS($( "#slider-timerange" ).slider( "values", 1 )));
} );
</script>
{% endblock %}