mirror of
https://github.com/twisterarmy/twister-calm.git
synced 2025-03-13 05:51:07 +00:00
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.
This commit is contained in:
parent
d68f7420e5
commit
15a8a38fae
@ -138,6 +138,12 @@ var TwisterOptions = function()
|
|||||||
$.Options.setOption(this.id, this.value);
|
$.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.initOptions = function() {
|
||||||
this.soundNotifOptions();
|
this.soundNotifOptions();
|
||||||
this.volumeControl();
|
this.volumeControl();
|
||||||
@ -145,6 +151,7 @@ var TwisterOptions = function()
|
|||||||
this.locLang();
|
this.locLang();
|
||||||
this.showPreviewOpt();
|
this.showPreviewOpt();
|
||||||
this.imgPreviwProxy();
|
this.imgPreviwProxy();
|
||||||
|
this.showAlienReply();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -138,10 +138,18 @@ function requestGetposts(req)
|
|||||||
// callback to getposts rpc when updating the timeline
|
// callback to getposts rpc when updating the timeline
|
||||||
// process the received posts (adding them to screen) and do another
|
// process the received posts (adding them to screen) and do another
|
||||||
// request if needed
|
// 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++ ) {
|
for( var i = 0; i < posts.length; i++ ) {
|
||||||
var post = posts[i];
|
var post = posts[i];
|
||||||
|
if (showAlienReplyOpt !== 'all') {
|
||||||
|
if (willBeHidden(post)) {
|
||||||
|
p2a--;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
var streamPost = postToElem(post, "original");
|
var streamPost = postToElem(post, "original");
|
||||||
var timePost = post["userpost"]["time"];
|
var timePost = post["userpost"]["time"];
|
||||||
streamPost.attr("data-time",timePost);
|
streamPost.attr("data-time",timePost);
|
||||||
@ -192,11 +200,15 @@ function processReceivedPosts(req, posts)
|
|||||||
}
|
}
|
||||||
req.doneReportProcessing(posts.length);
|
req.doneReportProcessing(posts.length);
|
||||||
|
|
||||||
if( req.mode == "done" ) {
|
//if the count of posts less then 5....
|
||||||
|
if( req.mode == "done" && p2a > 5 ) {
|
||||||
timelineLoaded = true;
|
timelineLoaded = true;
|
||||||
$.MAL.postboardLoaded();
|
$.MAL.postboardLoaded();
|
||||||
_refreshInProgress = false;
|
_refreshInProgress = false;
|
||||||
} else {
|
} else {
|
||||||
|
//we will request more older post...
|
||||||
|
req.count += postsPerRefresh;
|
||||||
|
req.mode = 'older';
|
||||||
requestGetposts(req);
|
requestGetposts(req);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -267,6 +279,16 @@ function processLastHave(userHaves)
|
|||||||
function processNewPostsConfirmation(expected, posts)
|
function processNewPostsConfirmation(expected, posts)
|
||||||
{
|
{
|
||||||
_newPostsPending += posts.length;
|
_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 ) {
|
if( _newPostsPending ) {
|
||||||
$.MAL.reportNewPosts(_newPostsPending);
|
$.MAL.reportNewPosts(_newPostsPending);
|
||||||
}
|
}
|
||||||
@ -288,3 +310,19 @@ function timelineChangedUser()
|
|||||||
_newPostsPending = 0;
|
_newPostsPending = 0;
|
||||||
timelineLoaded = false;
|
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
72
options.html
@ -54,9 +54,9 @@
|
|||||||
<div class="wrapper optionsPage">
|
<div class="wrapper optionsPage">
|
||||||
|
|
||||||
<div class="module">
|
<div class="module">
|
||||||
<h1>Use language</h1>
|
<h1>Interface</h1>
|
||||||
<div>
|
<h2>Language</h2>
|
||||||
<select name="" id="locLang">
|
<select id="locLang">
|
||||||
<option value="auto">Auto</option>
|
<option value="auto">Auto</option>
|
||||||
<option value="pt-BR">Braz. Portuguese</option>
|
<option value="pt-BR">Braz. Portuguese</option>
|
||||||
<option value="zh">Chinese</option>
|
<option value="zh">Chinese</option>
|
||||||
@ -70,9 +70,40 @@
|
|||||||
<option value="es">Spanish</option>
|
<option value="es">Spanish</option>
|
||||||
<option value="tr">Turkish</option>
|
<option value="tr">Turkish</option>
|
||||||
</select>
|
</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>
|
||||||
|
|
||||||
<div class="module">
|
<div class="module">
|
||||||
<h1>Sound notifications</h1>
|
<h1>Sound notifications</h1>
|
||||||
<h2>Mentions</h2>
|
<h2>Mentions</h2>
|
||||||
@ -105,37 +136,6 @@
|
|||||||
<option value="2">Ctrl/Cmd+Enter</option>
|
<option value="2">Ctrl/Cmd+Enter</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</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>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user