diff options
author | Freya Murphy <freya@freyacat.org> | 2024-03-30 12:14:42 -0400 |
---|---|---|
committer | Freya Murphy <freya@freyacat.org> | 2024-03-30 12:14:42 -0400 |
commit | 1f04b83be337cc91a3fabcf4e574e2306f3d2eaa (patch) | |
tree | 74d7d65a7047e60d1877384e3c7b0d70c7b0e49a /web/views/modal/new_post.php | |
parent | start database (user and post), and initial barebones home page (diff) | |
download | xssbook2-1f04b83be337cc91a3fabcf4e574e2306f3d2eaa.tar.gz xssbook2-1f04b83be337cc91a3fabcf4e574e2306f3d2eaa.tar.bz2 xssbook2-1f04b83be337cc91a3fabcf4e574e2306f3d2eaa.zip |
refactor
Diffstat (limited to 'web/views/modal/new_post.php')
-rw-r--r-- | web/views/modal/new_post.php | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/web/views/modal/new_post.php b/web/views/modal/new_post.php new file mode 100644 index 0000000..82243fb --- /dev/null +++ b/web/views/modal/new_post.php @@ -0,0 +1,46 @@ +<?php /* Copyright (c) 2024 Freya Murphy */ ?> +<?php /* vi: syntax=php */ ?> +<?php + $user = $this->main->user(); +?> +<form id="new-post-form"> +<div class="modal-content new-post-modal"> + <div class="row"> + <?php $this->view('template/pfp', array('user' => $user))?> + <div class="col ml"> + <strong><?=$user['first_name'] . ' ' . $user['last_name']?></strong> + <span class="dim"><?=lang('now')?></span> + </div> + </div> + <textarea + type="text" + name="content" + id="new-post-content" + placeholder="<?=lang('action_new_post_text', sub: [$user['first_name']])?>" + ></textarea> +</div> +<div class="modal-footer"> + <?=ilang('action_submit', + id: 'new-post-submit', + class: 'btn-action', + attrs: array('type' => 'submit'), + button: TRUE + )?> +</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> |