diff --git a/css/style.css b/css/style.css index 105e3e5..1fa1444 100644 --- a/css/style.css +++ b/css/style.css @@ -1929,12 +1929,13 @@ ol.toptrends-list { } .langFilterSimData { + color: rgba( 0, 0, 0, .7 ); font: 10px "Open Sans", sans-serif; text-align: center; } .langFilterSimData em { - color: rgba( 227, 79, 66, .5 ); + color: rgba( 227, 79, 66, .7 ); } /************************************* diff --git a/js/franc.js b/js/franc.js index 2ef0a10..54453e3 100644 --- a/js/franc.js +++ b/js/franc.js @@ -1 +1 @@ -!function(b,a){'object'==typeof exports&&'undefined'!=typeof module?module.exports=b():'function'==typeof define&&define.amd?define([],b):('undefined'!=typeof window?a=window:'undefined'!=typeof global?a=global:'undefined'!=typeof self&&(a=self),a.franc=b())}(function(){return function a(b,c,e){function f(d,k){if(!c[d]){if(!b[d]){var i=typeof require=='function'&&require;if(!k&&i)return i(d,!0);if(g)return g(d,!0);var j=new Error("Cannot find module '"+d+"'");throw j.code='MODULE_NOT_FOUND',j}var h=c[d]={exports:{}};b[d][0].call(h.exports,function(c){var a=b[d][1][c];return f(a?a:c)},h,h.exports,a,b,c,e)}return c[d].exports}var g=typeof require=='function'&&require;for(var d=0;da&&(a=c,e=b);return[e,a]}function l(g,a){var e,d,c,f;d=a[0][1],e=g.length*b-d,c=-1,f=a.length;while(++ca&&(a=c,e=b);return[e,a]}function l(g,a){var d=a[0][1],e=g.length*b-d,c=-1,f=a.length;while(++c langFilterAccuracy) { - if (langFilterProb[i][0] === 'und') { // FIXME maybe there's should be an option for whitelist mode to allow this + if (langFilterProb[i][0] === 'und') { // e.g. digits-only string will be detected as undefined and thereby will be allowed langFilterPass = true; - langFilterReason = 'it\'s undefined language'; - break; - } else if (langFilterProb[i][0] === 'cmn') { - langFilterPass = true; - langFilterReason = 'it\'s common language'; + langFilterReason = polyglot.t('its undefined language'); break; } else if (langFilterList.indexOf(langFilterProb[i][0]) > -1) { if ($.Options.getFilterLangOpt() === 'whitelist') { langFilterPass = true; - langFilterReason = 'it\'s '+langFilterProb[i][0]+', whitelisted'; + langFilterReason = polyglot.t('its this, whitelisted', {'this': '\''+langFilterProb[i][0]+'\''}); break; } else { langFilterPass = false; - langFilterReason = 'it\'s '+langFilterProb[i][0]+', blacklisted'; + langFilterReason = polyglot.t('its this, blacklisted', {'this': '\''+langFilterProb[i][0]+'\''}); break; } } @@ -532,6 +530,7 @@ function filterLangPost(post) { 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; } } diff --git a/js/options.js b/js/options.js index baf4fc3..ac22a84 100644 --- a/js/options.js +++ b/js/options.js @@ -455,7 +455,7 @@ var TwisterOptions = function() } this.getFilterLangListOpt = function () { - return $.Options.getOption('filterLangList', '').split(/\s*,\s*/); + return $.Options.getOption('filterLangList', '').replace(/\s+/g, '').split(/\s*,\s*/); } this.setFilterLangListOpt = function () { @@ -465,7 +465,7 @@ var TwisterOptions = function() } this.getFilterLangAccuracyOpt = function () { - return parseFloat($.Options.getOption('filterLangAccuracy', '0.63')); + return parseFloat($.Options.getOption('filterLangAccuracy', '0.82')); } this.setFilterLangAccuracyOpt = function () { diff --git a/js/twister_timeline.js b/js/twister_timeline.js index 7241514..498a253 100644 --- a/js/twister_timeline.js +++ b/js/twister_timeline.js @@ -238,10 +238,10 @@ function showPosts(req, posts) if ($.Options.getFilterLangSimulateOpt()) { // FIXME it's should be stuff from template actually if (typeof(post['langFilter']) !== 'undefined') { - streamPost.append('
This post is '+((post['langFilter']['pass'] === true) ? 'passed' : 'blocked')+' by language filter.
'); - streamPost.append('
Reason: '+post['langFilter']['reason']+' // Most possible language: '+post['langFilter']['prob'][0].toString()+'
'); + 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('
This post is not filtered by language.
'); + streamPost.append('
'+polyglot.t('This post is treated by language filter', {'treated': ''+polyglot.t('not analyzed')+''})+'
'); } } streamPost.show(); @@ -367,39 +367,36 @@ function timelineChangedUser() } function willBeHidden(post){ - var msg = post['userpost']['msg']; - var hidden = false; - if (post['userpost']['n'] === defaultScreenName) return false; - if ($.Options.getHideRepliesOpt() !== 'disable' && - /^\@/.test(msg) && - !(new RegExp('@' + defaultScreenName + '( |,|;|\\.|:|\\/|\\?|\\!|\\\\|\'|"|\\n|\\t|$)').test(msg))) - { + if (typeof(post['userpost']['rt']) !== 'undefined') { + 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; + } + } else { + var msg = post['userpost']['msg']; + if ($.Options.getHideRepliesOpt() !== 'disable' && + /^\@/.test(msg) && + !(new RegExp('@' + defaultScreenName + '( |,|;|\\.|:|\\/|\\?|\\!|\\\\|\'|"|\\n|\\t|$)').test(msg))) + { if ($.Options.getHideRepliesOpt() === 'only-me' || ($.Options.getHideRepliesOpt() === 'following' && followingUsers.indexOf(msg.substring(1, msg.search(/ |,|;|\.|:|\/|\?|\!|\\|'|"|\n|\t|$/))) === -1 )) { - hidden = 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) - { - if (hidden) - return false; - else - return true; + } } if (filterLangPost(post) === false) { - hidden = true; - console.log('post by @'+post['userpost']['n']+' was hidden because it didn\'t passed by language filter'); + // 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 hidden; + return false; } diff --git a/options.html b/options.html index 9ad49fa..1f4a35c 100644 --- a/options.html +++ b/options.html @@ -255,7 +255,7 @@

Comma separated ISO 639-3 language codes

Accuracy

-

+

Simulation mode

diff --git a/theme_calm/css/style.css b/theme_calm/css/style.css index 9359d57..f6c625b 100644 --- a/theme_calm/css/style.css +++ b/theme_calm/css/style.css @@ -2375,6 +2375,7 @@ textarea.splited-post { } .langFilterSimData { + color: rgba( 0, 0, 0, .7 ); font: 10px "Open Sans", sans-serif; text-align: center; } diff --git a/theme_nin/css/style.css b/theme_nin/css/style.css index 47dc77a..3847cf3 100644 --- a/theme_nin/css/style.css +++ b/theme_nin/css/style.css @@ -1824,6 +1824,7 @@ button.disabled:hover, .mini-profile-actions span.disabled:hover, a.button.disab } .langFilterSimData { + color: rgba( 0, 0, 0, .7 ); font: 10px "Open Sans", sans-serif; text-align: center; }