2018-01-28 23:22:43 +11:00
|
|
|
//お気に入り登録やブースト等、フォローやブロック等
|
|
|
|
//お気に入り登録
|
2018-03-21 16:36:02 +11:00
|
|
|
function fav(id, acct_id, remote) {
|
2018-01-28 23:22:43 +11:00
|
|
|
if ($("#pub_" + id).hasClass("faved")) {
|
|
|
|
var flag = "unfavourite";
|
|
|
|
} else {
|
|
|
|
var flag = "favourite";
|
|
|
|
}
|
|
|
|
var domain = localStorage.getItem("domain_" + acct_id);
|
2019-05-19 17:39:30 +10:00
|
|
|
var at = localStorage.getItem("acct_" + acct_id + "_at");
|
2018-01-28 23:22:43 +11:00
|
|
|
var start = "https://" + domain + "/api/v1/statuses/" + id + "/" + flag;
|
2018-04-17 03:10:35 +10:00
|
|
|
var httpreq = new XMLHttpRequest();
|
|
|
|
httpreq.open('POST', start, true);
|
|
|
|
httpreq.setRequestHeader('Content-Type', 'application/json');
|
|
|
|
httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
|
2019-03-08 05:19:26 +11:00
|
|
|
httpreq.responseType = "json";
|
2018-04-17 03:10:35 +10:00
|
|
|
httpreq.send();
|
2019-05-19 17:39:30 +10:00
|
|
|
httpreq.onreadystatechange = function () {
|
|
|
|
if (httpreq.readyState === 4) {
|
|
|
|
var json = httpreq.response;
|
|
|
|
if (remote != "remote") {
|
2018-04-17 03:10:35 +10:00
|
|
|
//APIのふぁぼカウントがおかしい
|
2019-05-19 17:39:30 +10:00
|
|
|
if ($("[toot-id=" + id + "] .fav_ct").text() == json.favourites_count) {
|
|
|
|
if (flag == "unfavourite") {
|
|
|
|
var fav = json.favourites_count - 1;
|
|
|
|
} else {
|
|
|
|
var fav = json.favourites_count + 1;
|
2018-04-17 03:10:35 +10:00
|
|
|
//var fav = json.favourites_count;
|
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
2018-04-17 03:10:35 +10:00
|
|
|
var fav = json.favourites_count;
|
|
|
|
}
|
|
|
|
$("[toot-id=" + id + "] .fav_ct").text(fav);
|
|
|
|
if (!json.reblog) {
|
|
|
|
} else {
|
|
|
|
$("[toot-id=" + id + "] .rt_ct").text(fav);
|
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
if ($("[toot-id=" + id + "]").hasClass("faved")) {
|
|
|
|
$("[toot-id=" + id + "]").removeClass("faved");
|
2018-04-17 03:10:35 +10:00
|
|
|
$(".fav_" + id).removeClass("yellow-text");
|
|
|
|
} else {
|
2019-05-19 17:39:30 +10:00
|
|
|
$("[toot-id=" + id + "]").addClass("faved");
|
2018-04-17 03:10:35 +10:00
|
|
|
$(".fav_" + id).addClass("yellow-text");
|
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
2019-06-07 02:11:04 +10:00
|
|
|
M.toast({ html: lang.lang_status_favWarn, displayLength: 1000 })
|
2019-05-19 17:39:30 +10:00
|
|
|
}
|
|
|
|
}
|
2018-04-17 03:10:35 +10:00
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
//ブースト
|
2018-03-21 16:36:02 +11:00
|
|
|
function rt(id, acct_id, remote) {
|
2018-01-28 23:22:43 +11:00
|
|
|
if ($("#pub_" + id).hasClass("rted")) {
|
|
|
|
var flag = "unreblog";
|
|
|
|
} else {
|
|
|
|
var flag = "reblog";
|
|
|
|
}
|
|
|
|
var domain = localStorage.getItem("domain_" + acct_id);
|
2019-05-19 17:39:30 +10:00
|
|
|
var at = localStorage.getItem("acct_" + acct_id + "_at");
|
2018-01-28 23:22:43 +11:00
|
|
|
var start = "https://" + domain + "/api/v1/statuses/" + id + "/" + flag;
|
2018-04-17 03:10:35 +10:00
|
|
|
var httpreq = new XMLHttpRequest();
|
|
|
|
httpreq.open('POST', start, true);
|
|
|
|
httpreq.setRequestHeader('Content-Type', 'application/json');
|
|
|
|
httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
|
2019-03-08 05:19:26 +11:00
|
|
|
httpreq.responseType = "json";
|
2018-04-17 03:10:35 +10:00
|
|
|
httpreq.send();
|
2019-05-19 17:39:30 +10:00
|
|
|
httpreq.onreadystatechange = function () {
|
2019-03-08 05:19:26 +11:00
|
|
|
if (httpreq.readyState === 4) {
|
2018-04-17 03:10:35 +10:00
|
|
|
var json = httpreq.response;
|
2019-05-19 17:39:30 +10:00
|
|
|
console.log(["Success: boost", json]);
|
2018-04-17 03:10:35 +10:00
|
|
|
if (remote != "remote") {
|
|
|
|
$("[toot-id=" + id + "] .fav_ct").text(json.favourites_count);
|
|
|
|
if (!json.reblog) {
|
|
|
|
if (flag == "unreblog") {
|
|
|
|
var rt = json.reblogs_count - 1;
|
|
|
|
} else {
|
|
|
|
var rt = json.reblogs_count + 1;
|
|
|
|
}
|
|
|
|
$("[toot-id=" + id + "] .rt_ct").text(rt);
|
|
|
|
} else {
|
|
|
|
$("[toot-id=" + id + "] .rt_ct").text(json.reblog.reblogs_count);
|
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
|
2018-04-17 03:10:35 +10:00
|
|
|
if ($("[toot-id=" + id + "]").hasClass("rted")) {
|
|
|
|
$("[toot-id=" + id + "]").removeClass("rted");
|
|
|
|
$(".rt_" + id).removeClass("teal-text");
|
|
|
|
} else {
|
|
|
|
$("[toot-id=" + id + "]").addClass("rted");
|
|
|
|
$(".rt_" + id).addClass("teal-text");
|
|
|
|
}
|
|
|
|
} else {
|
2019-06-07 02:11:04 +10:00
|
|
|
M.toast({ html: lang.lang_status_btWarn, displayLength: 1000 })
|
2018-04-17 03:10:35 +10:00
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
2018-03-21 16:36:02 +11:00
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
//フォロー
|
2019-05-19 17:39:30 +10:00
|
|
|
function follow(acct_id, remote) {
|
|
|
|
if (!acct_id && acct_id != "selector") {
|
2018-01-28 23:22:43 +11:00
|
|
|
var acct_id = $('#his-data').attr("use-acct");
|
2019-05-19 17:39:30 +10:00
|
|
|
} else if (acct_id == "selector") {
|
2018-03-21 16:36:02 +11:00
|
|
|
var acct_id = $("#user-acct-sel").val();
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
2018-03-21 16:36:02 +11:00
|
|
|
if (!remote && $("#his-data").hasClass("following")) {
|
2018-01-28 23:22:43 +11:00
|
|
|
var flag = "unfollow";
|
2018-07-30 21:03:49 +10:00
|
|
|
var flagm = "delete";
|
2018-01-28 23:22:43 +11:00
|
|
|
} else {
|
|
|
|
var flag = "follow";
|
2018-07-30 21:03:49 +10:00
|
|
|
var flagm = "create";
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
2018-03-21 16:36:02 +11:00
|
|
|
var id = $("#his-data").attr("user-id");
|
2019-05-19 17:39:30 +10:00
|
|
|
if (!remote) {
|
2018-03-21 16:36:02 +11:00
|
|
|
var remote = $("#his-data").attr("remote");
|
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
var domain = localStorage.getItem("domain_" + acct_id);
|
2019-05-19 17:39:30 +10:00
|
|
|
var at = localStorage.getItem("acct_" + acct_id + "_at");
|
|
|
|
if (localStorage.getItem("mode_" + domain) == "misskey") {
|
|
|
|
var start = "https://" + domain + "/api/following/" + flagm;
|
|
|
|
var user = $("#his-acct").text();
|
|
|
|
var ent = { "i": at, "userId": id }
|
|
|
|
} else if (remote == "true" && flag == "follow") {
|
2018-01-31 03:43:01 +11:00
|
|
|
var start = "https://" + domain + "/api/v1/follows";
|
2019-05-19 17:39:30 +10:00
|
|
|
var user = $("#his-acct").text();
|
|
|
|
var ent = { "uri": user }
|
|
|
|
} else {
|
2018-01-31 03:43:01 +11:00
|
|
|
var start = "https://" + domain + "/api/v1/accounts/" + id + "/" + flag;
|
2019-05-19 17:39:30 +10:00
|
|
|
var ent = {}
|
2018-01-31 03:43:01 +11:00
|
|
|
}
|
2018-04-17 03:10:35 +10:00
|
|
|
var httpreq = new XMLHttpRequest();
|
|
|
|
httpreq.open('POST', start, true);
|
|
|
|
httpreq.setRequestHeader('Content-Type', 'application/json');
|
|
|
|
httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
|
2019-03-08 05:19:26 +11:00
|
|
|
httpreq.responseType = "json";
|
2018-06-12 01:44:28 +10:00
|
|
|
httpreq.send(JSON.stringify(ent));
|
2019-05-19 17:39:30 +10:00
|
|
|
httpreq.onreadystatechange = function () {
|
2019-03-08 05:19:26 +11:00
|
|
|
if (httpreq.readyState === 4) {
|
2018-04-17 03:10:35 +10:00
|
|
|
var json = httpreq.response;
|
2019-05-19 17:39:30 +10:00
|
|
|
console.log(["Success: folllow", json]);
|
2018-04-17 03:10:35 +10:00
|
|
|
if ($("#his-data").hasClass("following")) {
|
|
|
|
$("#his-data").removeClass("following");
|
2019-01-26 14:24:26 +11:00
|
|
|
$("#his-follow-btn").text(lang.lang_status_follow);
|
2018-04-17 03:10:35 +10:00
|
|
|
} else {
|
|
|
|
$("#his-data").addClass("following");
|
2019-01-26 14:24:26 +11:00
|
|
|
$("#his-follow-btn").text(lang.lang_status_unfollow);
|
2018-04-17 03:10:35 +10:00
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
2018-04-17 03:10:35 +10:00
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
//ブロック
|
|
|
|
function block(acct_id) {
|
|
|
|
if (!acct_id) {
|
|
|
|
var acct_id = $('#his-data').attr("use-acct");
|
|
|
|
}
|
|
|
|
var id = $("#his-data").attr("user-id");
|
|
|
|
if ($("#his-data").hasClass("blocking")) {
|
|
|
|
var flag = "unblock";
|
|
|
|
} else {
|
|
|
|
var flag = "block";
|
|
|
|
}
|
|
|
|
var domain = localStorage.getItem("domain_" + acct_id);
|
2019-05-19 17:39:30 +10:00
|
|
|
var at = localStorage.getItem("acct_" + acct_id + "_at");
|
2018-01-28 23:22:43 +11:00
|
|
|
var start = "https://" + domain + "/api/v1/accounts/" + id + "/" + flag;
|
2018-04-17 03:10:35 +10:00
|
|
|
var httpreq = new XMLHttpRequest();
|
|
|
|
httpreq.open('POST', start, true);
|
|
|
|
httpreq.setRequestHeader('Content-Type', 'application/json');
|
|
|
|
httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
|
2019-03-08 05:19:26 +11:00
|
|
|
httpreq.responseType = "json";
|
2018-04-17 03:10:35 +10:00
|
|
|
httpreq.send();
|
2019-05-19 17:39:30 +10:00
|
|
|
httpreq.onreadystatechange = function () {
|
2019-03-08 05:19:26 +11:00
|
|
|
if (httpreq.readyState === 4) {
|
2018-04-17 03:10:35 +10:00
|
|
|
if ($("#his-data").hasClass("blocking")) {
|
|
|
|
$("#his-data").removeClass("blocking");
|
2019-01-26 14:24:26 +11:00
|
|
|
$("#his-block-btn").text(lang.lang_status_block);
|
2018-04-17 03:10:35 +10:00
|
|
|
} else {
|
|
|
|
$("#his-data").addClass("blocking");
|
2019-01-26 14:24:26 +11:00
|
|
|
$("#his-block-btn").text(lang.lang_status_unblock);
|
2018-04-17 03:10:35 +10:00
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
2018-04-17 03:10:35 +10:00
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
//ミュート
|
|
|
|
function mute(acct_id) {
|
|
|
|
if (!acct_id) {
|
|
|
|
var acct_id = $('#his-data').attr("use-acct");
|
|
|
|
}
|
|
|
|
var id = $("#his-data").attr("user-id");
|
|
|
|
if ($("#his-data").hasClass("muting")) {
|
|
|
|
var flag = "unmute";
|
2018-07-30 21:03:49 +10:00
|
|
|
var flagm = "delete";
|
2018-01-28 23:22:43 +11:00
|
|
|
} else {
|
|
|
|
var flag = "mute";
|
2018-07-30 21:03:49 +10:00
|
|
|
var flagm = "create";
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
|
|
|
var domain = localStorage.getItem("domain_" + acct_id);
|
2019-05-19 17:39:30 +10:00
|
|
|
var at = localStorage.getItem("acct_" + acct_id + "_at");
|
|
|
|
if (localStorage.getItem("mode_" + domain) == "misskey") {
|
|
|
|
var start = "https://" + domain + "/api/mute/" + flagm;
|
|
|
|
var ent = { "i": at, "userId": id }
|
|
|
|
var rq = JSON.stringify(ent);
|
|
|
|
} else {
|
2018-07-30 21:03:49 +10:00
|
|
|
var start = "https://" + domain + "/api/v1/accounts/" + id + "/" + flag;
|
2019-05-19 17:39:30 +10:00
|
|
|
var rq = "";
|
2018-07-30 21:03:49 +10:00
|
|
|
}
|
2018-04-17 03:10:35 +10:00
|
|
|
var httpreq = new XMLHttpRequest();
|
|
|
|
httpreq.open('POST', start, true);
|
|
|
|
httpreq.setRequestHeader('Content-Type', 'application/json');
|
|
|
|
httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
|
2019-03-08 05:19:26 +11:00
|
|
|
httpreq.responseType = "json";
|
2018-07-30 21:03:49 +10:00
|
|
|
httpreq.send(rq);
|
2019-05-19 17:39:30 +10:00
|
|
|
httpreq.onreadystatechange = function () {
|
2019-03-08 05:19:26 +11:00
|
|
|
if (httpreq.readyState === 4) {
|
2018-04-17 03:10:35 +10:00
|
|
|
if ($("#his-data").hasClass("muting")) {
|
|
|
|
$("#his-data").removeClass("muting");
|
2019-01-26 14:24:26 +11:00
|
|
|
$("#his-mute-btn").text(lang.lang_status_mute);
|
2018-04-17 03:10:35 +10:00
|
|
|
} else {
|
|
|
|
$("#his-data").addClass("muting");
|
2019-01-26 14:24:26 +11:00
|
|
|
$("#his-mute-btn").text(lang.lang_status_unmute);
|
2018-04-17 03:10:35 +10:00
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
2018-04-17 03:10:35 +10:00
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
//投稿削除
|
|
|
|
function del(id, acct_id) {
|
|
|
|
var domain = localStorage.getItem("domain_" + acct_id);
|
2019-05-19 17:39:30 +10:00
|
|
|
var at = localStorage.getItem("acct_" + acct_id + "_at");
|
|
|
|
if (localStorage.getItem("mode_" + domain) == "misskey") {
|
2018-07-30 21:03:49 +10:00
|
|
|
var start = "https://" + domain + "/api/notes/delete";
|
|
|
|
var httpreq = new XMLHttpRequest();
|
|
|
|
httpreq.open('POST', start, true);
|
|
|
|
httpreq.setRequestHeader('Content-Type', 'application/json');
|
2019-03-08 05:19:26 +11:00
|
|
|
httpreq.responseType = "json";
|
2019-05-19 17:39:30 +10:00
|
|
|
httpreq.send(JSON.stringify({ i: at, noteId: id }));
|
|
|
|
$("[toot-id=" + id + "]").hide();
|
|
|
|
$("[toot-id=" + id + "]").remove();
|
|
|
|
} else {
|
2018-07-30 21:03:49 +10:00
|
|
|
var start = "https://" + domain + "/api/v1/statuses/" + id;
|
|
|
|
var httpreq = new XMLHttpRequest();
|
|
|
|
httpreq.open('DELETE', start, true);
|
|
|
|
httpreq.setRequestHeader('Content-Type', 'application/json');
|
|
|
|
httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
|
2019-03-08 05:19:26 +11:00
|
|
|
httpreq.responseType = "json";
|
2018-07-30 21:03:49 +10:00
|
|
|
httpreq.send();
|
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
httpreq.onreadystatechange = function () {
|
2019-03-08 05:19:26 +11:00
|
|
|
if (httpreq.readyState === 4) {
|
2018-04-17 03:10:35 +10:00
|
|
|
}
|
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
2018-07-17 01:39:06 +10:00
|
|
|
//redraft
|
2019-05-19 17:39:30 +10:00
|
|
|
function redraft(id, acct_id) {
|
|
|
|
if (confirm(lang.lang_status_redraft)) {
|
2018-07-17 01:39:06 +10:00
|
|
|
show();
|
|
|
|
del(id, acct_id);
|
|
|
|
$("#post-acct-sel").prop("disabled", true);
|
2019-05-19 17:39:30 +10:00
|
|
|
var medias = $("[toot-id=" + id + "]").attr("data-medias");
|
|
|
|
var vismode = $("[toot-id=" + id + "] .vis-data").attr("data-vis");
|
2018-07-17 01:39:06 +10:00
|
|
|
vis(vismode);
|
|
|
|
$("#media").val(medias);
|
2019-05-19 17:39:30 +10:00
|
|
|
var ct = medias.split(",").length;
|
|
|
|
$("[toot-id=" + id + "] img.toot-img").each(function (i, elem) {
|
|
|
|
if (i < ct) {
|
|
|
|
var url = $(elem).attr("src");
|
|
|
|
console.log("Play back image data:" + url);
|
2018-07-17 01:39:06 +10:00
|
|
|
$('#preview').append('<img src="' + url + '" style="width:50px; max-height:100px;">');
|
|
|
|
}
|
|
|
|
});
|
2019-05-19 17:39:30 +10:00
|
|
|
var html = $("[toot-id=" + id + "] .toot").html();
|
|
|
|
html = html.replace(/^<p>(.+)<\/p>$/, "$1");
|
2018-07-17 01:39:06 +10:00
|
|
|
html = html.replace(/<br\s?\/?>/, "\n");
|
|
|
|
html = html.replace(/<p>/, "\n");
|
|
|
|
html = html.replace(/<\/p>/, "\n");
|
|
|
|
html = html.replace(/<img[\s\S]*alt="(.+?)"[\s\S]*?>/g, "$1");
|
2019-05-19 17:39:30 +10:00
|
|
|
html = $.strip_tags(html);
|
|
|
|
localStorage.setItem("nohide", true);
|
2018-07-29 17:37:54 +10:00
|
|
|
show();
|
2018-07-17 01:39:06 +10:00
|
|
|
$("#textarea").val(html);
|
2019-05-19 17:39:30 +10:00
|
|
|
var cwtxt = $("[toot-id=" + id + "] .cw_text").html();
|
|
|
|
if (cwtxt != "") {
|
|
|
|
cwtxt = $.strip_tags(cwtxt);
|
2019-02-01 03:30:25 +11:00
|
|
|
cw();
|
|
|
|
$("#cw-text").val(cwtxt);
|
|
|
|
}
|
2018-07-17 01:39:06 +10:00
|
|
|
}
|
|
|
|
}
|
2018-03-11 01:22:59 +11:00
|
|
|
//ピン留め
|
|
|
|
function pin(id, acct_id) {
|
|
|
|
if ($("#pub_" + id).hasClass("pined")) {
|
|
|
|
var flag = "unpin";
|
|
|
|
} else {
|
|
|
|
var flag = "pin";
|
|
|
|
}
|
|
|
|
var domain = localStorage.getItem("domain_" + acct_id);
|
2019-05-19 17:39:30 +10:00
|
|
|
var at = localStorage.getItem("acct_" + acct_id + "_at");
|
2018-03-11 01:22:59 +11:00
|
|
|
var start = "https://" + domain + "/api/v1/statuses/" + id + "/" + flag;
|
2018-04-17 03:10:35 +10:00
|
|
|
var httpreq = new XMLHttpRequest();
|
2018-09-05 01:04:56 +10:00
|
|
|
httpreq.open('POST', start, true);
|
2018-04-17 03:10:35 +10:00
|
|
|
httpreq.setRequestHeader('Content-Type', 'application/json');
|
|
|
|
httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
|
2019-03-08 05:19:26 +11:00
|
|
|
httpreq.responseType = "json";
|
2018-04-17 03:10:35 +10:00
|
|
|
httpreq.send();
|
2019-05-19 17:39:30 +10:00
|
|
|
httpreq.onreadystatechange = function () {
|
2019-03-08 05:19:26 +11:00
|
|
|
if (httpreq.readyState === 4) {
|
2018-04-17 03:10:35 +10:00
|
|
|
var json = httpreq.response;
|
2019-05-19 17:39:30 +10:00
|
|
|
console.log(["Success: pinned", json]);
|
2018-04-17 03:10:35 +10:00
|
|
|
if ($("[toot-id=" + id + "]").hasClass("pined")) {
|
|
|
|
$("[toot-id=" + id + "]").removeClass("pined");
|
|
|
|
$(".pin_" + id).removeClass("blue-text");
|
|
|
|
} else {
|
|
|
|
$("[toot-id=" + id + "]").addClass("pined");
|
|
|
|
$(".pin_" + id).addClass("blue-text");
|
|
|
|
}
|
2018-03-11 01:22:59 +11:00
|
|
|
}
|
2018-04-17 03:10:35 +10:00
|
|
|
}
|
2018-03-11 01:22:59 +11:00
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
|
|
|
|
//フォロリク
|
|
|
|
function request(id, flag, acct_id) {
|
|
|
|
var domain = localStorage.getItem("domain_" + acct_id);
|
2019-05-19 17:39:30 +10:00
|
|
|
var at = localStorage.getItem("acct_" + acct_id + "_at");
|
2018-01-28 23:22:43 +11:00
|
|
|
var start = "https://" + domain + "/api/v1/follow_requests/" + id + "/" + flag;
|
2018-04-17 03:10:35 +10:00
|
|
|
var httpreq = new XMLHttpRequest();
|
|
|
|
httpreq.open('POST', start, true);
|
|
|
|
httpreq.setRequestHeader('Content-Type', 'application/json');
|
|
|
|
httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
|
2019-03-08 05:19:26 +11:00
|
|
|
httpreq.responseType = "json";
|
2018-04-17 03:10:35 +10:00
|
|
|
httpreq.send();
|
2019-05-19 17:39:30 +10:00
|
|
|
httpreq.onreadystatechange = function () {
|
2019-03-08 05:19:26 +11:00
|
|
|
if (httpreq.readyState === 4) {
|
2018-04-17 03:10:35 +10:00
|
|
|
var json = httpreq.response;
|
2019-05-19 17:39:30 +10:00
|
|
|
console.log(["Success: request", "type:" + flag, json]);
|
2018-04-17 03:10:35 +10:00
|
|
|
showReq();
|
|
|
|
}
|
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
//ドメインブロック(未実装)
|
|
|
|
function domainblock(add, flag, acct_id) {
|
|
|
|
if (!acct_id) {
|
|
|
|
var acct_id = $('#his-data').attr("use-acct");
|
|
|
|
}
|
|
|
|
var domain = localStorage.getItem("domain_" + acct_id);
|
2019-05-19 17:39:30 +10:00
|
|
|
var at = localStorage.getItem("acct_" + acct_id + "_at");
|
2018-01-28 23:22:43 +11:00
|
|
|
var start = "https://" + domain + "/api/v1/domain_blocks"
|
2018-04-17 03:10:35 +10:00
|
|
|
var httpreq = new XMLHttpRequest();
|
|
|
|
httpreq.open('POST', start, true);
|
|
|
|
httpreq.setRequestHeader('Content-Type', 'application/json');
|
|
|
|
httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
|
2019-03-08 05:19:26 +11:00
|
|
|
httpreq.responseType = "json";
|
2018-04-17 03:10:35 +10:00
|
|
|
httpreq.send();
|
2019-05-19 17:39:30 +10:00
|
|
|
httpreq.onreadystatechange = function () {
|
2019-03-08 05:19:26 +11:00
|
|
|
if (httpreq.readyState === 4) {
|
2018-04-17 03:10:35 +10:00
|
|
|
var json = httpreq.response;
|
2019-05-19 17:39:30 +10:00
|
|
|
console.log(["Success: domain block", json]);
|
2018-04-17 03:10:35 +10:00
|
|
|
showDom();
|
|
|
|
}
|
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
function addDomainblock() {
|
|
|
|
var domain = $("#domainblock").val();
|
|
|
|
domainblock(domain, 'POST');
|
|
|
|
}
|
2018-03-11 01:22:59 +11:00
|
|
|
//ユーザー強調
|
2019-05-19 17:39:30 +10:00
|
|
|
function empUser() {
|
2018-03-11 01:22:59 +11:00
|
|
|
var usr = localStorage.getItem("user_emp");
|
|
|
|
var obj = JSON.parse(usr);
|
2019-05-19 17:39:30 +10:00
|
|
|
var id = $("#his-acct").attr("fullname");
|
|
|
|
if (!obj) {
|
|
|
|
var obj = [];
|
2018-03-11 01:22:59 +11:00
|
|
|
obj.push(id);
|
2019-06-07 02:11:04 +10:00
|
|
|
M.toast({ html: id + lang.lang_status_emphas, displayLength: 4000 })
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
2018-03-11 01:22:59 +11:00
|
|
|
var can;
|
2019-05-19 17:39:30 +10:00
|
|
|
Object.keys(obj).forEach(function (key) {
|
2018-03-11 01:22:59 +11:00
|
|
|
var usT = obj[key];
|
2019-05-19 17:39:30 +10:00
|
|
|
if (usT != id && !can) {
|
|
|
|
can = false;
|
|
|
|
} else {
|
|
|
|
can = true;
|
2018-03-11 01:22:59 +11:00
|
|
|
obj.splice(key, 1);
|
2019-06-07 02:11:04 +10:00
|
|
|
M.toast({ html: id + lang.lang_status_unemphas, displayLength: 4000 })
|
2018-03-11 01:22:59 +11:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
var json = JSON.stringify(obj);
|
|
|
|
localStorage.setItem("user_emp", json);
|
|
|
|
}
|
2018-09-05 01:04:56 +10:00
|
|
|
//Endorse
|
2019-05-19 17:39:30 +10:00
|
|
|
function pinUser() {
|
|
|
|
var id = $("#his-data").attr("user-id");
|
|
|
|
var acct_id = $("#his-data").attr("use-acct");
|
2018-09-05 01:04:56 +10:00
|
|
|
if ($("#his-end-btn").hasClass("endorsed")) {
|
|
|
|
var flag = "unpin";
|
|
|
|
} else {
|
|
|
|
var flag = "pin";
|
|
|
|
}
|
|
|
|
var domain = localStorage.getItem("domain_" + acct_id);
|
2019-05-19 17:39:30 +10:00
|
|
|
var at = localStorage.getItem("acct_" + acct_id + "_at");
|
2018-09-05 01:04:56 +10:00
|
|
|
var start = "https://" + domain + "/api/v1/accounts/" + id + "/" + flag;
|
|
|
|
var httpreq = new XMLHttpRequest();
|
|
|
|
httpreq.open('POST', start, true);
|
|
|
|
httpreq.setRequestHeader('Content-Type', 'application/json');
|
|
|
|
httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
|
2019-03-08 05:19:26 +11:00
|
|
|
httpreq.responseType = "json";
|
2018-09-05 01:04:56 +10:00
|
|
|
httpreq.send();
|
2019-05-19 17:39:30 +10:00
|
|
|
httpreq.onreadystatechange = function () {
|
2019-03-08 05:19:26 +11:00
|
|
|
if (httpreq.readyState === 4) {
|
2018-09-05 01:04:56 +10:00
|
|
|
var json = httpreq.response;
|
|
|
|
if ($("#his-end-btn").hasClass("endorsed")) {
|
|
|
|
$("#his-end-btn").removeClass("endorsed")
|
2019-01-26 14:24:26 +11:00
|
|
|
$("#his-end-btn").text(lang.lang_status_endorse)
|
2018-09-05 01:04:56 +10:00
|
|
|
} else {
|
|
|
|
$("#his-end-btn").addClass("endorsed")
|
2019-01-26 14:24:26 +11:00
|
|
|
$("#his-end-btn").text(lang.lang_status_unendorse)
|
2019-05-19 17:39:30 +10:00
|
|
|
|
2018-09-05 01:04:56 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-02-18 16:43:11 +11:00
|
|
|
//URLコピー
|
2019-05-19 17:39:30 +10:00
|
|
|
function tootUriCopy(url) {
|
2018-02-18 16:43:11 +11:00
|
|
|
execCopy(url);
|
2019-06-07 02:11:04 +10:00
|
|
|
M.toast({ html: lang.lang_details_url, displayLength: 1500 })
|
2018-03-21 16:36:02 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
//他のアカウントで…
|
2019-05-19 17:39:30 +10:00
|
|
|
function staEx(mode) {
|
|
|
|
var url = $("#tootmodal").attr("data-url");
|
2018-03-21 16:36:02 +11:00
|
|
|
var acct_id = $("#status-acct-sel").val();
|
|
|
|
var domain = localStorage.getItem("domain_" + acct_id);
|
2019-05-19 17:39:30 +10:00
|
|
|
var at = localStorage.getItem("acct_" + acct_id + "_at");
|
|
|
|
var start = "https://" + domain + "/api/v1/search?resolve=true&q=" + url
|
2018-03-21 16:36:02 +11:00
|
|
|
fetch(start, {
|
|
|
|
method: 'GET',
|
|
|
|
headers: {
|
|
|
|
'content-type': 'application/json',
|
|
|
|
'Authorization': 'Bearer ' + at
|
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
}).then(function (response) {
|
2018-03-21 16:36:02 +11:00
|
|
|
return response.json();
|
2019-05-19 17:39:30 +10:00
|
|
|
}).catch(function (error) {
|
2018-03-21 16:36:02 +11:00
|
|
|
todo(error);
|
|
|
|
console.error(error);
|
2019-05-19 17:39:30 +10:00
|
|
|
}).then(function (json) {
|
|
|
|
var id = json.statuses[0].id;
|
|
|
|
if (mode == "rt") {
|
2018-03-21 16:36:02 +11:00
|
|
|
rt(id, acct_id, 'remote')
|
2019-05-19 17:39:30 +10:00
|
|
|
} else if (mode == "fav") {
|
2018-03-21 16:36:02 +11:00
|
|
|
fav(id, acct_id, 'remote')
|
2019-05-19 17:39:30 +10:00
|
|
|
} else if (mode == "reply") {
|
2018-03-21 16:36:02 +11:00
|
|
|
reEx(id)
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return;
|
2018-05-02 14:14:03 +10:00
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
function toggleAction(id, tlid, acct_id) {
|
|
|
|
if (tlid == "notf") {
|
|
|
|
var tlide = "[data-notf=" + acct_id + "]";
|
|
|
|
} else {
|
|
|
|
var tlide = "[tlid=" + tlid + "]";
|
2018-05-02 14:14:03 +10:00
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
if (!$(tlide + " [toot-id=" + id + "]").hasClass("ext-mode")) {
|
|
|
|
$(tlide + " [toot-id=" + id + "] .type-a").hide();
|
|
|
|
$(tlide + " [toot-id=" + id + "] .type-b").show();
|
|
|
|
$(tlide + " [toot-id=" + id + "]").addClass("ext-mode")
|
|
|
|
$(tlide + " [toot-id=" + id + "] .act-icon").text("expand_less");
|
|
|
|
} else {
|
|
|
|
$(tlide + " [toot-id=" + id + "] .type-b").hide();
|
|
|
|
$(tlide + " [toot-id=" + id + "] .type-a").show();
|
|
|
|
$(tlide + " [toot-id=" + id + "]").removeClass("ext-mode")
|
|
|
|
$(tlide + " [toot-id=" + id + "] .act-icon").text("expand_more");
|
2018-05-02 14:14:03 +10:00
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
|
2018-02-18 16:43:11 +11:00
|
|
|
}
|