Browse Source

Not to show posts begins with alien mention

Ability not to show posts that begins with another user's @username in
timeline. Integrated from twister-html repo.
master
Hedgehog 11 years ago
parent
commit
15a8a38fae
  1. 7
      js/options.js
  2. 44
      js/twister_timeline.js
  3. 72
      options.html

7
js/options.js

@ -138,6 +138,12 @@ var TwisterOptions = function() @@ -138,6 +138,12 @@ var TwisterOptions = function()
$.Options.setOption(this.id, this.value);
})
}
this.showAlienReply = function () {
$('#showAlienReply').val($.Options.getOption('showAlienReply', 'all'));
$('#showAlienReply').on('change', function () {
$.Options.setOption(this.id, this.value);
})
}
this.initOptions = function() {
this.soundNotifOptions();
this.volumeControl();
@ -145,6 +151,7 @@ var TwisterOptions = function() @@ -145,6 +151,7 @@ var TwisterOptions = function()
this.locLang();
this.showPreviewOpt();
this.imgPreviwProxy();
this.showAlienReply();
}
}

44
js/twister_timeline.js

@ -138,10 +138,18 @@ function requestGetposts(req) @@ -138,10 +138,18 @@ function requestGetposts(req)
// callback to getposts rpc when updating the timeline
// process the received posts (adding them to screen) and do another
// request if needed
function processReceivedPosts(req, posts)
{
function processReceivedPosts(req, posts) {
//hiding posts can cause empty postboard, so we have to track the count...
var p2a = posts.length;
var showAlienReplyOpt = $.Options.getOption("showAlienReply", "only-me");
for( var i = 0; i < posts.length; i++ ) {
var post = posts[i];
if (showAlienReplyOpt !== 'all') {
if (willBeHidden(post)) {
p2a--;
continue;
}
}
var streamPost = postToElem(post, "original");
var timePost = post["userpost"]["time"];
streamPost.attr("data-time",timePost);
@ -192,11 +200,15 @@ function processReceivedPosts(req, posts) @@ -192,11 +200,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);
}
}
@ -267,6 +279,16 @@ function processLastHave(userHaves) @@ -267,6 +279,16 @@ function processLastHave(userHaves)
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 +310,19 @@ function timelineChangedUser() @@ -288,3 +310,19 @@ function timelineChangedUser()
_newPostsPending = 0;
timelineLoaded = false;
}
function willBeHidden(post){
var msg = post['userpost']['msg'];
if (post['userpost']['n'] !== defaultScreenName &&
$.Options.getOption("showAlienReply", "only-me") !== 'all' &&
/^\@/.test(msg) &&
!(new RegExp('@' + defaultScreenName + '( |,|;|\\.|:|\\/|\\?|\\!|\\\\|\'|"|\\n|$)').test(msg)))
{
if ($.Options.getOption("showAlienReply", "only-me") === 'only-me' ||
($.Options.getOption("showAlienReply", "only-me") === 'following' &&
followingUsers.indexOf(msg.substring(1, msg.search(/ |,|;|\.|:|\/|\?|\!|\\|'|"|\n/))) === -1 ))
{
return true
}
}
return false;
}

72
options.html

@ -54,9 +54,9 @@ @@ -54,9 +54,9 @@
<div class="wrapper optionsPage">
<div class="module">
<h1>Use language</h1>
<div>
<select name="" id="locLang">
<h1>Interface</h1>
<h2>Language</h2>
<select id="locLang">
<option value="auto">Auto</option>
<option value="pt-BR">Braz. Portuguese</option>
<option value="zh">Chinese</option>
@ -70,9 +70,40 @@ @@ -70,9 +70,40 @@
<option value="es">Spanish</option>
<option value="tr">Turkish</option>
</select>
</div>
<h2>Posts that begins with another user's @username</h2>
<select id="showAlienReply">
<option value="all">Show all</option>
<option value="only-me">Only if I'm in</option>
<option value="following">If it's between users I follow</option>
</select>
</div>
<div class="module">
<h1>Media links preview</h1>
<h2>Images preview</h2>
<select name="" id="imagesPreview" class="previewOpt">
<option value="enable">Enable</option>
<option value="disable">Disable</option>
</select>
<label><span>Display GIF images</span><input class="gifCheckBox" type="checkbox" name="imagesPreviewGif"></label>
<h2>Youtube links preview</h2>
<select name="" id="youtubePreview" class="previewOpt">
<option value="enable">Enable</option>
<option value="disable">Disable</option>
</select>
<h2>Vimeo links preview</h2>
<select name="" id="vimeoPreview" class="previewOpt">
<option value="enable">Enable</option>
<option value="disable">Disable</option>
</select>
<h2>Proxy for images preview</h2>
<select name="" id="imgPreviewProxy" class="previewOpt">
<option value="disable">Disable</option>
<option value="https://london-s01-i15-traffic.cyberghostvpn.com/go/browse.php?u=">London</option>
<option value="https://losangeles-s02-i01-traffic.cyberghostvpn.com/go/browse.php?u=">Los Angeles</option>
<option value="https://frankfurt-s02-i01-traffic.cyberghostvpn.com/go/browse.php?u=">Frankfurt</option>
<option value="https://bucharest-s05-i01-traffic.cyberghostvpn.com/go/browse.php?u=">Bucharest</option>
</select>
</div>
<div class="module">
<h1>Sound notifications</h1>
<h2>Mentions</h2>
@ -105,37 +136,6 @@ @@ -105,37 +136,6 @@
<option value="2">Ctrl/Cmd+Enter</option>
</select>
</div>
<div class="module">
<h1>Media links preview</h1>
<h2>Images preview</h2>
<select name="" id="imagesPreview" class="previewOpt">
<option value="enable">Enable</option>
<option value="disable">Disable</option>
</select>
<label><span>Display GIF images</span><input class="gifCheckBox" type="checkbox" name="imagesPreviewGif"></label>
<h2>Youtube links preview</h2>
<select name="" id="youtubePreview" class="previewOpt">
<option value="enable">Enable</option>
<option value="disable">Disable</option>
</select>
<h2>Vimeo links preview</h2>
<select name="" id="vimeoPreview" class="previewOpt">
<option value="enable">Enable</option>
<option value="disable">Disable</option>
</select>
</div>
<div class="module">
<h1>Output proxy</h1>
<h2>Images preview</h2>
<select name="" id="imgPreviewProxy" class="previewOpt">
<option value="disable">Disable</option>
<option value="https://london-s01-i15-traffic.cyberghostvpn.com/go/browse.php?u=">London</option>
<option value="https://losangeles-s02-i01-traffic.cyberghostvpn.com/go/browse.php?u=">Los Angeles</option>
<option value="https://frankfurt-s02-i01-traffic.cyberghostvpn.com/go/browse.php?u=">Frankfurt</option>
<option value="https://bucharest-s05-i01-traffic.cyberghostvpn.com/go/browse.php?u=">Bucharest</option>
</select>
</div>
</body>
</html>

Loading…
Cancel
Save