TheDesk Mio (15.9.0)

This commit is contained in:
cutls
2018-07-17 00:39:06 +09:00
parent 49a45f2ecf
commit faa8b70aff
15 changed files with 567 additions and 66 deletions

View File

@@ -70,8 +70,17 @@ function replyTL(id, acct_id) {
todo(error);
console.error(error);
}).then(function(json) {
var templete = parse([json], '', acct_id);
if(localStorage.getItem("filter_"+ acct_id)!="undefined"){
var mute=getFilterType(JSON.parse(localStorage.getItem("filter_"+ acct_id)),"thread");
}else{
var mute=[];
}
console.log(mute);
var templete = parse([json], '', acct_id,"","",mute);
$("#toot-reply").prepend(templete);
$("#toot-reply .hide").html("フィルターされました。");
$("#toot-reply .by_filter").css("display","block");
$("#toot-reply .by_filter").removeClass("hide");
jQuery("time.timeago").timeago();
if (json.in_reply_to_id) {
replyTL(json.in_reply_to_id, acct_id);
@@ -96,9 +105,16 @@ function context(id, acct_id) {
todo(error);
console.error(error);
}).then(function(json) {
var templete = parse(json.descendants, '', acct_id);
if(localStorage.getItem("filter_"+ acct_id)!="undefined"){
var mute=getFilterType(JSON.parse(localStorage.getItem("filter_"+ acct_id)),"thread");
}else{
var mute=[];
}
var templete = parse(json.descendants, '', acct_id,"","",mute);
$("#toot-after").html(templete);
$("#toot-after .hide").html("フィルターされました。");
$("#toot-after .by_filter").css("display","block");
$("#toot-after .by_filter").removeClass("hide");
jQuery("time.timeago").timeago();
});
}

View File

@@ -1,3 +1,4 @@
/*メディアフィルター機能*/
//各TL上方のMedia[On/Off]
function mediaToggle(tlid) {
var media = localStorage.getItem("media_" + tlid);
@@ -26,3 +27,320 @@ function mediaCheck(tlid) {
$("#timeline_"+tlid).removeClass("media-filter")
}
}
/* 削除追跡*/
function catchToggle(tlid) {
var catchck = localStorage.getItem("catch_" + tlid);
if (catchck) {
localStorage.removeItem("catch_" + tlid);
$("#sta-del-" + tlid).text("Off");
$("#sta-del-" + tlid).css("color",'red');
parseColumn();
} else {
localStorage.setItem("catch_" + tlid, "true");
$("#sta-del-" + tlid).text("On");
$("#sta-del-" + tlid).css("color",'#009688');
$("#timeline_"+tlid).addClass("media-filter");
parseColumn();
}
}
function catchCheck(tlid) {
var catchck = localStorage.getItem("catch_" + tlid);
if (catchck) {
$("#sta-del-" + tlid).text("On");
$("#sta-del-" + tlid).css("color",'#009688');
} else {
$("#sta-del-" + tlid).text("Off");
$("#sta-del-" + tlid).css("color",'red');
}
}
function catchCheck(tlid) {
var catchck = localStorage.getItem("catch_" + tlid);
if (catchck) {
$("#sta-del-" + tlid).text("On");
$("#sta-del-" + tlid).css("color",'#009688');
} else {
$("#sta-del-" + tlid).text("Off");
$("#sta-del-" + tlid).css("color",'red');
}
}
function delreset(tlid){
$("[tlid=" + tlid + "] .by_delcatch").hide();
$("[tlid=" + tlid + "] .by_delcatch").remove();
}
/*ワードフィルター機能*/
function filterToggle(){
if ($("#filter-box").hasClass("hide")) {
$("#filter-box").removeClass("hide");
$("#filter-box").addClass("show");
$("#filter-box").css("top",$('#filter-tgl').offset().top-$('#filter-box').height()/2+"px");
$("#filter-box").css("left",$('#filter-tgl').offset().left-410+"px");
//フィルターロード
} else {
$("#filter-box").removeClass("show");
$("#filter-box").addClass("hide")
}
}
function filter(){
$("#filtered-words").html("");
$("#filter-edit-id").val("")
var acct_id = $("#filter-acct-sel").val();
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_"+ acct_id + "_at");
var start = "https://" + domain + "/api/v1/filters"
console.log(start)
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) {
console.log(json);
if (json) {
var filters = "";
Object.keys(json).forEach(function(key) {
var filterword = json[key];
var context = filterword.context.join(',');
filters = filters + filterword.phrase+'<span class="sml">(for '+context+')</span>:<a onclick="filterEdit(\'' + filterword.id + '\',\'' + acct_id +
'\')" class="pointer">編集</a>/<a onclick="filterDel(' + filterword.id + ',' + acct_id +
')" class="pointer">削除</a><br> ';
});
if(filters==""){
filters="フィルターはありません<br>";
}
$("#filtered-words").html(filters);
}else{
$("#filtered-words").html("フィルターはありません");
}
});
}
function makeNewFilter(){
var acct_id = $("#filter-acct-sel").val();
var phr=$("#filter-add-word").val();
var cont=[];
if($("#home_filter:checked").val()){
cont.push("home");
}
if($("#local_filter:checked").val()){
cont.push("public");
}
if($("#notf_filter:checked").val()){
cont.push("notifications");
}
if($("#conv_filter:checked").val()){
cont.push("thread");
}
console.log(cont);
if(!cont.length){
$("#filtered-words").html('Error:適応範囲を最低一つ以上チェックしてください。');
}
var exc=$("#except_filter:checked").val();
var who=$("#wholeword_filter:checked").val();
var time=$("#days_filter").val()*24*60*60+$("#hours_filter").val()*60*60+$("#mins_filter").val()*60;
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_"+ acct_id + "_at");
if($("#filter-edit-id").val()){
var start = "https://" + domain + "/api/v1/filters/"+$("#filter-edit-id").val();
var method="PUT"
}else{
var start = "https://" + domain + "/api/v1/filters"
var method="POST"
}
var httpreq = new XMLHttpRequest();
httpreq.open(method, start, true);
httpreq.setRequestHeader('Content-Type', 'application/json');
httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
httpreq.responseType = 'json';
httpreq.send(JSON.stringify({
phrase: phr,
context: cont,
irreversible: exc,
whole_word:who,
expires_in:time
}));
httpreq.onreadystatechange = function() {
if (httpreq.readyState == 4) {
var json = httpreq.response;
filter();
filterUpdate(acct_id)
$("#filter-add-word").val("");
$("#home_filter").prop("checked",false);
$("#local_filter").prop("checked",false);
$("#notf_filter").prop("checked",false);
$("#conv_filter").prop("checked",false);
$("#except_filter").prop("checked",false);
$("#wholeword_filter").prop("checked",false);
$("#days_filter").val("0");
$("#hours_filter").val("0");
$("#mins_filter").val("0");
$("#add-filter-btn").text("追加");
$("#filter-edit-id").val("")
}
}
}
function filterEdit(id,acct_id){
$("#filter-add-word").val("");
$("#home_filter").prop("checked",false);
$("#local_filter").prop("checked",false);
$("#notf_filter").prop("checked",false);
$("#conv_filter").prop("checked",false);
$("#except_filter").prop("checked",false);
$("#wholeword_filter").prop("checked",false);
$("#days_filter").val("0");
$("#hours_filter").val("0");
$("#mins_filter").val("0");
$("#add-filter-btn").text("編集");
$("#filter-edit-id").val(id);
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_"+ acct_id + "_at");
var start = "https://" + domain + "/api/v1/filters/"+id
console.log(start)
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) {
console.log(json);
if (json) {
var now = new Date() ;
now = now.getTime() ;
var now = Math.floor(now / 1000 ) ;
$("#filter-add-word").val(json.phrase);
Object.keys(json.context).forEach(function(key) {
var context = json.context[key];
$("[value="+context+"]").prop("checked",true);
});
if(json.irreversible){
$("#except_filter").prop("checked",true);
}
if(json.whole_word){
$("#wholeword_filter").prop("checked",true);
}
var expires=date(json.expires_at, 'unix')-now;
var mins=Math.floor(expires/60)%60;
var hours=Math.floor(expires/3600)%24;
var days=Math.floor(expires/3600/24);
$("#days_filter").val(days);
$("#hours_filter").val(hours);
$("#mins_filter").val(mins);
}
});
}
function filterDel(id,acct_id){
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_"+ acct_id + "_at");
var start = "https://" + domain + "/api/v1/filters/"+id;
var httpreq = new XMLHttpRequest();
httpreq.open("DELETE", start, true);
httpreq.setRequestHeader('Content-Type', 'application/json');
httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
httpreq.responseType = 'json';
httpreq.send();
httpreq.onreadystatechange = function() {
if (httpreq.readyState == 4) {
var json = httpreq.response;
filter();
filterUpdate(acct_id)
}
}
}
function getFilter(acct_id){
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_"+ acct_id + "_at");
var start = "https://" + domain + "/api/v1/filters"
console.log(start)
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) {
localStorage.setItem("filter_"+ acct_id ,JSON.stringify(json));
});
}
function getFilterType(json,type){
if(type=="local"){
type="public";
}else if(type=="list"){
type="home";
}else if(type=="notf"){
type="notifi";
}
var mutedfilters=[];
Object.keys(json).forEach(function(key) {
var filterword = json[key];
var phrases = filterword.phrase;
if(filterword.context.join(",").indexOf(type)!== -1){
mutedfilters.push(phrases);
}
});
return mutedfilters;
}
function filterUpdate(acct_id){
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_"+ acct_id + "_at");
var start = "https://" + domain + "/api/v1/filters"
console.log(start)
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) {
localStorage.setItem("filter_"+ acct_id ,JSON.stringify(json));
filterUpdateInternal(json,"home");
filterUpdateInternal(json,"local");
filterUpdateInternal(json,"notf");
filterUpdateInternal(json,"pub");
});
}
function filterUpdateInternal(json,type){
var home=getFilterType(json,type);
var wordmute = localStorage.getItem("word_mute");
if(wordmute){
var wordmute = JSON.parse(wordmute);
home = home.concat(wordmute);
}
if(home){
$("[data-acct="+acct_id+"] [data-type="+type+"] .cvo").each(function(i, elem) {
var id=$(elem).attr("toot-id");
$("[toot-id="+id+"]").removeClass("hide");
var text=$(elem).find('.toot').html();
Object.keys(home).forEach(function(key8) {
var word = home[key8];
var regExp = new RegExp( word, "g" );
if($.strip_tags(text).match(regExp)){
$("[toot-id="+id+"]").addClass("hide");
}
});
});
}
}

