From fe5c0510819e6fa0597cd54c444c22baf70644e6 Mon Sep 17 00:00:00 2001 From: Simon Grim Date: Fri, 17 Apr 2015 00:11:33 +0500 Subject: [PATCH 1/2] option to disable toptrends module --- css/style.css | 10 +++-- home.html | 21 +++++---- js/interface_home.js | 82 +++++++++++++++++++++++------------- js/interface_localization.js | 2 +- js/options.js | 20 +++++++++ options.html | 24 +++++++---- theme_calm/css/style.css | 5 ++- theme_nin/css/style.css | 13 +++--- theme_nin/sass/style.sass | 10 +++-- 9 files changed, 127 insertions(+), 60 deletions(-) diff --git a/css/style.css b/css/style.css index 6c28d37..d89e75c 100644 --- a/css/style.css +++ b/css/style.css @@ -785,6 +785,7 @@ textarea.splited-post { opacity: 1; } +.refresh-toptrends, .refresh-users, .view-all-users { @@ -794,8 +795,9 @@ textarea.splited-post { } /*********************************** -**********TOP TRENDS**************** +************ TOP TRENDS ************ ***********************************/ + ol.toptrends-list { margin: 0% 5% 5% 5%; padding: 5px; @@ -803,9 +805,9 @@ ol.toptrends-list { border-top: solid 1px rgba( 69, 71, 77, .1 ); } -.toptrends h3 -{ - margin: 5% 5% 2% 5%; +.toptrends h3 { + margin: 5% 0% 2% 5%; + display: inline; } /*********************************** diff --git a/home.html b/home.html index e3eaa45..fb404ae 100644 --- a/home.html +++ b/home.html @@ -155,13 +155,8 @@
- -
-

Top Trends

-
    - -
-
+ +
@@ -215,7 +210,7 @@
-

Who to Follow

+

Who to Follow

. Refresh . @@ -225,6 +220,16 @@
+ +
+

Top Trends

+ . + Refresh +
    + +
+
+
  • diff --git a/js/interface_home.js b/js/interface_home.js index 4603759..734412a 100644 --- a/js/interface_home.js +++ b/js/interface_home.js @@ -118,45 +118,67 @@ var InterfaceFunctions = function() }); } - setTimeout(updateTrendingHashtags, 1000); - if ($.Options.getTopTrendsAutoUpdateOpt() === 'enable' && $.Options.getTopTrendsAutoUpdateTimerOpt() > 0) - setInterval(updateTrendingHashtags, $.Options.getTopTrendsAutoUpdateTimerOpt()*1000); + if ($.Options.getTopTrendsOpt() === 'enable') + initTopTrends(); + else + killTopTrends(); } }; +function initTopTrends() { + var $tt = $('.module.toptrends'); + if ($tt.length) { + $tt.html($('#toptrends-template').html()).show(); + var $ttRefresh = $tt.find('.refresh-toptrends'); + $ttRefresh.on('click', updateTrendingHashtags); + setTimeout(function() { $ttRefresh.click() }, 100); + } +} + +function killTopTrends() { + var $tt = $('.module.toptrends'); + if ($tt.length) + $tt.empty().hide(); +} + 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.getFilterLangOpt() !== 'disable' && $.Options.getFilterLangForTopTrendsOpt()) - var langFilterData = filterLang(ret[i]); - if (typeof(langFilterData) === 'undefined' || langFilterData['pass'] || $.Options.getFilterLangSimulateOpt()) { - var $li = $('
  • '); - var hashtagLinkTemplate = $('#hashtag-link-template').clone(true); + var $ttl = $('.module.toptrends .toptrends-list'); + if ($ttl.length) { + twisterRpc('gettrendinghashtags', [10], + function(args, ret) { + $ttl.empty(); + //console.log('hashtags trends: '+ret); + for( var i = 0; i < ret.length; i++ ) { + if ($.Options.getFilterLangOpt() !== 'disable' && $.Options.getFilterLangForTopTrendsOpt()) + var langFilterData = filterLang(ret[i]); + if (typeof(langFilterData) === 'undefined' || 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]); + hashtagLinkTemplate.removeAttr('id'); + hashtagLinkTemplate.attr('href',$.MAL.hashtagUrl(ret[i])); + hashtagLinkTemplate.text('#'+ret[i]); - $li.append(hashtagLinkTemplate); - if ($.Options.getFilterLangOpt() !== 'disable' && $.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')+''); + $li.append(hashtagLinkTemplate); + if ($.Options.getFilterLangOpt() !== 'disable' && $.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); + $ttl.append($li); + } } - } - }, {}, - function(args, ret) { - console.log('Error with gettrendinghashtags. Older twister daemon?'); - }, {} - ); + }, {}, + function(args, ret) { + console.log('Error with gettrendinghashtags. Older twister daemon?'); + }, {} + ); + if ($.Options.getTopTrendsAutoUpdateOpt() === 'enable' && $.Options.getTopTrendsAutoUpdateTimerOpt() > 0) + setTimeout(updateTrendingHashtags, $.Options.getTopTrendsAutoUpdateTimerOpt()*1000); + } }; //*********************************************** diff --git a/js/interface_localization.js b/js/interface_localization.js index 83626bc..d17f0ef 100644 --- a/js/interface_localization.js +++ b/js/interface_localization.js @@ -3570,7 +3570,7 @@ var fixedLabels = [ "button", ".postboard-news", ".post-area-new textarea", - ".refresh-users, .view-all-users", + ".refresh-toptrends, .refresh-users, .view-all-users", ".who-to-follow h3", ".userMenu-search-field", "a.dropdown-menu-item, a.direct-messages", diff --git a/js/options.js b/js/options.js index 1d76dbc..d28cfe9 100644 --- a/js/options.js +++ b/js/options.js @@ -372,6 +372,25 @@ var TwisterOptions = function() }); } + this.getTopTrendsOpt = function() { + return this.getOption('TopTrends', 'enable'); + } + + this.setTopTrendsOpt = function () { + function TopTrendsCfg() { + if ($.Options.getTopTrendsOpt() === 'enable') + $('#TopTrendsCont').show(); + else + $('#TopTrendsCont').hide(); + } + $('#TopTrends').val(this.getTopTrendsOpt()); + TopTrendsCfg(); + $('#TopTrends').on('change', function() { + $.Options.setOption(this.id, this.value); + TopTrendsCfg(); + }); + } + this.getTopTrendsAutoUpdateOpt = function() { return this.getOption('TopTrendsAutoUpdate', 'enable'); } @@ -601,6 +620,7 @@ var TwisterOptions = function() this.setUseProxyOpt(); this.setUseProxyForImgOnlyOpt(); this.setTopTrendsAutoUpdateOpt(); + this.setTopTrendsOpt(); this.setTopTrendsAutoUpdateTimerOpt(); this.setWhoToFollowOpt(); this.setSplitPostsOpt(); diff --git a/options.html b/options.html index 4788250..4464861 100644 --- a/options.html +++ b/options.html @@ -302,15 +302,23 @@

    Top Trends

    -
    +
    -

    Auto updating

    - -
    - second(s) +

    + +

    +
    +

    Auto updating

    + +
    + second(s) +
    diff --git a/theme_calm/css/style.css b/theme_calm/css/style.css index 8c5318c..aae48a6 100644 --- a/theme_calm/css/style.css +++ b/theme_calm/css/style.css @@ -969,6 +969,7 @@ textarea.splited-post { text-decoration: none; } +.refresh-toptrends, .refresh-users, .view-all-users { @@ -979,14 +980,16 @@ textarea.splited-post { } /*********************************** -********************* TOP TRENDS +************ TOP TRENDS ************ ***********************************/ + .module.toptrends { margin-top: 10px; } .module.toptrends h3 { margin: 5px 0 5px 10px; font: 14px 'Open Sans', sans-serif; + display: inline; } .module.toptrends ol { margin: 0 0 10px 10px; diff --git a/theme_nin/css/style.css b/theme_nin/css/style.css index 42bdde5..0878ab9 100644 --- a/theme_nin/css/style.css +++ b/theme_nin/css/style.css @@ -56,7 +56,7 @@ font-style: normal; } /* line 64, ../sass/_fonts.sass */ -[class^="icon-"]:before, [class*=" icon-"]:before, .extend-icon:before, .userMenu li.userMenu-config > a:before, .post-context span:before, .post-reply:before, .post-propagate:before, .post-favorite:before, .post .show-more:before, .mini-profile-actions span:before, ul.userMenu-search-profiles button:before, .mini-profile-indicators .userMenu-connections a:before, .mini-profile-indicators .userMenu-messages a:before, .mini-profile-indicators .userMenu-user a:before, .twister-user-remove:before, .refresh-users:before, .modal-close:before, .mark-all-as-read:before, .modal-back:before, .icon-down-after:after { +[class^="icon-"]:before, [class*=" icon-"]:before, .extend-icon:before, .userMenu li.userMenu-config > a:before, .post-context span:before, .post-reply:before, .post-propagate:before, .post-favorite:before, .post .show-more:before, .mini-profile-actions span:before, ul.userMenu-search-profiles button:before, .mini-profile-indicators .userMenu-connections a:before, .mini-profile-indicators .userMenu-messages a:before, .mini-profile-indicators .userMenu-user a:before, .twister-user-remove:before, .refresh-toptrends:before, .refresh-users:before, .modal-close:before, .mark-all-as-read:before, .modal-back:before, .icon-down-after:after { font-family: "fontello"; font-style: normal; font-weight: normal; @@ -198,7 +198,7 @@ /* '' */ /* line 183, ../sass/_fonts.sass */ -.icon-arrows:before, .refresh-users:before { +.icon-arrows:before, .refresh-toptrends:before, .refresh-users:before { content: ""; } @@ -1823,7 +1823,7 @@ button.disabled:hover, .mini-profile-actions span.disabled:hover, a.button.disab width: 90%; } -.options #filterLangListCont div,.options #TopTrendsAutoUpdateCont div { +.options #filterLangListCont div,.options #TopTrendsCont div { float: none; padding: 0px 4px; } @@ -2449,7 +2449,7 @@ button.follow:hover, .mini-profile-actions span.follow:hover, button.unfollow, . } /* line 499, ../sass/style.sass */ -.refresh-users { +.refresh-toptrends, .refresh-users { color: #66686B; cursor: pointer; font-size: 11px; @@ -2479,13 +2479,16 @@ button.follow:hover, .mini-profile-actions span.follow:hover, button.unfollow, . } /* line 527, ../sass/style.sass */ -.refresh-users:hover, .view-all-users:hover { +.refresh-toptrends:hover, .refresh-users:hover, .view-all-users:hover { color: #B4C669; text-decoration: none; background-color: transparent; } /***********TOP TRENDS************** */ +.toptrends h3 { + float: left; +} /* line 534, ../sass/style.sass */ ol.toptrends-list { margin: 0; diff --git a/theme_nin/sass/style.sass b/theme_nin/sass/style.sass index 54d8291..6c3e78f 100755 --- a/theme_nin/sass/style.sass +++ b/theme_nin/sass/style.sass @@ -516,7 +516,7 @@ textarea.splited-post .twister-user-remove:hover opacity: 1 -.refresh-users +.refresh-toptrends, .refresh-users @extend .icon-arrows @extend .extend-icon color: $main-color-dark @@ -544,13 +544,17 @@ textarea.splited-post margin: 0 0 0 15px position: relative -.refresh-users:hover, .view-all-users:hover +.refresh-toptrends:hover, .refresh-users:hover, .view-all-users:hover color: $main-color-color text-decoration: none background-color: transparent /***********TOP TRENDS***************/ +.toptrends + h3 + float: left + ol.toptrends-list margin: 0 margin-bottom: 10px @@ -1096,7 +1100,7 @@ ol.toptrends-list #filterLangList width: 90% - #filterLangListCont div, #TopTrendsAutoUpdateCont div + #filterLangListCont div, #TopTrendsCont div float: none padding: 0px 4px From bd65f882bd9f175de12aacd466ea8bed244883db Mon Sep 17 00:00:00 2001 From: Simon Grim Date: Fri, 17 Apr 2015 01:36:58 +0500 Subject: [PATCH 2/2] option.js clean-ups, default value for getIsFollowingMeOpt --- js/options.js | 334 +++++++++++++++++++++----------------------------- 1 file changed, 138 insertions(+), 196 deletions(-) diff --git a/js/options.js b/js/options.js index d28cfe9..fa615d3 100644 --- a/js/options.js +++ b/js/options.js @@ -20,15 +20,15 @@ var TwisterOptions = function() } this.soundNotifOptions = function() { - $('#notifyForm select').each(function(){ - this.value = $.Options.getOption(this.id, "false"); + $('#notifyForm select').each(function() { + this.value = $.Options.getOption(this.id, 'false'); }); var player = $('#player'); player[0].pause(); $('#player').empty(); - $('form#notifyForm').on('change','select',function(){ + $('form#notifyForm').on('change', 'select', function() { $.Options.setOption(this.id, this.value); if(this.value == false) {player[0].pause(); return;} @@ -46,10 +46,10 @@ var TwisterOptions = function() this.volumeControl = function() { var playerVol = $('#playerVol'); - playerVol[0].value = $.Options.getOption(playerVol[0].id, 1); + playerVol[0].value = this.getOption(playerVol[0].id, 1); $('.volValue').text((playerVol[0].value * 100).toFixed()); - playerVol.on('change',function(){ + playerVol.on('change', function() { $.Options.setOption(this.id, this.value); $('#player')[0].volume = (this.value); $('.volValue').text((this.value * 100).toFixed()); @@ -57,8 +57,8 @@ var TwisterOptions = function() } this.DMsNotif = function() { - var sndDM = $.Options.getOption('sndDM', "false"); - if( sndDM == "false") return; + var sndDM = this.getOption('sndDM', 'false'); + if ( sndDM === 'false') return; var player = $('#player'); $('#player').empty(); @@ -69,13 +69,13 @@ var TwisterOptions = function() player.attr('type', 'audio/ogg'); player.attr('src', 'sound/'+sndDM+'.ogg'); } - player[0].volume = $.Options.getOption('playerVol',1); + player[0].volume = this.getOption('playerVol',1); player[0].play(); } this.mensNotif = function() { - var sndMention = $.Options.getOption('sndMention', "false"); - if(sndMention == "false") return; + var sndMention = this.getOption('sndMention', 'false'); + if (sndMention === 'false') return; var player = $('#playerSec'); $('#playerSec').empty(); @@ -86,23 +86,22 @@ var TwisterOptions = function() player.attr('type', 'audio/ogg'); player.attr('src', 'sound/'+sndMention+'.ogg'); } - player[0].volume = $.Options.getOption('playerVol',1); + player[0].volume = this.getOption('playerVol',1); player[0].play(); } this.getShowDesktopNotifPostsOpt = function() { - return $.Options.getOption('showDesktopNotifPosts','enable'); + return this.getOption('showDesktopNotifPosts', 'enable'); } this.setShowDesktopNotifPostsOpt = function () { function showDesktopNotifPostsDesc() { - if ($.Options.getShowDesktopNotifPostsOpt() === 'enable') { - $('#showDesktopNotifPostsDesc')[0].style.display= 'inline'; - } else { - $('#showDesktopNotifPostsDesc')[0].style.display= 'none'; - } + if ($.Options.getShowDesktopNotifPostsOpt() === 'enable') + $('#showDesktopNotifPostsDesc').css('display', 'inline'); + else + $('#showDesktopNotifPostsDesc').css('display', 'none'); } - $('#showDesktopNotifPosts').val(this.getShowDesktopNotifPostsOpt()); + $('#showDesktopNotifPosts').val( this.getShowDesktopNotifPostsOpt() ); showDesktopNotifPostsDesc(); $('#showDesktopNotifPosts').on('change', function() { $.Options.setOption(this.id, this.value); @@ -111,28 +110,26 @@ var TwisterOptions = function() } this.getShowDesktopNotifPostsTimerOpt = function () { - return parseInt($.Options.getOption('showDesktopNotifPostsTimer', '6')); + return parseInt(this.getOption('showDesktopNotifPostsTimer', '6')); } this.setShowDesktopNotifPostsTimerOpt = function () { - $('#showDesktopNotifPostsTimer')[0].value = this.getShowDesktopNotifPostsTimerOpt().toString(); - - $('#showDesktopNotifPostsTimer').on('keyup', function () {setElemValNumeric(this, polyglot.t('second(s)'));}); + $('#showDesktopNotifPostsTimer').val( this.getShowDesktopNotifPostsTimerOpt().toString() ); + $('#showDesktopNotifPostsTimer').on('keyup', function () { setElemValNumeric(this, polyglot.t('second(s)')); }); } this.getShowDesktopNotifPostsModalOpt = function() { - return $.Options.getOption('showDesktopNotifPostsModal','enable'); + return this.getOption('showDesktopNotifPostsModal', 'enable'); } this.setShowDesktopNotifPostsModalOpt = function () { function showDesktopNotifPostsModalDesc() { - if ($.Options.getShowDesktopNotifPostsModalOpt() === 'enable') { - $('#showDesktopNotifPostsModalDesc')[0].style.display= 'inline'; - } else { - $('#showDesktopNotifPostsModalDesc')[0].style.display= 'none'; - } + if ($.Options.getShowDesktopNotifPostsModalOpt() === 'enable') + $('#showDesktopNotifPostsModalDesc').css('display', 'inline'); + else + $('#showDesktopNotifPostsModalDesc').css('display', 'none'); } - $('#showDesktopNotifPostsModal').val(this.getShowDesktopNotifPostsModalOpt()); + $('#showDesktopNotifPostsModal').val( this.getShowDesktopNotifPostsModalOpt() ); showDesktopNotifPostsModalDesc(); $('#showDesktopNotifPostsModal').on('change', function() { $.Options.setOption(this.id, this.value); @@ -141,28 +138,26 @@ var TwisterOptions = function() } this.getShowDesktopNotifPostsModalTimerOpt = function () { - return parseInt($.Options.getOption('showDesktopNotifPostsModalTimer', '6')); + return parseInt(this.getOption('showDesktopNotifPostsModalTimer', '6')); } this.setShowDesktopNotifPostsModalTimerOpt = function () { - $('#showDesktopNotifPostsModalTimer')[0].value = this.getShowDesktopNotifPostsModalTimerOpt().toString(); - - $('#showDesktopNotifPostsModalTimer').on('keyup', function () {setElemValNumeric(this, polyglot.t('second(s)'));}); + $('#showDesktopNotifPostsModalTimer').val( this.getShowDesktopNotifPostsModalTimerOpt().toString() ); + $('#showDesktopNotifPostsModalTimer').on('keyup', function () { setElemValNumeric(this, polyglot.t('second(s)')); }); } this.getShowDesktopNotifMentionsOpt = function() { - return $.Options.getOption('showDesktopNotifMentions','enable'); + return this.getOption('showDesktopNotifMentions', 'enable'); } this.setShowDesktopNotifMentionsOpt = function () { function showDesktopNotifMentionsDesc() { - if ($.Options.getShowDesktopNotifMentionsOpt() === 'enable') { - $('#showDesktopNotifMentionsDesc')[0].style.display= 'inline'; - } else { - $('#showDesktopNotifMentionsDesc')[0].style.display= 'none'; - } + if ($.Options.getShowDesktopNotifMentionsOpt() === 'enable') + $('#showDesktopNotifMentionsDesc').css('display', 'inline'); + else + $('#showDesktopNotifMentionsDesc').css('display', 'none'); } - $('#showDesktopNotifMentions').val(this.getShowDesktopNotifMentionsOpt()); + $('#showDesktopNotifMentions').val( this.getShowDesktopNotifMentionsOpt() ); showDesktopNotifMentionsDesc(); $('#showDesktopNotifMentions').on('change', function() { $.Options.setOption(this.id, this.value); @@ -171,28 +166,26 @@ var TwisterOptions = function() } this.getShowDesktopNotifMentionsTimerOpt = function () { - return parseInt($.Options.getOption('showDesktopNotifMentionsTimer', '60')); + return parseInt(this.getOption('showDesktopNotifMentionsTimer', '60')); } this.setShowDesktopNotifMentionsTimerOpt = function () { - $('#showDesktopNotifMentionsTimer')[0].value = this.getShowDesktopNotifMentionsTimerOpt().toString(); - + $('#showDesktopNotifMentionsTimer').val( this.getShowDesktopNotifMentionsTimerOpt().toString() ); $('#showDesktopNotifMentionsTimer').on('keyup', function () {setElemValNumeric(this, polyglot.t('second(s)'));}); } this.getShowDesktopNotifDMsOpt = function() { - return $.Options.getOption('showDesktopNotifDMs','enable'); + return this.getOption('showDesktopNotifDMs', 'enable'); } this.setShowDesktopNotifDMsOpt = function () { function showDesktopNotifDMsDesc() { - if ($.Options.getShowDesktopNotifDMsOpt() === 'enable') { - $('#showDesktopNotifDMsDesc')[0].style.display= 'inline'; - } else { - $('#showDesktopNotifDMsDesc')[0].style.display= 'none'; - } + if ($.Options.getShowDesktopNotifDMsOpt() === 'enable') + $('#showDesktopNotifDMsDesc').css('display', 'inline'); + else + $('#showDesktopNotifDMsDesc').css('display', 'none'); } - $('#showDesktopNotifDMs').val(this.getShowDesktopNotifDMsOpt()); + $('#showDesktopNotifDMs').val( this.getShowDesktopNotifDMsOpt() ); showDesktopNotifDMsDesc(); $('#showDesktopNotifDMs').on('change', function() { $.Options.setOption(this.id, this.value); @@ -201,13 +194,12 @@ var TwisterOptions = function() } this.getShowDesktopNotifDMsTimerOpt = function () { - return parseInt($.Options.getOption('showDesktopNotifDMsTimer', '60')); + return parseInt(this.getOption('showDesktopNotifDMsTimer', '60')); } this.setShowDesktopNotifDMsTimerOpt = function () { - $('#showDesktopNotifDMsTimer')[0].value = this.getShowDesktopNotifDMsTimerOpt().toString(); - - $('#showDesktopNotifDMsTimer').on('keyup', function () {setElemValNumeric(this, polyglot.t('second(s)'));}); + $('#showDesktopNotifDMsTimer').val( this.getShowDesktopNotifDMsTimerOpt().toString() ); + $('#showDesktopNotifDMsTimer').on('keyup', function () { setElemValNumeric(this, polyglot.t('second(s)')); }); } this.setTestDesktopNotif = function() { @@ -216,160 +208,135 @@ var TwisterOptions = function() }) } - this.keysSendDefault = "ctrlenter"; + this.keysSendDefault = 'ctrlenter'; this.keysSend = function() { - $('#keysOpt select')[0].value = $.Options.getOption('keysSend',this.keysSendDefault); - - $('#keysOpt select').on('change', function(){ - $.Options.setOption(this.id, this.value); - }) + $('#keysOpt select').val( this.getOption('keysSend',this.keysSendDefault) ); + $('#keysOpt select').on('change', function() { $.Options.setOption(this.id, this.value); }); } this.keyEnterToSend = function() { - return $.Options.getOption('keysSend',this.keysSendDefault) == "enter"; + return this.getOption('keysSend', this.keysSendDefault) === 'enter'; } this.setLang = function() { - $('#language').val($.Options.getOption('locLang','auto')) - $('#language').on('change', function(){ + $('#language').val( this.getOption('locLang', 'auto') ); + $('#language').on('change', function() { $.Options.setOption('locLang', $(this).val()); location.reload(); }) } this.getTheme = function() { - return $.Options.getOption('theme','original'); + return this.getOption('theme', 'original'); } this.setTheme = function() { - $('#theme').val(this.getTheme()) - $('#theme').on('change', function(){ + $('#theme').val( this.getTheme() ) + $('#theme').on('change', function() { $.Options.setOption('theme', $(this).val()); location.reload(); }); } this.getLineFeedsOpt = function() { - return $.Options.getOption('displayLineFeeds',"disable"); + return this.getOption('displayLineFeeds', 'disable'); } this.setLineFeedsOpt = function() { - $('#lineFeedsOpt select')[0].value = this.getLineFeedsOpt(); - - $('#lineFeedsOpt select').on('change', function(){ - $.Options.setOption(this.id, this.value); - }) + $('#lineFeedsOpt select').val( this.getLineFeedsOpt() ); + $('#lineFeedsOpt select').on('change', function() { $.Options.setOption(this.id, this.value); }); } this.getShowPreviewOpt = function() { - return $.Options.getOption('displayPreview',"disable"); + return this.getOption('displayPreview', 'disable'); } this.setShowPreviewOpt = function () { - $('#showPreviewOpt select')[0].value = this.getShowPreviewOpt(); - - $('#showPreviewOpt select').on('change', function(){ - $.Options.setOption(this.id, this.value); - }); + $('#showPreviewOpt select').val( this.getShowPreviewOpt() ); + $('#showPreviewOpt select').on('change', function() { $.Options.setOption(this.id, this.value); }); } this.getUnicodeConversionOpt = function () { - return $.Options.getOption('unicodeConversion', "disable"); + return this.getOption('unicodeConversion', 'disable'); } this.setUnicodeConversionOpt = function () { - $("#unicodeConversion")[0].value = this.getUnicodeConversionOpt(); + $('#unicodeConversion').val( this.getUnicodeConversionOpt() ); - if (this.getUnicodeConversionOpt() === "custom") - $("#unicodeConversionOpt .suboptions")[0].style.height = "230px"; + if (this.getUnicodeConversionOpt() === 'custom') + $('#unicodeConversionOpt .suboptions').css('height', 'auto'); - $("#unicodeConversion").on('change', function () { + $('#unicodeConversion').on('change', function () { $.Options.setOption(this.id, this.value); - if (this.value === "custom") - $("#unicodeConversionOpt .suboptions")[0].style.height = "230px"; + if (this.value === 'custom') + $('#unicodeConversionOpt .suboptions').css('height', 'auto'); else - $("#unicodeConversionOpt .suboptions")[0].style.height = "0px"; + $('#unicodeConversionOpt .suboptions').css('height', '0px'); }); } this.getConvertPunctuationsOpt = function() { - return $.Options.getOption('convertPunctuationsOpt', false); + return this.getOption('convertPunctuationsOpt', false); } this.setConvertPunctuationsOpt = function () { - $('#convertPunctuationsOpt')[0].checked = this.getConvertPunctuationsOpt(); - - $('#convertPunctuationsOpt').on('change', function(){ - $.Options.setOption(this.id, this.checked); - }); + $('#convertPunctuationsOpt').prop('checked', this.getConvertPunctuationsOpt()); + $('#convertPunctuationsOpt').on('change', function() { $.Options.setOption(this.id, this.checked); }); } this.getConvertEmotionsOpt = function() { - return $.Options.getOption('convertEmotionsOpt', false); + return this.getOption('convertEmotionsOpt', false); } this.setConvertEmotionsOpt = function () { - $('#convertEmotionsOpt')[0].checked = this.getConvertEmotionsOpt(); - - $('#convertEmotionsOpt').on('change', function(){ - $.Options.setOption(this.id, this.checked); - }); + $('#convertEmotionsOpt').prop('checked', this.getConvertEmotionsOpt()); + $('#convertEmotionsOpt').on('change', function() { $.Options.setOption(this.id, this.checked); }); } this.getConvertSignsOpt = function() { - return $.Options.getOption('convertSignsOpt', false); + return this.getOption('convertSignsOpt', false); } this.setConvertSignsOpt = function () { - $('#convertSignsOpt')[0].checked = this.getConvertSignsOpt(); - - $('#convertSignsOpt').on('change', function(){ - $.Options.setOption(this.id, this.checked); - }); + $('#convertSignsOpt').prop('checked', this.getConvertSignsOpt()); + $('#convertSignsOpt').on('change', function() { $.Options.setOption(this.id, this.checked); }); } this.getConvertFractionsOpt = function() { - return $.Options.getOption('convertFractionsOpt', false); + return this.getOption('convertFractionsOpt', false); } this.setConvertFractionsOpt = function () { - $('#convertFractionsOpt')[0].checked = this.getConvertFractionsOpt(); - - $('#convertFractionsOpt').on('change', function(){ - $.Options.setOption(this.id, this.checked); - }); + $('#convertFractionsOpt').prop('checked', this.getConvertFractionsOpt()); + $('#convertFractionsOpt').on('change', function() { $.Options.setOption(this.id, this.checked); }); } this.getUseProxyOpt = function () { - return $.Options.getOption('useProxy', 'disable'); + return this.getOption('useProxy', 'disable'); } this.setUseProxyOpt = function () { - $('#useProxy')[0].value = this.getUseProxyOpt(); + $('#useProxy').val( this.getUseProxyOpt() ); if (this.getUseProxyOpt() === 'disable') - $('#useProxyForImgOnly').attr('disabled','disabled'); + $('#useProxyForImgOnly').attr('disabled', 'disabled'); $('#useProxy').on('change', function () { $.Options.setOption(this.id, this.value); - if (this.value === 'disable') - $('#useProxyForImgOnly').attr('disabled','disabled'); + $('#useProxyForImgOnly').attr('disabled', 'disabled'); else $('#useProxyForImgOnly').removeAttr('disabled'); }); } this.getUseProxyForImgOnlyOpt = function () { - return $.Options.getOption('useProxyForImgOnly', false); + return this.getOption('useProxyForImgOnly', false); } this.setUseProxyForImgOnlyOpt = function () { - $('#useProxyForImgOnly')[0].checked = this.getUseProxyForImgOnlyOpt(); - - $('#useProxyForImgOnly').on('change', function () { - $.Options.setOption(this.id, this.checked); - }); + $('#useProxyForImgOnly').prop('checked', this.getUseProxyForImgOnlyOpt()); + $('#useProxyForImgOnly').on('change', function () { $.Options.setOption(this.id, this.checked); }); } this.getTopTrendsOpt = function() { @@ -383,7 +350,7 @@ var TwisterOptions = function() else $('#TopTrendsCont').hide(); } - $('#TopTrends').val(this.getTopTrendsOpt()); + $('#TopTrends').val( this.getTopTrendsOpt() ); TopTrendsCfg(); $('#TopTrends').on('change', function() { $.Options.setOption(this.id, this.value); @@ -397,13 +364,12 @@ var TwisterOptions = function() this.setTopTrendsAutoUpdateOpt = function () { function TopTrendsAutoUpdateCfg() { - if ($.Options.getTopTrendsAutoUpdateOpt() === 'enable') { - $('#TopTrendsAutoUpdateOpt')[0].style.display= 'inline'; - } else { - $('#TopTrendsAutoUpdateOpt')[0].style.display= 'none'; - } + if ($.Options.getTopTrendsAutoUpdateOpt() === 'enable') + $('#TopTrendsAutoUpdateOpt').css('display', 'inline'); + else + $('#TopTrendsAutoUpdateOpt').css('display', 'none'); } - $('#TopTrendsAutoUpdate').val(this.getTopTrendsAutoUpdateOpt()); + $('#TopTrendsAutoUpdate').val( this.getTopTrendsAutoUpdateOpt() ); TopTrendsAutoUpdateCfg(); $('#TopTrendsAutoUpdate').on('change', function() { $.Options.setOption(this.id, this.value); @@ -416,9 +382,8 @@ var TwisterOptions = function() } this.setTopTrendsAutoUpdateTimerOpt = function () { - $('#TopTrendsAutoUpdateTimer')[0].value = this.getTopTrendsAutoUpdateTimerOpt().toString(); - - $('#TopTrendsAutoUpdateTimer').on('keyup', function () {setElemValNumeric(this, polyglot.t('second(s)'));}); + $('#TopTrendsAutoUpdateTimer').val( this.getTopTrendsAutoUpdateTimerOpt().toString() ); + $('#TopTrendsAutoUpdateTimer').on('keyup', function () { setElemValNumeric(this, polyglot.t('second(s)')); }); } this.getWhoToFollowOpt = function() { @@ -430,81 +395,64 @@ var TwisterOptions = function() $('#WhoToFollow').on('change', function() { $.Options.setOption(this.id, this.value); }); } - this.getSplitPostsOpt = function (){ - return $.Options.getOption('splitPosts', 'disable'); + this.getSplitPostsOpt = function () { + return this.getOption('splitPosts', 'disable'); } this.setSplitPostsOpt = function () { - $('#splitPosts')[0].value = this.getSplitPostsOpt(); - - $('#splitPosts').on('change', function () { - $.Options.setOption(this.id, this.value); - }); + $('#splitPosts').val( this.getSplitPostsOpt() ); + $('#splitPosts').on('change', function () { $.Options.setOption(this.id, this.value); }); } this.getHideRepliesOpt = function () { - return $.Options.getOption('hideReplies', 'following'); + return this.getOption('hideReplies', 'following'); } this.setHideRepliesOpt = function () { - $('#hideReplies')[0].value = this.getHideRepliesOpt(); - - $('#hideReplies').on('change', function () { - $.Options.setOption(this.id, this.value); - }); + $('#hideReplies').val( this.getHideRepliesOpt() ); + $('#hideReplies').on('change', function () { $.Options.setOption(this.id, this.value); }); } this.getHideCloseRTsOpt = function () { - return $.Options.getOption('hideCloseRTs', 'disable'); + return this.getOption('hideCloseRTs', 'disable'); }; this.setHideCloseRTsOpt = function () { - $('#hideCloseRTs')[0].value = this.getHideCloseRTsOpt(); - - if (this.getHideCloseRTsOpt() === 'disable') { - $('#hideCloseRTsDesc')[0].style.display = 'none'; - } else { - $('#hideCloseRTsDesc')[0].style.display = 'inline'; + function hideCloseRTsCfg() { + if ($.Options.getHideCloseRTsOpt() === 'disable') + $('#hideCloseRTsDesc').css('display', 'none'); + else + $('#hideCloseRTsDesc').css('display', 'inline'); } - + $('#hideCloseRTs').val( this.getHideCloseRTsOpt() ); + hideCloseRTsCfg(); $('#hideCloseRTs').on('change', function () { $.Options.setOption(this.id, this.value); - - if (this.value === 'disable') { - $('#hideCloseRTsDesc')[0].style.display = 'none'; - } else { - $('#hideCloseRTsDesc')[0].style.display = 'inline'; - } + hideCloseRTsCfg(); }); }; this.getHideCloseRTsHourOpt = function () { - return parseInt($.Options.getOption('hideCloseRtsHour', '1')); + return parseInt(this.getOption('hideCloseRtsHour', '1')); }; this.setHideCloseRTsHourOpt = function () { - $('#hideCloseRtsHour')[0].value = this.getHideCloseRTsHourOpt().toString(); - - $('#hideCloseRtsHour').on('keyup', function () {setElemValNumeric(this, polyglot.t('hour(s)'));}); - }; - - this.getIsFollowingMeOpt = function () { - return $.Options.getOption('isFollowingMe'); + $('#hideCloseRtsHour').val( this.getHideCloseRTsHourOpt().toString() ); + $('#hideCloseRtsHour').on('keyup', function () { setElemValNumeric(this, polyglot.t('hour(s)')); }); }; this.getFilterLangOpt = function() { - return this.getOption('filterLang','disable'); + return this.getOption('filterLang', 'disable'); } this.setFilterLangOpt = function () { function filterLangListCont() { - if ( $.Options.getFilterLangOpt() !== 'disable' ) { - $('#filterLangListCont')[0].style.display= 'block'; - } else { - $('#filterLangListCont')[0].style.display= 'none'; - } + if ( $.Options.getFilterLangOpt() !== 'disable' ) + $('#filterLangListCont').css('display', 'block'); + else + $('#filterLangListCont').css('display', 'none'); } - $('#filterLang').val(this.getFilterLangOpt()); + $('#filterLang').val( this.getFilterLangOpt() ); filterLangListCont(); $('#filterLang').on('change', function() { $.Options.setOption(this.id, this.value); @@ -517,9 +465,9 @@ var TwisterOptions = function() } this.setFilterLangListOpt = function () { - $('#filterLangList').val(this.getFilterLangListOpt()); + $('#filterLangList').val( this.getFilterLangListOpt() ); - $('#filterLangList').on('keyup', function () {$.Options.setOption(this.id, this.value);}); + $('#filterLangList').on('keyup', function () { $.Options.setOption(this.id, this.value); }); } this.getFilterLangAccuracyOpt = function () { @@ -527,8 +475,8 @@ var TwisterOptions = function() } this.setFilterLangAccuracyOpt = function () { - $('#filterLangAccuracy').val(this.getFilterLangAccuracyOpt()); - $('#filterLangAccuracyVal').text(this.getFilterLangAccuracyOpt()); + $('#filterLangAccuracy').val( this.getFilterLangAccuracyOpt() ); + $('#filterLangAccuracyVal').text( this.getFilterLangAccuracyOpt() ); $('#filterLangAccuracy').on('change', function () { $.Options.setOption(this.id, this.value); $('#filterLangAccuracyVal').text(this.value); @@ -541,8 +489,7 @@ var TwisterOptions = function() this.setFilterLangForPostboardOpt = function () { $('#filterLangForPostboard').prop('checked', this.getFilterLangForPostboardOpt()); - - $('#filterLangForPostboard').on('click', function () {$.Options.setOption(this.id, this.checked);}); + $('#filterLangForPostboard').on('click', function () { $.Options.setOption(this.id, this.checked); }); } this.getFilterLangForSearchingOpt = function () { @@ -551,8 +498,7 @@ var TwisterOptions = function() this.setFilterLangForSearchingOpt = function () { $('#filterLangForSearching').prop('checked', this.getFilterLangForSearchingOpt()); - - $('#filterLangForSearching').on('click', function () {$.Options.setOption(this.id, this.checked);}); + $('#filterLangForSearching').on('click', function () { $.Options.setOption(this.id, this.checked); }); } this.getFilterLangForTopTrendsOpt = function () { @@ -561,8 +507,7 @@ var TwisterOptions = function() this.setFilterLangForTopTrendsOpt = function () { $('#filterLangForTopTrends').prop('checked', this.getFilterLangForTopTrendsOpt()); - - $('#filterLangForTopTrends').on('click', function () {$.Options.setOption(this.id, this.checked);}); + $('#filterLangForTopTrends').on('click', function () { $.Options.setOption(this.id, this.checked); }); } this.getFilterLangSimulateOpt = function () { @@ -571,28 +516,25 @@ var TwisterOptions = function() this.setFilterLangSimulateOpt = function () { $('#filterLangSimulate').prop('checked', this.getFilterLangSimulateOpt()); - - $('#filterLangSimulate').on('click', function () {$.Options.setOption(this.id, this.checked);}); + $('#filterLangSimulate').on('click', function () { $.Options.setOption(this.id, this.checked); }); } - this.setIsFollowingMeOpt = function () { - $('#isFollowingMe')[0].value = this.getIsFollowingMeOpt(); + this.getIsFollowingMeOpt = function () { + return this.getOption('isFollowingMe', 'in-profile'); + }; - $('#isFollowingMe').on('change', function () { - $.Options.setOption(this.id, this.value); - }); + this.setIsFollowingMeOpt = function () { + $('#isFollowingMe').val( this.getIsFollowingMeOpt() ); + $('#isFollowingMe').on('change', function () { $.Options.setOption(this.id, this.value); }); }; this.getDMCopySelfOpt = function() { - return $.Options.getOption('dmCopySelf',"enable"); + return this.getOption('dmCopySelf', 'enable'); } this.setDMCopySelfOpt = function () { - $('#dmCopySelfOpt select')[0].value = this.getDMCopySelfOpt(); - - $('#dmCopySelfOpt select').on('change', function(){ - $.Options.setOption(this.id, this.value); - }); + $('#dmCopySelfOpt select').val( this.getDMCopySelfOpt() ); + $('#dmCopySelfOpt select').on('change', function() { $.Options.setOption(this.id, this.value); }); } this.InitOptions = function() {