(.+)<\/p>$/,"$1");
+ html = html.replace(/
/, "\n");
+ html = html.replace(/
/, "\n");
+ html = html.replace(/<\/p>/, "\n");
+ html = html.replace(//g, "$1");
+ html=$.strip_tags(html);
+ $("#textarea").val(html);
+ }
+}
//ピン留め
function pin(id, acct_id) {
if ($("#pub_" + id).hasClass("pined")) {
diff --git a/app/js/tl/datails.js b/app/js/tl/datails.js
index 34b7996c..bedafb87 100644
--- a/app/js/tl/datails.js
+++ b/app/js/tl/datails.js
@@ -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();
});
}
diff --git a/app/js/tl/filter.js b/app/js/tl/filter.js
index 398d7c1e..cd0490a9 100644
--- a/app/js/tl/filter.js
+++ b/app/js/tl/filter.js
@@ -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+'(for '+context+'):編集/削除
';
+ });
+ if(filters==""){
+ filters="フィルターはありません
";
+ }
+ $("#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");
+ }
+ });
+ });
+ }
+}
\ No newline at end of file
diff --git a/app/js/tl/mix.js b/app/js/tl/mix.js
index 0ba08740..1a3d2b20 100644
--- a/app/js/tl/mix.js
+++ b/app/js/tl/mix.js
@@ -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