2018-01-28 23:22:43 +11:00
|
|
|
//トゥートの詳細
|
|
|
|
function details(id, acct_id) {
|
2018-02-18 03:44:03 +11:00
|
|
|
$(".toot-reset").html("データなし");
|
2018-01-28 23:22:43 +11:00
|
|
|
var html = $("#pub_" + id).html();
|
|
|
|
$("#toot-this").html(html);
|
|
|
|
$('#tootmodal').modal('open');
|
|
|
|
var domain = localStorage.getItem("domain_" + acct_id);
|
|
|
|
var at = localStorage.getItem(domain + "_at");
|
|
|
|
var start = "https://" + domain + "/api/v1/statuses/" + id;
|
|
|
|
fetch(start, {
|
|
|
|
method: 'GET',
|
|
|
|
headers: {
|
|
|
|
'content-type': 'application/json',
|
|
|
|
'Authorization': 'Bearer ' + at
|
|
|
|
},
|
|
|
|
}).then(function(response) {
|
|
|
|
return response.json();
|
|
|
|
}).catch(function(error) {
|
|
|
|
todo(error);
|
|
|
|
console.error(error);
|
|
|
|
}).then(function(json) {
|
|
|
|
$("#toot-this .fav_ct").text(json.favourites_count);
|
|
|
|
$("#toot-this .rt_ct").text(json.reblogs_count);
|
2018-02-18 03:44:03 +11:00
|
|
|
$("#tootmodal").attr("data-url",json.url);
|
2018-01-28 23:22:43 +11:00
|
|
|
if (json.in_reply_to_id) {
|
|
|
|
replyTL(json.in_reply_to_id, acct_id);
|
|
|
|
}
|
|
|
|
context(id, acct_id);
|
|
|
|
faved(id, acct_id);
|
|
|
|
rted(id, acct_id);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
//返信タイムライン
|
|
|
|
function replyTL(id, acct_id) {
|
|
|
|
var domain = localStorage.getItem("domain_" + acct_id);
|
|
|
|
var at = localStorage.getItem(domain + "_at");
|
|
|
|
var start = "https://" + domain + "/api/v1/statuses/" + id;
|
|
|
|
fetch(start, {
|
|
|
|
method: 'GET',
|
|
|
|
headers: {
|
|
|
|
'content-type': 'application/json',
|
|
|
|
'Authorization': 'Bearer ' + at
|
|
|
|
},
|
|
|
|
}).then(function(response) {
|
|
|
|
return response.json();
|
|
|
|
}).catch(function(error) {
|
|
|
|
todo(error);
|
|
|
|
console.error(error);
|
|
|
|
}).then(function(json) {
|
|
|
|
var templete = parse([json]);
|
|
|
|
$("#toot-reply").prepend(templete);
|
|
|
|
jQuery("time.timeago").timeago();
|
|
|
|
if (json.in_reply_to_id) {
|
|
|
|
replyTL(json.in_reply_to_id, acct_id);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
//コンテクストってなんですか
|
|
|
|
function context(id, acct_id) {
|
|
|
|
var domain = localStorage.getItem("domain_" + acct_id);
|
|
|
|
var at = localStorage.getItem(domain + "_at");
|
|
|
|
var start = "https://" + domain + "/api/v1/statuses/" + id + "/context";
|
|
|
|
fetch(start, {
|
|
|
|
method: 'GET',
|
|
|
|
headers: {
|
|
|
|
'content-type': 'application/json',
|
|
|
|
'Authorization': 'Bearer ' + at
|
|
|
|
},
|
|
|
|
}).then(function(response) {
|
|
|
|
return response.json();
|
|
|
|
}).catch(function(error) {
|
|
|
|
todo(error);
|
|
|
|
console.error(error);
|
|
|
|
}).then(function(json) {
|
|
|
|
var templete = parse(json.descendants);
|
|
|
|
$("#toot-after").html(templete);
|
|
|
|
beforeToot(id, acct_id);
|
|
|
|
jQuery("time.timeago").timeago();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
//前のトゥート(Back TL)
|
|
|
|
function beforeToot(id, acct_id) {
|
|
|
|
var domain = localStorage.getItem("domain_" + acct_id);
|
|
|
|
var at = localStorage.getItem(domain + "_at");
|
|
|
|
var start = "https://" + domain +
|
|
|
|
"/api/v1/timelines/public?local=true&max_id=" + id;
|
|
|
|
fetch(start, {
|
|
|
|
method: 'GET',
|
|
|
|
headers: {
|
|
|
|
'content-type': 'application/json',
|
|
|
|
'Authorization': 'Bearer ' + at
|
|
|
|
},
|
|
|
|
}).then(function(response) {
|
|
|
|
return response.json();
|
|
|
|
}).catch(function(error) {
|
|
|
|
todo(error);
|
|
|
|
console.error(error);
|
|
|
|
}).then(function(json) {
|
|
|
|
var templete = parse(json);
|
|
|
|
$("#toot-before").html(templete);
|
|
|
|
jQuery("time.timeago").timeago();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
//ふぁぼ一覧
|
|
|
|
function faved(id, acct_id) {
|
|
|
|
var domain = localStorage.getItem("domain_" + acct_id);
|
|
|
|
var at = localStorage.getItem(domain + "_at");
|
|
|
|
var start = "https://" + domain + "/api/v1/statuses/" + id + "/favourited_by";
|
|
|
|
fetch(start, {
|
|
|
|
method: 'GET',
|
|
|
|
headers: {
|
|
|
|
'content-type': 'application/json',
|
|
|
|
'Authorization': 'Bearer ' + at
|
|
|
|
},
|
|
|
|
}).then(function(response) {
|
|
|
|
return response.json();
|
|
|
|
}).catch(function(error) {
|
|
|
|
todo(error);
|
|
|
|
console.error(error);
|
|
|
|
}).then(function(json) {
|
|
|
|
var templete = userparse(json);
|
|
|
|
$("#toot-fav").html(templete);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
//ブースト一覧
|
|
|
|
function rted(id, acct_id) {
|
|
|
|
var domain = localStorage.getItem("domain_" + acct_id);
|
|
|
|
var at = localStorage.getItem(domain + "_at");
|
|
|
|
var start = "https://" + domain + "/api/v1/statuses/" + id + "/reblogged_by";
|
|
|
|
fetch(start, {
|
|
|
|
method: 'GET',
|
|
|
|
headers: {
|
|
|
|
'content-type': 'application/json',
|
|
|
|
'Authorization': 'Bearer ' + at
|
|
|
|
},
|
|
|
|
}).then(function(response) {
|
|
|
|
return response.json();
|
|
|
|
}).catch(function(error) {
|
|
|
|
todo(error);
|
|
|
|
console.error(error);
|
|
|
|
}).then(function(json) {
|
|
|
|
var templete = userparse(json);
|
|
|
|
$("#toot-rt").html(templete);
|
|
|
|
});
|
|
|
|
}
|
2018-02-18 03:44:03 +11:00
|
|
|
//URL等のコピー
|
|
|
|
function cbCopy(mode){
|
|
|
|
var url=$("#tootmodal").attr("data-url");
|
|
|
|
var urls = url.match(/https?:\/\/([-.a-zA-Z0-9]+)/);
|
|
|
|
var domain=urls[1];
|
|
|
|
if(mode=="emb"){
|
|
|
|
var emb='<iframe src="'+url+'/embed" class="mastodon-embed" style="max-width: 100%; border: 0" width="400"></iframe><script src="https://'+domain+'/embed.js" async="async"></script>';
|
|
|
|
execCopy(emb)
|
2018-02-18 05:44:20 +11:00
|
|
|
Materialize.toast("埋め込みHTMLをコピーしました", 1500);
|
2018-02-18 03:44:03 +11:00
|
|
|
}else{
|
|
|
|
execCopy(url)
|
2018-02-18 05:44:20 +11:00
|
|
|
Materialize.toast("トゥートURLをコピーしました", 1500);
|
2018-02-18 03:44:03 +11:00
|
|
|
}
|
|
|
|
}
|