From 3c6b307edef74fbbd43eb545db986f50507d0284 Mon Sep 17 00:00:00 2001 From: erqan Date: Fri, 18 Apr 2014 16:09:23 +0300 Subject: [PATCH 1/4] hiding options for the posts those begin with a mention --- js/interface_localization.js | 14 +++++++++++-- js/options.js | 17 +++++++++++++-- js/twister_timeline.js | 40 ++++++++++++++++++++++++++++++++++-- options.html | 17 +++++++++++++++ 4 files changed, 82 insertions(+), 6 deletions(-) diff --git a/js/interface_localization.js b/js/interface_localization.js index 3efedb6..f379811 100644 --- a/js/interface_localization.js +++ b/js/interface_localization.js @@ -211,7 +211,12 @@ if(preferredLanguage == "en"){ "Split only new post": "Split only new post", "Split all": "Split all", "Don't split": "Don't split", - "Split long posts": "Split long posts" + "Split long posts": "Split long posts", + "Posts that begin with mention": "Posts that begin with mention", + "Show all": "Show all", + "Show only if I am in": "Show only if I am in", + "Show if it's between users I follow": "Show if it's between users I follow", + "Postboard displays": "Postboard displays" }; } if(preferredLanguage == "es"){ @@ -1822,7 +1827,12 @@ if(preferredLanguage == "tr"){ "Split only new post": "Sadece yeni postaları böl", "Split all": "Hepsini böl", "Don't split": "Bölme", - "Split long posts": "Uzun gönderileri böl" + "Split long posts": "Uzun gönderileri böl", + "Posts that begin with mention": "Bahsettiği kullanıcının adıyla başlayan gönderiler", + "Show all": "Hepsini göster", + "Show only if I am in": "Sadece ben içindeysem göster", + "Show if it's between users I follow": "Takip ettiğim kullanıcılar arasında ise göster", + "Postboard displays": "Zaman çizelgesinde" }; } diff --git a/js/options.js b/js/options.js index 6bdcb53..1410d17 100644 --- a/js/options.js +++ b/js/options.js @@ -247,7 +247,7 @@ var TwisterOptions = function() return $.Options.getOption('splitPosts', 'disable'); } - this.setSplitPostsOpt = function (){ + this.setSplitPostsOpt = function () { $('#splitPosts')[0].value = this.getSplitPostsOpt(); if (this.getSplitPostsOpt() === 'enable') @@ -255,7 +255,7 @@ var TwisterOptions = function() else $("#splitPostWarning")[0].style.display = "none"; - $('#splitPosts').on('change', function (){ + $('#splitPosts').on('change', function () { $.Options.setOption(this.id, this.value); if (this.value === 'enable') @@ -265,6 +265,18 @@ var TwisterOptions = function() }); } + this.getHideRepliesOpt = function () { + return $.Options.getOption('hideReplies', 'following'); + } + + this.setHideRepliesOpt = function () { + $('#hideReplies')[0].value = this.getHideRepliesOpt(); + + $('#hideReplies').on('change', function () { + $.Options.setOption(this.id, this.value); + }); + } + this.InitOptions = function() { this.soundNotifOptions(); this.volumeControl(); @@ -281,6 +293,7 @@ var TwisterOptions = function() this.setUseProxyOpt(); this.setUseProxyForImgOnlyOpt(); this.setSplitPostsOpt(); + this.setHideRepliesOpt(); } } diff --git a/js/twister_timeline.js b/js/twister_timeline.js index 755d759..6b8f710 100644 --- a/js/twister_timeline.js +++ b/js/twister_timeline.js @@ -140,8 +140,15 @@ function requestGetposts(req) // request if needed function processReceivedPosts(req, posts) { + //hiding posts can cause empty postboard, so we have to track the count... + var p2a = posts.length; for( var i = 0; i < posts.length; i++ ) { var post = posts[i]; + if (willBeHiden(post)) { + p2a--; + continue; + } + var streamPost = postToElem(post, "original"); var timePost = post["userpost"]["time"]; streamPost.attr("data-time",timePost); @@ -192,11 +199,15 @@ function processReceivedPosts(req, posts) } req.doneReportProcessing(posts.length); - if( req.mode == "done" ) { + //if the count of posts less then 5.... + if( req.mode == "done" && p2a > 5) { timelineLoaded = true; $.MAL.postboardLoaded(); _refreshInProgress = false; } else { + //we will request more older post... + req.count += postsPerRefresh; + req.mode = 'older'; requestGetposts(req); } } @@ -266,7 +277,15 @@ function processLastHave(userHaves) // callback for getposts to update the number of new pending posts not shown in timeline function processNewPostsConfirmation(expected, posts) { - _newPostsPending += posts.length; + //we don't want to produce alert for the posts that won't be displayed + var p2h = 0; + for( var i = posts.length-1; i >= 0; i-- ) { + if (willBeHiden(posts[i])) { + //posts.splice(i, 1); + p2h++; + } + } + _newPostsPending += posts.length - p2h; if( _newPostsPending ) { $.MAL.reportNewPosts(_newPostsPending); } @@ -288,3 +307,20 @@ function timelineChangedUser() _newPostsPending = 0; timelineLoaded = false; } + +function willBeHiden(post){ + var msg = post['userpost']['msg']; + if (post['userpost']['n'] !== defaultScreenName && + $.Options.getHideRepliesOpt() !== 'disable' && + /^\@/.test(msg) && + !(new RegExp('@' + defaultScreenName + '( |,|;|\\.|:|\\/|\\?|\\!|\\\\|\'|"|\\n|$)').test(msg))) + { + if ($.Options.getHideRepliesOpt() === 'only-me' || + ($.Options.getHideRepliesOpt() === 'following' && + followingUsers.indexOf(msg.substring(1, msg.search(/ |,|;|\.|:|\/|\?|\!|\\|'|"|\n/))) === -1 )) + { + return true + } + } + return false; +} \ No newline at end of file diff --git a/options.html b/options.html index cdb7abc..8da9846 100644 --- a/options.html +++ b/options.html @@ -136,6 +136,23 @@ +
+
+

Postboard displays

+
+
+
+

Posts that begin with mention

+ +
+
+
+
+

Posts display

From 4024c5fce4fad1a38dc36da627ebf9c4507f47da Mon Sep 17 00:00:00 2001 From: erqan Date: Sun, 20 Apr 2014 00:39:17 +0300 Subject: [PATCH 2/4] hiding options for RTs those are sent originally by following users --- js/interface_localization.js | 12 ++++++++-- js/options.js | 45 ++++++++++++++++++++++++++++++++++++ js/twister_timeline.js | 11 ++++++++- options.html | 13 +++++++++++ 4 files changed, 78 insertions(+), 3 deletions(-) diff --git a/js/interface_localization.js b/js/interface_localization.js index f379811..3c9ee55 100644 --- a/js/interface_localization.js +++ b/js/interface_localization.js @@ -216,7 +216,11 @@ if(preferredLanguage == "en"){ "Show all": "Show all", "Show only if I am in": "Show only if I am in", "Show if it's between users I follow": "Show if it's between users I follow", - "Postboard displays": "Postboard displays" + "Postboard displays": "Postboard displays", + "RTs those are close to original twist": "RTs those are close to original twist", + "Show if the original is older than": "Show if the original is older than", + "hour(s)": "hour(s)", + "only numbers are allowed!": "only numbers are allowed!" }; } if(preferredLanguage == "es"){ @@ -1832,7 +1836,11 @@ if(preferredLanguage == "tr"){ "Show all": "Hepsini göster", "Show only if I am in": "Sadece ben içindeysem göster", "Show if it's between users I follow": "Takip ettiğim kullanıcılar arasında ise göster", - "Postboard displays": "Zaman çizelgesinde" + "Postboard displays": "Zaman çizelgesinde", + "RTs those are close to original twist": "Orjinal twist'e yakın olan RTler", + "Show if the original is older than": "Orjinali yandaki süreden daha eskiyse göster", + "hour(s)": "saat", + "only numbers are allowed!": "sadece rakam girilebilir!" }; } diff --git a/js/options.js b/js/options.js index 1410d17..72aa037 100644 --- a/js/options.js +++ b/js/options.js @@ -277,6 +277,49 @@ var TwisterOptions = function() }); } + this.getHideCloseRTsOpt = function () { + return $.Options.getOption('hideCloseRTs', 'disable'); + }; + + this.setHideCloseRTsOpt = function () { + $('#hideCloseRTs')[0].value = this.getHideCloseRTsOpt(); + + if (this.getHideCloseRTsOpt() === 'disable') { + $('#hideCloseRTsDesc')[0].style.display = 'none'; + } else { + $('#hideCloseRTsDesc')[0].style.display = 'inline'; + } + + $('#hideCloseRTs').on('change', function () { + $.Options.setOption(this.id, this.value); + + if (this.value === 'disable') { + $('#hideCloseRTsDesc')[0].style.display = 'none'; + } else { + $('#hideCloseRTsDesc')[0].style.display = 'inline'; + } + }); + }; + + this.getHideCloseRTsHourOpt = function () { + return parseInt($.Options.getOption('hideCloseRtsHour', '1')); + }; + + this.setHideCloseRTsHourOpt = function () { + $('#hideCloseRtsHour')[0].value = this.getHideCloseRTsHourOpt().toString(); + + $('#hideCloseRtsHour').on('keyup', function () { + if (/^\d+$/.test(this.value)) { + this.style.backgroundColor = ''; + $.Options.setOption(this.id, this.value); + $(this).next('span').text(polyglot.t('hour(s)')); + } else { + this.style.backgroundColor = '#f00'; + $(this).next('span').text(polyglot.t('only numbers are allowed!')); + } + }); + }; + this.InitOptions = function() { this.soundNotifOptions(); this.volumeControl(); @@ -294,6 +337,8 @@ var TwisterOptions = function() this.setUseProxyForImgOnlyOpt(); this.setSplitPostsOpt(); this.setHideRepliesOpt(); + this.setHideCloseRTsHourOpt(); + this.setHideCloseRTsOpt(); } } diff --git a/js/twister_timeline.js b/js/twister_timeline.js index 6b8f710..67db343 100644 --- a/js/twister_timeline.js +++ b/js/twister_timeline.js @@ -319,8 +319,17 @@ function willBeHiden(post){ ($.Options.getHideRepliesOpt() === 'following' && followingUsers.indexOf(msg.substring(1, msg.search(/ |,|;|\.|:|\/|\?|\!|\\|'|"|\n/))) === -1 )) { - return true + return true; } } + + if (typeof(post['userpost']['rt']) !== 'undefined' && + $.Options.getHideCloseRTsOpt() != 'disable' && + followingUsers.indexOf(post['userpost']['rt']['n']) > -1 && + parseInt(post['userpost']['time']) - parseInt(post['userpost']['rt']['time']) < $.Options.getHideCloseRTsHourOpt() * 3600) + { + return true; + } + return false; } \ No newline at end of file diff --git a/options.html b/options.html index 8da9846..c354289 100644 --- a/options.html +++ b/options.html @@ -150,6 +150,19 @@
+
+
+
+

RTs those are close to original twist

+ +
+ hour(s) +
+
+
From c879a8573499a7fccec4951a5abea386e26ac7e2 Mon Sep 17 00:00:00 2001 From: erqan Date: Mon, 21 Apr 2014 14:46:57 +0300 Subject: [PATCH 3/4] own retwists are set to be displayed always --- js/twister_timeline.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/js/twister_timeline.js b/js/twister_timeline.js index 67db343..280f489 100644 --- a/js/twister_timeline.js +++ b/js/twister_timeline.js @@ -310,8 +310,11 @@ function timelineChangedUser() function willBeHiden(post){ var msg = post['userpost']['msg']; - if (post['userpost']['n'] !== defaultScreenName && - $.Options.getHideRepliesOpt() !== 'disable' && + + if (post['userpost']['n'] === defaultScreenName) + return false; + + if ($.Options.getHideRepliesOpt() !== 'disable' && /^\@/.test(msg) && !(new RegExp('@' + defaultScreenName + '( |,|;|\\.|:|\\/|\\?|\\!|\\\\|\'|"|\\n|$)').test(msg))) { From 4f8bcf5e8014343290f071e488f755e8151266fc Mon Sep 17 00:00:00 2001 From: erqan Date: Fri, 25 Apr 2014 01:27:11 +0300 Subject: [PATCH 4/4] RT of any hidden post will be displayed --- js/twister_timeline.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/js/twister_timeline.js b/js/twister_timeline.js index 280f489..e77c0a7 100644 --- a/js/twister_timeline.js +++ b/js/twister_timeline.js @@ -144,7 +144,7 @@ function processReceivedPosts(req, posts) var p2a = posts.length; for( var i = 0; i < posts.length; i++ ) { var post = posts[i]; - if (willBeHiden(post)) { + if (willBeHidden(post)) { p2a--; continue; } @@ -280,8 +280,7 @@ function processNewPostsConfirmation(expected, posts) //we don't want to produce alert for the posts that won't be displayed var p2h = 0; for( var i = posts.length-1; i >= 0; i-- ) { - if (willBeHiden(posts[i])) { - //posts.splice(i, 1); + if (willBeHidden(posts[i])) { p2h++; } } @@ -308,8 +307,9 @@ function timelineChangedUser() timelineLoaded = false; } -function willBeHiden(post){ +function willBeHidden(post){ var msg = post['userpost']['msg']; + var hidden = false; if (post['userpost']['n'] === defaultScreenName) return false; @@ -322,7 +322,7 @@ function willBeHiden(post){ ($.Options.getHideRepliesOpt() === 'following' && followingUsers.indexOf(msg.substring(1, msg.search(/ |,|;|\.|:|\/|\?|\!|\\|'|"|\n/))) === -1 )) { - return true; + hidden = true; } } @@ -331,8 +331,11 @@ function willBeHiden(post){ followingUsers.indexOf(post['userpost']['rt']['n']) > -1 && parseInt(post['userpost']['time']) - parseInt(post['userpost']['rt']['time']) < $.Options.getHideCloseRTsHourOpt() * 3600) { - return true; + if (hidden) + return false; + else + return true; } - return false; + return hidden; } \ No newline at end of file