31 lines
1.1 KiB
JavaScript
31 lines
1.1 KiB
JavaScript
/**
|
|
* Version display: fetch version.json and render a small, unobtrusive
|
|
* version badge fixed to the bottom-right of the page.
|
|
* Extracted from inline <script> for CSP compliance (G56-08).
|
|
*
|
|
* The page <title> is still suffixed with the version for tab/bookmark
|
|
* context, but the in-page header keeps only the human-readable title.
|
|
*/
|
|
(function () {
|
|
// Derive the title prefix from the existing <title> element
|
|
// (e.g. "Post-Quantum Nostr" or "Verify NIP-QR Event")
|
|
var titlePrefix = document.title || '';
|
|
|
|
fetch('./js/version.json')
|
|
.then(function (r) { return r.json(); })
|
|
.then(function (v) {
|
|
var versionText = v.VERSION || '';
|
|
// Suffix the browser tab/bookmark title with the version.
|
|
document.title = titlePrefix + ' ' + versionText;
|
|
|
|
// Render a small fixed version badge in the bottom-right corner.
|
|
if (versionText) {
|
|
var badge = document.createElement('div');
|
|
badge.className = 'pq-version-badge';
|
|
badge.textContent = versionText;
|
|
document.body.appendChild(badge);
|
|
}
|
|
})
|
|
.catch(function () { /* version.json not found — keep default title */ });
|
|
})();
|