From 5e9701dfa3485789323d196c3df9b668261f83e1 Mon Sep 17 00:00:00 2001 From: nekobit Date: Mon, 18 Jul 2022 23:15:29 +0000 Subject: [PATCH] No JS replybox FossilOrigin-Name: 47e174164920f713bc3f7409dbc1e0b9195677fcf4b064679dffd76a2ab399fd --- dist/js/main.js | 105 +------------------------------- dist/treebird.css | 5 ++ src/status.c | 35 ++++++++++- src/status.h | 1 + static/interaction_buttons.tmpl | 5 +- static/post.tmpl | 3 +- static/reply_checkbox.tmpl | 5 ++ static/reply_link.tmpl | 5 ++ static/status.tmpl | 3 + 9 files changed, 55 insertions(+), 112 deletions(-) create mode 100644 static/reply_checkbox.tmpl create mode 100644 static/reply_link.tmpl diff --git a/dist/js/main.js b/dist/js/main.js index 90a87a0..30afa55 100644 --- a/dist/js/main.js +++ b/dist/js/main.js @@ -1,12 +1,4 @@ (function(){ - // Global state variable - // let state = { - // file: { - // files: {}, - // file_counter: 0, - // } - // }; - Element.prototype.insertAfter = function(element) { element.parentNode.insertBefore(this, element.nextSibling); }; @@ -44,77 +36,7 @@ document.querySelectorAll("input[type=text], input[type=url], input[type=email], input[type=password], textarea").forEach((i) => { i.addEventListener("keydown", e => form_enter_submit(e, i)); }); - - - function construct_quick_reply_form(status) - { - let src = document.createElement("form"); - src.action = "/status/create"; - src.method = "post"; - src.enctype = "multipart/form-data"; - src.className = "statusbox-quickreply"; - let hiddeninput = document.createElement("input"); - hiddeninput.type = "hidden"; - hiddeninput.name = "replyid" - hiddeninput.value = status.id; - let statusbox = document.createElement("div"); - statusbox.className = "statusbox statusbox-ani"; - - let textarea = document.createElement("textarea"); - textarea.placeholder = "Just landed in N.Y."; - textarea.rows = 5; - textarea.tabindex = 1; - textarea.name = "content"; - - // Load placeholder text - let instance_info = status.querySelector(".instance-info"); - textarea.innerText = reply_get_mentions( - instance_info ? instance_info.innerText : null, - status.querySelector(".status-content").innerHTML - ); - - let statusfooter = document.createElement("div"); - statusfooter.className = "statusfooter"; - let statusfooter_sides = { - left: document.createElement("div"), - right: document.createElement("div"), - } - let select = document.createElement("select"); - let files_input = document.createElement("input"); - statusfooter_sides.left.className = "statusfooter-left"; - select.innerHTML = ` - - - - - - `.trim(); - files_input.type = "file"; - files_input.name = "file"; - files_input.tabindex = 4; - files_input.multiple = ""; - - statusfooter_sides.right.className = "statusfooter-right"; - let submitbtn = document.createElement("input"); - submitbtn.className = "btn post-btn"; - submitbtn.type = "submit"; - submitbtn.value = "Post"; - submitbtn.tabindex = 2; - - - statusfooter_sides.left.appendChild(select); - statusfooter_sides.left.appendChild(files_input); - statusfooter_sides.right.appendChild(submitbtn); - statusfooter.appendChild(statusfooter_sides.left); - statusfooter.appendChild(statusfooter_sides.right); - statusbox.appendChild(textarea); - textarea.addEventListener("keydown", e => form_enter_submit(e, textarea)); - statusbox.appendChild(statusfooter); - src.appendChild(hiddeninput); - src.appendChild(statusbox); - return src; - } - + function construct_query(query) { query_string = ""; @@ -239,24 +161,6 @@ return false; } - function create_reply_form(e) - { - e.preventDefault(); - let status = e.target.closest(".status"); - - if (status.nextSibling.className === "statusbox-quickreply") - { - status.nextSibling.remove(); - } - else { - let form = construct_quick_reply_form(status); - form.insertAfter(status); - } - - - return false; - } - function frame_resize() { let rightbar_frame = document.querySelector("#rightbar .sidebar-frame"); @@ -379,10 +283,6 @@ let interact_btn = document.getElementsByClassName("statbtn"); // Add event listener to add specificied buttons - for (let i = 0; i < reply_btn.length; ++i) - { - reply_btn[i].addEventListener('click', create_reply_form); - } for (let i = 0; i < interact_btn.length; ++i) { interact_btn[i].addEventListener('click', status_interact_props); @@ -401,8 +301,5 @@ { file_input.addEventListener('change', evt_file_upload); } - - // let submit = document.querySelector("form"); - // submit.onsubmit }); })(); diff --git a/dist/treebird.css b/dist/treebird.css index d28397c..0d70b85 100644 --- a/dist/treebird.css +++ b/dist/treebird.css @@ -715,6 +715,11 @@ svg.in-reply-to-icon line-height: 23px; } +input[type=checkbox].hidden:not(:checked) + .reply-form +{ + display: none; +} + .notification-compact .notification-content { color: #808080; diff --git a/src/status.c b/src/status.c index 34025e1..70bbb9a 100644 --- a/src/status.c +++ b/src/status.c @@ -49,6 +49,8 @@ #include "../static/likeboost.ctmpl" #include "../static/reactions_btn.ctmpl" #include "../static/interaction_buttons.ctmpl" +#include "../static/reply_link.ctmpl" +#include "../static/reply_checkbox.ctmpl" #include "../static/menu_item.ctmpl" #include "../static/like_btn.ctmpl" #include "../static/repeat_btn.ctmpl" @@ -270,6 +272,7 @@ char* construct_interaction_buttons(struct session* ssn, char* likeboost_html = NULL; char* reply_count = NULL; char* repeat_count = NULL; + char* reply_btn; char* favourites_count = NULL; char* emoji_picker_html = NULL; char* reactions_btn_html = NULL; @@ -323,17 +326,36 @@ char* construct_interaction_buttons(struct session* ssn, struct like_btn_template ldata = { .favourite_active = status->favourited ? "active" : "" }; like_btn = tmpl_gen_like_btn(&ldata, NULL); } + + // Weather it should be a link or a