diff options
author | Freya Murphy <freya@freyacat.org> | 2024-12-23 11:13:27 -0500 |
---|---|---|
committer | Freya Murphy <freya@freyacat.org> | 2024-12-23 11:13:27 -0500 |
commit | 5a2ba9c2e7605bb788bc406184547d22c6436867 (patch) | |
tree | cbd988d534e8a8593a31d70571222443f80da0b3 /src/web/_views/_modal/new_post.php | |
parent | fix about modal (diff) | |
download | xssbook2-5a2ba9c2e7605bb788bc406184547d22c6436867.tar.gz xssbook2-5a2ba9c2e7605bb788bc406184547d22c6436867.tar.bz2 xssbook2-5a2ba9c2e7605bb788bc406184547d22c6436867.zip |
v2.1.0, refactor w/ crimson
Diffstat (limited to 'src/web/_views/_modal/new_post.php')
-rw-r--r-- | src/web/_views/_modal/new_post.php | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/web/_views/_modal/new_post.php b/src/web/_views/_modal/new_post.php new file mode 100644 index 0000000..aff19a5 --- /dev/null +++ b/src/web/_views/_modal/new_post.php @@ -0,0 +1,56 @@ +<?php /* Copyright (c) 2024 Freya Murphy */ ?> +<?php /* vi: syntax=php */ ?> +<form id="new-post-form"> +<div class="modal-content new-post-modal"> + <div class="row"> + <?=pfp($session)?> + <div class="col ml"> + <strong><?=$session['first_name'] . ' ' . $session['last_name']?></strong> + <span class="subtext"><?=ucfirst(lang('now'))?></span> + </div> + </div> + <textarea + type="text" + name="content" + id="new-post-content" + placeholder="<?=ucfirst(lang('action_new_post_text', sub: [$session['first_name']]))?>" + ></textarea> +</div> +<div class="modal-footer"> + <?=ilang('action_submit', + id: 'new-post-submit', + class: 'btn btn-submit btn-alt grow', + attrs: array('type' => 'submit'), + type: 'button', + )?> +</div> +</form> +<script> + $('#new-post-form').submit(function(e) { + e.preventDefault(); + let content = $('#new-post-content').val(); + let me = $(this); + + const getPost = function(data) { + if (data) { + $('#post-container').prepend(data); + } + me.closest('.modal-container').remove(); + } + + const onPost = function(data) { + let id = data[0].id; + $.get({ + url: '/_post/post?id=' + id, + success: getPost + }); + } + + $.ajax({ + url: '/api/post', + method: 'POST', + data: JSON.stringify({ content }), + success: onPost + }); + }); +</script> |