77 lines
3.9 KiB
HTML
77 lines
3.9 KiB
HTML
@include(snippets/header)
|
|
<div class="pagewrapper">
|
|
<div id="main" class="admin-container">
|
|
<div class="container">
|
|
<h2>Message of the Day (MOTD)</h2>
|
|
<p style="color: #ccc; margin-bottom: 20px;">This message is displayed <strong>inside the navbar</strong> (at the bottom) so it stays visible while scrolling. Supports Markdown and HTML.</p>
|
|
|
|
<div class="admin-motd-form">
|
|
<form id="motd-form" action="/admin/motd" method="POST" onsubmit="event.preventDefault(); saveMotd(this);">
|
|
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
|
|
<div style="margin-bottom: 20px;">
|
|
<label for="motd-text" style="display: block; margin-bottom: 8px; color: var(--accent);">MOTD Content (Markdown supported)</label>
|
|
<textarea id="motd-text" name="motd" style="width: 100%; min-height: 200px; background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.1); color: #fff; padding: 15px; border-radius: 4px; font-family: inherit; font-size: 1.1em; resize: vertical;">{!! motd !!}</textarea>
|
|
</div>
|
|
|
|
<div style="display: flex; gap: 10px; align-items: center;">
|
|
<button type="submit" class="btn-primary" style="width: auto; padding: 10px 30px;">Save MOTD</button>
|
|
<button type="button" class="btn-remove" style="width: auto; padding: 10px 20px;" onclick="document.getElementById('motd-text').value=''; saveMotd(document.getElementById('motd-form'));">Clear MOTD</button>
|
|
<span id="motd-status" style="margin-left: 10px; font-weight: bold; display: none;"></span>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<div style="margin-top: 40px; padding: 20px; background: rgba(0,0,0,0.2); border-left: 4px solid var(--accent); border-radius: 4px;">
|
|
<h4 style="color: var(--accent); margin-top: 0;">Preview Tip</h4>
|
|
<p style="margin-bottom: 0;">You can use <strong>Markdown</strong> syntax like <code># Header</code>, <code>**bold**</code>, <code>[links](url)</code>, or standard HTML. The message updates instantly site-wide when you click Save.
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
async function saveMotd(form) {
|
|
const status = document.getElementById('motd-status');
|
|
const textarea = document.getElementById('motd-text');
|
|
const motd = textarea.value;
|
|
|
|
status.textContent = 'Saving...';
|
|
status.style.color = 'var(--accent)';
|
|
status.style.display = 'inline';
|
|
|
|
try {
|
|
const res = await fetch(form.action, {
|
|
method: 'POST',
|
|
headers: {
|
|
'X-Requested-With': 'XMLHttpRequest',
|
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
'X-CSRF-Token': window.f0ckSession?.csrf_token
|
|
},
|
|
body: new URLSearchParams(new FormData(form))
|
|
});
|
|
|
|
const data = await res.json();
|
|
if (data.success) {
|
|
status.textContent = 'Saved!';
|
|
status.style.color = '#28a745';
|
|
|
|
if (typeof window.updateMotdUI === 'function') {
|
|
window['motd_dismissed'] = false; // Force show on save
|
|
window.updateMotdUI(motd);
|
|
}
|
|
|
|
setTimeout(() => {
|
|
status.style.display = 'none';
|
|
}, 2000);
|
|
} else {
|
|
throw new Error(data.msg || 'Unknown error');
|
|
}
|
|
} catch (err) {
|
|
console.error('MOTD Save Error:', err);
|
|
status.textContent = 'Error: ' + err.message;
|
|
status.style.color = '#d9534f';
|
|
}
|
|
}
|
|
</script>
|
|
</div>
|
|
</div>
|
|
@include(snippets/footer) |