From 6937f2b7fb38a8f45c67bec58b29c63593363d81 Mon Sep 17 00:00:00 2001 From: df Date: Tue, 10 Nov 2020 14:22:26 +0000 Subject: [PATCH] Add thumbnail viewer to Manage Bookmarks --- webif/html/browse/bookmarks/script.js | 66 ++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 7 deletions(-) diff --git a/webif/html/browse/bookmarks/script.js b/webif/html/browse/bookmarks/script.js index 02174c7a..5a99e3c7 100644 --- a/webif/html/browse/bookmarks/script.js +++ b/webif/html/browse/bookmarks/script.js @@ -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'); + }); }); +});