Skip to content

Commit

Permalink
Removed ende template
Browse files Browse the repository at this point in the history
  • Loading branch information
z2-2z committed Dec 23, 2023
1 parent b2e0c4d commit 84b97fd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
13 changes: 9 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import sys
import os
import json

from flask import Flask, render_template, request, send_from_directory

Expand All @@ -16,10 +17,14 @@ def custom_static(filename):
def index():
global files
idx = int(request.args.get("image", 0))
if idx >= 0 and idx < len(files):
return render_template("index.html", img=files[idx], pageno=idx + 1)
else:
return render_template("ende.html")
if idx >= len(files):
idx = len(files) - 1
if idx < 0:
idx = 0
pageno = None
if idx >= 0 and idx < len(files) - 1:
pageno = idx + 1
return render_template("index.html", img=files[idx], pageno=json.dumps(pageno))

def main():
global files
Expand Down
10 changes: 0 additions & 10 deletions templates/ende.html

This file was deleted.

11 changes: 9 additions & 2 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@
<link rel="stylesheet" href="/static/style.css"/>
<script>
window.dalli_cfg = {
img: "{{url_for('custom_static', filename=img)}}"
img: "{{url_for('custom_static', filename=img)}}",
next: {{pageno}},
};

document.addEventListener("DOMContentLoaded", function () {
if (window.dalli_cfg.next === null) {
document.getElementById("btn-next").disabled = true;
}
});
</script>
<style>
body {
Expand All @@ -22,7 +29,7 @@
<canvas id="canvas"></canvas>
<div id="toolbar">
<form method="get" action="/">
<input type="hidden" name="image" value="{{pageno}}"/>
<input type="hidden" id="next-image" name="image" value="{{ pageno }}"/>
<input type="submit" id="btn-next" value="N&auml;chstes Bild"/>
</form>
<button id="btn-hint">Freilegen</button>
Expand Down

0 comments on commit 84b97fd

Please sign in to comment.