2018-01-28 23:22:43 +11:00
|
|
|
/*投稿系*/
|
|
|
|
//投稿
|
|
|
|
function post() {
|
|
|
|
var str = $("#textarea").val();
|
|
|
|
var acct_id = $("#post-acct-sel").val();
|
|
|
|
localStorage.setItem("last-use", acct_id);
|
|
|
|
todo("Posting");
|
|
|
|
var domain = localStorage.getItem("domain_" + acct_id);
|
|
|
|
var at = localStorage.getItem(domain + "_at");
|
|
|
|
var start = "https://" + domain + "/api/v1/statuses";
|
|
|
|
var reply = $("#reply").val();
|
|
|
|
var media = $("#media").val();
|
|
|
|
if ($("#nsfw").hasClass("nsfw-avail")) {
|
|
|
|
var nsfw = "true";
|
|
|
|
} else {
|
|
|
|
var nsfw = "false";
|
|
|
|
}
|
|
|
|
var vis = $("#vis").text();
|
|
|
|
if ($("#cw").hasClass("cw-avail")) {
|
|
|
|
var spo = $("#cw-text").val();
|
|
|
|
} else {
|
|
|
|
var spo = "";
|
|
|
|
}
|
|
|
|
fetch(start, {
|
|
|
|
method: 'POST',
|
|
|
|
headers: {
|
|
|
|
'content-type': 'application/json',
|
|
|
|
'Authorization': 'Bearer ' + at
|
|
|
|
},
|
|
|
|
body: JSON.stringify({
|
|
|
|
status: str,
|
|
|
|
in_reply_to_id: reply,
|
|
|
|
media_ids: media.split(","),
|
|
|
|
sensitive: nsfw,
|
|
|
|
spoiler_text: spo,
|
|
|
|
visibility: vis
|
|
|
|
})
|
|
|
|
}).then(function(response) {
|
|
|
|
return response.json();
|
|
|
|
}).catch(function(error) {
|
|
|
|
todo(error);
|
|
|
|
console.error(error);
|
|
|
|
}).then(function(json) {
|
|
|
|
console.log(json);
|
|
|
|
var box = localStorage.getItem("box");
|
|
|
|
if (box == "yes") {
|
|
|
|
hide();
|
2018-02-24 03:02:44 +11:00
|
|
|
}else if (box == "hide"){
|
2018-02-25 02:59:53 +11:00
|
|
|
$("body").addClass("mini-post");
|
|
|
|
$(".mini-btn").text("expand_less");
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
|
|
|
todc();
|
|
|
|
clear();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
//クリア(Shift+C)
|
|
|
|
function clear() {
|
|
|
|
$("#textarea").val("");
|
2018-02-24 03:02:44 +11:00
|
|
|
$("#textarea").attr("placeholder", "");
|
2018-01-28 23:22:43 +11:00
|
|
|
$("#reply").val("");
|
|
|
|
$("#media").val("");
|
|
|
|
var cwt = localStorage.getItem("cw-text");
|
|
|
|
if (cwt) {
|
|
|
|
$("#cw-text").val(cwt);
|
|
|
|
} else {
|
|
|
|
$("#cw-text").val("");
|
|
|
|
}
|
|
|
|
$("#cw").addClass("blue");
|
|
|
|
$("#cw").removeClass("yellow");
|
|
|
|
$("#cw").removeClass("cw-avail");
|
|
|
|
$("#rec").text("いいえ");
|
|
|
|
$("#mec").text("なし");
|
|
|
|
var vis = localStorage.getItem("vis");
|
|
|
|
if (!vis) {
|
|
|
|
$("#vis").text("public");
|
|
|
|
} else {
|
|
|
|
if (vis == "memory") {
|
|
|
|
localStorage.setItem("vis-memory", $("#vis").text());
|
|
|
|
} else {
|
|
|
|
$("#vis").text(vis);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$("#nsfw").addClass("blue");
|
|
|
|
$("#nsfw").removeClass("yellow");
|
|
|
|
$("#nsi").html("lock_open");
|
|
|
|
$("#nsfw").removeClass("nsfw-avail");
|
|
|
|
$("#nsc").text("なし");
|
|
|
|
$("#drag").css("background-color", "#e0e0e0");
|
|
|
|
$("#preview").html("");
|
2018-02-19 04:41:25 +11:00
|
|
|
$("#toot-post-btn").prop("disabled", false);
|
2018-02-24 03:02:44 +11:00
|
|
|
$("#post-acct-sel").prop("disabled", false);
|
|
|
|
$('select').material_select();
|
2018-02-19 04:41:25 +11:00
|
|
|
localStorage.removeItem("image");
|
2018-01-28 23:22:43 +11:00
|
|
|
if ($("#post-box").hasClass("post-more")) {
|
|
|
|
$("#file-wrap").html(
|
|
|
|
'<input class="more-show" style="display:inline-block;" type="file" name="pic" id="upfile" onchange="pimg(document.getElementById(\'upfile\').files);" multiple>'
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
$("#file-wrap").html(
|
|
|
|
'<input class="more-show" type="file" name="pic" id="upfile" onchange="pimg(document.getElementById(\'upfile\').files);" multiple>'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|