//DM(Conv) TL
function dm(acct_id, tlid, type,delc,voice) {
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_"+ acct_id + "_at");
var start = "https://" + domain + "/api/v1/conversations";
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 = '
'+dmListParse(json, type, acct_id, tlid, "", mute)+'
';
localStorage.setItem("lastobj_"+ tlid,json[0].id)
$("#timeline_" + tlid).html(templete);
additional(acct_id, tlid);
jQuery("time.timeago").timeago();
todc();
//reload(type, '', acct_id, tlid, data, mute, delc,voice);
$(window).scrollTop(0);
});
}
function dmmore(tlid){
var multi = localStorage.getItem("column");
var obj = JSON.parse(multi);
var acct_id = obj[tlid].domain;
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_"+ acct_id + "_at");
var sid = $("#timeline_" + tlid + " .cvo").last().attr("unique-id");
var start = "https://" + domain + "/api/v1/conversations?max_id="+sid;
var type="dm";
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 = ''+dmListParse(json, type, acct_id, tlid, "", mute)+'
';
$("#timeline_" + tlid).append(templete);
additional(acct_id, tlid);
jQuery("time.timeago").timeago();
moreloading=false;
})
}
//DMオブジェクトパーサー(トゥート)
function dmListParse(obj, mix, acct_id, tlid, popup, mutefilter) {
console.log(obj);
var templete = '';
if(obj[0]){
localStorage.setItem("lastunix_"+ tlid,date(obj[0].created_at, 'unix'));
}
var actb = localStorage.getItem("action_btns");
var actb='re,rt,fav,qt,del,pin,red';
if(actb){
var actb = actb.split(',');
var disp={};
for(var k=0;k';
var regExp = new RegExp(":" + shortcode + ":", "g");
dis_name = dis_name.replace(regExp, emoji_url);
});
}
var noticeavatar="";
var if_notf="";
var uniqueid=toot.id;
var notice = "";
var boostback = "";
//ユーザー強調
if(toot.account.username!=toot.account.acct){
var fullname=toot.account.acct;
}else{
var domain = localStorage.getItem("domain_" + acct_id);
var fullname=toot.account.acct+"@"+domain;
}
if(useremp){
Object.keys(useremp).forEach(function(key10) {
var user = useremp[key10];
if(user==fullname){
boostback = "emphasized";
}
});
}
var id = toot.id;
var home = "";
if (toot.account.locked) {
var locked = ' ';
} else {
var locked = "";
}
if (!toot.application) {
var via = '';
viashow="hide";
} else {
var via = escapeHTML(toot.application.name);
//強調チェック
Object.keys(emp).forEach(function(key6) {
var cli = emp[key6];
if(cli == via){
boostback = "emphasized";
}
});
//ミュートチェック
Object.keys(mute).forEach(function(key7) {
var cli = mute[key7];
if(cli == via){
boostback = "hide";
}
});
}
if(mix=="pinned"){
boostback = "emphasized";
}
if (toot.spoiler_text && cw) {
var content = toot.content;
var spoil = escapeHTML(toot.spoiler_text);
var spoiler = "cw cw_hide_" + toot.id;
var api_spoil = "gray";
var spoiler_show = ''+lang.lang_parse_cwshow+'
';
} else {
var ct1 = toot.content.split('').length + toot.content.split('
').length -2;
var ct2 = toot.content.split('').length + toot.content.split('
').length -2;
if(ct1>ct2){ var ct= ct1; }else{ var ct= ct2; }
if ((sent < ct && $.mb_strlen($.strip_tags(toot.content)) > 5) || ($.strip_tags(toot.content).length > ltr && $.mb_strlen($.strip_tags(toot.content)) > 5)) {
var content = ''+lang.lang_parse_fulltext+'
' + toot.content
var spoil = '' + $.mb_substr($.strip_tags(
toot.content), 0, 100) +
''+lang.lang_parse_autofold+'';
var spoiler = "cw cw_hide_" + toot.id;
var spoiler_show = ''+lang.lang_parse_more+'
';
} else {
var content = toot.content;
var spoil = escapeHTML(toot.spoiler_text);
var spoiler = "";
var spoiler_show = "";
}
}
var urls = $.strip_tags(content).replace(/\n/g, " ").match(
/https?:\/\/([-a-zA-Z0-9@.]+)\/?(?!.*((media|tags)|mentions)).*([-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)?/
);
if (urls) {
var analyze = ''+lang.lang_parse_url+'
';
} else {
var analyze = '';
}
var viewer = "";
var hasmedia = "";
var youtube = "";
if(toot.emojis){
var emojick = toot.emojis[0];
}else{
var emojick=false;
}
//絵文字があれば
if (emojick) {
Object.keys(toot.emojis).forEach(function(key5) {
var emoji = toot.emojis[key5];
var shortcode = emoji.shortcode;
var emoji_url = '';
var regExp = new RegExp(":" + shortcode + ":", "g");
content = content.replace(regExp, emoji_url);
spoil = spoil.replace(regExp, emoji_url);
});
}
//ニコフレ絵文字
if(toot.profile_emojis){
var nicoemojick = toot.profile_emojis[0];
}else{
var nicoemojick=false;
}
//絵文字があれば
if (nicoemojick) {
Object.keys(toot.profile_emojis).forEach(function(keynico) {
var emoji = toot.profile_emojis[keynico];
var shortcode = emoji.shortcode;
var emoji_url = '';
var regExp = new RegExp(":" + shortcode + ":", "g");
content = content.replace(regExp, emoji_url);
spoil = spoil.replace(regExp, emoji_url);
});
}
//デフォ絵文字
content=twemoji.parse(content);
if(dis_name){
dis_name=twemoji.parse(dis_name);
}
if(spoil){
spoil=twemoji.parse(spoil);
}
var mediack = toot.media_attachments[0];
//メディアがあれば
var media_ids="";
if (mediack) {
hasmedia = "hasmedia";
var cwdt = 100 / toot.media_attachments.length;
Object.keys(toot.media_attachments).forEach(function(key2) {
var media = toot.media_attachments[key2];
var purl = media.preview_url;
media_ids=media_ids+media.id+",";
var url = media.url;
if (toot.sensitive && nsfw) {
var sense = "sensitive"
} else {
var sense = ""
}
viewer = viewer + '';
});
media_ids = media_ids.slice(0, -1) ;
} else {
viewer = "";
hasmedia = "nomedia";
}
var menck = toot.mentions[0];
var mentions = "";
//メンションであれば
if (menck) {
mentions = "";
Object.keys(toot.mentions).forEach(function(key3) {
var mention = toot.mentions[key3];
mentions = mentions + '@' + mention.acct + ' ';
});
mentions = '' + mentions + '
';
}
var tagck = toot.tags[0];
var tags = "";
//タグであれば
if (tagck) {
Object.keys(toot.tags).forEach(function(key4) {
var tag = toot.tags[key4];
tags = tags + '#' + tag.name + ':TL Toot '+
'Pin ';
});
tags = '' + tags + '
';
}
//アニメ再生
if (gif == "yes") {
var avatar = toot.account.avatar;
} else {
var avatar = toot.account.avatar_static;
}
//ワードミュート
if(wordmute){
Object.keys(wordmute).forEach(function(key8) {
var worde = wordmute[key8];
if(worde){
if(worde.tag){
var word=worde.tag;
}else{
var word=worde
}
var regExp = new RegExp( word, "g" ) ;
if($.strip_tags(content).match(regExp)){
boostback = "hide by_filter";
}
}
});
}
//ワード強調
if(wordemp){
Object.keys(wordemp).forEach(function(key9) {
var word = wordemp[key9];
if(word){
var word=word.tag;
var regExp = new RegExp( word, "g" ) ;
content=content.replace(regExp,''+escapeHTML(word)+"");
}
});
}
//日本語じゃない
if(toot.language!="ja"){
var trans='';
}else{
var trans="";
}
if (toot.favourited) {
var if_fav = " yellow-text";
var fav_app = "faved";
} else {
var if_fav = "";
var fav_app = "";
}
//Cards
if (!card && toot.card) {
var cards=toot.card;
if (cards.provider_name=="Twitter"){
if(cards.image){
var twiImg='
';
}else{
var twiImg='';
}
analyze='';
}
if (cards.title) {
analyze="URL"+lang.lang_cards_check+":
Title:" + escapeHTML(cards.title) + "
" +
escapeHTML(cards.description) + "";
}
if (cards.html) {
analyze=cards.html+'picture_in_picture_alt';
}
}
//Ticker
var tickerdom="";
if(ticker){
var tickerdata=localStorage.getItem("ticker")
if(tickerdata){
var tickerdata=JSON.parse(tickerdata);
var thisdomain=toot.account.acct.split("@");
if(thisdomain.length>1){
thisdomain=thisdomain[1];
}
for( var i=0; i '+escapeHTML(value.name)+'';
break;
}
}
}
}
templete = templete + '';
});
return templete;
}