Add thumbnail viewer to Manage Bookmarks
This commit is contained in:
parent
0e66340b42
commit
08ec7643f7
|
@ -45,18 +45,23 @@ var dir = '$dir';
|
|||
</td><td><div id=slider></div></td></tr>
|
||||
<tr><td align=right>
|
||||
<span class=left>Current: <span id=curbmk></span></span><br><br><br>
|
||||
<button id=genthumbs title=\"Generate Thumbnails\" class=left>Generate Thumbnails</button>
|
||||
<button id=genthumbs title=\"Generate Thumbnails\"
|
||||
class=left>Generate Thumbnails</button>
|
||||
</td><td>
|
||||
<div id=thumbs class=hidden>
|
||||
<table><tr>"
|
||||
<table><tr>
|
||||
"
|
||||
set times {}
|
||||
loop v $start $limit $incr {
|
||||
lappend times $v
|
||||
puts "<th style=\"text-align: center\"><span class=mark>[format "%+d" $v]</span>s</th>"
|
||||
lappend times $v
|
||||
puts "
|
||||
<th style=\"text-align: center\"><span class=mark>
|
||||
[format "%+d" $v]</span>s</th>
|
||||
"
|
||||
}
|
||||
puts "</tr><tr>"
|
||||
foreach v $times {
|
||||
puts "<td><img class=bmp src=/img/generating.png pos=$v></td>"
|
||||
puts "<td><img class=bmp src=/img/generating.png pos=$v></td>"
|
||||
}
|
||||
puts "
|
||||
</tr></table>
|
||||
|
@ -64,10 +69,10 @@ puts "
|
|||
</table>
|
||||
<div id=buttons>
|
||||
<button id=save>Save Bookmarks</button>
|
||||
<button id=back>Back to Media Browser</button>"
|
||||
<button id=back>Back to Media Browser</button>
|
||||
"
|
||||
if {[system pkginst nicesplice]} {
|
||||
puts "
|
||||
<button id=crop>Go to Crop</button>"
|
||||
puts "<button id=crop>Go to Crop</button>"
|
||||
}
|
||||
puts "
|
||||
</div>
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
var curval = 0;
|
||||
var $slider;
|
||||
var values;
|
||||
|
||||
function toTimeStr(tval) {
|
||||
|
||||
function
|
||||
toTimeStr(tval)
|
||||
{
|
||||
return new Date(null, null, null, null, null, tval)
|
||||
.toTimeString().match(/\d{2}:\d{2}:\d{2}/)[0] + ' ';
|
||||
.toTimeString().match(/\d{2}:\d{2}:\d{2}/)[0] + ' ';
|
||||
}
|
||||
|
||||
function
|
||||
function
|
||||
valarray(valstr)
|
||||
{
|
||||
return valstr.trim().split(/ +/);
|
||||
|
@ -76,39 +78,42 @@ draw_slider()
|
|||
};
|
||||
|
||||
function
|
||||
regenthumbs(curbmkstr) {
|
||||
regenthumbs(curbmkstr)
|
||||
{
|
||||
$('#curbmk').html(curbmkstr);
|
||||
$('#thumbs').hide();
|
||||
$('#genthumbs')
|
||||
.button('enable')
|
||||
.button('option', 'icon', 'ui-icon-zoomin');
|
||||
.button('enable')
|
||||
.button('option', 'icon', 'ui-icon-zoomin');
|
||||
}
|
||||
|
||||
function
|
||||
update_slider() {
|
||||
function
|
||||
update_slider()
|
||||
{
|
||||
setvals();
|
||||
|
||||
|
||||
/* slider values are strings */
|
||||
var curvalstr = "" + curval;
|
||||
if (!values.includes(curvalstr)) {
|
||||
/* try to map current selected bmk to new bmk */
|
||||
var ovalues = $slider.slider( "option", "values" );
|
||||
var ovalues = $slider.slider("option", "values");
|
||||
var nn = ovalues.indexOf(curvalstr);
|
||||
if (nn < 0) {
|
||||
curval = 0;
|
||||
} else {
|
||||
if (nn >= values.length) nn = values.length - 1;
|
||||
curval = nn >= 0? values[nn]: 0;
|
||||
if (nn >= values.length)
|
||||
nn = values.length - 1;
|
||||
curval = nn >= 0 ? values[nn] : 0;
|
||||
}
|
||||
regenthumbs(toTimeStr(curval));
|
||||
}
|
||||
$('#slider .ui-slider-handle').each( function(i) {
|
||||
if (i >= values.length)
|
||||
$('#slider .ui-slider-handle').each(function(i) {
|
||||
if (i >= values.length)
|
||||
$(this).hide();
|
||||
else
|
||||
$(this).show();
|
||||
});
|
||||
$slider.slider( "option", "values", values );
|
||||
});
|
||||
$slider.slider("option", "values", values);
|
||||
};
|
||||
|
||||
function
|
||||
|
@ -120,7 +125,7 @@ refreshtimes()
|
|||
$.each(values, function(k, v) {
|
||||
t += toTimeStr(v);
|
||||
});
|
||||
$('#slider .ui-slider-handle').each( function(i) {
|
||||
$('#slider .ui-slider-handle').each(function(i) {
|
||||
$(this).attr('title', toTimeStr(values[i]));
|
||||
});
|
||||
}
|
||||
|
@ -130,7 +135,7 @@ refreshtimes()
|
|||
function
|
||||
sortmarks()
|
||||
{
|
||||
values.sort(function(a, b){return a-b});
|
||||
values.sort(function(a, b){return a - b});
|
||||
$('#bookmarks').val(values.join(" "));
|
||||
}
|
||||
|
||||
|
@ -142,18 +147,18 @@ $('#curbmk').html(toTimeStr(curval));
|
|||
|
||||
$('#addbmark').button({icons: {primary: "ui-icon-plus"}, text: false})
|
||||
.on('click', function() {
|
||||
$('#bookmarks').val('0 ' + $('#bookmarks').val());
|
||||
curval = 0;
|
||||
update_slider();
|
||||
$('#bookmarks').val('0 ' + $('#bookmarks').val());
|
||||
curval = 0;
|
||||
update_slider();
|
||||
});
|
||||
|
||||
$('#delbmark').button({icons: {primary: "ui-icon-minus"}, text: false})
|
||||
.on('click', function() {
|
||||
var cur = $('#bookmarks').val();
|
||||
cur = cur.replace(
|
||||
new RegExp('(^| )' + curval + '( |$)', ''), ' ').trim();
|
||||
$('#bookmarks').val(cur);
|
||||
update_slider();
|
||||
var cur = $('#bookmarks').val();
|
||||
cur = cur.replace(
|
||||
new RegExp('(^| )' + curval + '( |$)', ''), ' ').trim();
|
||||
$('#bookmarks').val(cur);
|
||||
update_slider();
|
||||
});
|
||||
|
||||
$('#save').button({icons: {primary: "ui-icon-disk"}})
|
||||
|
@ -178,54 +183,62 @@ $('#crop').button({icons: {primary: "ui-icon-arrowreturnthick-1-e"}})
|
|||
window.location.href.replace('/bookmarks/?','/crop/crop.jim?');
|
||||
});
|
||||
|
||||
$('#crop').button({icons: {primary: "ui-icon-arrowreturnthick-1-e"}})
|
||||
.on('click', function() {
|
||||
window.location =
|
||||
window.location.href.replace('/bookmarks/?','/crop/crop.jim?');
|
||||
});
|
||||
|
||||
$('#update').button()
|
||||
.on('click', function() {
|
||||
update_slider();
|
||||
update_slider();
|
||||
});
|
||||
|
||||
$('#slider')
|
||||
.on('slidechange', function(evt, ui) {
|
||||
var tstr = toTimeStr(curval);
|
||||
if (tstr != $('#curbmk').html()) {
|
||||
regenthumbs(tstr);
|
||||
}
|
||||
.on('slidechange', function(evt, ui) {
|
||||
var tstr = toTimeStr(curval);
|
||||
if (tstr != $('#curbmk').html())
|
||||
regenthumbs(tstr);
|
||||
});
|
||||
|
||||
$('#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++;
|
||||
});
|
||||
$('#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+curval,
|
||||
'e': last+curval,
|
||||
'i': incr
|
||||
}, function() {
|
||||
$('#thumbs').show();
|
||||
$('img.bmp').each(function(i) {
|
||||
/* cast to "int" */
|
||||
var pos = $(this).attr('pos')|0;
|
||||
$(this).attr('src',
|
||||
'/browse/thumbnail/fetch.jim?file=' +
|
||||
encodeURIComponent(file) + '&pos=' + (curval+pos).toFixed(1));
|
||||
});
|
||||
$('#genthumbs').button('option', 'icon', 'ui-icon-zoomin');
|
||||
$.get('/browse/thumbnail/mkrange.jim', {
|
||||
'file': file,
|
||||
's': start+curval,
|
||||
'e': last+curval,
|
||||
'i': incr
|
||||
}, function() {
|
||||
$('#thumbs').show();
|
||||
$('img.bmp').each(function(i) {
|
||||
/* cast to "int" */
|
||||
var pos = $(this).attr('pos')|0;
|
||||
$(this).attr('src',
|
||||
'/browse/thumbnail/fetch.jim?' +
|
||||
'file=' + encodeURIComponent(file) +
|
||||
'&pos=' + (curval+pos).toFixed(1));
|
||||
});
|
||||
$('#genthumbs').button('option', 'icon', 'ui-icon-zoomin');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue