thedesk/app/js/post/use-txtbox.js

79 lines
2.2 KiB
JavaScript
Raw Normal View History

2018-04-07 14:31:09 +10:00
/*リプライ*/
2019-05-19 17:39:30 +10:00
function re(id, ats_cm, acct_id, mode) {
2019-03-13 02:51:07 +11:00
clear();
2019-05-19 17:39:30 +10:00
var ats = ats_cm.split(',');
localStorage.setItem("nohide", true);
2018-04-07 14:31:09 +10:00
show();
$("#reply").val(id);
2019-05-19 17:39:30 +10:00
for (var i = 0; i < ats.length; i++) {
var at = ats[i];
var te = $("#textarea").val();
if (at != localStorage.getItem("user_" + acct_id)) {
$("#textarea").val("@" + at + " " + te);
2019-03-21 15:39:30 +11:00
}
2019-03-13 02:51:07 +11:00
}
2019-01-26 14:24:26 +11:00
$("#rec").text(lang.lang_yesno);
2018-04-07 14:31:09 +10:00
$("#post-acct-sel").val(acct_id);
2018-05-10 02:01:06 +10:00
$("#post-acct-sel").prop("disabled", true);
2019-06-16 21:35:15 +10:00
$('select').formSelect();
2019-05-19 17:39:30 +10:00
$("#textarea").attr("placeholder", lang.lang_usetxtbox_reply);
2018-04-07 14:31:09 +10:00
$("#textarea").focus();
2019-05-19 17:39:30 +10:00
var profimg = localStorage.getItem("prof_" + acct_id);
if (!profimg) {
profimg = "../../img/missing.svg";
2018-08-21 04:26:14 +10:00
}
2019-05-19 17:39:30 +10:00
$("#acct-sel-prof").attr("src", profimg);
2018-04-07 14:31:09 +10:00
vis(mode);
}
2019-05-19 17:39:30 +10:00
function reEx(id) {
2018-04-07 14:31:09 +10:00
$('#tootmodal').modal('close');
2019-05-19 17:39:30 +10:00
var at = $("#tootmodal").attr("data-user");
2018-04-07 14:31:09 +10:00
var acct_id = $("#status-acct-sel").val();
2019-05-19 17:39:30 +10:00
var mode = $("#tootmodal .vis-data").attr("data-vis");
re(id, at, acct_id, mode);
2018-04-07 14:31:09 +10:00
}
//引用
2019-05-19 17:39:30 +10:00
function qt(id, acct_id, at, url) {
localStorage.setItem("nohide", true);
2018-04-07 14:31:09 +10:00
var qt = localStorage.getItem("quote");
2019-05-19 17:39:30 +10:00
if (!qt) {
var qt = "simple";
2018-04-07 14:31:09 +10:00
}
2019-05-19 17:39:30 +10:00
if (qt == "nothing") {
2019-03-13 02:51:07 +11:00
return false;
}
2019-05-19 17:39:30 +10:00
if (qt == "simple") {
2018-04-07 14:31:09 +10:00
show();
2019-05-19 17:39:30 +10:00
$("#textarea").val("\n" + url);
} else if (qt == "mention") {
2018-04-07 14:31:09 +10:00
show();
2019-05-19 17:39:30 +10:00
$("#textarea").val("\n" + url + " From:@" + at);
} else if (qt == "full") {
2018-04-07 14:31:09 +10:00
show();
2019-05-19 17:39:30 +10:00
var html = $("[toot-id=" + id + "] .toot").html();
2018-04-07 14:31:09 +10:00
html = html.match(/^<p>(.+)<\/p>$/)[1];
html = html.replace(/<br\s?\/?>/, "\n");
html = html.replace(/<p>/, "\n");
html = html.replace(/<\/p>/, "\n");
2019-05-19 17:39:30 +10:00
html = $.strip_tags(html);
$("#textarea").val("\n" + "@" + at + " " + html + "\n" + url);
2019-09-08 02:33:01 +10:00
} else if (qt == "apiQuote") {
clear();
localStorage.setItem("nohide", true);
show();
$("#quote").val(id);
$("#post-acct-sel").val(acct_id);
$("#post-acct-sel").prop("disabled", true);
$('select').formSelect();
$("#textarea").attr("placeholder", lang.lang_usetxtbox_reply);
$("#textarea").focus();
var profimg = localStorage.getItem("prof_" + acct_id);
if (!profimg) {
profimg = "../../img/missing.svg";
}
$("#acct-sel-prof").attr("src", profimg);
2018-04-07 14:31:09 +10:00
}
$("#post-acct-sel").val(acct_id);
2019-06-16 21:35:15 +10:00
$('select').formSelect();
$("#textarea").focus();
2018-04-07 14:31:09 +10:00
}