Add: show dialogs when muting and blocking

This commit is contained in:
Cutls 2019-08-19 22:55:50 +09:00
parent 68328a9449
commit 4416c56884

View File

@ -147,77 +147,109 @@ function follow(acct_id, remote) {
//ブロック //ブロック
function block(acct_id) { 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")) { if ($("#his-data").hasClass("blocking")) {
var flag = "unblock"; var flag = "unblock";
var txt = lang.lang_status_unmute
} else { } else {
var flag = "block"; var flag = "block";
var txt = lang.lang_status_block
} }
var domain = localStorage.getItem("domain_" + acct_id); Swal.fire({
var at = localStorage.getItem("acct_" + acct_id + "_at"); title: txt,
var start = "https://" + domain + "/api/v1/accounts/" + id + "/" + flag; text: "",
var httpreq = new XMLHttpRequest(); type: 'warning',
httpreq.open('POST', start, true); showCancelButton: true,
httpreq.setRequestHeader('Content-Type', 'application/json'); confirmButtonColor: '#3085d6',
httpreq.setRequestHeader('Authorization', 'Bearer ' + at); cancelButtonColor: '#d33',
httpreq.responseType = "json"; confirmButtonText: lang.lang_yesno,
httpreq.send(); cancelButtonText: lang.lang_no
httpreq.onreadystatechange = function () { }).then((result) => {
if (httpreq.readyState === 4) { if (result.value) {
if ($("#his-data").hasClass("blocking")) { if (!acct_id) {
$("#his-data").removeClass("blocking"); var acct_id = $('#his-data').attr("use-acct");
$("#his-block-btn").text(lang.lang_status_block); }
} else { var id = $("#his-data").attr("user-id");
$("#his-data").addClass("blocking"); var domain = localStorage.getItem("domain_" + acct_id);
$("#his-block-btn").text(lang.lang_status_unblock); var at = localStorage.getItem("acct_" + acct_id + "_at");
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);
httpreq.responseType = "json";
httpreq.send();
httpreq.onreadystatechange = function () {
if (httpreq.readyState === 4) {
if ($("#his-data").hasClass("blocking")) {
$("#his-data").removeClass("blocking");
$("#his-block-btn").text(lang.lang_status_block);
} else {
$("#his-data").addClass("blocking");
$("#his-block-btn").text(lang.lang_status_unblock);
}
}
} }
} }
} });
} }
//ミュート //ミュート
function muteDo(acct_id) { function muteDo(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")) { if ($("#his-data").hasClass("muting")) {
var flag = "unmute"; var flag = "unmute";
var flagm = "delete"; var flagm = "delete";
var txt = lang.lang_status_unmute
} else { } else {
var flag = "mute"; var flag = "mute";
var flagm = "create"; var flagm = "create";
var txt = lang.lang_status_mute
} }
var domain = localStorage.getItem("domain_" + acct_id); Swal.fire({
var at = localStorage.getItem("acct_" + acct_id + "_at"); title: txt,
if (localStorage.getItem("mode_" + domain) == "misskey") { text: "",
var start = "https://" + domain + "/api/mute/" + flagm; type: 'warning',
var ent = { "i": at, "userId": id } showCancelButton: true,
var rq = JSON.stringify(ent); confirmButtonColor: '#3085d6',
} else { cancelButtonColor: '#d33',
var start = "https://" + domain + "/api/v1/accounts/" + id + "/" + flag; confirmButtonText: lang.lang_yesno,
var rq = ""; cancelButtonText: lang.lang_no
} }).then((result) => {
var httpreq = new XMLHttpRequest(); if (result.value) {
httpreq.open('POST', start, true); if (!acct_id) {
httpreq.setRequestHeader('Content-Type', 'application/json'); var acct_id = $('#his-data').attr("use-acct");
httpreq.setRequestHeader('Authorization', 'Bearer ' + at); }
httpreq.responseType = "json"; var id = $("#his-data").attr("user-id");
httpreq.send(rq); var domain = localStorage.getItem("domain_" + acct_id);
httpreq.onreadystatechange = function () { var at = localStorage.getItem("acct_" + acct_id + "_at");
if (httpreq.readyState === 4) { if (localStorage.getItem("mode_" + domain) == "misskey") {
if ($("#his-data").hasClass("muting")) { var start = "https://" + domain + "/api/mute/" + flagm;
$("#his-data").removeClass("muting"); var ent = { "i": at, "userId": id }
$("#his-mute-btn").text(lang.lang_status_mute); var rq = JSON.stringify(ent);
} else { } else {
$("#his-data").addClass("muting"); var start = "https://" + domain + "/api/v1/accounts/" + id + "/" + flag;
$("#his-mute-btn").text(lang.lang_status_unmute); var rq = "";
}
var httpreq = new XMLHttpRequest();
httpreq.open('POST', start, true);
httpreq.setRequestHeader('Content-Type', 'application/json');
httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
httpreq.responseType = "json";
httpreq.send(rq);
httpreq.onreadystatechange = function () {
if (httpreq.readyState === 4) {
if ($("#his-data").hasClass("muting")) {
$("#his-data").removeClass("muting");
$("#his-mute-btn").text(lang.lang_status_mute);
} else {
$("#his-data").addClass("muting");
$("#his-mute-btn").text(lang.lang_status_unmute);
}
}
} }
} }
} });
} }
//投稿削除 //投稿削除