thedesk/app/js/tl/parse.js

1004 lines
34 KiB
JavaScript
Raw Normal View History

2018-01-28 23:22:43 +11:00
//オブジェクトパーサー(トゥート)
2019-03-16 21:06:03 +11:00
function parse(obj, mix, acct_id, tlid, popup, mutefilter, type) {
2018-01-28 23:22:43 +11:00
var templete = '';
2018-08-17 03:21:40 +10:00
if(obj[0]){
2019-03-08 05:19:26 +11:00
if(tlid===1){
2018-08-17 03:21:40 +10:00
console.log("testalive:"+"lastunix_"+ tlid+":"+date(obj[0].created_at, 'unix'))
}
localStorage.setItem("lastunix_"+ tlid,date(obj[0].created_at, 'unix'));
}
2018-07-17 01:39:06 +10:00
var actb='re,rt,fav,qt,del,pin,red';
2018-05-02 14:14:03 +10:00
if(actb){
var actb = actb.split(',');
var disp={};
for(var k=0;k<actb.length;k++){
if(k<4){
var tp="type-a";
}else{
var tp="type-b";
}
disp[actb[k]]=tp;
}
}
2019-03-13 02:51:07 +11:00
var qt = localStorage.getItem("quote");
2019-03-15 22:12:11 +11:00
if(qt=="nothing" || !qt){
2019-03-13 02:51:07 +11:00
var qtClass="hide";
}else{
var qtClass="";
}
2018-01-28 23:22:43 +11:00
var datetype = localStorage.getItem("datetype");
var nsfwtype = localStorage.getItem("nsfw");
var sent = localStorage.getItem("sentence");
2018-02-24 03:02:44 +11:00
var ltr = localStorage.getItem("letters");
2018-02-18 18:29:06 +11:00
var gif = localStorage.getItem("gif");
2018-03-11 01:22:59 +11:00
var imh = localStorage.getItem("img-height");
2019-04-11 02:52:01 +10:00
if(!imh){
imh=200;
}
2019-03-22 01:38:15 +11:00
if(imh=="full"){
imh="auto";
}else{
imh=imh+"px";
}
2018-03-27 13:39:35 +11:00
//独自ロケール
var locale = localStorage.getItem("locale");
if(locale=="yes"){
var locale=false;
}
2018-03-31 13:39:06 +11:00
//ネイティブ通知
var native=localStorage.getItem("nativenotf");
if(!native){
native="yes";
}
2018-03-11 01:22:59 +11:00
//クライアント強調
var emp = localStorage.getItem("client_emp");
if(emp){
var emp = JSON.parse(emp);
}
//クライアントミュート
var mute = localStorage.getItem("client_mute");
if(mute){
var mute = JSON.parse(mute);
}
//ユーザー強調
var useremp = localStorage.getItem("user_emp");
if(useremp){
var useremp = JSON.parse(useremp);
}
//ワード強調
var wordemp = localStorage.getItem("word_emp");
if(wordemp){
var wordemp = JSON.parse(wordemp);
}
//ワードミュート
var wordmute = localStorage.getItem("word_mute");
if(wordmute){
var wordmute = JSON.parse(wordmute);
2018-07-17 01:39:06 +10:00
wordmute = wordmute.concat(mutefilter);
}else{
wordmute = mutefilter;
2018-03-11 01:22:59 +11:00
}
2018-12-09 05:46:01 +11:00
//Ticker
var tickerck = localStorage.getItem("ticker_ok");
if(tickerck){
var ticker=true;
}else{
var ticker=false;
}
2019-03-06 19:08:48 +11:00
//Animation
var anime = localStorage.getItem("animation");
if (anime=="yes" || !anime) {
var animecss="cvo-anime";
}else{
var animecss="";
}
2018-12-09 05:46:01 +11:00
//Cards
var card = localStorage.getItem("card_" + tlid);
2018-07-17 01:39:06 +10:00
2018-01-28 23:22:43 +11:00
if (!sent) {
2019-03-08 05:19:26 +11:00
sent = 500;
2018-01-28 23:22:43 +11:00
}
2018-02-26 00:37:04 +11:00
if (!ltr) {
var ltr = 500;
}
2018-01-28 23:22:43 +11:00
if (!nsfwtype || nsfwtype == "yes") {
var nsfw = "ok";
} else {
var nsfw;
}
var cwtype = localStorage.getItem("cw");
if (!cwtype || cwtype == "yes") {
var cw = "ok";
} else {
var cw;
}
if (!datetype) {
datetype = "absolute";
}
2018-02-24 03:02:44 +11:00
if (!gif) {
var gif = "yes";
2018-02-18 18:29:06 +11:00
}
2018-03-11 01:22:59 +11:00
if (!imh) {
var imh = "200";
}
if(!emp){
var emp=[];
}
if(!mute){
var mute=[];
}
if(!useremp){
var useremp=[];
}
if(!wordemp){
var wordemp=[];
}
if(!wordmute){
var wordmute=[];
}
2018-05-02 14:14:03 +10:00
//via通知
var viashow=localStorage.getItem("viashow");
if(!viashow){
2018-07-22 23:03:46 +10:00
viashow="via-hide";
}
if(viashow=="hide"){
viashow="via-hide";
2018-05-02 14:14:03 +10:00
}
2018-03-27 13:39:35 +11:00
//認証なしTL
if(mix=="noauth"){
var noauth="hide";
2018-05-20 16:17:10 +10:00
var antinoauth="";
2018-03-27 13:39:35 +11:00
}else{
var noauth="";
2018-05-20 16:17:10 +10:00
var antinoauth="hide";
2018-03-27 13:39:35 +11:00
}
2019-03-16 21:06:03 +11:00
//DMTL
if(type=="dm"){
var dmHide="hide";
var antidmHide="";
}else{
var dmHide="";
var antidmHide="hide";
}
2018-05-02 14:14:03 +10:00
//マウスオーバーのみ
var mouseover=localStorage.getItem("mouseover");
if(!mouseover){
mouseover="";
2018-08-17 03:21:40 +10:00
}else if(mouseover=="yes" || mouseover=="click"){
2018-05-02 14:14:03 +10:00
mouseover="hide";
}else if(mouseover=="no"){
mouseover="";
}
2018-09-06 02:47:27 +10:00
//リプカウント
var replyct_view=localStorage.getItem("replyct");
if(!replyct_view){
replyct_view="hidden";
}
2018-01-28 23:22:43 +11:00
var local = [];
2018-03-11 01:22:59 +11:00
var times=[];
2018-01-28 23:22:43 +11:00
Object.keys(obj).forEach(function(key) {
var toot = obj[key];
2019-03-16 21:06:03 +11:00
if(type=="dm"){
var dmid=toot.id;
toot=toot.last_status;
}
2018-05-10 01:33:08 +10:00
var dis_name=escapeHTML(toot.account.display_name);
if(toot.account.emojis){
var actemojick = toot.account.emojis[0];
}else{
var actemojick=false;
}
//絵文字があれば
if (actemojick) {
Object.keys(toot.account.emojis).forEach(function(key5) {
var emoji = toot.account.emojis[key5];
var shortcode = emoji.shortcode;
2019-03-06 22:56:39 +11:00
var emoji_url = '<img draggable="false" src="' + emoji.url +
2018-06-18 00:26:45 +10:00
'" class="emoji-img" data-emoji="'+shortcode+'" alt=" :'+shortcode+': ">';
2018-05-10 01:33:08 +10:00
var regExp = new RegExp(":" + shortcode + ":", "g");
dis_name = dis_name.replace(regExp, emoji_url);
2018-05-10 02:01:06 +10:00
2018-05-10 01:33:08 +10:00
});
}
2018-08-21 04:26:14 +10:00
var noticeavatar="";
2018-03-20 15:55:25 +11:00
if (mix == "notf") {
2018-08-21 04:26:14 +10:00
if (gif == "yes") {
noticeavatar = toot.account.avatar;
} else {
noticeavatar = toot.account.avatar_static;
}
noticeavatar='<a onclick="udg(\'' + toot.account.id +
'\',' + acct_id + ');" user="' + toot.account.acct + '" class="udg">' +
2019-03-06 22:56:39 +11:00
'<img draggable="false" src="' + noticeavatar +
2018-08-21 04:26:14 +10:00
'" width="20" class="notf-icon prof-img" user="' + toot.account.acct +
'"></a>';
2018-02-26 00:37:04 +11:00
if (toot.type == "mention") {
2019-01-26 14:24:26 +11:00
var what = lang.lang_parse_mentioned;
2018-05-26 02:37:35 +10:00
var icon = "fa-share teal-text";
2018-08-23 03:29:39 +10:00
noticeavatar="";
2018-02-26 00:37:04 +11:00
} else if (toot.type == "reblog") {
2019-01-26 14:24:26 +11:00
var what = lang.lang_parse_bted;
2018-05-26 02:37:35 +10:00
var icon = "fa-retweet light-blue-text";
if(!locale && localStorage.getItem("bt_" + acct_id)){
what = localStorage.getItem("bt_" + acct_id);
2018-03-27 13:39:35 +11:00
}
2018-02-26 00:37:04 +11:00
} else if (toot.type == "favourite") {
2019-01-26 14:24:26 +11:00
var what = lang.lang_parse_faved;
2018-05-26 02:37:35 +10:00
var icon = "fa-star yellow-text";
if(!locale && localStorage.getItem("fav_" + acct_id)){
what = localStorage.getItem("fav_" + acct_id);
2018-03-27 13:39:35 +11:00
}
2019-04-03 01:42:25 +11:00
} else if (toot.type == "poll") {
var what = lang.lang_parse_polled;
var icon = "fa-tasks purple-text";
2018-02-26 00:37:04 +11:00
}
2018-05-26 02:37:35 +10:00
var noticetext = '<span class="cbadge cbadge-hover"title="' + date(toot.created_at,
2019-04-13 13:41:58 +10:00
'absolute') + '('+lang.lang_parse_notftime+')"><i class="far fa-clock"></i>' + date(toot.created_at,
2018-02-26 00:37:04 +11:00
datetype) +
2019-04-13 13:41:58 +10:00
'</span><i class="big-text fas '+icon+'"></i><a onclick="udg(\'' + toot.account.id +
2018-05-26 02:37:35 +10:00
'\',\'' + acct_id + '\')" class="pointer grey-text">' + dis_name +
2018-07-05 11:26:07 +10:00
"(@" + toot.account.acct +
2018-05-26 02:37:35 +10:00
")</a>";
2018-02-26 00:37:04 +11:00
var notice = noticetext;
var memory = localStorage.getItem("notice-mem");
if (popup >= 0 && obj.length < 5 && noticetext != memory) {
2018-08-17 03:21:40 +10:00
if(localStorage.getItem("hasNotfC_" + acct_id)!="true"){
if (toot.type == "mention") {
var replyct=localStorage.getItem("notf-reply_" + acct_id)
$(".notf-reply_" + acct_id).text(replyct*1-(-1));
localStorage.setItem("notf-reply_" + acct_id,replyct*1-(-1))
$(".notf-reply_" + acct_id).removeClass("hide")
}else if (toot.type == "reblog") {
var btct=localStorage.getItem("notf-bt_" + acct_id)
$(".notf-bt_" + acct_id).text(btct*1-(-1));
localStorage.setItem("notf-bt_" + acct_id,btct*1-(-1))
$(".notf-bt_" + acct_id).removeClass("hide")
}else if (toot.type == "favourite") {
var favct=localStorage.getItem("notf-fav_" + acct_id)
$(".notf-fav_" + acct_id).text(favct*1-(-1));
localStorage.setItem("notf-fav_" + acct_id,favct*1-(-1))
$(".notf-fav_" + acct_id).removeClass("hide")
}
2018-07-28 07:25:12 +10:00
}
2018-08-17 03:21:40 +10:00
2018-03-14 05:31:31 +11:00
var domain = localStorage.getItem("domain_" + acct_id);
2018-03-20 15:55:25 +11:00
if(popup>0){
2018-07-29 17:37:54 +10:00
Materialize.toast("["+domain+"]"+escapeHTML(toot.account.display_name)+what, popup * 1000);
2018-03-20 15:55:25 +11:00
}
2018-05-26 05:00:04 +10:00
if(native=="yes"){
var electron = require("electron");
var ipc = electron.ipcRenderer;
var os = electron.remote.process.platform;
var options = {
body: toot.account.display_name+"(" + toot.account.acct +")"+what+"\n\n"+$.strip_tags(toot.status.content),
icon: toot.account.avatar
};
if(os=="darwin"){
var n = new Notification('TheDesk:'+domain, options);
}else{
2018-09-10 03:06:00 +10:00
ipc.send('native-notf', [
'TheDesk:'+domain,
toot.account.display_name+"(" + toot.account.acct +")"+what+"\n\n"+$.strip_tags(toot.status.content),
toot.account.avatar,
"toot",
acct_id,
toot.status.id
]);
2018-05-26 05:00:04 +10:00
}
}
2018-08-17 03:21:40 +10:00
if(localStorage.getItem("hasNotfC_" + acct_id)!="true"){
$(".notf-icon_" + acct_id).addClass("red-text");
}
2018-02-26 00:37:04 +11:00
localStorage.setItem("notice-mem", noticetext);
noticetext = "";
}
2018-04-01 00:55:47 +11:00
var if_notf='data-notfIndv="'+acct_id+"_"+toot.id+'"';
2018-03-11 01:22:59 +11:00
var toot = toot.status;
2018-05-10 01:33:08 +10:00
var dis_name=escapeHTML(toot.account.display_name);
if(toot.account.emojis){
var actemojick = toot.account.emojis[0];
}else{
var actemojick=false;
}
//絵文字があれば
if (actemojick) {
Object.keys(toot.account.emojis).forEach(function(key5) {
var emoji = toot.account.emojis[key5];
var shortcode = emoji.shortcode;
var emoji_url = '<img src="' + emoji.url +
2018-06-18 00:26:45 +10:00
'" class="emoji-img" data-emoji="'+shortcode+'" alt=" :'+shortcode+': ">';
2018-05-10 01:33:08 +10:00
var regExp = new RegExp(":" + shortcode + ":", "g");
dis_name = dis_name.replace(regExp, emoji_url);
});
}
2018-02-26 00:37:04 +11:00
}else{
2018-04-01 00:55:47 +11:00
var if_notf="";
2018-02-26 00:37:04 +11:00
if (toot.reblog) {
2018-08-21 04:26:14 +10:00
if (gif == "yes") {
noticeavatar = toot.account.avatar;
} else {
noticeavatar = toot.account.avatar_static;
}
noticeavatar='<a onclick="udg(\'' + toot.account.id +
'\',' + acct_id + ');" user="' + toot.account.acct + '" class="udg">' +
2019-03-06 22:56:39 +11:00
'<img draggable="false" src="' + noticeavatar +
2018-08-21 04:26:14 +10:00
'" width="20" class="notf-icon prof-img" user="' + toot.account.acct +
'"></a>';
2019-01-26 14:24:26 +11:00
var rebtxt = lang.lang_parse_btedsimple;
2018-05-26 02:37:35 +10:00
var rticon = "fa-retweet light-blue-text";
2018-03-27 13:39:35 +11:00
if(localStorage.getItem("domain_" + acct_id)=="imastodon.net" && !locale){
rebtxt = ":「わかるわ」";
}else if(localStorage.getItem("domain_" + acct_id)=="mstdn.osaka" && !locale){
rebtxt = "がしばいた";
}
2019-04-13 13:41:58 +10:00
var notice = '<i class="big-text fas '+rticon+'"></i>'+ dis_name + "(@" + toot.account.acct +
2018-05-26 02:37:35 +10:00
")<br>";
2018-03-11 01:22:59 +11:00
var boostback = "shared";
2018-07-19 02:05:53 +10:00
var uniqueid=toot.id;
2018-02-26 00:37:04 +11:00
var toot = toot.reblog;
2018-05-10 02:01:06 +10:00
var dis_name=escapeHTML(toot.account.display_name);
if(toot.account.emojis){
var actemojick = toot.account.emojis[0];
}else{
2018-07-19 02:05:53 +10:00
var uniqueid=toot.id;
2018-05-10 02:01:06 +10:00
var actemojick=false;
}
//絵文字があれば
if (actemojick) {
Object.keys(toot.account.emojis).forEach(function(key5) {
var emoji = toot.account.emojis[key5];
var shortcode = emoji.shortcode;
2019-03-06 22:56:39 +11:00
var emoji_url = '<img draggable="false" src="' + emoji.url +
2018-06-18 00:26:45 +10:00
'" class="emoji-img" data-emoji="'+shortcode+'" alt=" :'+shortcode+': ">';
2018-05-10 02:01:06 +10:00
var regExp = new RegExp(":" + shortcode + ":", "g");
dis_name = dis_name.replace(regExp, emoji_url);
});
}
2018-02-26 00:37:04 +11:00
} else {
2018-07-19 02:05:53 +10:00
var uniqueid=toot.id;
2018-02-26 00:37:04 +11:00
var notice = "";
2019-03-06 19:08:48 +11:00
var boostback = "unshared";
2018-03-11 01:22:59 +11:00
//ユーザー強調
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";
}
});
}
2018-02-26 00:37:04 +11:00
}
}
2018-01-28 23:22:43 +11:00
var id = toot.id;
if (mix == "home") {
2018-03-27 13:39:35 +11:00
var home = ""
2018-03-11 01:22:59 +11:00
var divider = '<div class="divider"></div>';
2018-01-28 23:22:43 +11:00
} else {
var home = "";
2018-02-24 03:02:44 +11:00
var divider = '<div class="divider"></div>';
2018-01-28 23:22:43 +11:00
}
if (toot.account.locked) {
2019-04-13 13:41:58 +10:00
var locked = ' <i class="fas fa-lock red-text"></i>';
2018-01-28 23:22:43 +11:00
} else {
var locked = "";
}
if (!toot.application) {
2019-01-29 12:49:14 +11:00
var via = '';
2019-02-01 03:30:25 +11:00
viashow="hide";
2018-01-28 23:22:43 +11:00
} else {
var via = toot.application.name;
2018-03-11 01:22:59 +11:00
//強調チェック
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";
}
});
2018-01-28 23:22:43 +11:00
}
2019-02-01 03:30:25 +11:00
if(mix=="pinned"){
boostback = "emphasized";
}
2018-01-28 23:22:43 +11:00
if (toot.spoiler_text && cw) {
var content = toot.content;
2018-03-15 06:42:48 +11:00
var spoil = escapeHTML(toot.spoiler_text);
2018-01-28 23:22:43 +11:00
var spoiler = "cw cw_hide_" + toot.id;
var api_spoil = "gray";
var spoiler_show = '<a href="#" onclick="cw_show(\'' + toot.id +
2019-01-26 14:24:26 +11:00
'\')" class="nex parsed">'+lang.lang_parse_cwshow+'</a><br>';
2018-01-28 23:22:43 +11:00
} else {
2018-03-20 15:55:25 +11:00
var ct1 = toot.content.split('</p>').length + toot.content.split('<br />').length -2;
var ct2 = toot.content.split('</p>').length + toot.content.split('<br>').length -2;
2018-03-18 02:00:53 +11:00
if(ct1>ct2){ var ct= ct1; }else{ var ct= ct2; }
2018-02-24 03:02:44 +11:00
if ((sent < ct && $.mb_strlen($.strip_tags(toot.content)) > 5) || ($.strip_tags(toot.content).length > ltr && $.mb_strlen($.strip_tags(toot.content)) > 5)) {
2019-01-26 14:24:26 +11:00
var content = '<span class="gray">'+lang.lang_parse_fulltext+'</span><br>' + toot.content
2018-02-24 03:02:44 +11:00
var spoil = '<span class="cw-long-' + toot.id + '">' + $.mb_substr($.strip_tags(
toot.content), 0, 100) +
2019-01-26 14:24:26 +11:00
'</span><span class="gray">'+lang.lang_parse_autofold+'</span>';
2018-01-28 23:22:43 +11:00
var spoiler = "cw cw_hide_" + toot.id;
var spoiler_show = '<a href="#" onclick="cw_show(\'' + toot.id +
2019-01-26 14:24:26 +11:00
'\')" class="nex parsed">'+lang.lang_parse_more+'</a><br>';
2018-01-28 23:22:43 +11:00
} else {
var content = toot.content;
2018-03-15 06:42:48 +11:00
var spoil = escapeHTML(toot.spoiler_text);
2018-01-28 23:22:43 +11:00
var spoiler = "";
var spoiler_show = "";
}
}
2018-03-20 15:55:25 +11:00
var urls = $.strip_tags(content).replace(/\n/g, " ").match(
2018-02-24 03:02:44 +11:00
/https?:\/\/([-a-zA-Z0-9@.]+)\/?(?!.*((media|tags)|mentions)).*([-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)?/
2018-02-13 06:16:46 +11:00
);
2018-02-24 03:02:44 +11:00
if (urls) {
var analyze = '<a onclick="additionalIndv(\'' + tlid + '\',' + acct_id +
2019-01-26 14:24:26 +11:00
',\'' + id + '\')" class="add-show pointer">'+lang.lang_parse_url+'</a><br>';
2018-02-24 03:02:44 +11:00
} else {
var analyze = '';
2018-02-13 06:16:46 +11:00
}
2018-01-28 23:22:43 +11:00
var viewer = "";
2018-02-24 03:02:44 +11:00
var hasmedia = "";
2018-01-28 23:22:43 +11:00
var youtube = "";
2018-03-13 04:41:38 +11:00
if(toot.emojis){
var emojick = toot.emojis[0];
}else{
var emojick=false;
}
2018-01-28 23:22:43 +11:00
//絵文字があれば
if (emojick) {
Object.keys(toot.emojis).forEach(function(key5) {
var emoji = toot.emojis[key5];
var shortcode = emoji.shortcode;
2019-03-06 22:56:39 +11:00
var emoji_url = '<img draggable="false" src="' + emoji.url +
2018-06-18 00:26:45 +10:00
'" class="emoji-img" data-emoji="'+shortcode+'" alt=" :'+shortcode+': ">';
2018-01-28 23:22:43 +11:00
var regExp = new RegExp(":" + shortcode + ":", "g");
content = content.replace(regExp, emoji_url);
2018-03-15 06:42:48 +11:00
spoil = spoil.replace(regExp, emoji_url);
2018-01-28 23:22:43 +11:00
});
}
2018-08-21 04:26:14 +10:00
//ニコフレ絵文字
if(toot.profile_emojis){
var nicoemojick = toot.profile_emojis[0];
}else{
var nicoemojick=false;
}
2019-04-13 00:12:57 +10:00
//絵文字があれば(nico)
2018-08-21 04:26:14 +10:00
if (nicoemojick) {
Object.keys(toot.profile_emojis).forEach(function(keynico) {
var emoji = toot.profile_emojis[keynico];
var shortcode = emoji.shortcode;
2019-03-06 22:56:39 +11:00
var emoji_url = '<img draggable="false" src="' + emoji.url +
2018-08-21 04:26:14 +10:00
'" class="emoji-img" data-emoji="'+shortcode+'" alt=" :'+shortcode+': ">';
var regExp = new RegExp(":" + shortcode + ":", "g");
content = content.replace(regExp, emoji_url);
spoil = spoil.replace(regExp, emoji_url);
});
}
2018-03-18 02:00:53 +11:00
//デフォ絵文字
2018-05-26 22:48:13 +10:00
content=twemoji.parse(content);
2018-03-27 13:39:35 +11:00
if(dis_name){
2018-05-26 22:48:13 +10:00
dis_name=twemoji.parse(dis_name);
2018-03-27 13:39:35 +11:00
}
if(spoil){
2018-05-26 22:48:13 +10:00
spoil=twemoji.parse(spoil);
2018-03-27 13:39:35 +11:00
}
if(noticetext){
2018-05-26 22:48:13 +10:00
noticetext=twemoji.parse(noticetext);
2018-03-27 13:39:35 +11:00
}
if(notice){
2018-05-26 22:48:13 +10:00
notice=twemoji.parse(notice);
2018-03-18 02:00:53 +11:00
}
2018-01-28 23:22:43 +11:00
var mediack = toot.media_attachments[0];
//メディアがあれば
2018-07-17 01:39:06 +10:00
var media_ids="";
2018-01-28 23:22:43 +11:00
if (mediack) {
2018-02-18 03:44:03 +11:00
hasmedia = "hasmedia";
2018-07-17 01:39:06 +10:00
var cwdt = 100 / toot.media_attachments.length;
2018-01-28 23:22:43 +11:00
Object.keys(toot.media_attachments).forEach(function(key2) {
var media = toot.media_attachments[key2];
var purl = media.preview_url;
2018-07-17 01:39:06 +10:00
media_ids=media_ids+media.id+",";
2018-01-28 23:22:43 +11:00
var url = media.url;
if (toot.sensitive && nsfw) {
var sense = "sensitive"
} else {
var sense = ""
}
2018-08-17 03:21:40 +10:00
viewer = viewer + '<a onclick="imgv(\'' + id + '\',\'' + key2 + '\',\'' +
acct_id + '\')" id="' + id + '-image-' + key2 + '" data-url="' + url +
2019-03-06 22:56:39 +11:00
'" data-type="' + media.type + '" class="img-parsed"><img draggable="false" src="' +
2018-02-24 03:02:44 +11:00
purl + '" class="' + sense +
2019-03-22 01:38:15 +11:00
' toot-img pointer" style="width:calc(' + cwdt + '% - 1px); height:'+imh+';"></a></span>';
2018-01-28 23:22:43 +11:00
});
2018-07-17 01:39:06 +10:00
media_ids = media_ids.slice(0, -1) ;
2018-01-28 23:22:43 +11:00
} else {
viewer = "";
2018-02-18 03:44:03 +11:00
hasmedia = "nomedia";
2018-01-28 23:22:43 +11:00
}
var menck = toot.mentions[0];
var mentions = "";
//メンションであれば
if (menck) {
2018-05-12 04:12:25 +10:00
mentions = "";
2019-03-13 02:51:07 +11:00
var to_mention=[];
2018-01-28 23:22:43 +11:00
Object.keys(toot.mentions).forEach(function(key3) {
var mention = toot.mentions[key3];
mentions = mentions + '<a onclick="udg(\'' + mention.id + '\',' +
acct_id + ')" class="pointer">@' + mention.acct + '</a> ';
2019-03-13 02:51:07 +11:00
//自分は除外
//自インスタンスかどうかを確認し、IDの一致
if(mention.acct==mention.username && mention.id==localStorage.getItem("user-id_" + acct_id)){
//自分
}else{
//そのトゥの人NG
if(toot.account.acct!=mention.acct){
to_mention.push(mention.acct);
}
}
2018-01-28 23:22:43 +11:00
});
2019-03-13 02:51:07 +11:00
to_mention.push(toot.account.acct);
2018-02-24 03:02:44 +11:00
mentions = '<div style="float:right">' + mentions + '</div>';
2019-03-13 02:51:07 +11:00
}else{
var to_mention=[toot.account.acct];
2018-01-28 23:22:43 +11:00
}
var tagck = toot.tags[0];
var tags = "";
//タグであれば
if (tagck) {
Object.keys(toot.tags).forEach(function(key4) {
var tag = toot.tags[key4];
2018-05-12 04:12:25 +10:00
tags = tags + '<span class="hide" data-tag="' + tag.name + '">#' + tag.name + ':<a onclick="tl(\'tag\',\'' + tag.name + '\',' + acct_id +
2019-01-26 14:24:26 +11:00
',\'add\')" class="pointer" title="' +lang.lang_parse_tagTL.replace("{{tag}}" ,'#'+tag.name)+ '">TL</a> <a onclick="brInsert(\'#' + tag.name + '\')" class="pointer" title="' + lang.lang_parse_tagtoot.replace("{{tag}}" ,'#'+tag.name) + '">Toot</a> '+
'<a onclick="tagPin(\'' + tag.name + '\')" class="pointer" title="' +lang.lang_parse_tagpin.replace("{{tag}}" ,'#'+tag.name)+ '">Pin</a></span> ';
2018-01-28 23:22:43 +11:00
});
2018-02-24 03:02:44 +11:00
tags = '<div style="float:right">' + tags + '</div>';
2018-01-28 23:22:43 +11:00
}
2018-09-06 02:47:27 +10:00
//リプ数
if(toot.replies_count || toot.replies_count===0){
var replyct=toot.replies_count;
if(replyct_view=="hidden" && replyct>1){
replyct="1+";
}
}else{
var replyct="";
}
2018-02-18 16:43:11 +11:00
//公開範囲を取得
2018-02-24 03:02:44 +11:00
var vis = "";
var visen = toot.visibility;
if (visen == "public") {
var vis =
2019-01-26 14:24:26 +11:00
'<i class="text-darken-3 material-icons gray sml vis-data pointer" title="'+lang.lang_parse_public+'('+lang.lang_parse_clickcopy+')" data-vis="public" onclick="staCopy(\''+id+'\')" style="font-size:1rem;">public</i>';
2018-02-26 00:37:04 +11:00
var can_rt = "";
2018-02-24 03:02:44 +11:00
} else if (visen == "unlisted") {
var vis =
2019-01-26 14:24:26 +11:00
'<i class="text-darken-3 material-icons blue-text vis-data pointer" title="'+lang.lang_parse_unlisted+'('+lang.lang_parse_clickcopy+')" data-vis="unlisted" onclick="staCopy(\''+id+'\')" style="font-size:1rem;">lock_open</i>';
2018-02-26 00:37:04 +11:00
var can_rt = "";
2018-04-16 23:58:14 +10:00
} else if (visen == "private") {
2018-02-24 03:02:44 +11:00
var vis =
2019-01-26 14:24:26 +11:00
'<i class="text-darken-3 material-icons orange-text vis-data pointer" title="'+lang.lang_parse_private+'('+lang.lang_parse_clickcopy+')" data-vis="private" onclick="staCopy(\''+id+'\')" style="font-size:1rem;">lock</i>';
2018-02-26 00:37:04 +11:00
var can_rt = "hide";
2018-02-24 03:02:44 +11:00
} else if (visen == "direct") {
var vis =
2019-01-26 14:24:26 +11:00
'<i class="text-darken-3 material-icons red-text vis-data pointer" title="'+lang.lang_parse_direct+'('+lang.lang_parse_clickcopy+')" data-vis="direct" onclick="staCopy(\''+id+'\')" style="font-size:1rem;">mail</i>';
2018-02-26 00:37:04 +11:00
var can_rt = "hide";
2018-02-18 16:43:11 +11:00
}
2018-01-28 23:22:43 +11:00
if (toot.account.acct == localStorage.getItem("user_" + acct_id)) {
var if_mine = "";
2018-05-02 14:14:03 +10:00
var mine_via="type-b";
2018-01-28 23:22:43 +11:00
} else {
var if_mine = "hide";
2018-05-02 14:14:03 +10:00
var mine_via="";
2018-01-28 23:22:43 +11:00
}
if (toot.favourited) {
var if_fav = " yellow-text";
var fav_app = "faved";
} else {
var if_fav = "";
var fav_app = "";
}
if (toot.reblogged) {
var if_rt = "teal-text";
var rt_app = "rted";
} else {
var if_rt = "";
var rt_app = "";
}
2018-03-11 01:22:59 +11:00
if (toot.pinned) {
var if_pin = "blue-text";
var pin_app = "pinned";
} else {
var if_pin = "";
var pin_app = "";
}
2018-02-18 18:29:06 +11:00
//アニメ再生
2018-02-24 03:02:44 +11:00
if (gif == "yes") {
var avatar = toot.account.avatar;
} else {
var avatar = toot.account.avatar_static;
2018-02-18 18:29:06 +11:00
}
2018-03-11 01:22:59 +11:00
//ワードミュート
if(wordmute){
Object.keys(wordmute).forEach(function(key8) {
var worde = wordmute[key8];
if(worde){
2018-07-17 01:39:06 +10:00
if(worde.tag){
var word=worde.tag;
}else{
var word=worde
}
2018-03-11 01:22:59 +11:00
var regExp = new RegExp( word, "g" ) ;
2018-05-10 01:33:08 +10:00
if($.strip_tags(content).match(regExp)){
2018-07-17 01:39:06 +10:00
boostback = "hide by_filter";
2018-03-11 01:22:59 +11:00
}
}
});
}
//ワード強調
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,'<span class="emp">'+word+"</span>");
}
});
}
2018-03-31 13:39:06 +11:00
//日本語じゃない
2019-03-08 05:19:26 +11:00
if(toot.language!=lang.language && toot.language){
var trans='<div class="action pin"><a onclick="trans(\''+toot.language+'\',\''+lang.language+'\')" class="waves-effect waves-dark btn-flat" style="padding:0" title="'+lang.lang_parse_trans+'"><i class="material-icons">g_translate</i></a></div>';
2018-03-31 13:39:06 +11:00
}else{
var trans="";
}
2018-12-09 05:46:01 +11:00
//Cards
if (!card && toot.card) {
var cards=toot.card;
if (cards.provider_name=="Twitter"){
if(cards.image){
2019-03-06 22:56:39 +11:00
var twiImg='<br><img draggable="false" src="'+cards.image+'">';
}else{
var twiImg='';
}
analyze='<blockquote class="twitter-tweet"><b>'+escapeHTML(cards.author_name)+'</b><br>'+escapeHTML(cards.description)+twiImg+'</blockquote>';
2018-12-09 05:46:01 +11:00
}
if (cards.title) {
analyze="<span class=\"gray\">URL"+lang.lang_cards_check+":<br>Title:" + escapeHTML(cards.title) + "<br>" +
escapeHTML(cards.description) + "</span>";
}
if (cards.html) {
analyze=cards.html+'<i class="material-icons" onclick="pip('+id+')" title="'+lang.lang_cards_pip+'">picture_in_picture_alt</i>';
}
2018-12-09 05:46:01 +11:00
}
//Ticker
var tickerdom="";
if(ticker){
2019-02-27 03:51:37 +11:00
var tickerdata=localStorage.getItem("ticker")
if(tickerdata){
var tickerdata=JSON.parse(tickerdata);
2018-12-09 05:46:01 +11:00
var thisdomain=toot.account.acct.split("@");
if(thisdomain.length>1){
thisdomain=thisdomain[1];
}
for( var i=0; i<tickerdata.length; i++) {
var value=tickerdata[i];
if(value.domain==thisdomain){
2019-03-06 22:56:39 +11:00
var tickerdom='<div style="background:linear-gradient(to left,transparent, '+value.bg+' 96%) !important; color:'+value.text+';width:100%; height:0.9rem; font-size:0.8rem;"><img draggable="false" src="'+value.image+'" style="height:100%;"><span style="position:relative; top:-0.2rem;"> '+value.name+'</span></div>';
2018-12-09 05:46:01 +11:00
break;
}
}
}
2019-02-27 03:51:37 +11:00
}
2019-03-06 19:08:48 +11:00
//Poll
var poll="";
if(toot.poll){
var choices=toot.poll.options;
if(toot.poll.voted){
var myvote=lang.lang_parse_voted;
var result_hide="";
}else{
myvote='<a onclick="voteMastodon(\''+acct_id+'\',\''+toot.poll.id+'\')" class="votebtn">'+lang.lang_parse_vote+'</a><br>';
2019-03-06 22:56:39 +11:00
if(choices[0].votes_count===0 || choices[0].votes_count>0){
myvote=myvote+'<a onclick="showResult(\''+acct_id+'\',\''+toot.poll.id+'\')" class="pointer">'+lang.lang_parse_unvoted+"</a>";
}
2019-03-06 19:08:48 +11:00
var result_hide="hide";
}
2019-03-08 05:19:26 +11:00
if(toot.poll.expired){
var ended=lang.lang_parse_endedvote;
}else{
var ended=date(toot.poll.expires_at, datetype);
}
2019-03-06 19:08:48 +11:00
Object.keys(choices).forEach(function(keyc) {
var choice = choices[keyc];
2019-03-08 05:19:26 +11:00
if(!toot.poll.voted && !toot.poll.expired){
2019-03-06 19:08:48 +11:00
var votesel='voteSelMastodon(\''+acct_id+'\',\''+toot.poll.id+'\','+keyc+','+toot.poll.multiple+')';
var voteclass="pointer waves-effect waves-light";
}else{
var votesel="";
var voteclass="";
}
2019-04-13 00:26:38 +10:00
poll=poll+'<div class="'+voteclass+' vote vote_'+acct_id+'_'+toot.poll.id+'_'+keyc+'" onclick="'+votesel+'">'+escapeHTML(choice.title)+'<span class="vote_'+acct_id+'_'+toot.poll.id+'_result '+result_hide+'">('+choice.votes_count+')</span></div>';
2019-03-06 19:08:48 +11:00
});
2019-04-13 00:26:38 +10:00
poll='<div class="vote_'+acct_id+'_'+toot.poll.id+'">'+poll+myvote+'<span class="cbadge cbadge-hover" title="' + date(toot.poll.expires_at, 'absolute') +
2019-04-13 13:41:58 +10:00
'"><i class="far fa-calendar-times"></i>' +
2019-03-08 05:19:26 +11:00
ended+ '</span></div>';
2019-03-06 19:08:48 +11:00
}
2018-02-18 16:43:11 +11:00
templete = templete + '<div id="pub_' + toot.id + '" class="cvo ' +
2018-03-11 01:22:59 +11:00
boostback + ' ' + fav_app + ' ' + rt_app + ' ' + pin_app +
2019-03-06 19:08:48 +11:00
' ' + hasmedia + ' '+animecss+'" toot-id="' + id + '" unique-id="' + uniqueid + '" data-medias="'+media_ids+' " unixtime="' + date(obj[
2018-08-17 03:21:40 +10:00
key].created_at, 'unix') + '" '+if_notf+' onmouseover="mov(\'' + toot.id + '\',\''+tlid+'\',\'mv\')" onclick="mov(\'' + toot.id + '\',\''+tlid+'\',\'cl\')" onmouseout="resetmv(\'mv\')">' +
2018-02-24 03:02:44 +11:00
'<div class="area-notice"><span class="gray sharesta">' + notice + home +
'</span></div>' +
'<div class="area-icon"><a onclick="udg(\'' + toot.account.id +
'\',' + acct_id + ');" user="' + toot.account.acct + '" class="udg">' +
2019-03-06 22:56:39 +11:00
'<img draggable="false" src="' + avatar +
2018-02-24 03:02:44 +11:00
'" width="40" class="prof-img" user="' + toot.account.acct +
2018-08-21 04:26:14 +10:00
'"></a>'+noticeavatar+'</div>' +
2018-05-26 02:37:35 +10:00
'<div class="area-display_name"><div class="flex-name"><span class="user">' +
2018-03-27 13:39:35 +11:00
dis_name +
2018-02-25 18:21:13 +11:00
'</span><span class="sml gray" style="overflow: hidden;white-space: nowrap;text-overflow: ellipsis; cursor:text;"> @' +
2018-02-24 03:02:44 +11:00
toot.account.acct + locked + '</span></div>' +
2018-05-26 02:37:35 +10:00
'<div class="flex-time"><span class="cbadge cbadge-hover pointer waves-effect" onclick="tootUriCopy(\'' +
2018-02-24 03:02:44 +11:00
toot.url + '\');" title="' + date(toot.created_at, 'absolute') +
2019-04-13 13:41:58 +10:00
'('+lang.lang_parse_clickcopyurl+')"><i class="far fa-clock"></i>' +
2018-05-26 02:37:35 +10:00
date(toot.created_at, datetype) + '</span>' +
'</div></div>' +
2018-12-09 05:46:01 +11:00
'<div class="area-toot">'+tickerdom+'<span class="' +
2019-01-29 12:49:14 +11:00
api_spoil + ' cw_text_' + toot.id + '"><span class="cw_text">' + spoil + "</span>" + spoiler_show +
2019-04-11 13:52:38 +10:00
'</span><span class="toot ' + spoiler + '">' + content +poll+
2018-02-24 03:02:44 +11:00
'</span>' +
'' + viewer + '' +
'</div><div class="area-additional"><span class="additional">' + analyze +
'</span>' +
2019-04-11 13:52:38 +10:00
'' + mentions + tags + '</div>' +
2018-05-02 14:14:03 +10:00
'<div class="area-vis"></div>'+
2018-07-17 01:39:06 +10:00
'<div class="area-actions '+mouseover+'">' +
2018-05-26 02:37:35 +10:00
'<div class="action">'+vis+'</div>'+
2019-01-26 14:24:26 +11:00
'<div class="action '+antinoauth+'"><a onclick="detEx(\''+toot.url+'\',\'main\')" class="waves-effect waves-dark details" style="padding:0">'+lang.lang_parse_det+'</a></div>' +
2019-03-16 21:06:03 +11:00
'<div class="action '+antidmHide+'"><a onclick="details(\'' + toot.id + '\',' + acct_id +',\''+tlid+'\',\'normal\')" class="waves-effect waves-dark details" style="padding:0">'+lang.lang_parse_thread+'</a></div>' +
2018-05-20 16:17:10 +10:00
'<div class="action '+disp["re"]+' '+noauth+'"><a onclick="re(\'' + toot.id +
2019-03-13 02:51:07 +11:00
'\',\'' + to_mention + '\',' +
2018-03-14 05:31:31 +11:00
acct_id + ',\''+visen+
2019-04-13 13:41:58 +10:00
'\')" class="waves-effect waves-dark btn-flat actct" style="padding:0" title="'+lang.lang_parse_replyto+'"><i class="fas fa-share"></i><span class="rep_ct">' + replyct +
2018-09-06 02:47:27 +10:00
'</a></span></a></div>' +
2018-05-20 16:17:10 +10:00
'<div class="action '+can_rt+' '+disp["rt"]+' '+noauth+'"><a onclick="rt(\'' + toot.id + '\',' + acct_id +
2018-02-24 03:02:44 +11:00
',\'' + tlid +
2019-04-13 13:41:58 +10:00
'\')" class="waves-effect waves-dark btn-flat actct" style="padding:0" title="'+lang.lang_parse_bt+'"><i class="fas fa-retweet ' +
2018-02-24 03:02:44 +11:00
if_rt + ' rt_' + toot.id + '"></i><span class="rt_ct">' + toot.reblogs_count +
'</span></a></div>' +
2019-03-13 02:51:07 +11:00
'<div class="action '+can_rt+' '+disp["qt"]+' '+noauth+' '+qtClass+'"><a onclick="qt(\'' + toot.id + '\',' + acct_id +
2018-04-07 14:31:09 +10:00
',\'' + toot.account.acct +'\',\''+toot.url+
2019-04-13 13:41:58 +10:00
'\')" class="waves-effect waves-dark btn-flat actct" style="padding:0" title="'+lang.lang_parse_quote+'"><i class="text-darken-3 fas fa-quote-right"></i></a></div>' +
2018-05-20 16:17:10 +10:00
'<div class="action '+disp["fav"]+' '+noauth+'"><a onclick="fav(\'' + toot.id + '\',' + acct_id +
2018-02-24 03:02:44 +11:00
',\'' + tlid +
2019-04-13 13:41:58 +10:00
'\')" class="waves-effect waves-dark btn-flat actct" style="padding:0" title="'+lang.lang_parse_fav+'"><i class="fas text-darken-3 fa-star' +
2018-02-24 03:02:44 +11:00
if_fav + ' fav_' + toot.id + '"></i><span class="fav_ct">' + toot.favourites_count +
'</a></span></div>' +
2018-05-20 16:17:10 +10:00
'<div class="' + if_mine + ' action '+disp["del"]+' '+noauth+'"><a onclick="del(\'' + toot.id + '\',' +
2018-02-24 03:02:44 +11:00
acct_id +
2019-04-13 13:41:58 +10:00
')" class="waves-effect waves-dark btn-flat" style="padding:0" title="'+lang.lang_parse_del+'"><i class="far fa-trash"></i></a></div>' +
2018-05-20 16:17:10 +10:00
'<div class="' + if_mine + ' action pin '+disp["pin"]+' '+noauth+'"><a onclick="pin(\'' + toot.id + '\',' +
2018-03-11 01:22:59 +11:00
acct_id +
2019-04-13 13:41:58 +10:00
')" class="waves-effect waves-dark btn-flat" style="padding:0" title="'+lang.lang_parse_pin+'"><i class="fas fa-map-pin pin_' + toot.id + ' '+if_pin+'"></i></a></div>'
2018-07-17 01:39:06 +10:00
+'<div class="' + if_mine + ' action '+disp["red"]+' '+noauth+'"><a onclick="redraft(\'' + toot.id + '\',' +
acct_id +
2019-01-26 14:24:26 +11:00
')" class="waves-effect waves-dark btn-flat" style="padding:0" title="'+lang.lang_parse_redraft+'"><i class="material-icons">redo</i></a></div>'+trans+
2018-07-28 07:25:12 +10:00
'<span class="cbadge viabadge waves-effect '+viashow+' '+mine_via+'" onclick="client(\''+$.strip_tags(via)+'\')" title="via ' + $.strip_tags(via) + '">via ' +
via +
'</span>'+
2018-08-17 03:21:40 +10:00
'</div><div class="area-side '+mouseover+'"><div class="action ' + if_mine + ' '+noauth+'"><a onclick="toggleAction(\'' + toot.id + '\',\''+tlid+'\',\''+acct_id+'\')" class="waves-effect waves-dark btn-flat" style="padding:0"><i class="text-darken-3 material-icons act-icon">expand_more</i></a></div>' +
2018-05-20 16:17:10 +10:00
'<div class="action '+noauth+'"><a onclick="details(\'' + toot.id + '\',' + acct_id +
2019-03-16 21:06:03 +11:00
',\''+tlid+'\',\'normal\')" class="waves-effect waves-dark btn-flat details '+dmHide+'" style="padding:0"><i class="text-darken-3 material-icons">more_vert</i></a></div>' +
2018-07-28 07:25:12 +10:00
'</div></div>' +
2018-07-17 01:39:06 +10:00
'</div></div>';
2018-01-28 23:22:43 +11:00
});
if (mix == "mix") {
2018-03-11 01:22:59 +11:00
return [templete, local, times]
2018-01-28 23:22:43 +11:00
} else {
return templete;
}
}
//オブジェクトパーサー(ユーザーデータ)
2018-02-26 02:32:10 +11:00
function userparse(obj, auth, acct_id, tlid, popup) {
2018-03-27 13:39:35 +11:00
//独自ロケール
var locale = localStorage.getItem("locale");
if(locale=="yes"){
var locale=false;
}
2018-01-28 23:22:43 +11:00
var templete = '';
2018-02-24 03:02:44 +11:00
var datetype = localStorage.getItem("datetype");
2018-01-28 23:22:43 +11:00
Object.keys(obj).forEach(function(key) {
var toot = obj[key];
if(!toot.username){
2018-08-10 01:18:35 +10:00
var raw=toot;
toot=toot.account;
var notf=true;
}else{
var notf=false;
}
2018-01-28 23:22:43 +11:00
if (toot.locked) {
2019-04-13 13:41:58 +10:00
var locked = ' <i class="fas fa-lock red-text"></i>';
2018-01-28 23:22:43 +11:00
} else {
var locked = "";
}
if (auth) {
var auth = '<i class="material-icons gray pointer" onclick="request(\'' +
toot.id + '\',\'authorize\',' + acct_id + ')">person_add</i>';
} else {
var auth = "";
}
2019-01-26 14:24:26 +11:00
var ftxt=lang.lang_parse_followed;
2019-03-06 19:08:48 +11:00
if(!locale && localStorage.getItem("followlocale_" + acct_id)){
ftxt = localStorage.getItem("followlocale_" + acct_id);
2018-03-27 13:39:35 +11:00
}
if(popup > 0 || popup==-1 || notf){
2018-08-10 01:18:35 +10:00
var notftext=ftxt+'<br>';
2018-02-24 03:02:44 +11:00
}else{
var notftext="";
}
2018-02-26 02:32:10 +11:00
var memory = localStorage.getItem("notice-mem");
2018-07-30 21:03:49 +10:00
if (popup >= 0 && obj.length < 5 && notftext != memory) {
Materialize.toast(escapeHTML(toot.display_name)+":"+ftxt, popup * 1000);
2018-02-26 02:32:10 +11:00
$(".notf-icon_" + tlid).addClass("red-text");
2018-07-30 21:03:49 +10:00
localStorage.setItem("notice-mem", notftext);
notftext = "";
2018-09-10 03:06:00 +10:00
var native=localStorage.getItem("nativenotf");
if(!native){
native="yes";
}
if(native=="yes"){
var electron = require("electron");
var ipc = electron.ipcRenderer;
var os = electron.remote.process.platform;
var options = {
body: toot.display_name+"(" + toot.acct +")"+ftxt,
icon: toot.avatar
};
var domain = localStorage.getItem("domain_" + acct_id);
if(os=="darwin"){
var n = new Notification('TheDesk:'+domain, options);
}else{
ipc.send('native-notf', [
'TheDesk:'+domain,
toot.display_name+"(" + toot.acct +")"+ftxt,
toot.avatar,
"userdata",
acct_id,
toot.id
]);
}
}
2018-02-26 02:32:10 +11:00
}
if(toot.display_name){
var dis_name=escapeHTML(toot.display_name);
}else{
var dis_name=toot.username;
}
2018-09-10 03:06:00 +10:00
//ネイティブ通知
2018-05-26 22:48:13 +10:00
if(toot.emojis){
var actemojick = toot.emojis[0];
}else{
var actemojick=false;
}
//絵文字があれば
if (actemojick) {
Object.keys(toot.emojis).forEach(function(key5) {
var emoji = toot.emojis[key5];
var shortcode = emoji.shortcode;
2019-03-06 22:56:39 +11:00
var emoji_url = '<img draggable="false" src="' + emoji.url +
2018-06-18 00:26:45 +10:00
'" class="emoji-img" data-emoji="'+shortcode+'" alt=" :'+shortcode+': ">';
2018-05-26 22:48:13 +10:00
var regExp = new RegExp(":" + shortcode + ":", "g");
dis_name = dis_name.replace(regExp, emoji_url);
});
}
if(dis_name){
dis_name=twemoji.parse(dis_name);
}
if(toot.avatar){
var avatar=toot.avatar;
}else{
2019-02-05 13:33:32 +11:00
var avatar="../../img/missing.svg";
}
2018-01-28 23:22:43 +11:00
templete = templete +
2018-07-29 17:37:54 +10:00
'<div class="cvo" style="padding-top:5px;" user-id="' + toot.id + '"><div class="area-notice">' +
2018-02-24 03:02:44 +11:00
notftext +
2018-07-29 17:37:54 +10:00
'</div><div class="area-icon"><a onclick="udg(\'' + toot.id + '\',' +
2018-01-28 23:22:43 +11:00
acct_id + ');" user="' + toot.acct + '" class="udg">' +
2019-03-06 22:56:39 +11:00
'<img draggable="false" src="' + avatar + '" width="40" class="prof-img" user="' + toot
2018-01-28 23:22:43 +11:00
.acct + '"></a></div>' +
2018-07-29 17:37:54 +10:00
'<div class="area-display_name"><div class="flex-name"><span class="user">' +
dis_name + '</span>' +
'<span class="sml gray" style="overflow: hidden;white-space: nowrap;text-overflow: ellipsis;user-select:auto; cursor:text;"> @' +
toot.acct + locked + auth +'</span>' +
'</div>' +
'</div>' +
'<div style="justify-content:space-around" class="area-toot"> <div class="cbadge" style="width:100px;">Follows:' +
2018-02-24 03:02:44 +11:00
toot.following_count +
'</div><div class="cbadge" style="width:100px;">Followers:' + toot.followers_count +
2018-01-28 23:22:43 +11:00
'</div>' +
2018-07-29 17:37:54 +10:00
'</div>' +
2018-01-28 23:22:43 +11:00
'</div>' +
'</div>';
});
return templete;
}
2018-03-11 01:22:59 +11:00
//クライアントダイアログ
function client(name) {
if(name!="Unknown"){
//聞く
localStorage.removeItem("client_mute");
var electron = require("electron");
var remote=electron.remote;
var dialog=remote.dialog;
const options = {
type: 'info',
2019-01-26 14:24:26 +11:00
title: lang.lang_parse_clientop,
message: name+lang.lang_parse_clienttxt,
buttons: [lang.lang_parse_clientno,lang.lang_parse_clientemp, lang.lang_parse_clientmute]
2018-03-11 01:22:59 +11:00
}
dialog.showMessageBox(options, function(arg) {
2019-03-08 05:19:26 +11:00
if(arg===1){
2018-03-11 01:22:59 +11:00
var cli = localStorage.getItem("client_emp");
var obj = JSON.parse(cli);
if(!obj){
var obj=[];
obj.push(name);
2019-01-26 14:24:26 +11:00
Materialize.toast(name+lang.lang_status_emphas, 2000);
2018-03-11 01:22:59 +11:00
}else{
var can;
Object.keys(obj).forEach(function(key) {
var cliT = obj[key];
if(cliT!=name && !can){
can=false;
}else{
can=true;
obj.splice(key, 1);
2019-01-26 14:24:26 +11:00
Materialize.toast(name+lang.lang_status_unemphas, 2000);
2018-03-11 01:22:59 +11:00
}
});
if(!can){
obj.push(name);
2019-01-26 14:24:26 +11:00
Materialize.toast(name+lang.lang_status_emphas, 2000);
2018-03-11 01:22:59 +11:00
}else{
}
}
var json = JSON.stringify(obj);
localStorage.setItem("client_emp", json);
2019-03-08 05:19:26 +11:00
}else if(arg===2){
2018-03-11 01:22:59 +11:00
var cli = localStorage.getItem("client_mute");
var obj = JSON.parse(cli);
if(!obj){
var obj=[];
}
obj.push(name);
var json = JSON.stringify(obj);
localStorage.setItem("client_mute", json);
2019-01-26 14:24:26 +11:00
Materialize.toast(name+lang.lang_parse_mute, 2000);
2018-03-11 01:22:59 +11:00
}else{
return;
}
parseColumn();
})
}
}