28 lines
873 B
HTML
28 lines
873 B
HTML
<p>Here you can write a new news article. This will replace the current one on town pages.</p>
|
|
|
|
<form action="/admin/news" method="post" id="news_form">
|
|
<textarea name="content" style="display: block; width: 100%; min-height: 240px;"></textarea>
|
|
<div>
|
|
<label for="author">Author</label>
|
|
<input type="text" name="author" id="author" value="{{ username }}">
|
|
</div>
|
|
<button type="submit" class="ui button primary">Submit</button>
|
|
</form>
|
|
|
|
<script>
|
|
$('#news_form').on('submit', function(e) {
|
|
e.preventDefault()
|
|
|
|
$('#main .ui.alert').remove()
|
|
|
|
$.post('/admin/news', $(this).serialize())
|
|
.done(function(data) {
|
|
const alertClass = data.success ? 'success' : 'failure'
|
|
$('#main').prepend(`<div class="ui alert ${alertClass}">${data.message}</div>`)
|
|
})
|
|
.fail(function() {
|
|
$('#main').prepend('<div class="ui alert failure">Request failed</div>')
|
|
})
|
|
})
|
|
</script>
|