//オブジェクトパーサー(トゥート)
function parse(obj, mix, acct_id, tlid, popup) {
var templete = '';
var datetype = localStorage.getItem("datetype");
var nsfwtype = localStorage.getItem("nsfw");
var sent = localStorage.getItem("sentence");
var ltr = localStorage.getItem("letters");
var gif = localStorage.getItem("gif");
var imh = localStorage.getItem("img-height");
//クライアント強調
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);
}
if (!sent) {
var sent = 500;
}
if (!ltr) {
var ltr = 500;
}
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";
}
if (!gif) {
var gif = "yes";
}
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=[];
}
var local = [];
var times=[];
Object.keys(obj).forEach(function(key) {
var toot = obj[key];
if (toot.reblog) {
var notice = toot.account.display_name + "(" + toot.account.acct +
")がブースト
";
var boostback = "shared";
var toot = toot.reblog;
}else{
var notice="";
}
var id = toot.id;
var divider = '
';
if (toot.account.locked) {
var locked = ' ';
} else {
var locked = "";
}
if (!toot.application) {
var via = 'Unknown';
} else {
var via = toot.application.name;
//ミュートチェック
Object.keys(mute).forEach(function(key7) {
var cli = mute[key7];
if(cli == via){
boostback = "hide";
}
});
}
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 = '見る
';
} 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 = '以下全文
' + toot.content
var spoil = '' + $.mb_substr($.strip_tags(
toot.content), 0, 100) +
'自動折りたたみ';
var spoiler = "cw cw_hide_" + toot.id;
var spoiler_show = '続き…
';
} else {
var content = toot.content;
var spoil = escapeHTML(toot.spoiler_text);
var spoiler = "";
var spoiler_show = "";
}
}
var urls = content.match(
/https?:\/\/([-a-zA-Z0-9@.]+)\/?(?!.*((media|tags)|mentions)).*([-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)?/
);
if (urls) {
var analyze = '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);
});
}
//デフォ絵文字
var defemo=content.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g);
if(defemo && defemo[0]){
defemo = defemo.filter(function (x, i, self) {
return self.indexOf(x) === i;
});
Object.keys(defemo).forEach(function(key12) {
var demo=defemo[key12];
var regExp = new RegExp(demo, "g");
for(var i=0;i');
break;
}
}
}
break;
}
}
});
}
var mediack = toot.media_attachments[0];
//メディアがあれば
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;
var url = media.url;
if (toot.sensitive && nsfw) {
var sense = "sensitive"
} else {
var sense = ""
}
viewer = viewer + '';
});
} else {
viewer = "";
hasmedia = "nomedia";
}
var menck = toot.mentions[0];
var mentions = "";
//メンションであれば
if (menck) {
mentions = "Links: ";
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) {
if (!menck) {
tags = "Links: ";
}
Object.keys(toot.tags).forEach(function(key4) {
var tag = toot.tags[key4];
tags = tags + '#' + tag.name + ' TL Toot '+
'Pin ';
});
tags = '' + tags + '
';
}
//公開範囲を取得
var vis = "";
var visen = toot.visibility;
if (visen == "public") {
var vis =
'public';
var can_rt = "";
} else if (visen == "unlisted") {
var vis =
'lock_open';
var can_rt = "";
} else if (visen == "plivate") {
var vis =
'lock';
var can_rt = "hide";
} else if (visen == "direct") {
var vis =
'mail';
var can_rt = "hide";
}
if (toot.account.acct == localStorage.getItem("user_" + acct_id)) {
var if_mine = "";
} else {
var if_mine = "hide";
}
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 = "";
}
if (toot.pinned) {
var if_pin = "blue-text";
var pin_app = "pinned";
} else {
var if_pin = "";
var pin_app = "";
}
//アニメ再生
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){
var word=worde.tag;
var regExp = new RegExp( word, "g" ) ;
if(content.match(regExp)){
boostback = "hide";
}
}
});
}
//ワード強調
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,''+word+"");
}
});
}
templete = templete + '' +
'' + divider;
});
if (mix == "mix") {
return [templete, local, times]
} else {
return templete;
}
}
//オブジェクトパーサー(ユーザーデータ)
function userparse(obj, auth, acct_id, tlid, popup) {
var templete = '';
var datetype = localStorage.getItem("datetype");
Object.keys(obj).forEach(function(key) {
var toot = obj[key];
if (toot.locked) {
var locked = ' ';
} else {
var locked = "";
}
if (auth) {
var auth = 'person_add';
} else {
var auth = "";
}
if(popup > 0){
var notftext='' + date(toot.created_at,
datetype) +
'フォローされました。
';
}else{
var notftext="";
}
var memory = localStorage.getItem("notice-mem");
if (popup >= 0 && obj.length < 5 && noticetext != memory) {
Materialize.toast(escapeHTML(toot.display_name)+"にフォローされました", popup * 1000);
$(".notf-icon_" + tlid).addClass("red-text");
localStorage.setItem("notice-mem", noticetext);
noticetext = "";
}
templete = templete +
'' +
notftext +
'
' +
'
' +
'
' +
escapeHTML(toot.display_name) + '
' +
'
@' +
toot.acct + locked + '
' +
'
' + auth +
'
Follows:' +
toot.following_count +
'
Followers:' + toot.followers_count +
'
' +
'
' +
'
' +
'
';
});
return templete;
}
//クライアントダイアログ
function scrollevent(){}
function todo(){}
function todc(){}
function vis(){ $('#myModal').modal('hide') }
function additional(){}
function re(){ alert("設計中") }