summaryrefslogtreecommitdiff
path: root/web/views/modal/new_post.php
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--web/views/modal/new_post.php (renamed from web/views/modal/new-post.php)24
1 files changed, 21 insertions, 3 deletions
diff --git a/web/views/modal/new-post.php b/web/views/modal/new_post.php
index 7215862..82243fb 100644
--- a/web/views/modal/new-post.php
+++ b/web/views/modal/new_post.php
@@ -1,7 +1,9 @@
+<?php /* Copyright (c) 2024 Freya Murphy */ ?>
+<?php /* vi: syntax=php */ ?>
<?php
$user = $this->main->user();
?>
-<form>
+<form id="new-post-form">
<div class="modal-content new-post-modal">
<div class="row">
<?php $this->view('template/pfp', array('user' => $user))?>
@@ -12,8 +14,8 @@
</div>
<textarea
type="text"
- name="text"
- id="text"
+ name="content"
+ id="new-post-content"
placeholder="<?=lang('action_new_post_text', sub: [$user['first_name']])?>"
></textarea>
</div>
@@ -26,3 +28,19 @@
)?>
</div>
</form>
+<script>
+ $('#new-post-form').submit(function(e) {
+ e.preventDefault();
+ let content = $('#new-post-content').val();
+
+ $.ajax({
+ url: '/api/post',
+ method: 'POST',
+ data: JSON.stringify({ content }),
+ success: function(data) {
+ window.location.reload();
+ },
+ error: errorToast
+ });
+ });
+</script>