Atlas: Versions-Tag rechts unten auf allen Hauptseiten
- App/version.json mit Commit-SHA + Build-Datum - App/assets/js/version-tag.js — rendert kleines Tag rechts unten - Eingebunden in schueler, teacher, index, login, admin, profil - Ermoeglicht Vergleich lokal vs. geograsim.at auf einen Blick Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* GeoGraSim — Versions-Tag
|
||||
* Rendert kleinen Hinweis rechts unten auf jeder Seite, damit lokal vs.
|
||||
* produktiv schnell abzugleichen ist.
|
||||
*
|
||||
* Einbinden: <script src="assets/js/version-tag.js" defer></script>
|
||||
* (Pfad relativ zur Datei, die es einbindet. Im PHP-Wrapper aus BASE_PATH.)
|
||||
*
|
||||
* Liest version.json, zeigt Commit-SHA + Datum. Bei Fetch-Fehler (z.B.
|
||||
* CORS, offline) zeigt es nichts — stumm, statt kaputt.
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
if (window.__GGS_VERSION_TAG_DONE__) return;
|
||||
window.__GGS_VERSION_TAG_DONE__ = true;
|
||||
|
||||
// Pfad zur version.json ermitteln
|
||||
var script = document.currentScript;
|
||||
var versionUrl = 'version.json';
|
||||
if (script && script.src) {
|
||||
// Script-Src: .../assets/js/version-tag.js -> version.json auf gleicher Ebene wie assets/
|
||||
var base = script.src.replace(/\/assets\/js\/version-tag\.js.*$/, '/');
|
||||
versionUrl = base + 'version.json';
|
||||
}
|
||||
|
||||
fetch(versionUrl, { cache: 'no-store' })
|
||||
.then(function (r) { return r.ok ? r.json() : null; })
|
||||
.then(function (v) {
|
||||
if (!v) return;
|
||||
var el = document.createElement('div');
|
||||
el.className = 'ggs-version-tag';
|
||||
el.title = 'Commit ' + v.commit + ' · ' + v.date;
|
||||
el.innerHTML = '<span class="ggs-version-sha">' + v.commit + '</span>' +
|
||||
'<span class="ggs-version-date">' + v.date + '</span>';
|
||||
Object.assign(el.style, {
|
||||
position: 'fixed',
|
||||
right: '6px',
|
||||
bottom: '6px',
|
||||
zIndex: '99998',
|
||||
background: 'rgba(20,40,50,0.7)',
|
||||
color: 'rgba(255,255,255,0.75)',
|
||||
fontFamily: 'ui-monospace, Menlo, Consolas, monospace',
|
||||
fontSize: '10px',
|
||||
lineHeight: '1.2',
|
||||
padding: '3px 7px',
|
||||
borderRadius: '4px',
|
||||
pointerEvents: 'auto',
|
||||
userSelect: 'all',
|
||||
cursor: 'help',
|
||||
display: 'flex',
|
||||
gap: '6px',
|
||||
alignItems: 'center'
|
||||
});
|
||||
el.querySelector('.ggs-version-sha').style.fontWeight = '700';
|
||||
el.querySelector('.ggs-version-date').style.opacity = '0.7';
|
||||
document.body.appendChild(el);
|
||||
})
|
||||
.catch(function () { /* stumm */ });
|
||||
})();
|
||||
Reference in New Issue
Block a user