partial implementation of first_eid, last_eid -- I think the vals work -- they do for searches anyway, but not stored in pa_user_state yet

This commit is contained in:
2022-01-25 00:48:14 +11:00
parent 65ebfe2d31
commit 08ca9b4e74
7 changed files with 182 additions and 69 deletions

View File

@@ -26,11 +26,12 @@
var current={{current}}
var eids="{{eids}}"
var eid_lst=eids.split(",")
var offset={{OPT.offset}}
var last_entry_in_db={{OPT.last_entry_in_db}}
{% for id in objs %}
e=new Object()
e.url = "{{objs[id].FullPathOnFS()|safe}}"
e.name = e.url
e.type = "{{objs[id].type.name}}"
{% if objs[id].file_details.faces %}
e.face_model="{{objs[id].file_details.faces[0].facefile_lnk.model_used}}"
@@ -75,20 +76,29 @@
function CallViewListRoute(dir)
{
s='<form id="_fmv" method="POST" action="/viewlist">'
s+='<input type="hidden" name="eids" value="'+$("#eids").val() + '">'
s+='<input type="hidden" name="cwd" value="{{OPT.cwd}}">'
s+='<input type="hidden" name="root" value="{{OPT.root}}">'
s+='<input type="hidden" name="orig_url" value="{{OPT.orig_url}}">'
s+='<input type="hidden" name="view_eid" value="{{OPT.view_eid}}">'
s+='<input type="hidden" name="fullscreen" value="' + fullscreen + '">'
s+='<input type="hidden" name="' + dir + '" value="1">'
data="eids="+$("#eids").val()
data+="&cwd={{OPT.cwd}}"
data+="&root={{OPT.root}}"
data+="&orig_url={{OPT.orig_url}}"
data+="&view_eid={{OPT.view_eid}}"
// just to save this in pa_user_state
data+="&fullscreen="+fullscreen
// direction (next/prev)
data+="&"+dir+ "=1"
{% if search_term is defined %}
s+='<input type="hidden" name="search_term" value="{{search_term}}">'
data+="&search_term={{search_term}}"
{% endif %}
s+='</form>'
$(s).appendTo('body')
$('#_fmv').submit();
$.ajax({ type: 'POST', data: data, url: '/viewlist', success: function(res){
console.log(res);
current=res.current
eids=res.eids
objs=res.objs
eid_lst=eids.split(",")
offset=res.offset
last_entry_in_db=res.last_entry_in_db
ViewImageOrVideo()
}
})
}
</script>
@@ -109,7 +119,7 @@
prev=cidx-1
if( prev < 0 )
{
if( {{OPT.offset}} )
if( offset )
{
CallViewListRoute('prev')
return
@@ -160,28 +170,26 @@
<button title="Show next image" class="col-auto btn btn-outline-info px-2" style="padding: 10%" id="ra"
onClick="
{% if OPT.last_entry_in_db is defined %}
if( current == {{OPT.last_entry_in_db}} )
if( current == last_entry_in_db )
{
$('#ra').attr('disabled', true )
return
}
{% endif %}
if( document.fullscreen == false )
fullscreen = false
cidx = eid_lst.indexOf(current.toString())
if( cidx < eid_lst.length-1 )
{
current=eid_lst[cidx+1]
ViewImageOrVideo()
$('#la').attr('disabled', false )
}
else
{
{# only go next route if list contains as many elements as we asked to display... can be more than how_many on any page in reality, as its really how_many per dir? #}
if( eid_lst.length >= {{OPT.how_many}} )
CallViewListRoute('next')
}
if( document.fullscreen == false )
fullscreen = false
cidx = eid_lst.indexOf(current.toString())
if( cidx < eid_lst.length-1 )
{
current=eid_lst[cidx+1]
ViewImageOrVideo()
$('#la').attr('disabled', false )
}
else
{
{# only go next route if list contains as many elements as we asked to display... can be more than how_many on any page in reality, as its really how_many per dir? #}
if( eid_lst.length >= {{OPT.how_many}} )
CallViewListRoute('next')
}
">
<svg width="16" height="16" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#next"/></svg>
</button>