v0.1.33: Fix scanForDevices is not defined error
Some checks failed
Deploy to GitHub Pages / build (push) Has been cancelled
Deploy to GitHub Pages / deploy (push) Has been cancelled

- Fixed JavaScript scope issue by injecting scan function into existing script section
- Scan function now properly available when button is clicked
- Improved JavaScript injection strategy to avoid separate script tag conflicts
- Updated version to 0.1.33 in all files

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
paul2212
2026-03-18 18:05:26 +01:00
parent 7e2c841f81
commit 620e433547
4 changed files with 27 additions and 10 deletions

View File

@@ -5,6 +5,16 @@ All notable changes to this project are documented in this file.
The format is based on Keep a Changelog and this project uses Semantic Versioning. The format is based on Keep a Changelog and this project uses Semantic Versioning.
## [0.1.33] - 2026-03-18
### Fixed
- **Web UI**: Fixed "scanForDevices is not defined" error by injecting scan function into existing script section instead of separate script tag.
- **Web UI**: Ensured scan JavaScript is properly scoped and available when button is clicked.
### Changed
- **Web UI**: Improved JavaScript injection strategy to avoid scope issues.
- **Web UI**: Scan function now injected directly into main script section for proper global availability.
## [0.1.32] - 2026-03-18 ## [0.1.32] - 2026-03-18
### Fixed ### Fixed

View File

@@ -1,5 +1,5 @@
name: "Fichero Printer" name: "Fichero Printer"
version: "0.1.32" version: "0.1.33"
slug: "fichero_printer" slug: "fichero_printer"
description: "REST API for the Fichero D11s (AiYin) thermal label printer over Bluetooth" description: "REST API for the Fichero D11s (AiYin) thermal label printer over Bluetooth"
url: "https://git.leuschner.dev/Tobias/Fichero" url: "https://git.leuschner.dev/Tobias/Fichero"

View File

@@ -77,7 +77,7 @@ async def lifespan(app: FastAPI): # noqa: ARG001
app = FastAPI( app = FastAPI(
title="Fichero Printer API", title="Fichero Printer API",
description="REST API for the Fichero D11s (AiYin) thermal label printer.", description="REST API for the Fichero D11s (AiYin) thermal label printer.",
version = "0.1.32", version = "0.1.33",
lifespan=lifespan, lifespan=lifespan,
docs_url=None, docs_url=None,
redoc_url=None, redoc_url=None,
@@ -134,7 +134,7 @@ def _ui_html() -> str:
</div> </div>
""" """
scan_script = r''' scan_script = r'''
<script> // Scan for BLE Devices function
async function scanForDevices() { async function scanForDevices() {
console.log('Scan function called - checking elements...'); console.log('Scan function called - checking elements...');
const resultsEl = document.getElementById('scan-results'); const resultsEl = document.getElementById('scan-results');
@@ -187,18 +187,25 @@ def _ui_html() -> str:
console.log('Scan completed. Final result:', resultsEl.textContent); console.log('Scan completed. Final result:', resultsEl.textContent);
} }
} }
</script>
''' '''
# Inject after the main content but before scripts # Inject scan HTML after main content
if "</main>" in template: if "</main>" in template:
parts = template.split("</main>", 1) parts = template.split("</main>", 1)
template = parts[0] + "</main>" + scan_html + scan_script + parts[1] template = parts[0] + "</main>" + scan_html + parts[1]
elif "</body>" in template: elif "</body>" in template:
parts = template.split("</body>", 1) parts = template.split("</body>", 1)
template = parts[0] + scan_html + scan_script + "</body>" + parts[1] template = parts[0] + scan_html + "</body>" + parts[1]
else: else:
# Fallback if no main or body tag # Fallback if no main or body tag
template += scan_html + scan_script template += scan_html
# Inject scan script before the closing </script> tag of the main script
if "</script>" in template:
parts = template.rsplit("</script>", 1)
template = parts[0] + scan_script + "</script>" + parts[1]
else:
# Fallback if no script tag found
template += f"<script>{scan_script}</script>"
return template return template

View File

@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project] [project]
name = "fichero-printer" name = "fichero-printer"
version = "0.1.32" version = "0.1.33"
description = "Web GUI, Python CLI, and protocol documentation for the Fichero D11s thermal label printer." description = "Web GUI, Python CLI, and protocol documentation for the Fichero D11s thermal label printer."
readme = "README.md" readme = "README.md"
requires-python = ">=3.10" requires-python = ">=3.10"