View File

@@ -1,6 +1,6 @@
//Integrated TL
function mixtl(acct_id, tlid, type) {
console.log(type);
function mixtl(acct_id, tlid, type,delc) {
console.log(delc);
localStorage.removeItem("morelock")
localStorage.setItem("now", type);
todo("Integrated TL Loading...(Local)");
@@ -48,11 +48,16 @@ function mixtl(acct_id, tlid, type) {
var pkey=key*1+1;
if(pkey<timeline.length){
if(date(timeline[key].created_at,"unix")!=date(timeline[pkey].created_at,"unix")){
if(localStorage.getItem("filter_"+ acct_id)!="undefined"){
var mute=getFilterType(JSON.parse(localStorage.getItem("filter_"+ acct_id)),"mix");
}else{
var mute=[];
}
if(type=="integrated"){
templete = templete+parse([timeline[key]], '', acct_id, tlid);
templete = templete+parse([timeline[key]], '', acct_id, tlid, "", mute);
}else if(type=="plus"){
if(timeline[key].account.acct==timeline[key].account.username){
templete = templete+parse([timeline[key]], '', acct_id, tlid);
templete = templete+parse([timeline[key]], '', acct_id, tlid, "", mute);
}
}
@@ -62,7 +67,7 @@ function mixtl(acct_id, tlid, type) {
});
$("#timeline_" + tlid).html(templete);
mixre(acct_id, tlid, type);
mixre(acct_id, tlid, type, mute,delc);
additional(acct_id, tlid);
jQuery("time.timeago").timeago();
todc();
@@ -72,7 +77,7 @@ function mixtl(acct_id, tlid, type) {
//Streamingに接続
function mixre(acct_id, tlid, TLtype) {
function mixre(acct_id, tlid, TLtype, mute,delc) {
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_"+ acct_id + "_at");
var startHome = "wss://" + domain +
@@ -99,10 +104,16 @@ function mixre(acct_id, tlid, TLtype) {
console.log(obj);
var type = JSON.parse(mess.data).event;
if (type == "delete") {
$("[toot-id=" + JSON.parse(mess.data).payload + "]").hide();
$("[toot-id=" + JSON.parse(mess.data).payload + "]").remove();
if(delc=="true"){
$("#timeline_"+tlid+" [toot-id=" + JSON.parse(mess.data).payload + "]").addClass("emphasized");
$("#timeline_"+tlid+" [toot-id=" + JSON.parse(mess.data).payload + "]").addClass("by_delcatch");
}else{
$("[toot-id=" + JSON.parse(mess.data).payload + "]").hide();
$("[toot-id=" + JSON.parse(mess.data).payload + "]").remove();
}
} else if (type == "update") {
var templete = parse([obj], '', acct_id, tlid);
var templete = parse([obj], '', acct_id, tlid,"",mute);
if (!$("#timeline_"+tlid+" [toot-id="+obj.id+"]").length) {
var pool = localStorage.getItem("pool_" + tlid);
if (pool && templete) {
@@ -126,14 +137,19 @@ function mixre(acct_id, tlid, TLtype) {
console.log(obj);
var type = JSON.parse(mess.data).event;
if (type == "delete") {
$("[toot-id=" + JSON.parse(mess.data).payload + "]").hide();
$("[toot-id=" + JSON.parse(mess.data).payload + "]").remove();
if(delc=="true"){
$("[toot-id=" + JSON.parse(mess.data).payload + "]").addClass("emphasized");
$("[toot-id=" + JSON.parse(mess.data).payload + "]").addClass("by_delcatch");
}else{
$("[toot-id=" + JSON.parse(mess.data).payload + "]").hide();
$("[toot-id=" + JSON.parse(mess.data).payload + "]").remove();
}
} else if (type == "update") {
if(TLtype=="integrated"){
var templete = parse([obj], '', acct_id, tlid);
}else if(TLtype=="plus"){
if(obj.account.acct==obj.account.username){
var templete = parse([obj], '', acct_id, tlid);
var templete = parse([obj], '', acct_id, tlid,"",mute);
}else{
var templete="";
}
@@ -212,11 +228,16 @@ function mixmore(tlid,type) {
var pkey=key*1+1;
if(pkey<20){
if(date(timeline[key].created_at,"unix")!=date(timeline[pkey].created_at,"unix")){
if(localStorage.getItem("filter_"+ acct_id)!="undefined"){
var mute=getFilterType(JSON.parse(localStorage.getItem("filter_"+ acct_id)),"mix");
}else{
var mute=[];
}
if(type=="integrated"){
templete = templete+parse([timeline[key]], '', acct_id, tlid);
templete = templete+parse([timeline[key]], '', acct_id, tlid,"",mute);
}else if(type=="plus"){
if(timeline[key].account.acct==timeline[key].account.username){
templete = templete+parse([timeline[key]], '', acct_id, tlid);
templete = templete+parse([timeline[key]], '', acct_id, tlid,"",mute);
}
}
}

View File

@@ -22,8 +22,10 @@ function notf(acct_id, tlid, sys) {
todo(error);
console.error(error);
}).then(function(json) {
if(json[0]){
var templete="";
var lastnotf=localStorage.getItem("lastnotf_" + acct_id);
console.log(domain);
localStorage.setItem("lastnotf_" + acct_id,json[0].id);
Object.keys(json).forEach(function(key) {
var obj = json[key];
@@ -37,7 +39,7 @@ function notf(acct_id, tlid, sys) {
var os = electron.remote.process.platform;
var options = {
body: ct+"件の新しい通知",
icon: tlocalStorage.getItem("prof_"+acct_id)
icon: localStorage.getItem("prof_"+acct_id)
};
if(os=="darwin"){
var n = new Notification('TheDesk:'+domain, options);
@@ -46,12 +48,16 @@ function notf(acct_id, tlid, sys) {
}
}
if(localStorage.getItem("filter_"+ acct_id)!="undefined"){
var mute=getFilterType(JSON.parse(localStorage.getItem("filter_"+ acct_id)),"notif");
}else{
var mute=[];
}
if(obj.type!="follow"){
templete = templete+parse([obj], 'notf', acct_id, 'notf', -1);
templete = templete+parse([obj], 'notf', acct_id, 'notf', -1, mute);
}else{
templete = templete+userparse([obj.account], 'notf', acct_id, 'notf', -1);
}
});
if (sys == "direct") {
@@ -61,6 +67,7 @@ function notf(acct_id, tlid, sys) {
}
jQuery("time.timeago").timeago();
}
$("#notf-box").addClass("fetched");
todc();
});

View File

@@ -1,8 +1,8 @@
//オブジェクトパーサー(トゥート)
function parse(obj, mix, acct_id, tlid, popup) {
function parse(obj, mix, acct_id, tlid, popup, mutefilter) {
var templete = '';
var actb = localStorage.getItem("action_btns");
var actb='re,rt,fav,qt,del,pin';
var actb='re,rt,fav,qt,del,pin,red';
if(actb){
var actb = actb.split(',');
var disp={};
@@ -55,7 +55,13 @@ function parse(obj, mix, acct_id, tlid, popup) {
var wordmute = localStorage.getItem("word_mute");
if(wordmute){
var wordmute = JSON.parse(wordmute);
wordmute = wordmute.concat(mutefilter);
}else{
wordmute = mutefilter;
}
if (!sent) {
var sent = 500;
}
@@ -368,12 +374,14 @@ function parse(obj, mix, acct_id, tlid, popup) {
}
var mediack = toot.media_attachments[0];
//メディアがあれば
var media_ids="";
if (mediack) {
hasmedia = "hasmedia";
var cwdt = 100 / toot.media_attachments.length
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"
@@ -386,6 +394,7 @@ function parse(obj, mix, acct_id, tlid, popup) {
purl + '" class="' + sense +
' toot-img pointer" style="width:' + cwdt + '%; height:'+imh+'px;"></a></span>';
});
media_ids = media_ids.slice(0, -1) ;
} else {
viewer = "";
hasmedia = "nomedia";
@@ -473,10 +482,14 @@ function parse(obj, mix, acct_id, tlid, popup) {
Object.keys(wordmute).forEach(function(key8) {
var worde = wordmute[key8];
if(worde){
var word=worde.tag;
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";
boostback = "hide by_filter";
}
}
});
@@ -500,7 +513,7 @@ function parse(obj, mix, acct_id, tlid, popup) {
}
templete = templete + '<div id="pub_' + toot.id + '" class="cvo ' +
boostback + ' ' + fav_app + ' ' + rt_app + ' ' + pin_app +
' ' + hasmedia + '" toot-id="' + id + '" unixtime="' + date(obj[
' ' + hasmedia + '" toot-id="' + id + '" data-medias="'+media_ids+' " unixtime="' + date(obj[
key].created_at, 'unix') + '" '+if_notf+' onmouseover="mov(\'' + toot.id + '\',\''+tlid+'\')" onmouseout="resetmv()">' +
'<div class="area-notice"><span class="gray sharesta">' + notice + home +
'</span></div>' +
@@ -527,7 +540,7 @@ function parse(obj, mix, acct_id, tlid, popup) {
'</span>' +
'' + mentions + tags + '</div>' +
'<div class="area-vis"></div>'+
'<div class="area-actions '+mouseover+'" style="padding:0; margin:0; top:-20px; display:flex; justify-content:space-around; max-width:100%; ">' +
'<div class="area-actions '+mouseover+'">' +
'<div class="action">'+vis+'</div>'+
'<div class="action '+antinoauth+'"><a onclick="detEx(\''+toot.url+'\',\'main\')" class="waves-effect waves-dark details" style="padding:0">詳細(メインアカウント経由)</a></div>' +
'<div class="action '+disp["re"]+' '+noauth+'"><a onclick="re(\'' + toot.id +
@@ -552,14 +565,17 @@ function parse(obj, mix, acct_id, tlid, popup) {
')" class="waves-effect waves-dark btn-flat" style="padding:0" title="このトゥートを削除"><i class="fa fa-trash-o"></i></a></div>' +
'<div class="' + if_mine + ' action pin '+disp["pin"]+' '+noauth+'"><a onclick="pin(\'' + toot.id + '\',' +
acct_id +
')" class="waves-effect waves-dark btn-flat" style="padding:0" title="このトゥートをピン留め"><i class="fa fa-map-pin pin_' + toot.id + ' '+if_pin+'"></i></a></div>' +trans+
')" class="waves-effect waves-dark btn-flat" style="padding:0" title="このトゥートをピン留め"><i class="fa fa-map-pin pin_' + toot.id + ' '+if_pin+'"></i></a></div>'
+'<div class="' + if_mine + ' action '+disp["red"]+' '+noauth+'"><a onclick="redraft(\'' + toot.id + '\',' +
acct_id +
')" class="waves-effect waves-dark btn-flat" style="padding:0" title="このトゥートを削除して再投稿"><i class="material-icons">redo</i></a></div>'+trans+
'<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>' +
'<div class="action '+noauth+'"><a onclick="details(\'' + toot.id + '\',' + acct_id +
',\''+tlid+'\')" class="waves-effect waves-dark btn-flat details" style="padding:0"><i class="text-darken-3 material-icons">more_vert</i></a></div>' +
'<span class="cbadge waves-effect '+viashow+' '+mine_via+'" onclick="client(\''+$.strip_tags(via)+'\')" title="via ' + $.strip_tags(via) + '">via ' +
via +
'</span></div></div>' +
'</div></div>' + divider;
'</div></div>';
});
if (mix == "mix") {
return [templete, local, times]

View File

@@ -10,7 +10,7 @@ if(location.search){
}
//よく使うタグ
function tagShow(tag){
$("[data-tag="+tag+"]").toggleClass("hide");
$("[data-tag="+decodeURI(tag)+"]").toggleClass("hide");
}
//タグ追加
function tagPin(tag){

View File

@@ -1,5 +1,5 @@
//TL取得
function tl(type, data, acct_id, tlid) {
function tl(type, data, acct_id, tlid, delc) {
scrollevent();
localStorage.removeItem("morelock");
localStorage.removeItem("pool");
@@ -36,14 +36,14 @@ function tl(type, data, acct_id, tlid) {
$("#notice_" + tlid).text("Integrated TL(" + localStorage.getItem(
"user_" + acct_id) + "@" + domain + ")");
$("#notice_icon_" + tlid).text("merge_type");
mixtl(acct_id, tlid, "integrated");
mixtl(acct_id, tlid, "integrated",delc);
return;
}else if (type == "plus") {
//Local+なら飛ばす
$("#notice_" + tlid).text("Local+ TL(" + localStorage.getItem(
"user_" + acct_id) + "@" + domain + ")");
$("#notice_icon_" + tlid).text("people_outline");
mixtl(acct_id, tlid, "plus");
mixtl(acct_id, tlid, "plus",delc);
return;
}else if (type == "notf") {
//通知なら飛ばす
@@ -89,18 +89,24 @@ function tl(type, data, acct_id, tlid) {
todo(error);
console.error(error);
}).then(function(json) {
var templete = parse(json, type, acct_id, tlid);
if(localStorage.getItem("filter_"+ acct_id)!="undefined"){
var mute=getFilterType(JSON.parse(localStorage.getItem("filter_"+ acct_id)),type);
}else{
var mute=[];
}
var templete = parse(json, type, acct_id, tlid, "", mute);
$("#timeline_" + tlid).html(templete);
additional(acct_id, tlid);
jQuery("time.timeago").timeago();
todc();
reload(type, '', acct_id, tlid, data);
reload(type, '', acct_id, tlid, data, mute, delc);
$(window).scrollTop(0);
});
}
//Streaming接続
function reload(type, cc, acct_id, tlid, data) {
function reload(type, cc, acct_id, tlid, data, mute, delc) {
if (!type) {
var type = localStorage.getItem("now");
}
@@ -157,13 +163,19 @@ function reload(type, cc, acct_id, tlid, data) {
var typeA = JSON.parse(mess.data).event;
if (typeA == "delete") {
var obj = JSON.parse(mess.data).payload;
$("[toot-id=" + JSON.parse(mess.data).payload + "]").hide();
$("[toot-id=" + JSON.parse(mess.data).payload + "]").remove();
if(delc=="true"){
$("#timeline_"+tlid+" [toot-id=" + JSON.parse(mess.data).payload + "]").addClass("emphasized");
$("#timeline_"+tlid+" [toot-id=" + JSON.parse(mess.data).payload + "]").addClass("by_delcatch");
}else{
$("[toot-id=" + JSON.parse(mess.data).payload + "]").hide();
$("[toot-id=" + JSON.parse(mess.data).payload + "]").remove();
}
} else if (typeA == "update") {
var obj = JSON.parse(JSON.parse(mess.data).payload);
console.log(obj);
if($("#timeline_" + tlid +" [toot-id=" + obj.id + "]").length < 1){
var templete = parse([obj], type, acct_id, tlid);
var templete = parse([obj], type, acct_id, tlid,"",mute);
var pool = localStorage.getItem("pool_" + tlid);
if (pool) {
pool = templete + pool;
@@ -181,6 +193,8 @@ function reload(type, cc, acct_id, tlid, data) {
}
todc();
}else if(typeA=="filters_changed"){
filterUpdate(acct_id);
}
websocket[wsid].onclose = function(mess) {
console.log("Close Streaming API:" + type);
@@ -241,7 +255,7 @@ function moreload(type, tlid) {
todo(error);
console.error(error);
}).then(function(json) {
var templete = parse(json, '', acct_id, tlid);
var templete = parse(json, '', acct_id, tlid,"",mute);
$("#timeline_" + tlid).append(templete);
additional(acct_id, tlid);
jQuery("time.timeago").timeago();