2018-01-28 23:22:43 +11:00
|
|
|
/*投稿系*/
|
|
|
|
//投稿
|
|
|
|
function post() {
|
2018-05-20 16:17:10 +10:00
|
|
|
if($("#toot-post-btn").prop("disabled")){
|
|
|
|
return
|
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
var str = $("#textarea").val();
|
|
|
|
var acct_id = $("#post-acct-sel").val();
|
|
|
|
localStorage.setItem("last-use", acct_id);
|
|
|
|
var domain = localStorage.getItem("domain_" + acct_id);
|
2018-06-18 00:26:45 +10:00
|
|
|
if(domain=="theboss.tech"){
|
|
|
|
if(~str.indexOf("#")){
|
|
|
|
if(str.indexOf("#theboss_tech")=="-1"){
|
|
|
|
if(!confirm("デフォルトタグが挿入されていません。このまま投稿するとローカルには表示されません。")){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(domain=="dtp-mstdn.jp"){
|
|
|
|
if(~str.indexOf("#")){
|
|
|
|
if(str.indexOf("#dtp")=="-1"){
|
|
|
|
if(!confirm("デフォルトタグが挿入されていません。このまま投稿するとローカルには表示されません。")){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$("#toot-post-btn").prop("disabled", true);
|
|
|
|
todo("Posting");
|
2018-07-07 03:51:48 +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";
|
|
|
|
var reply = $("#reply").val();
|
2018-03-20 15:55:25 +11:00
|
|
|
var toot={
|
|
|
|
status: str
|
|
|
|
}
|
|
|
|
if(reply){
|
|
|
|
toot.in_reply_to_id=reply
|
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
var media = $("#media").val();
|
2018-03-20 15:55:25 +11:00
|
|
|
if(media){
|
2018-03-27 13:39:35 +11:00
|
|
|
toot.media_ids=media.split(",");
|
2018-03-20 15:55:25 +11:00
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
if ($("#nsfw").hasClass("nsfw-avail")) {
|
|
|
|
var nsfw = "true";
|
2018-03-20 15:55:25 +11:00
|
|
|
toot.sensitive=nsfw;
|
2018-01-28 23:22:43 +11:00
|
|
|
} else {
|
|
|
|
var nsfw = "false";
|
|
|
|
}
|
|
|
|
var vis = $("#vis").text();
|
2018-03-21 16:36:02 +11:00
|
|
|
if(vis!="inherit"){
|
2018-03-20 15:55:25 +11:00
|
|
|
toot.visibility=vis;
|
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
if ($("#cw").hasClass("cw-avail")) {
|
|
|
|
var spo = $("#cw-text").val();
|
2018-03-14 05:31:31 +11:00
|
|
|
cw();
|
2018-03-20 15:55:25 +11:00
|
|
|
toot.spoiler_text=spo;
|
2018-01-28 23:22:43 +11:00
|
|
|
} else {
|
|
|
|
var spo = "";
|
|
|
|
}
|
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);
|
|
|
|
httpreq.responseType = 'json';
|
|
|
|
httpreq.send(JSON.stringify(toot));
|
|
|
|
httpreq.onreadystatechange = function() {
|
|
|
|
if (httpreq.readyState == 4) {
|
2018-07-28 07:25:12 +10:00
|
|
|
if(str.indexOf(localStorage.getItem("stable"))==-1){
|
|
|
|
localStorage.removeItem("stable")
|
|
|
|
}
|
2018-04-17 03:10:35 +10:00
|
|
|
var json = httpreq.response;
|
|
|
|
console.log(json);
|
|
|
|
var box = localStorage.getItem("box");
|
|
|
|
if (box == "yes") {
|
|
|
|
hide();
|
|
|
|
}else if (box == "hide"){
|
|
|
|
$("body").addClass("mini-post");
|
|
|
|
$(".mini-btn").text("expand_less");
|
|
|
|
}
|
2018-05-20 16:17:10 +10:00
|
|
|
$("#toot-post-btn").prop("disabled", false);
|
2018-04-17 03:10:35 +10:00
|
|
|
todc();
|
|
|
|
clear();
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
2018-04-17 03:10:35 +10:00
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
//クリア(Shift+C)
|
|
|
|
function clear() {
|
|
|
|
$("#textarea").val("");
|
2018-07-28 07:25:12 +10:00
|
|
|
if(localStorage.getItem("stable")){
|
|
|
|
$("#textarea").val(localStorage.getItem("stable"));
|
|
|
|
}
|
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("");
|
|
|
|
}
|
2018-05-02 14:14:03 +10:00
|
|
|
$("#cw").removeClass("yellow-text");
|
2018-01-28 23:22:43 +11:00
|
|
|
$("#cw").removeClass("cw-avail");
|
|
|
|
$("#rec").text("いいえ");
|
|
|
|
$("#mec").text("なし");
|
2018-06-18 00:26:45 +10:00
|
|
|
loadVis();
|
2018-05-02 14:14:03 +10:00
|
|
|
$("#nsfw").removeClass("yellow-text");
|
|
|
|
$("#nsfw").html("visibility_off");
|
2018-01-28 23:22:43 +11:00
|
|
|
$("#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-05-20 16:17:10 +10:00
|
|
|
if(localStorage.getItem("mainuse")=="main"){
|
|
|
|
multi();
|
|
|
|
}
|
2018-03-27 13:39:35 +11:00
|
|
|
}
|