33dc5406b2
- api/logout.php: destroys session + clears cookie, redirects to / - api/guest-session.php: sets guest flag, lets users explore without account - layout.php: removes hard PHP redirect; authenticated users see email + "Logg ut" in topbar; guests see guest banner (sticky, dismissible) and auth gate modal (dismissible via localStorage) instead of redirect - layout_footer.php: injects auth gate modal + JS for banner/modal dismiss - layout_dashboard.php: adds username + "Logg ut" to dash-topbar - index.php: adds "Utforsk uten konto" link under primary login CTA - tools.css: .guest-banner, .auth-gate-*, .topbar-user, .dash-topbar__user Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
107 lines
4.6 KiB
PHP
107 lines
4.6 KiB
PHP
</section><!-- /tool-panel -->
|
|
|
|
<aside class="reasoning-panel" aria-labelledby="reasoningTitle">
|
|
<?php if (!empty($reasoningPanelOverride)): ?>
|
|
<?= $reasoningPanelOverride ?>
|
|
<?php else: ?>
|
|
<div class="reasoning-head">
|
|
<p class="eyebrow"><?= htmlspecialchars(dbnToolsT('reasoning_eyebrow', $uiLang ?? dbnToolsCurrentLanguage())) ?></p>
|
|
<h2 id="reasoningTitle"><?= htmlspecialchars(dbnToolsT('reasoning_title', $uiLang ?? dbnToolsCurrentLanguage())) ?></h2>
|
|
</div>
|
|
<ol id="traceList" class="trace-list">
|
|
<li>
|
|
<span class="trace-status waiting"></span>
|
|
<div>
|
|
<strong><?= htmlspecialchars(dbnToolsT('waiting_title', $uiLang ?? dbnToolsCurrentLanguage())) ?></strong>
|
|
<p><?= htmlspecialchars(dbnToolsT('waiting_text', $uiLang ?? dbnToolsCurrentLanguage())) ?></p>
|
|
</div>
|
|
</li>
|
|
</ol>
|
|
<?php endif; ?>
|
|
</aside>
|
|
</section><!-- /workspace -->
|
|
</main><!-- /appShell -->
|
|
<?php require_once __DIR__ . '/footer.php'; ?>
|
|
<script src="assets/js/tools.js" defer></script>
|
|
<?php if (!empty($extraScripts) && is_array($extraScripts)): foreach ($extraScripts as $extraScript): ?>
|
|
<script src="<?= htmlspecialchars((string)$extraScript) ?>" defer></script>
|
|
<?php endforeach; endif; ?>
|
|
<script src="assets/js/corpus-save.js" defer></script>
|
|
|
|
<!-- Save-to-corpus dialog (shared across all tool pages) -->
|
|
<dialog id="save-corpus-dialog" class="save-corpus-dialog">
|
|
<form method="dialog" id="save-corpus-form">
|
|
<h3>Save to corpus</h3>
|
|
<p class="save-corpus-hint">This will be indexed and searchable in your private corpus.</p>
|
|
<label>
|
|
<span>Title <span aria-hidden="true">*</span></span>
|
|
<input id="save-corpus-title" type="text" required placeholder="Give this entry a title…" autocomplete="off">
|
|
</label>
|
|
<label>
|
|
<span>Tags <span class="save-corpus-optional">(comma-separated)</span></span>
|
|
<input id="save-corpus-tags" type="text" placeholder="e.g. barnevern, 2024, kjennelse">
|
|
</label>
|
|
<menu>
|
|
<button type="submit" class="btn-primary">Save to corpus</button>
|
|
<button type="button" id="save-corpus-cancel">Cancel</button>
|
|
</menu>
|
|
</form>
|
|
</dialog>
|
|
|
|
<?php if (!empty($layoutIsGuest)): ?>
|
|
<!-- Auth gate modal — shown to unauthenticated visitors unless they dismissed it -->
|
|
<div id="authGate" class="auth-gate-backdrop" hidden aria-modal="true" role="dialog" aria-labelledby="authGateTitle">
|
|
<div class="auth-gate-card">
|
|
<p class="auth-gate-eyebrow">Do Better Norge</p>
|
|
<h2 id="authGateTitle" class="auth-gate-title">Logg inn for å bruke verktøyene</h2>
|
|
<p class="auth-gate-body">Våre juridiske AI-verktøy krever en gratis konto. Registrer deg på sekunder med Google.</p>
|
|
<div class="auth-gate-actions">
|
|
<a id="authGateLogin" href="/?return=<?= htmlspecialchars($layoutReturnUrl ?? '') ?>" class="auth-gate-btn auth-gate-btn--primary">Logg inn / Registrer deg</a>
|
|
<button id="authGateDismiss" class="auth-gate-btn auth-gate-btn--ghost">Fortsett uten konto</button>
|
|
</div>
|
|
<p class="auth-gate-note">Gratis tilgang · Ingen kredittkort</p>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
(function () {
|
|
'use strict';
|
|
var GATE_KEY = 'dbn-auth-gate-v1';
|
|
var BANNER_KEY = 'dbn-guest-banner-v1';
|
|
var gate = document.getElementById('authGate');
|
|
var banner = document.getElementById('guestBanner');
|
|
var bannerClose = document.getElementById('guestBannerClose');
|
|
|
|
// Show or hide the guest banner
|
|
if (banner) {
|
|
if (localStorage.getItem(BANNER_KEY) === 'closed') {
|
|
banner.hidden = true;
|
|
}
|
|
if (bannerClose) {
|
|
bannerClose.addEventListener('click', function () {
|
|
localStorage.setItem(BANNER_KEY, 'closed');
|
|
banner.hidden = true;
|
|
});
|
|
}
|
|
}
|
|
|
|
// Show auth gate modal unless already dismissed
|
|
if (gate && localStorage.getItem(GATE_KEY) !== 'dismissed') {
|
|
gate.hidden = false;
|
|
document.getElementById('authGateDismiss').addEventListener('click', function () {
|
|
localStorage.setItem(GATE_KEY, 'dismissed');
|
|
gate.hidden = true;
|
|
});
|
|
// Close on backdrop click
|
|
gate.addEventListener('click', function (e) {
|
|
if (e.target === gate) {
|
|
localStorage.setItem(GATE_KEY, 'dismissed');
|
|
gate.hidden = true;
|
|
}
|
|
});
|
|
}
|
|
}());
|
|
</script>
|
|
<?php endif; ?>
|
|
</body>
|
|
</html>
|