Browse Source

hiding options for the posts those begin with a mention

master
erqan 11 years ago
parent
commit
3c6b307ede
  1. 14
      js/interface_localization.js
  2. 17
      js/options.js
  3. 40
      js/twister_timeline.js
  4. 17
      options.html

14
js/interface_localization.js

@ -211,7 +211,12 @@ if(preferredLanguage == "en"){ @@ -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"){ @@ -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"
};
}

17
js/options.js

@ -247,7 +247,7 @@ var TwisterOptions = function() @@ -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() @@ -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() @@ -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() @@ -281,6 +293,7 @@ var TwisterOptions = function()
this.setUseProxyOpt();
this.setUseProxyForImgOnlyOpt();
this.setSplitPostsOpt();
this.setHideRepliesOpt();
}
}

40
js/twister_timeline.js

@ -140,8 +140,15 @@ function requestGetposts(req) @@ -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) @@ -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) @@ -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() @@ -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;
}

17
options.html

@ -136,6 +136,23 @@ @@ -136,6 +136,23 @@
</div>
</div>
<div class="postboard-display">
<div class="module">
<p class="label"> Postboard displays </p>
<br/>
<div>
<form action="" id="hideRepliesOpt">
<p class="label">Posts that begin with mention</p>
<select name="" id="hideReplies">
<option value="disable">Show all</option>
<option value="only-me">Show only if I am in</option>
<option value="following">Show if it's between users I follow</option>
</select>
</form>
</div>
</div>
</div>
<div class="posts-display">
<div class="module">
<p class="label"> Posts display </p>

Loading…
Cancel
Save