Add thumbnail viewer to Manage Bookmarks

This commit is contained in:
df 2020-11-10 14:22:26 +00:00
parent 086814cafa
commit 6937f2b7fb

View File

@ -1,11 +1,17 @@
var curval = 0;
var $slider;
var end = -1;
function toTimeStr(tval) {
return new Date(null, null, null, null, null, tval)
.toTimeString().match(/\d{2}:\d{2}:\d{2}/)[0] + ' '
}
function
setvals()
{
values = $.trim($('#bookmarks').val()).split(/ +/);
if (!values.length || values[0] == '')
if (values.length > 0 && values[0] != '')
{
refreshtimes();
return;
@ -68,13 +74,12 @@ refreshtimes()
values = $.trim($('#bookmarks').val()).split(/ +/);
if (!values.length || values[0] == '')
{
$('#bookmarkstime').text(t);
return;
$.each(values, function(k, v) {
/* cast to "int" */
end = v|0;
t += toTimeStr(v);
});
}
$.each(values, function(k, v) {
t += new Date(null, null, null, null, null, v)
.toTimeString().match(/\d{2}:\d{2}:\d{2}/)[0] + ' ';
});
$('#bookmarkstime').text(t);
}
@ -90,6 +95,7 @@ $(function() {
$('#bookmarks').val($('#bookmarks').attr('init'));
draw_slider();
$('#curbmk').html(toTimeStr(end));
$('#addbmark').button({icons: {primary: "ui-icon-plus"}, text: false})
.on('click', function() {
@ -127,6 +133,52 @@ $('#update').button()
draw_slider();
});
$('#slider')
.on('slidechange', function(evt, ui) {
if (end != ui.value) {
end = ui.value;
$('#curbmk').html(toTimeStr(end));
$('#thumbs').hide();
$('#genthumbs')
.button('enable')
.button('option', 'icon', 'ui-icon-zoomin');
}
});
$('#genthumbs').button( { icons: {primary: "ui-icon-zoomin"}, disabled: false } )
.on('click', function() {
var start;
var incr = -1;
var last;
$(this)
.button('disable')
.button('option', 'icon', 'ui-icon-refresh');
$('img.bmp').each(function(i) {
if (start === undefined) {
start = $(this).attr('pos')|0;
} else {
last = $(this).attr('pos')|0;
}
incr++;
});
incr = (last - start) / incr;
$.get('/browse/thumbnail/mkrange.jim',
{
'file': file,
's': start+end,
'e': last+end,
'i': incr
}, function() {
$('#thumbs').show();
$('img.bmp').each(function(i) {
var pos = $(this).attr('pos')|0;
$(this).attr('src',
'/browse/thumbnail/fetch.jim?file=' +
encodeURIComponent(file) + '&pos=' + (end+pos).toFixed(1));
});
$('#genthumbs').button('option', 'icon', 'ui-icon-zoomin');
});
});
});