removed use of last_entry_in_db (boolean) and replaced with use of current/first_eid/last_eid in PA_USER_STATE so it persists across reloads/back buttons, and allows full use of ajax data retrieval in the background for the viewer (so fullscreen stays across page loads), and the next/prev buttons are set on the image load, not after they have been pressed "one too many times"

This commit is contained in:
2022-01-27 14:27:52 +11:00
parent 08ca9b4e74
commit 55724ccd59
5 changed files with 64 additions and 33 deletions

View File

@@ -27,7 +27,8 @@
var eids="{{eids}}"
var eid_lst=eids.split(",")
var offset={{OPT.offset}}
var last_entry_in_db={{OPT.last_entry_in_db}}
var first_eid={{OPT.first_eid}}
var last_eid={{OPT.last_eid}}
{% for id in objs %}
e=new Object()
@@ -54,6 +55,8 @@
function PrettyFname(fname)
{
console.log('PrettyFname called')
console.log('fname='+fname)
s='<span class="alert alert-secondary py-2">'
if( fname.indexOf( "static/Import" ) == 0 )
{
@@ -95,7 +98,6 @@
objs=res.objs
eid_lst=eids.split(",")
offset=res.offset
last_entry_in_db=res.last_entry_in_db
ViewImageOrVideo()
}
})
@@ -109,7 +111,7 @@
<input type="hidden" name="eids" value={{eids}}>
<div class="row">
<button title="Show previous image" class="col-auto btn btn-outline-info px-2" style="padding: 10%" id="la"
{% if OPT.offset == 0 and eids.find(current|string) == 0 %}
{% if OPT.first_eid == current %}
disabled
{% endif %}
onClick="
@@ -133,6 +135,8 @@
$('#ra').attr('disabled', false )
current=eid_lst[prev]
ViewImageOrVideo()
if( current == first_eid )
$('#la').attr('disabled', true )
">
<svg width="16" height="16" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#prev"/></svg>
</button>
@@ -169,12 +173,10 @@
</script>
<button title="Show next image" class="col-auto btn btn-outline-info px-2" style="padding: 10%" id="ra"
{% if OPT.last_eid == current %}
disabled
{% endif %}
onClick="
if( current == last_entry_in_db )
{
$('#ra').attr('disabled', true )
return
}
if( document.fullscreen == false )
fullscreen = false
cidx = eid_lst.indexOf(current.toString())
@@ -182,13 +184,16 @@
{
current=eid_lst[cidx+1]
ViewImageOrVideo()
$('#la').attr('disabled', false )
if( current != first_eid )
$('#la').attr('disabled', false )
}
else
CallViewListRoute('next')
if( current == last_eid )
{
{# 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')
$('#ra').attr('disabled', true )
return
}
">
<svg width="16" height="16" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#next"/></svg>