Introduce: SweetAlert
This commit is contained in:
@@ -205,17 +205,27 @@ element.addEventListener("paste", function (e) {
|
||||
// 画像以外がペーストされたときのために、元に戻しておく
|
||||
});
|
||||
function deleteImage(key) {
|
||||
if (!confirm(lang.lang_postimg_delete)) {
|
||||
return false;
|
||||
}
|
||||
var media = $("#media").val();
|
||||
var arr = media.split(",");
|
||||
for (var i = 0; i < media.length; i++) {
|
||||
if (arr[i] == key) {
|
||||
arr.splice(i, 1);
|
||||
break;
|
||||
Swal.fire({
|
||||
title: lang.lang_postimg_delete,
|
||||
type: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: lang.lang_yesno,
|
||||
cancelButtonText: lang.lang_no
|
||||
}).then((result) => {
|
||||
if (result.value) {
|
||||
var media = $("#media").val();
|
||||
var arr = media.split(",");
|
||||
for (var i = 0; i < media.length; i++) {
|
||||
if (arr[i] == key) {
|
||||
arr.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
$("#media").val(arr.join(","));
|
||||
$('#preview [data-media=' + key + ']').remove();
|
||||
}
|
||||
}
|
||||
$("#media").val(arr.join(","));
|
||||
$('#preview [data-media=' + key + ']').remove();
|
||||
})
|
||||
|
||||
}
|
@@ -17,24 +17,6 @@ function post(mode, postvis) {
|
||||
var acct_id = $("#post-acct-sel").val();
|
||||
localStorage.setItem("last-use", acct_id);
|
||||
var domain = localStorage.getItem("domain_" + acct_id);
|
||||
if (domain == "theboss.tech") {
|
||||
if (~str.indexOf("#")) {
|
||||
if (str.indexOf("#theboss_tech") == "-1") {
|
||||
if (!confirm(lang.lang_post_tagTL)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (domain == "dtp-mstdn.jp") {
|
||||
if (~str.indexOf("#")) {
|
||||
if (str.indexOf("#dtp") == "-1") {
|
||||
if (!confirm(lang.lang_post_tagTL)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!localStorage.getItem("cw_sentence")) {
|
||||
var cw_sent = 500;
|
||||
} else {
|
||||
@@ -91,22 +73,11 @@ function post(mode, postvis) {
|
||||
} else {
|
||||
var vis = $("#vis").text();
|
||||
}
|
||||
|
||||
if (vis != "inherit" && vis != "local") {
|
||||
toot.visibility = vis;
|
||||
} else if (vis == "local") {
|
||||
toot.status = str + "👁️";
|
||||
}
|
||||
//ここに非公開・未収載タグについてwarn
|
||||
if (domain != "kirishima.cloud" && domain != "imastodon.net") {
|
||||
if (~str.indexOf("#")) {
|
||||
if (vis == "local" || vis == "unlisted" || vis == "direct" || vis == "private") {
|
||||
if (!confirm(lang.lang_post_tagVis)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($("#cw").hasClass("cw-avail")) {
|
||||
var spo = $("#cw-text").val();
|
||||
cw();
|
||||
|
@@ -253,39 +253,50 @@ function del(id, acct_id) {
|
||||
}
|
||||
//redraft
|
||||
function redraft(id, acct_id) {
|
||||
if (confirm(lang.lang_status_redraft)) {
|
||||
show();
|
||||
del(id, acct_id);
|
||||
$("#post-acct-sel").prop("disabled", true);
|
||||
var medias = $("[toot-id=" + id + "]").attr("data-medias");
|
||||
var vismode = $("[toot-id=" + id + "] .vis-data").attr("data-vis");
|
||||
vis(vismode);
|
||||
$("#media").val(medias);
|
||||
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);
|
||||
$('#preview').append('<img src="' + url + '" style="width:50px; max-height:100px;">');
|
||||
Swal.fire({
|
||||
title: lang.lang_status_redraftTitle,
|
||||
text: lang.lang_status_redraft,
|
||||
type: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: lang.lang_yesno,
|
||||
cancelButtonText: lang.lang_no
|
||||
}).then((result) => {
|
||||
if (result.value) {
|
||||
show();
|
||||
del(id, acct_id);
|
||||
$("#post-acct-sel").prop("disabled", true);
|
||||
var medias = $("[toot-id=" + id + "]").attr("data-medias");
|
||||
var vismode = $("[toot-id=" + id + "] .vis-data").attr("data-vis");
|
||||
vis(vismode);
|
||||
$("#media").val(medias);
|
||||
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);
|
||||
$('#preview').append('<img src="' + url + '" style="width:50px; max-height:100px;">');
|
||||
}
|
||||
});
|
||||
var html = $("[toot-id=" + id + "] .toot").html();
|
||||
html = html.replace(/^<p>(.+)<\/p>$/, "$1");
|
||||
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");
|
||||
html = $.strip_tags(html);
|
||||
localStorage.setItem("nohide", true);
|
||||
show();
|
||||
$("#textarea").val(html);
|
||||
var cwtxt = $("[toot-id=" + id + "] .cw_text").html();
|
||||
if (cwtxt != "") {
|
||||
cwtxt = $.strip_tags(cwtxt);
|
||||
cw();
|
||||
$("#cw-text").val(cwtxt);
|
||||
}
|
||||
});
|
||||
var html = $("[toot-id=" + id + "] .toot").html();
|
||||
html = html.replace(/^<p>(.+)<\/p>$/, "$1");
|
||||
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");
|
||||
html = $.strip_tags(html);
|
||||
localStorage.setItem("nohide", true);
|
||||
show();
|
||||
$("#textarea").val(html);
|
||||
var cwtxt = $("[toot-id=" + id + "] .cw_text").html();
|
||||
if (cwtxt != "") {
|
||||
cwtxt = $.strip_tags(cwtxt);
|
||||
cw();
|
||||
$("#cw-text").val(cwtxt);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
//ピン留め
|
||||
function pin(id, acct_id) {
|
||||
|
Reference in New Issue
Block a user