forked from mirrors/treebird
JS reply_get_mentions
FossilOrigin-Name: 8d6cc782d8149bfb3b0d223cea058c8fc7a4141f191b7d25e3280de1d87dd2cf
This commit is contained in:
parent
d3554ba3f2
commit
7b852dbbcb
2 changed files with 27 additions and 6 deletions
29
dist/js/main.js
vendored
29
dist/js/main.js
vendored
|
@ -10,7 +10,22 @@ function get_cookie(cookiestr)
|
|||
.split('=')[1];
|
||||
}
|
||||
|
||||
function construct_quick_reply_form(replyid)
|
||||
// TODO Check if logged in .acct value is the same
|
||||
function reply_get_mentions(reply, content)
|
||||
{
|
||||
const regexpr = /<a target="_parent" class="mention" href="https?:\/\/.*?\/@(.*?)@(.*?)">.*?<\/a>/g;
|
||||
const arr = [...content.matchAll(regexpr)];
|
||||
let res = reply ? `@${reply} ` : "";
|
||||
const matches = content.matchAll(regexpr);
|
||||
|
||||
for (let x of matches)
|
||||
{
|
||||
res += `@${x[1]}@${x[2]} `;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
function construct_quick_reply_form(status)
|
||||
{
|
||||
let src = document.createElement("form");
|
||||
src.action = "/status/create";
|
||||
|
@ -20,7 +35,7 @@ function construct_quick_reply_form(replyid)
|
|||
let hiddeninput = document.createElement("input");
|
||||
hiddeninput.type = "hidden";
|
||||
hiddeninput.name = "replyid"
|
||||
hiddeninput.value = replyid;
|
||||
hiddeninput.value = status.id;
|
||||
let statusbox = document.createElement("div");
|
||||
statusbox.className = "statusbox statusbox-ani";
|
||||
|
||||
|
@ -30,6 +45,13 @@ function construct_quick_reply_form(replyid)
|
|||
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 = {
|
||||
|
@ -187,9 +209,8 @@ function create_reply_form(e)
|
|||
status.nextSibling.remove();
|
||||
}
|
||||
else {
|
||||
let form = construct_quick_reply_form(status.id);
|
||||
let form = construct_quick_reply_form(status);
|
||||
form.insertAfter(status);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
4
dist/treebird20.css
vendored
4
dist/treebird20.css
vendored
|
@ -1183,7 +1183,7 @@ p}
|
|||
{
|
||||
display: block;
|
||||
padding: 3px 2px 5px;
|
||||
min-width: 43px;
|
||||
min-width: 39px;
|
||||
}
|
||||
|
||||
.view-btn
|
||||
|
@ -1243,7 +1243,7 @@ p}
|
|||
|
||||
.status-interact .count
|
||||
{
|
||||
font-size: 14px;
|
||||
font-size: 12px;
|
||||
padding-bottom: 3px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue