diff --git a/js/interface_home.js b/js/interface_home.js
index 139d5b5..c034507 100644
--- a/js/interface_home.js
+++ b/js/interface_home.js
@@ -67,22 +67,6 @@ var InterfaceFunctions = function()
$(".dropdown-menu-following").attr("href","#");
$(".dropdown-menu-following").bind("click", function()
{ alert(polyglot.t("You are not following anyone because you are not logged in."))} );
- twisterRpc("gettrendinghashtags", [10],
- function(args, ret) {
- for( var i = 0; i < ret.length; i++ ) {
-
- var $li = $("
");
- var hashtagLinkTemplate = $("#hashtag-link-template").clone(true);
- hashtagLinkTemplate.removeAttr("id");
- hashtagLinkTemplate.attr("href",$.MAL.hashtagUrl(ret[i]));
- hashtagLinkTemplate.text("#"+ret[i]);
- $li.append(hashtagLinkTemplate);
- $(".toptrends-list").append($li);
- }
- }, {},
- function(args, ret) {
- console.log("Error with gettrendinghashtags. Older twister daemon?");
- }, {});
}
else
{
@@ -119,23 +103,6 @@ var InterfaceFunctions = function()
setTimeout("getRandomFollowSuggestion(processSuggestion)", 1000);
setTimeout("getRandomFollowSuggestion(processSuggestion)", 1000);
- twisterRpc("gettrendinghashtags", [10],
- function(args, ret) {
- for( var i = 0; i < ret.length; i++ ) {
-
- var $li = $("");
- var hashtagLinkTemplate = $("#hashtag-link-template").clone(true);
- hashtagLinkTemplate.removeAttr("id");
- hashtagLinkTemplate.attr("href",$.MAL.hashtagUrl(ret[i]));
- hashtagLinkTemplate.text("#"+ret[i]);
- $li.append(hashtagLinkTemplate);
- $(".toptrends-list").append($li);
- }
- }, {},
- function(args, ret) {
- console.log("Error with gettrendinghashtags. Older twister daemon?");
- }, {});
-
if( args.cbFunc )
args.cbFunc(args.cbArg);
}, {cbFunc:cbFunc, cbArg:cbArg});
@@ -154,9 +121,47 @@ var InterfaceFunctions = function()
});
});
}
+
+ setTimeout(updateTrendingHashtags, 1000);
+ setInterval(updateTrendingHashtags, 120*1000); // FIXME should be an option for this
}
};
+function updateTrendingHashtags() {
+ twisterRpc('gettrendinghashtags', [10],
+ function(args, ret) {
+ $('.toptrends-list').empty();
+ //console.log('hashtags trends: '+ret);
+ for( var i = 0; i < ret.length; i++ ) {
+ if ($.Options.getFilterLangForTopTrendsOpt())
+ var langFilterData = filterLang(ret[i]);
+ if (!$.Options.getFilterLangForTopTrendsOpt() || langFilterData['pass'] || $.Options.getFilterLangSimulateOpt()) {
+ var $li = $('');
+ var hashtagLinkTemplate = $('#hashtag-link-template').clone(true);
+
+ hashtagLinkTemplate.removeAttr('id');
+ hashtagLinkTemplate.attr('href',$.MAL.hashtagUrl(ret[i]));
+ hashtagLinkTemplate.text('#'+ret[i]);
+
+ $li.append(hashtagLinkTemplate);
+ if ($.Options.getFilterLangSimulateOpt()) {
+ if (typeof(langFilterData) !== 'undefined') {
+ $li.append(' '+((langFilterData['pass']) ? polyglot.t('passed') : polyglot.t('blocked'))+': '+langFilterData['prob'][0].toString()+'');
+ } else {
+ $li.append(' '+polyglot.t('not analyzed')+'');
+ }
+ }
+
+ $('.toptrends-list').append($li);
+ }
+ }
+ }, {},
+ function(args, ret) {
+ console.log('Error with gettrendinghashtags. Older twister daemon?');
+ }, {}
+ );
+};
+
//***********************************************
//******************* INIT **************
//***********************************************
diff --git a/js/interface_localization.js b/js/interface_localization.js
index 4b0a292..e69c8ae 100644
--- a/js/interface_localization.js
+++ b/js/interface_localization.js
@@ -3125,25 +3125,25 @@ if(preferredLanguage == "tr"){
"hour(s)": "saat",
"second(s)": "saniye",
"only numbers are allowed!": "sadece rakam girilebilir!",
- "Language filtering": "Language filtering",
- "By blacklist": "By blacklist",
- "By whitelist": "By whitelist",
- "Comma separated ISO 639-3 language codes": "Comma separated ISO 639-3 language codes",
- "Accuracy": "Accuracy",
- "Simulation mode": "Simulation mode",
- "This post is treated by language filter": "This post is %{treated} by language filter.",
- "blocked": "blocked",
- "passed": "passed",
- "not analyzed": "not analyzed",
- "Reason: this": "Reason: %{this}",
- "this doesnt contain that": "%{this} does not contain %{that}",
- "blacklist": "blacklist",
- "whitelist": "whitelist",
- "language of this": "language of this",
- "its undefined language": "it is undefined language",
- "its this, blacklisted": "it is %{this}, blacklisted",
- "its this, whitelisted": "it is %{this}, whitelisted",
- "Most possible language: this": "Most possible language: %{this}",
+ "Language filtering": "Dile göre süzme",
+ "By blacklist": "Kara liste ile",
+ "By whitelist": "Beyaz liste ile",
+ "Comma separated ISO 639-3 language codes": "Virgülle ayrılmış ISO 639-3 dil kodları",
+ "Accuracy": "Hassasiyet",
+ "Simulation mode": "Benzetim yap",
+ "This post is treated by language filter": "Bu gönderi dil süzgeci tarafından %{treated}.",
+ "blocked": "engellendi",
+ "passed": "kabul edildi",
+ "not analyzed": "incelenmedi",
+ "Reason: this": "Sebep: %{this}",
+ "this doesnt contain that": "%{that} %{this} tarafından kapsanmıyor",
+ "blacklist": "beyaz liste",
+ "whitelist": "kara liste",
+ "language of this": "dili",
+ "its undefined language": "belirsiz dil",
+ "its this, blacklisted": "%{this}, engellendi",
+ "its this, whitelisted": "%{this}, kabul edildi",
+ "Most possible language: this": "Muhtemel dil: %{this}",
"Show with every user name": "Tüm kullanıcı adlarının yanında göster",
"Show at profile modal only": "Sadece profilinde göster",
"Show if a user follows me": "Bir kullanıcının beni takip edip etmediğini göster",
diff --git a/js/mobile_abstract.js b/js/mobile_abstract.js
index 97d1422..942702a 100644
--- a/js/mobile_abstract.js
+++ b/js/mobile_abstract.js
@@ -488,7 +488,7 @@ var MAL = function()
jQuery.MAL = new MAL;
-function filterLangPost(post) {
+function filterLang(string) {
if ($.Options.getFilterLangOpt() !== 'disable' && $.Options.getFilterLangListOpt().length > 0) {
var langFilterAccuracy = $.Options.getFilterLangAccuracyOpt();
var langFilterList = $.Options.getFilterLangListOpt();
@@ -497,14 +497,18 @@ function filterLangPost(post) {
var langFilterPass = ($.Options.getFilterLangOpt() === 'whitelist') ? false : true;
var langFilterReason = polyglot.t('this doesnt contain that', {'this': polyglot.t($.Options.getFilterLangOpt()), 'that': polyglot.t('language of this')});
- if (typeof(post['userpost']['rt']) !== 'undefined') {
- langFilterSubj = post['userpost']['rt']['msg'];
- } else {
- langFilterSubj = post['userpost']['msg'];
- }
- // we cut out any mentions, links and # symbols from hashtags and clear spaces before detection attempts:
- langFilterSubj = langFilterSubj.replace(/\@\S\w*|https?:\/\/\S*|\#/g, '').replace(/\s+/g, ' ').trim();
- langFilterProb = franc.all(langFilterSubj, {'minLength': 4}); // FIXME minLength may become configurable option at some time
+ // before detection attempts we cut out any mentions and links, and replace _ with space
+ langFilterSubj = string.replace(/@\S\w*|https?:\/\/\S*/g, '').replace(/_+/g, ' ')
+ // replace zero-width word boundaries, such as between letters from different alphabets [or other symbols], with spaces
+ // FIXME not so good idea because 'Za pomocą białej listy' may turn into 'Za pomoc ą bia ł ej listy' for e.g.
+ // FIXME but first one was recognized as 'hrv' and second as 'pol' and you know it's 'pol' actually
+ .replace(/\b/g, ' ')
+ // cut out some more symbols
+ .replace(/[#\[\]\(\)\{\}\-\+\=\^\:\;\\\/]/g, '')
+ // clear unwanted spaces
+ .replace(/\s+/g, ' ').trim();
+
+ langFilterProb = franc.all(langFilterSubj, {'minLength': 2}); // FIXME minLength may become configurable option at some time
for (var i = 0; i < langFilterProb.length; i++) {
if (langFilterProb[i][1] > langFilterAccuracy) {
if (langFilterProb[i][0] === 'und') { // e.g. digits-only string will be detected as undefined and thereby will be allowed
@@ -524,14 +528,9 @@ function filterLangPost(post) {
}
}
}
- post['langFilter'] = {};
- post['langFilter']['subj'] = langFilterSubj;
- post['langFilter']['prob'] = langFilterProb;
- post['langFilter']['pass'] = langFilterPass;
- post['langFilter']['reason'] = langFilterReason;
//console.log('langFilter | status: '+((langFilterPass === true) ? polyglot.t('passed') : polyglot.t('blocked'))+' | reason: '+langFilterReason+' | subject: \''+langFilterSubj+'\'');
- return ($.Options.getFilterLangSimulateOpt()) ? true : langFilterPass;
+ return {'subj': langFilterSubj, 'prob': langFilterProb, 'pass': langFilterPass, 'reason': langFilterReason};
}
}
diff --git a/js/options.js b/js/options.js
index ac22a84..33504c0 100644
--- a/js/options.js
+++ b/js/options.js
@@ -477,6 +477,36 @@ var TwisterOptions = function()
});
}
+ this.getFilterLangForPostboardOpt = function () {
+ return $.Options.getOption('filterLangForPostboard', true);
+ }
+
+ this.setFilterLangForPostboardOpt = function () {
+ $('#filterLangForPostboard').prop('checked', $.Options.getFilterLangForPostboardOpt());
+
+ $('#filterLangForPostboard').on('click', function () {$.Options.setOption(this.id, this.checked);});
+ }
+
+ this.getFilterLangForSearchingOpt = function () {
+ return $.Options.getOption('filterLangForSearching', true);
+ }
+
+ this.setFilterLangForSearchingOpt = function () {
+ $('#filterLangForSearching').prop('checked', $.Options.getFilterLangForSearchingOpt());
+
+ $('#filterLangForSearching').on('click', function () {$.Options.setOption(this.id, this.checked);});
+ }
+
+ this.getFilterLangForTopTrendsOpt = function () {
+ return $.Options.getOption('filterLangForTopTrends', true);
+ }
+
+ this.setFilterLangForTopTrendsOpt = function () {
+ $('#filterLangForTopTrends').prop('checked', $.Options.getFilterLangForTopTrendsOpt());
+
+ $('#filterLangForTopTrends').on('click', function () {$.Options.setOption(this.id, this.checked);});
+ }
+
this.getFilterLangSimulateOpt = function () {
return $.Options.getOption('filterLangSimulate', false);
}
@@ -538,6 +568,9 @@ var TwisterOptions = function()
this.setFilterLangOpt();
this.setFilterLangListOpt();
this.setFilterLangAccuracyOpt();
+ this.setFilterLangForPostboardOpt();
+ this.setFilterLangForSearchingOpt();
+ this.setFilterLangForTopTrendsOpt();
this.setFilterLangSimulateOpt();
this.setIsFollowingMeOpt();
this.setDMCopySelfOpt();
diff --git a/js/twister_actions.js b/js/twister_actions.js
index f25c62a..3c109fe 100644
--- a/js/twister_actions.js
+++ b/js/twister_actions.js
@@ -340,6 +340,22 @@ function processHashtag(postboard, hashtag, data) {
var key = userpost["n"] + ";" + userpost["time"];
if( !(key in _hashtagProcessedMap) ) {
_hashtagProcessedMap[key] = true;
+
+ if ($.Options.getFilterLangForSearchingOpt()) {
+ if (typeof(userpost['rt']) !== 'undefined') {
+ var msg = userpost['rt']['msg'];
+ } else {
+ var msg = userpost['msg'];
+ }
+ langFilterData = filterLang(msg);
+ if ($.Options.getFilterLangSimulateOpt()) {
+ data[i]['langFilter'] = langFilterData;
+ } else {
+ if (!langFilterData['pass'])
+ continue;
+ }
+ }
+
_hashtagPendingPosts.push(data[i]);
_hashtagPendingPostsUpdated++;
}
@@ -363,8 +379,11 @@ function processHashtag(postboard, hashtag, data) {
function displayHashtagPending(postboard) {
for( var i = 0; i < _hashtagPendingPosts.length; i++ ) {
- var streamPost = postToElem(_hashtagPendingPosts[i], "original");
- var timePost = _hashtagPendingPosts[i]["userpost"]["time"];
+ var post = _hashtagPendingPosts[i];
+ //console.log(post);
+ var streamPost = postToElem(post, "original");
+ var timePost = post["userpost"]["time"];
+ streamPost.attr("data-time",timePost);
var streamItems = postboard.children();
if( streamItems.length == 0) {
diff --git a/js/twister_formatpost.js b/js/twister_formatpost.js
index 53026c8..e164cb6 100644
--- a/js/twister_formatpost.js
+++ b/js/twister_formatpost.js
@@ -119,8 +119,19 @@ function postToElem( post, kind, promoted ) {
retweetedByElem.text('@'+retweeted_by);
}
- if (typeof(promoted) !== 'undefined' && promoted)
+ if (typeof(promoted) !== 'undefined' && promoted) {
elem.find('.post-propagate').remove();
+ } else {
+ if ($.Options.getFilterLangSimulateOpt()) {
+ // FIXME it's must be stuff from template actually
+ if (typeof(post['langFilter']) !== 'undefined') {
+ elem.append(''+polyglot.t('This post is treated by language filter', {'treated': ''+((post['langFilter']['pass']) ? polyglot.t('passed') : polyglot.t('blocked'))+''})+'
');
+ elem.append(''+polyglot.t('Reason: this', {'this': ''+post['langFilter']['reason']+''})+' // '+polyglot.t('Most possible language: this', {'this': ''+post['langFilter']['prob'][0].toString()+''})+'
');
+ } else {
+ elem.append(''+polyglot.t('This post is treated by language filter', {'treated': ''+polyglot.t('not analyzed')+''})+'
');
+ }
+ }
+ }
return elem;
}
diff --git a/js/twister_timeline.js b/js/twister_timeline.js
index 498a253..a6835b6 100644
--- a/js/twister_timeline.js
+++ b/js/twister_timeline.js
@@ -235,15 +235,6 @@ function showPosts(req, posts)
}
if( streamPostAppended ) {
- if ($.Options.getFilterLangSimulateOpt()) {
- // FIXME it's should be stuff from template actually
- if (typeof(post['langFilter']) !== 'undefined') {
- streamPost.append(''+polyglot.t('This post is treated by language filter', {'treated': ''+((post['langFilter']['pass'] === true) ? polyglot.t('passed') : polyglot.t('blocked'))+''})+'
');
- streamPost.append(''+polyglot.t('Reason: this', {'this': ''+post['langFilter']['reason']+''})+' // '+polyglot.t('Most possible language: this', {'this': ''+post['langFilter']['prob'][0].toString()+''})+'
');
- } else {
- streamPost.append(''+polyglot.t('This post is treated by language filter', {'treated': ''+polyglot.t('not analyzed')+''})+'
');
- }
- }
streamPost.show();
}
req.reportProcessedPost(post["userpost"]["n"],post["userpost"]["k"], streamPostAppended);
@@ -371,14 +362,21 @@ function willBeHidden(post){
return false;
if (typeof(post['userpost']['rt']) !== 'undefined') {
+ // hope it is not too egocentric to overcome HideCloseRTsOpt this way
+ if (post['userpost']['rt']['n'] === defaultScreenName)
+ return false;
+
if ($.Options.getHideCloseRTsOpt() != 'disable' &&
followingUsers.indexOf(post['userpost']['rt']['n']) > -1 &&
parseInt(post['userpost']['time']) - parseInt(post['userpost']['rt']['time']) < $.Options.getHideCloseRTsHourOpt() * 3600)
{
return true;
}
+
+ var msg = post['userpost']['rt']['msg'];
} else {
var msg = post['userpost']['msg'];
+
if ($.Options.getHideRepliesOpt() !== 'disable' &&
/^\@/.test(msg) &&
!(new RegExp('@' + defaultScreenName + '( |,|;|\\.|:|\\/|\\?|\\!|\\\\|\'|"|\\n|\\t|$)').test(msg)))
@@ -392,10 +390,13 @@ function willBeHidden(post){
}
}
- if (filterLangPost(post) === false) {
- // TODO maybe we need a counter of posts blocked by language filter and even caching of them and button to show?
- //console.log('post by @'+post['userpost']['n']+' was hidden because it didn\'t passed by language filter:');
- return true;
+ if ($.Options.getFilterLangForPostboardOpt()) {
+ post['langFilter'] = filterLang(msg);
+ if (!post['langFilter']['pass'] && !$.Options.getFilterLangSimulateOpt()) {
+ // TODO maybe we need a counter of posts blocked by language filter and even caching of them and button to show?
+ //console.log('post by @'+post['userpost']['n']+' was hidden because it didn\'t passed by language filter:');
+ return true;
+ }
}
return false;
diff --git a/options.html b/options.html
index 1f4a35c..a8af2d3 100644
--- a/options.html
+++ b/options.html
@@ -240,24 +240,30 @@
+
+