mirror of
https://github.com/twisterarmy/twister-html.git
synced 2025-01-12 16:07:59 +00:00
rewrite of options.js to get it more useful and faster, move localizeLabels() to theme_option.js of nin, introduce playSound(), clean up a bit trailing spaces
This commit is contained in:
parent
5764e60957
commit
ede178eb32
@ -208,8 +208,8 @@ function updateHashtagModal(postboard,hashtag,timeoutArgs) {
|
||||
requestHashtag(postboard,hashtag,resource,timeoutArgs);
|
||||
|
||||
if( _hashtagPendingPostsUpdated ) {
|
||||
if (resource != 'mention' && $.Options.getShowDesktopNotifPostsModalOpt() === 'enable') {
|
||||
$.MAL.showDesktopNotif(false, polyglot.t('You got')+' '+polyglot.t("new_posts", _hashtagPendingPostsUpdated)+' '+polyglot.t('in search result')+'.', false,'twister_notification_new_posts_modal', $.Options.getShowDesktopNotifPostsModalTimerOpt(), function() {
|
||||
if (resource != 'mention' && $.Options.showDesktopNotifPostsModal.val === 'enable') {
|
||||
$.MAL.showDesktopNotif(false, polyglot.t('You got')+' '+polyglot.t("new_posts", _hashtagPendingPostsUpdated)+' '+polyglot.t('in search result')+'.', false,'twister_notification_new_posts_modal', $.Options.showDesktopNotifPostsModalTimer.val, function() {
|
||||
$(".postboard-news").hide();
|
||||
displayHashtagPending($(".hashtag-modal .postboard-posts"));
|
||||
}, false)
|
||||
@ -231,10 +231,9 @@ function openMentionsModal(e)
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
if(!defaultScreenName)
|
||||
{
|
||||
alert(polyglot.t("No one can mention you because you are not logged in."));
|
||||
return;
|
||||
if (!defaultScreenName) {
|
||||
alert(polyglot.t("No one can mention you because you are not logged in."));
|
||||
return;
|
||||
}
|
||||
|
||||
var username;
|
||||
@ -370,7 +369,7 @@ function openWhoToFollowModal() {
|
||||
function newConversationModal(username,resource) {
|
||||
|
||||
var hashtagModalContent = $( "#hashtag-modal-template" ).children().clone(true);
|
||||
|
||||
|
||||
requestPost(hashtagModalContent.find(".postboard-posts"),username,resource,
|
||||
function(args){
|
||||
postLi=args.hashtagModalContent.find(".postboard-posts").children().first();
|
||||
@ -406,7 +405,7 @@ function openConversationModal(username,resource)
|
||||
{
|
||||
|
||||
var conversationModalClass = "conversation-modal";
|
||||
openModal( conversationModalClass );
|
||||
openModal( conversationModalClass );
|
||||
|
||||
var conversationModalContent = newConversationModal(username,resource);
|
||||
conversationModalContent.appendTo("." + conversationModalClass + " .modal-content");
|
||||
@ -419,21 +418,21 @@ function openConversationModal(username,resource)
|
||||
function watchHashChange(e)
|
||||
{
|
||||
|
||||
if(e!=null){
|
||||
if(e!=null){
|
||||
|
||||
var prevurlsplit = e.oldURL.split('#');
|
||||
var prevhashstring=prevurlsplit[1];
|
||||
var prevhashstring=prevurlsplit[1];
|
||||
|
||||
var notFirstModalView=(prevhashstring!=undefined && prevhashstring.length>0 );
|
||||
var notNavigatedBackToFirstModalView=(window.history.state==null || ( window.history.state!=null && window.history.state.showCloseButton!=false ) )
|
||||
|
||||
|
||||
if(notFirstModalView && notNavigatedBackToFirstModalView ){
|
||||
$('.modal-back').css('display','inline');
|
||||
} else {
|
||||
window.history.pushState({showCloseButton:false},null,null);
|
||||
$('.modal-back').css('display','none');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
loadModalFromHash();
|
||||
@ -461,7 +460,7 @@ function loadModalFromHash(){
|
||||
}else if (hashdata[1] == 'following') {
|
||||
openFollowingModal(hashdata[2]);
|
||||
}else if (hashdata[1] == 'conversation') {
|
||||
splithashdata2=hashdata[2].split(':')
|
||||
splithashdata2=hashdata[2].split(':')
|
||||
//console.log('username='+splithashdata2[0]+' resource='+splithashdata2[1]);
|
||||
openConversationModal(splithashdata2[0],splithashdata2[1]);
|
||||
}
|
||||
@ -479,11 +478,11 @@ function initHashWatching()
|
||||
{
|
||||
// Register custom protocol handler
|
||||
already_registered = _getResourceFromStorage("twister_protocol_registered");
|
||||
|
||||
|
||||
if (window.navigator && window.navigator.registerProtocolHandler && !already_registered){
|
||||
var local_twister_url = window.location.protocol + '//' + window.location.host + '/home.html#%s';
|
||||
window.navigator.registerProtocolHandler('web+twister', local_twister_url, 'Twister');
|
||||
_putResourceIntoStorage("twister_protocol_registered", true);
|
||||
_putResourceIntoStorage("twister_protocol_registered", true);
|
||||
}
|
||||
|
||||
// Register hash spy and launch it once
|
||||
@ -500,9 +499,9 @@ var reTwistPopup = function( e )
|
||||
{
|
||||
if(!defaultScreenName)
|
||||
{
|
||||
e.stopPropagation();
|
||||
alert(polyglot.t("You have to log in to retransmit messages."));
|
||||
return;
|
||||
e.stopPropagation();
|
||||
alert(polyglot.t('You have to log in to retransmit messages.'));
|
||||
return;
|
||||
}
|
||||
|
||||
var reTwistClass = "reTwist";
|
||||
@ -628,7 +627,7 @@ var postExpandFunction = function( e, postLi )
|
||||
|
||||
$postExpandedContent.slideDown( "fast" );
|
||||
|
||||
if ($.Options.getShowPreviewOpt() == 'enable'){
|
||||
if ($.Options.showPreview.val === 'enable') {
|
||||
var previewContainer=$postExpandedContent.find(".preview-container")[0];
|
||||
/* was the preview added before... */
|
||||
if ($(previewContainer).children().length == 0) {
|
||||
@ -676,9 +675,9 @@ var postReplyClick = function( e )
|
||||
{
|
||||
if(!defaultScreenName)
|
||||
{
|
||||
e.stopPropagation();
|
||||
alert(polyglot.t("You have to log in to post replies."));
|
||||
return;
|
||||
e.stopPropagation();
|
||||
alert(polyglot.t('You have to log in to post replies.'));
|
||||
return;
|
||||
}
|
||||
var post = $(this).closest(".post");
|
||||
if( !post.hasClass( "original" ) ) {
|
||||
@ -703,14 +702,13 @@ var composeNewPost = function( e, postAreaNew )
|
||||
//se o usuário clicar fora é pra fechar
|
||||
postAreaNew.clickoutside( unfocusThis );
|
||||
|
||||
if ($.Options.getSplitPostsOpt() === "enable")
|
||||
if ($.Options.splitPosts.val === 'enable')
|
||||
usePostSpliting = true;
|
||||
else if ($.Options.getSplitPostsOpt() === "only-new") {
|
||||
else if ($.Options.splitPosts.val === 'only-new') {
|
||||
var $postOrig = postAreaNew.closest(".post-data");
|
||||
|
||||
if (!$postOrig.length) {
|
||||
if (!$postOrig.length)
|
||||
$postOrig = postAreaNew.closest(".modal-content").find(".post-data");
|
||||
}
|
||||
|
||||
if ($postOrig.length)
|
||||
usePostSpliting = false;
|
||||
@ -749,7 +747,7 @@ function replyTextInput(e) {
|
||||
var $this = $( this );
|
||||
var tweetForm = $this.parents("form");
|
||||
if( tweetForm != undefined ) {
|
||||
if ($.Options.getUnicodeConversionOpt() !== "disable")
|
||||
if ($.Options.unicodeConversion.val !== 'disable')
|
||||
$this.val(convert2Unicodes($this.val(), $this));
|
||||
|
||||
if (usePostSpliting && !$this.parents('.directMessages').length) {
|
||||
@ -933,14 +931,14 @@ function replyTextKeySend(e) {
|
||||
var tweetAction = tweetForm.find(".post-submit");
|
||||
if( !tweetAction.length ) tweetAction = tweetForm.find(".dm-submit");
|
||||
|
||||
if( $.Options.keyEnterToSend() && $('.dropdown-menu').css('display') == 'none'){
|
||||
if ($.Options.keysSend.val === 'enter' && $('.dropdown-menu').css('display') == 'none') {
|
||||
if (e.keyCode === 13 && (!e.metaKey && !e.ctrlKey)) {
|
||||
$this.val($this.val().trim());
|
||||
if( !tweetAction.hasClass("disabled")) {
|
||||
tweetAction.click();
|
||||
}
|
||||
}
|
||||
} else if( !$.Options.keyEnterToSend() ){
|
||||
} else if ($.Options.keysSend.val === 'ctrlenter') {
|
||||
if (e.keyCode === 13 && (e.metaKey || e.ctrlKey)) {
|
||||
$this.val($this.val().trim());
|
||||
if( !tweetAction.hasClass("disabled") ) {
|
||||
@ -1295,37 +1293,29 @@ function convert2Unicodes(s, ta)
|
||||
ta.data("disabledUnicodeRules", []);
|
||||
var ranges = getRangesForUnicodeConversion(s);
|
||||
var list;
|
||||
if ($.Options.getUnicodeConversionOpt() === "enable" || $.Options.getConvertPunctuationsOpt())
|
||||
{
|
||||
if ($.Options.unicodeConversion.val === 'enable' || $.Options.convertPunctuations.val) {
|
||||
list = unicodeConversionList.punctuation;
|
||||
s = getUnicodeReplacement(s, list, ranges, ta);
|
||||
}
|
||||
if ($.Options.getUnicodeConversionOpt() === "enable"|| $.Options.getConvertEmotionsOpt())
|
||||
{
|
||||
if ($.Options.unicodeConversion.val === 'enable' || $.Options.convertEmotions.val) {
|
||||
list = unicodeConversionList.emotions;
|
||||
s = getUnicodeReplacement(s, list, ranges, ta);
|
||||
}
|
||||
if ($.Options.getUnicodeConversionOpt() === "enable"|| $.Options.getConvertSignsOpt())
|
||||
{
|
||||
if ($.Options.unicodeConversion.val === 'enable' || $.Options.convertSigns.val) {
|
||||
list = unicodeConversionList.signs;
|
||||
s = getUnicodeReplacement(s, list, ranges, ta);
|
||||
}
|
||||
if ($.Options.getUnicodeConversionOpt() === "enable"|| $.Options.getConvertFractionsOpt())
|
||||
{
|
||||
if ($.Options.unicodeConversion.val === 'enable' || $.Options.convertFractions.val) {
|
||||
list = unicodeConversionList.fractions;
|
||||
s = getUnicodeReplacement(s, list, ranges, ta);
|
||||
}
|
||||
|
||||
if (ta.data("unicodeConversionStack").length > 0)
|
||||
{
|
||||
if (ta.data("unicodeConversionStack").length > 0) {
|
||||
var ub = ta.closest(".post-area-new").find(".undo-unicode");
|
||||
ub.text(polyglot.t("undo") + ": " + ta.data("unicodeConversionStack")[0].u);
|
||||
$.MAL.enableButton(ub);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else
|
||||
$.MAL.disableButton(ta.closest(".post-area-new").find(".undo-unicode"));
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
@ -1446,7 +1436,7 @@ var postSubmit = function(e, oldLastPostId)
|
||||
closeModal($this);
|
||||
} else if ($this.parents('.prompt-wrapper').length) {
|
||||
closePrompt();
|
||||
}
|
||||
}
|
||||
|
||||
if($this.closest('.post-area,.post-reply-content')){
|
||||
$('.post-area-new').removeClass('open').find('textarea').blur();
|
||||
@ -1471,7 +1461,7 @@ var retweetSubmit = function(e)
|
||||
|
||||
function changeStyle() {
|
||||
var style, profile, menu;
|
||||
var theme = $.Options.getTheme();
|
||||
var theme = $.Options.theme.val;
|
||||
|
||||
if(theme == 'nin')
|
||||
{
|
||||
@ -1582,7 +1572,7 @@ function initInterfaceCommon() {
|
||||
$( ".modal-propagate").click( retweetSubmit );
|
||||
$( ".expanded-content .show-more").bind('click', openConversationClick);
|
||||
|
||||
if ($.Options.getUnicodeConversionOpt() === "disable")
|
||||
if ($.Options.unicodeConversion.val === 'disable')
|
||||
$( ".undo-unicode" ).click( undoLastUnicode ).css("display", "none");
|
||||
else
|
||||
$( ".undo-unicode" ).click( undoLastUnicode );
|
||||
@ -1601,7 +1591,7 @@ function initInterfaceCommon() {
|
||||
replaceDashboards();
|
||||
$( window ).resize(replaceDashboards);
|
||||
|
||||
if ($.Options.getWhoToFollowOpt() === 'enable')
|
||||
if ($.Options.WhoToFollow.val === 'enable')
|
||||
initWhoToFollow();
|
||||
else
|
||||
killInterfaceModule('who-to-follow');
|
||||
|
@ -6,8 +6,7 @@
|
||||
//***********************************************
|
||||
//******************* DECLARATIONS **************
|
||||
//***********************************************
|
||||
var InterfaceFunctions = function()
|
||||
{
|
||||
var InterfaceFunctions = function() {
|
||||
//faço os binds no init
|
||||
this.init = function()
|
||||
{
|
||||
@ -115,18 +114,17 @@ var InterfaceFunctions = function()
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if ($.Options.getTopTrendsOpt() === 'enable')
|
||||
if ($.Options.TopTrends.val === 'enable')
|
||||
initTopTrends();
|
||||
else
|
||||
killInterfaceModule('toptrends');
|
||||
|
||||
if ($.Options.getTwistdayReminderOpt() === 'enable')
|
||||
if ($.Options.TwistdayReminder.val === 'enable')
|
||||
initTwistdayReminder();
|
||||
else
|
||||
killInterfaceModule('twistday-reminder');
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function initTopTrends() {
|
||||
var $tt = initInterfaceModule('toptrends');
|
||||
@ -148,9 +146,9 @@ function updateTrendingHashtags() {
|
||||
function(args, ret) {
|
||||
//console.log('hashtags trends: '+ret);
|
||||
for( var i = 0; i < ret.length; i++ ) {
|
||||
if ($.Options.getFilterLangOpt() !== 'disable' && $.Options.getFilterLangForTopTrendsOpt())
|
||||
if ($.Options.filterLang.val !== 'disable' && $.Options.filterLangForTopTrends.val)
|
||||
var langFilterData = filterLang(ret[i]);
|
||||
if (typeof(langFilterData) === 'undefined' || langFilterData['pass'] || $.Options.getFilterLangSimulateOpt()) {
|
||||
if (typeof(langFilterData) === 'undefined' || langFilterData['pass'] || $.Options.filterLangSimulate.val) {
|
||||
var $li = $('<li>');
|
||||
var hashtagLinkTemplate = $('#hashtag-link-template').clone(true);
|
||||
|
||||
@ -159,7 +157,7 @@ function updateTrendingHashtags() {
|
||||
hashtagLinkTemplate.text('#'+ret[i]);
|
||||
|
||||
$li.append(hashtagLinkTemplate);
|
||||
if ($.Options.getFilterLangOpt() !== 'disable' && $.Options.getFilterLangSimulateOpt()) {
|
||||
if ($.Options.filterLang.val !== 'disable' && $.Options.filterLangSimulate.val) {
|
||||
if (typeof(langFilterData) !== 'undefined') {
|
||||
$li.append(' <span class="langFilterSimData"><em>'+((langFilterData['pass']) ? polyglot.t('passed') : polyglot.t('blocked'))+'</em>: '+langFilterData['prob'][0].toString()+'</span>');
|
||||
} else {
|
||||
@ -180,10 +178,10 @@ function updateTrendingHashtags() {
|
||||
console.log('Error with gettrendinghashtags. Older twister daemon?');
|
||||
}, {}
|
||||
);
|
||||
if ($list.children().length && $.Options.getTopTrendsAutoUpdateOpt() === 'enable' && $.Options.getTopTrendsAutoUpdateTimerOpt() > 0)
|
||||
setTimeout(updateTrendingHashtags, $.Options.getTopTrendsAutoUpdateTimerOpt()*1000);
|
||||
if ($list.children().length && $.Options.TopTrendsAutoUpdate.val === 'enable' && $.Options.TopTrendsAutoUpdateTimer.val > 0)
|
||||
setTimeout(updateTrendingHashtags, $.Options.TopTrendsAutoUpdateTimer.val * 1000);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function initTwistdayReminder() {
|
||||
var $module = initInterfaceModule('twistday-reminder');
|
||||
@ -235,7 +233,7 @@ function refreshTwistdayReminder() {
|
||||
list.find('[data-screen-name='+lucky+']').closest('li').remove();
|
||||
}
|
||||
|
||||
var showUpcomingTimer = ($.Options.getTwistdayReminderShowUpcomingOpt() === 'enable') ? $.Options.getTwistdayReminderShowUpcomingTimerOpt() *3600 : 0;
|
||||
var showUpcomingTimer = ($.Options.TwistdayReminderShowUpcoming.val === 'enable') ? $.Options.TwistdayReminderShowUpcomingTimer.val * 3600 : 0;
|
||||
var listCurrent = $module.find('.current .list');
|
||||
var listUpcoming = $module.find('.upcoming .list');
|
||||
var d = new Date();
|
||||
@ -283,8 +281,8 @@ function refreshTwistdayReminder() {
|
||||
function(arg, ret) { console.log('ajax error:' + ret); }, null);
|
||||
}
|
||||
}
|
||||
if ($.Options.getTwistdayReminderAutoUpdateOpt() === 'enable' && $.Options.getTwistdayReminderAutoUpdateTimerOpt() > 0)
|
||||
setTimeout(refreshTwistdayReminder, $.Options.getTwistdayReminderAutoUpdateTimerOpt()*1000);
|
||||
if ($.Options.TwistdayReminderAutoUpdate.val === 'enable' && $.Options.TwistdayReminderAutoUpdateTimer.val > 0)
|
||||
setTimeout(refreshTwistdayReminder, $.Options.TwistdayReminderAutoUpdateTimer.val * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,24 +6,22 @@
|
||||
// translators: add your language code here such as "es" for Spanish, "ru" for Russian
|
||||
var knownLanguages = ["en","es","nl","it","fr","ru","de","zh-CN","ja","pt-BR","tr","uk","cs"];
|
||||
|
||||
if( $.Options.getOption('locLang','auto') == 'auto'){
|
||||
// detect language with JavaScript
|
||||
preferredLanguage = window.navigator.userLanguage || window.navigator.language || "en";
|
||||
if(knownLanguages.indexOf(preferredLanguage) > -1){
|
||||
// en for en or similar
|
||||
preferredLanguage = preferredLanguage;
|
||||
}
|
||||
else if(knownLanguages.indexOf(preferredLanguage.split("-")[0]) > -1){
|
||||
// en for en-US or similar
|
||||
preferredLanguage = preferredLanguage.split("-")[0];
|
||||
}
|
||||
else{
|
||||
// did not find match
|
||||
preferredLanguage = "en";
|
||||
}
|
||||
}else{
|
||||
preferredLanguage = $.Options.getOption('locLang','en');
|
||||
}
|
||||
if ($.Options.locLang.val === 'auto') {
|
||||
// detect language with JavaScript
|
||||
preferredLanguage = window.navigator.userLanguage || window.navigator.language || 'en';
|
||||
if (knownLanguages.indexOf(preferredLanguage) > -1) {
|
||||
// en for en or similar
|
||||
preferredLanguage = preferredLanguage;
|
||||
} else if (knownLanguages.indexOf(preferredLanguage.split('-')[0]) > -1) {
|
||||
// en for en-US or similar
|
||||
preferredLanguage = preferredLanguage.split('-')[0];
|
||||
} else {
|
||||
// did not find match
|
||||
preferredLanguage = 'en';
|
||||
}
|
||||
} else
|
||||
preferredLanguage = $.Options.locLang.val;
|
||||
|
||||
// set up Polyglot
|
||||
polyglot = new Polyglot();
|
||||
var wordset = {};
|
||||
|
@ -24,13 +24,13 @@ var MAL = function()
|
||||
$.mobile.hidePageLoadingMsg();
|
||||
var curPage = $.mobile.activePage.attr("id");
|
||||
$( '#'+curPage+' .content ul.posts').listview('refresh');
|
||||
|
||||
|
||||
installPostboardClick();
|
||||
} else {
|
||||
$(".postboard-loading").hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.dmThreadListLoaded = function() {
|
||||
if( $.hasOwnProperty("mobile") ) {
|
||||
$.mobile.hidePageLoadingMsg();
|
||||
@ -103,8 +103,8 @@ var MAL = function()
|
||||
newTweetsBarMenu.text(String(newPosts));
|
||||
newTweetsBarMenu.addClass("show");
|
||||
|
||||
if ($.Options.getShowDesktopNotifPostsOpt() === 'enable') {
|
||||
this.showDesktopNotif(false, polyglot.t('You got')+' '+polyglot.t('new_posts', newPosts)+' '+polyglot.t('in postboard')+'.', false,'twister_notification_new_posts', $.Options.getShowDesktopNotifPostsTimerOpt(), (function() {
|
||||
if ($.Options.showDesktopNotifPosts.val === 'enable') {
|
||||
this.showDesktopNotif(false, polyglot.t('You got')+' '+polyglot.t('new_posts', newPosts)+' '+polyglot.t('in postboard')+'.', false,'twister_notification_new_posts', $.Options.showDesktopNotifPostsTimer.val, (function() {
|
||||
requestTimelineUpdate('pending',this,followingUsers,promotedPostsOnly);
|
||||
}).bind(newPosts), false)
|
||||
}
|
||||
@ -117,7 +117,7 @@ var MAL = function()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.getStreamPostsParent = function() {
|
||||
if( $.hasOwnProperty("mobile") ) {
|
||||
return $( '.timeline ul');
|
||||
@ -183,7 +183,7 @@ var MAL = function()
|
||||
return "#hashtag?hashtag=" + h;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.dmchatUrl = function(username) {
|
||||
if( $.hasOwnProperty("mobile") ) {
|
||||
return "#dmchat?user=" + username;
|
||||
@ -199,7 +199,7 @@ var MAL = function()
|
||||
return "#following?user=" + username;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.followUrl = function(username) {
|
||||
if( $.hasOwnProperty("mobile") ) {
|
||||
return "#following?follow=" + username;
|
||||
@ -232,7 +232,7 @@ var MAL = function()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
this.updateNewMentionsUI = function(newMentions) {
|
||||
if( $.hasOwnProperty("mobile") ) {
|
||||
var $mentionsCounterBtnText = $(".mentions-count .ui-btn-text");
|
||||
@ -398,20 +398,22 @@ var MAL = function()
|
||||
window.location.href = "home.html";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.soundNotifyMentions = function() {
|
||||
if( $.hasOwnProperty("mobile") ) {
|
||||
} else {
|
||||
$.Options.mensNotif();
|
||||
}
|
||||
}
|
||||
if ($.mobile) {
|
||||
} else {
|
||||
if ($.Options.sndMention.val !== 'false')
|
||||
playSound('player', $.Options.sndMention.val);
|
||||
}
|
||||
};
|
||||
|
||||
this.soundNotifyDM = function() {
|
||||
if( $.hasOwnProperty("mobile") ) {
|
||||
} else {
|
||||
$.Options.DMsNotif();
|
||||
}
|
||||
}
|
||||
if ($.mobile) {
|
||||
} else {
|
||||
if ($.Options.sndDM.val !== 'false')
|
||||
playSound('playerSec', $.Options.sndDM.val);
|
||||
}
|
||||
};
|
||||
|
||||
this.showDesktopNotif = function(notifyTitle, notifyBody, notifyIcon, notifyTag, notifyTimer, actionOnClick, actionOnPermDenied) {
|
||||
function doNotification() {
|
||||
@ -451,7 +453,7 @@ var MAL = function()
|
||||
} else {
|
||||
doNotification();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.reqRepAfterCB = function(postLi, postsFromJson) {
|
||||
if ($.hasOwnProperty("mobile")) {
|
||||
@ -488,18 +490,38 @@ var MAL = function()
|
||||
|
||||
jQuery.MAL = new MAL;
|
||||
|
||||
function playSound(player, sound) {
|
||||
if ($.mobile) {
|
||||
} else {
|
||||
var player = $('#'+player);
|
||||
if (player.length) {
|
||||
player[0].pause();
|
||||
//player.empty();
|
||||
|
||||
if (player[0].canPlayType('audio/mpeg;'))
|
||||
player.attr({type: 'audio/mpeg', src: 'sound/' + sound + '.mp3'});
|
||||
else
|
||||
player.attr({type: 'audio/ogg', src: 'sound/' + sound + '.ogg'});
|
||||
|
||||
player[0].volume = $.Options.playerVol.val;
|
||||
player[0].play();
|
||||
} else
|
||||
console.warn('cannot find player to play sound, selector: #'+player);
|
||||
}
|
||||
}
|
||||
|
||||
function filterLang(string) {
|
||||
var langFilterMode = $.Options.getFilterLangOpt();
|
||||
var langFilterMode = $.Options.filterLang.val;
|
||||
|
||||
if (langFilterMode !== 'disable') {
|
||||
var langFilterSubj = '';
|
||||
var langFilterProb = [];
|
||||
var langFilterPass = true;
|
||||
var langFilterReason = '';
|
||||
var langFilterList = $.Options.getFilterLangListOpt();
|
||||
var langFilterList = $.Options.filterLangList.val;
|
||||
|
||||
if (langFilterList.length > 0) {
|
||||
var langFilterAccuracy = $.Options.getFilterLangAccuracyOpt();
|
||||
var langFilterAccuracy = $.Options.filterLangAccuracy.val;
|
||||
langFilterPass = (langFilterMode === 'whitelist') ? false : true;
|
||||
langFilterReason = polyglot.t('this doesnt contain that', {'this': polyglot.t(langFilterMode), 'that': polyglot.t('language of this')});
|
||||
|
||||
|
1028
js/options.js
1028
js/options.js
File diff suppressed because it is too large
Load Diff
@ -162,12 +162,12 @@ function requestPost(containerToAppend,username,resource,cbFunc,cbArgs){
|
||||
console.log(postFromJson);
|
||||
|
||||
appendPostToContainer(postFromJson,args.containerToAppend);
|
||||
|
||||
|
||||
if(args.cbFunc!=undefined) args.cbFunc(args.cbArgs);
|
||||
|
||||
}
|
||||
},
|
||||
{containerToAppend:containerToAppend,cbFunc:cbFunc,cbArgs:cbArgs}
|
||||
|
||||
}
|
||||
},
|
||||
{containerToAppend:containerToAppend,cbFunc:cbFunc,cbArgs:cbArgs}
|
||||
);
|
||||
|
||||
}
|
||||
@ -185,7 +185,7 @@ function requestPostRecursively(containerToAppend,username,resource,count,useGet
|
||||
}
|
||||
|
||||
profilePostsLoading = true;
|
||||
|
||||
|
||||
if( useGetposts ) {
|
||||
req = {username: username}
|
||||
if( max_id != -1 ) {
|
||||
@ -290,7 +290,7 @@ function updateProfileData(profileModalContent, username) {
|
||||
getFollowers( username, profileModalContent.find(".followers-count") );
|
||||
getNumFollowing( username, profileModalContent.find(".following-count") );
|
||||
getWhoFollows ( username, profileModalContent.find(".who-follow") );
|
||||
|
||||
|
||||
profileModalContent.find(".following-count").parent().attr("href", $.MAL.followingUrl(username));
|
||||
|
||||
var postsView = profileModalContent.find(".postboard-posts");
|
||||
@ -333,7 +333,7 @@ function requestHashtag(postboard,hashtag,resource, timeoutArgs) {
|
||||
dhtget( hashtag, resource, "m",
|
||||
function(args, data) {
|
||||
processHashtag(args.postboard, args.hashtag, data);
|
||||
}, {postboard:postboard,hashtag:hashtag},
|
||||
}, {postboard:postboard,hashtag:hashtag},
|
||||
timeoutArgs);
|
||||
}
|
||||
|
||||
@ -345,14 +345,14 @@ function processHashtag(postboard, hashtag, data) {
|
||||
if( !(key in _hashtagProcessedMap) ) {
|
||||
_hashtagProcessedMap[key] = true;
|
||||
|
||||
if ($.Options.getFilterLangOpt() !== 'disable' && $.Options.getFilterLangForSearchingOpt()) {
|
||||
if ($.Options.filterLang.val !== 'disable' && $.Options.filterLangForSearching.val) {
|
||||
if (typeof(userpost['rt']) !== 'undefined') {
|
||||
var msg = userpost['rt']['msg'];
|
||||
} else {
|
||||
var msg = userpost['msg'];
|
||||
}
|
||||
langFilterData = filterLang(msg);
|
||||
if ($.Options.getFilterLangSimulateOpt()) {
|
||||
if ($.Options.filterLangSimulate.val) {
|
||||
data[i]['langFilter'] = langFilterData;
|
||||
} else {
|
||||
if (!langFilterData['pass'])
|
||||
|
@ -121,7 +121,7 @@ function newDirectMsg(msg, dm_screenname) {
|
||||
if( lastPostId != undefined ) {
|
||||
var paramsOrig = [defaultScreenName, lastPostId + 1, dm_screenname, msg]
|
||||
var paramsOpt = paramsOrig
|
||||
var copySelf = ($.Options.getDMCopySelfOpt() === 'enable')
|
||||
var copySelf = ($.Options.dmCopySelf.val === 'enable')
|
||||
if( copySelf && dm_screenname[0] !== '*' ) {
|
||||
paramsOpt = paramsOrig.concat(true)
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ function postToElem( post, kind, promoted ) {
|
||||
if (typeof(promoted) !== 'undefined' && promoted) {
|
||||
elem.find('.post-propagate').remove();
|
||||
} else {
|
||||
if ($.Options.getFilterLangOpt() !== 'disable' && $.Options.getFilterLangSimulateOpt()) {
|
||||
if ($.Options.filterLang.val !== 'disable' && $.Options.filterLangSimulate.val) {
|
||||
// FIXME it's must be stuff from template actually
|
||||
if (typeof(post['langFilter']) !== 'undefined') {
|
||||
if (typeof(post['langFilter']['prob'][0]) !== 'undefined')
|
||||
@ -253,8 +253,8 @@ function htmlFormatMsg(msg, mentions) {
|
||||
}
|
||||
|
||||
function proxyURL(url) {
|
||||
var proxyOpt = $.Options.getUseProxyOpt();
|
||||
if (proxyOpt !== 'disable' && !$.Options.getUseProxyForImgOnlyOpt()) {
|
||||
var proxyOpt = $.Options.useProxy.val;
|
||||
if (proxyOpt !== 'disable' && !$.Options.useProxyForImgOnly.val) {
|
||||
// proxy alternatives may be added to options page
|
||||
if (proxyOpt === 'ssl-proxy-my-addr') {
|
||||
url = ['https://ssl-proxy.my-addr.org/myaddrproxy.php/',
|
||||
@ -270,7 +270,7 @@ function proxyURL(url) {
|
||||
// TODO: add options for emotions; msg = $.emotions(msg);
|
||||
// TODO: add at least basic markdown (optional) like *text* -> bold text and _text_ -> italic text
|
||||
function _formatText(msg) {
|
||||
if ($.Options.getLineFeedsOpt() === 'enable')
|
||||
if ($.Options.displayLineFeeds.val === 'enable')
|
||||
msg = msg.replace(/\n/g, '<br />');
|
||||
|
||||
return msg;
|
||||
|
@ -208,7 +208,7 @@ function getProfileResource( username, resource, item, cbFunc, cbArg ){
|
||||
function getFullname( username, item ){
|
||||
// Set the username first in case the profile has no fullname
|
||||
item.text(username);
|
||||
getProfileResource( username, "fullname", undefined,
|
||||
getProfileResource( username, "fullname", undefined,
|
||||
function(args, value) {
|
||||
if( value ) {
|
||||
value.replace(/^\s+|\s+$/g, '');
|
||||
@ -217,7 +217,7 @@ function getFullname( username, item ){
|
||||
}
|
||||
}, {item: item} );
|
||||
if (typeof(twisterFollowingO) !== 'undefined' &&
|
||||
($.Options.getIsFollowingMeOpt() === 'everywhere' || item.hasClass('profile-name'))) {
|
||||
($.Options.isFollowingMe.val === 'everywhere' || item.hasClass('profile-name'))) {
|
||||
if (twisterFollowingO.knownFollowers.indexOf(username) > -1) {
|
||||
item.addClass('isFollowing');
|
||||
item.attr("title", polyglot.t("follows you"));
|
||||
@ -332,10 +332,9 @@ function _putResourceIntoStorage(locator, data) {
|
||||
|
||||
// get avatar and set it in img.attr("src")
|
||||
function getAvatar( username, img ){
|
||||
var theme = $.Options.getTheme();
|
||||
if( username == "nobody" ) {
|
||||
if(theme == 'nin') {img.attr('src', "theme_nin/img/tornado_avatar.png");}
|
||||
else {img.attr('src', "img/tornado_avatar.png");}
|
||||
if (username === 'nobody') {
|
||||
img.attr('src', ($.Options.theme.val === 'nin') ?
|
||||
'theme_nin/img/tornado_avatar.png' : 'img/tornado_avatar.png');
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -102,8 +102,8 @@ function requestMentionsCount() {
|
||||
if ( _newMentions ) {
|
||||
$.MAL.soundNotifyMentions();
|
||||
|
||||
if ($.Options.getShowDesktopNotifMentionsOpt() === 'enable') {
|
||||
$.MAL.showDesktopNotif(false, polyglot.t('You got')+' '+polyglot.t('new_mentions', _newMentions)+'.', false,'twister_notification_new_mentions', $.Options.getShowDesktopNotifMentionsTimerOpt(), function(){$.MAL.showMentions(defaultScreenName)}, false)
|
||||
if ($.Options.showDesktopNotifMentions.val === 'enable') {
|
||||
$.MAL.showDesktopNotif(false, polyglot.t('You got')+' '+polyglot.t('new_mentions', _newMentions)+'.', false,'twister_notification_new_mentions', $.Options.showDesktopNotifMentionsTimer.val, function(){$.MAL.showMentions(defaultScreenName)}, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -117,8 +117,8 @@ function requestMentionsCount() {
|
||||
if ( newDMs ) {
|
||||
$.MAL.soundNotifyDM();
|
||||
|
||||
if ($.Options.getShowDesktopNotifDMsOpt() === 'enable') {
|
||||
$.MAL.showDesktopNotif(false, polyglot.t('You got')+' '+polyglot.t('new_direct_messages', newDMs)+'.', false, 'twister_notification_new_DMs', $.Options.getShowDesktopNotifDMsTimerOpt(), function(){$.MAL.showDMchat()}, false)
|
||||
if ($.Options.showDesktopNotifDMs.val === 'enable') {
|
||||
$.MAL.showDesktopNotif(false, polyglot.t('You got')+' '+polyglot.t('new_direct_messages', newDMs)+'.', false, 'twister_notification_new_DMs', $.Options.showDesktopNotifDMsTimer.val, function(){$.MAL.showDMchat()}, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -365,9 +365,9 @@ function willBeHidden(post){
|
||||
if (post['userpost']['rt']['n'] === defaultScreenName)
|
||||
return false;
|
||||
|
||||
if ($.Options.getHideCloseRTsOpt() != 'disable' &&
|
||||
if ($.Options.hideCloseRTs.val !== 'disable' &&
|
||||
followingUsers.indexOf(post['userpost']['rt']['n']) > -1 &&
|
||||
parseInt(post['userpost']['time']) - parseInt(post['userpost']['rt']['time']) < $.Options.getHideCloseRTsHourOpt() * 3600)
|
||||
parseInt(post['userpost']['time']) - parseInt(post['userpost']['rt']['time']) < $.Options.hideCloseRTsHour.val * 3600)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -376,12 +376,11 @@ function willBeHidden(post){
|
||||
} else {
|
||||
var msg = post['userpost']['msg'];
|
||||
|
||||
if ($.Options.getHideRepliesOpt() !== 'disable' &&
|
||||
/^\@/.test(msg) &&
|
||||
if ($.Options.hideReplies.val !== 'disable' && /^\@/.test(msg) &&
|
||||
!(new RegExp('@' + defaultScreenName + '( |,|;|\\.|:|\\/|\\?|\\!|\\\\|\'|"|\\n|\\t|$)').test(msg)))
|
||||
{
|
||||
if ($.Options.getHideRepliesOpt() === 'only-me' ||
|
||||
($.Options.getHideRepliesOpt() === 'following' &&
|
||||
if ($.Options.hideReplies.val === 'only-me' ||
|
||||
($.Options.hideReplies.val === 'following' &&
|
||||
followingUsers.indexOf(msg.substring(1, msg.search(/ |,|;|\.|:|\/|\?|\!|\\|'|"|\n|\t|$/))) === -1 ))
|
||||
{
|
||||
return true;
|
||||
@ -389,9 +388,9 @@ function willBeHidden(post){
|
||||
}
|
||||
}
|
||||
|
||||
if ($.Options.getFilterLangOpt() !== 'disable' && $.Options.getFilterLangForPostboardOpt()) {
|
||||
if ($.Options.filterLang.val !== 'disable' && $.Options.filterLangForPostboard.val) {
|
||||
post['langFilter'] = filterLang(msg);
|
||||
if (!post['langFilter']['pass'] && !$.Options.getFilterLangSimulateOpt()) {
|
||||
if (!post['langFilter']['pass'] && !$.Options.filterLangSimulate.val) {
|
||||
// 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;
|
||||
|
10
options.html
10
options.html
@ -21,10 +21,12 @@
|
||||
<script src="js/polyglot.min.js"></script>
|
||||
<script src="js/interface_localization.js"></script>
|
||||
|
||||
<script>$(function(){
|
||||
initInterfaceCommon();
|
||||
$.Options.InitOptions();})
|
||||
changeStyle();
|
||||
<script>
|
||||
$(function() {
|
||||
initInterfaceCommon();
|
||||
$.Options.initControls();
|
||||
})
|
||||
changeStyle();
|
||||
</script>
|
||||
</head>
|
||||
|
||||
|
@ -46,5 +46,16 @@ $(function(){
|
||||
$(this).text('').attr('title', polyglot.t('Unfollow'));
|
||||
});
|
||||
|
||||
if (/\/options.html$/i.test(document.location))
|
||||
$(document).ready(localizeLabels);
|
||||
});
|
||||
|
||||
function localizeLabels() {
|
||||
$("label[for=tab_language]").text(polyglot.t("Language"));
|
||||
$("label[for=t-2]").text(polyglot.t("Theme"));
|
||||
$("label[for=t-3]").text(polyglot.t("Notifications"));
|
||||
$("label[for=t-4]").text(polyglot.t("Keys"));
|
||||
$("label[for=t-5]").text(polyglot.t("Appearance"));
|
||||
$("label[for=t-6]").text(polyglot.t("Users"));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user