From 9a97fd03288e97b0d855d9259898f1290d1bd1c4 Mon Sep 17 00:00:00 2001 From: Simon Grim Date: Fri, 14 Jul 2017 03:17:18 +0500 Subject: [PATCH] add option to enable/disable encryption of DMs's data cache, separate section for DMs in options --- js/interface_localization.js | 39 ++++++++++++++++++++++++------------ js/options.js | 4 ++++ js/twister_newmsgs.js | 6 ++++-- options.html | 35 +++++++++++++++++++++++--------- theme_nin/css/style.css | 2 +- theme_nin/js/theme_option.js | 12 ++++------- theme_nin/sass/_tabs.sass | 5 ++--- 7 files changed, 67 insertions(+), 36 deletions(-) diff --git a/js/interface_localization.js b/js/interface_localization.js index abf858c..945a05c 100644 --- a/js/interface_localization.js +++ b/js/interface_localization.js @@ -367,7 +367,8 @@ if(preferredLanguage == "en"){ "Language": "Language", "Sound": "Sound", "Users": "Users", - "Direct Message's copy to self": "Direct Message's copy to self", + 'dm_copy_outgoing_to_self': 'Copy outgoing messages to self', + 'dm_encrypt_local_cache': 'Encrypt local data cache', "Terminate Daemon": "Terminate Daemon", "New post": "New post", "Search": "Search", @@ -736,7 +737,8 @@ if(preferredLanguage == "es"){ "Language": "Idioma", "Sound": "Sonido", "Users": "Usuarios", - "Direct Message's copy to self": "Direct Message's copy to self", + 'dm_copy_outgoing_to_self': 'Copy outgoing messages to self', + 'dm_encrypt_local_cache': 'Encrypt local data cache', "Traffic information": "Traffic information", "DHT Torrents:": "DHT Torrents:", "Peers:": "Peers:", @@ -1099,7 +1101,8 @@ if(preferredLanguage == "uk"){ "Language": "Мова", "Sound": "Звук", "Users": "Користувачі", - "Direct Message's copy to self": "Повідомлення скопійовано самому собі", + 'dm_copy_outgoing_to_self': 'Повідомлення скопійовано самому собі', + 'dm_encrypt_local_cache': 'Encrypt local data cache', "Traffic information": "Статистика трафіку", "Direct messages with": "Співбесіда з", "DHT Torrents:": "DHT Torrents:", @@ -1465,7 +1468,8 @@ if(preferredLanguage == "zh-CN"){ "Language": "语言", "Sound": "声音", "Users": "用户", - "Direct Message's copy to self": "将私信发一份副本给我", + 'dm_copy_outgoing_to_self': '将私信发一份副本给我', + 'dm_encrypt_local_cache': 'Encrypt local data cache', "Terminate Daemon": "终止后台进程", "New post": "新推文", "Search": "搜索", @@ -1835,7 +1839,8 @@ if(preferredLanguage == "nl"){ "Language": "Language", "Sound": "Sound", "Users": "Users", - "Direct Message's copy to self": "Direct Message's copy to self", + 'dm_copy_outgoing_to_self': 'Copy outgoing messages to self', + 'dm_encrypt_local_cache': 'Encrypt local data cache', "Traffic information": "Traffic information", "DHT Torrents:": "DHT Torrents:", "Peers:": "Peers:", @@ -2199,7 +2204,8 @@ if(preferredLanguage == "it"){ "Language": "Language", "Sound": "Sound", "Users": "Users", - "Direct Message's copy to self": "Direct Message's copy to self", + 'dm_copy_outgoing_to_self': 'Copy outgoing messages to self', + 'dm_encrypt_local_cache': 'Encrypt local data cache', "Traffic information": "Traffic information", "DHT Torrents:": "DHT Torrents:", "Peers:": "Peers:", @@ -2565,7 +2571,8 @@ if(preferredLanguage == "fr"){ "Language": "Language", "Sound": "Sound", "Users": "Users", - "Direct Message's copy to self": "Direct Message's copy to self", + 'dm_copy_outgoing_to_self': 'Copy outgoing messages to self', + 'dm_encrypt_local_cache': 'Encrypt local data cache', "Traffic information": "Traffic information", "DHT Torrents:": "DHT Torrents:", "Peers:": "Peers:", @@ -2932,7 +2939,8 @@ if(preferredLanguage == "ru"){ "Language": "Язык", "Sound": "Звук", "Users": "Пользователи", - "Direct Message's copy to self": "Синхронизировать отправленные личные сообщения", + 'dm_copy_outgoing_to_self': 'Синхронизировать отправленные личные сообщения', + 'dm_encrypt_local_cache': 'Шифровать локальный кэш данных', "Terminate Daemon": "Выключить twister демон", "New post": "Новый пост", "Search": "Поиск", @@ -3304,7 +3312,8 @@ if(preferredLanguage == "de"){ "Language": "Language", "Sound": "Sound", "Users": "Users", - "Direct Message's copy to self": "Kopie der Direktnachricht an mich selbst", + 'dm_copy_outgoing_to_self': 'Kopie der Direktnachricht an mich selbst', + 'dm_encrypt_local_cache': 'Encrypt local data cache', "Traffic information": "Traffic information", "DHT Torrents:": "DHT Torrents:", "Peers:": "Peers:", @@ -3667,7 +3676,8 @@ if(preferredLanguage == "ja"){ "Language": "Language", "Sound": "Sound", "Users": "Users", - "Direct Message's copy to self": "Direct Message's copy to self", + 'dm_copy_outgoing_to_self': 'Copy outgoing messages to self', + 'dm_encrypt_local_cache': 'Encrypt local data cache', "Traffic information": "Traffic information", "DHT Torrents:": "DHT Torrents:", "Peers:": "Peers:", @@ -4035,7 +4045,8 @@ if(preferredLanguage == "pt-BR"){ "Language": "Language", "Sound": "Sound", "Users": "Users", - "Direct Message's copy to self": "Direct Message's copy to self", + 'dm_copy_outgoing_to_self': 'Copy outgoing messages to self', + 'dm_encrypt_local_cache': 'Encrypt local data cache', "Traffic information": "Traffic information", "DHT Torrents:": "DHT Torrents:", "Peers:": "Peers:", @@ -4400,7 +4411,8 @@ if(preferredLanguage == "tr"){ "Language": "Dil", "Sound": "Ses", "Users": "Kullanıcılar", - "Direct Message's copy to self": "Özel iletinin kopyasını sakla", + 'dm_copy_outgoing_to_self': 'Özel iletinin kopyasını sakla', + 'dm_encrypt_local_cache': 'Encrypt local data cache', "Traffic information": "Trafik bilgileri", "DHT Torrents:": "DHT Torrentleri:", "Peers:": "Eşler:", @@ -4765,7 +4777,8 @@ if(preferredLanguage == "cs"){ "Language": "Jazyk", "Sound": "Zvuky", "Users": "Uživatelé", - "Direct Message's copy to self": "Posílat kopie přímých zpráv sám sobě", + 'dm_copy_outgoing_to_self': 'Posílat kopie přímých zpráv sám sobě', + 'dm_encrypt_local_cache': 'Encrypt local data cache', "New post": "Nový příspěvek", "Search": "Hledat", "Direct Msg": "Přímá zpráva", diff --git a/js/options.js b/js/options.js index 84f17cb..0eac0a1 100644 --- a/js/options.js +++ b/js/options.js @@ -227,6 +227,10 @@ function twisterOptions() { name: 'dmCopySelf', valDefault: 'enable' }); + this.add({ + name: 'dmEncryptCache', + valDefault: 'enable' + }); this.add({ name: 'hideReplies', valDefault: 'following' diff --git a/js/twister_newmsgs.js b/js/twister_newmsgs.js index 5d175a8..dc147ff 100644 --- a/js/twister_newmsgs.js +++ b/js/twister_newmsgs.js @@ -200,8 +200,10 @@ function saveDMsToStorage() { }; } - pool = twister.var.key.pub.encrypt(JSON.stringify(pool)); - delete pool.orig; // WORKAROUND the decrypt function does .slice(0, orig) but something goes wrong in process of buffer decoding (if original string contains non-ASCII characters) and orig may be smaller than the actual size, if it is undefined .slice gets it whole + if ($.Options.get('dmEncryptCache') === 'enable') { + pool = twister.var.key.pub.encrypt(JSON.stringify(pool)); + delete pool.orig; // WORKAROUND the decrypt function does .slice(0, orig) but something goes wrong in process of buffer decoding (if original string contains non-ASCII characters) and orig may be smaller than the actual size, if it is undefined .slice gets it whole + } $.initNamespaceStorage(defaultScreenName).localStorage.set('DMs', pool); } diff --git a/options.html b/options.html index c115791..1cc3a23 100644 --- a/options.html +++ b/options.html @@ -52,6 +52,8 @@ + + @@ -194,6 +196,30 @@ +
+
+

Direct Messages

+
+
+

dm_copy_outgoing_to_self

+ +
+
+
+
+

dm_encrypt_local_cache

+ +
+
+
+
+

Keys

@@ -457,15 +483,6 @@
-
-
-

Direct Message's copy to self

- -
-
diff --git a/theme_nin/css/style.css b/theme_nin/css/style.css index dd551e0..1504e1a 100644 --- a/theme_nin/css/style.css +++ b/theme_nin/css/style.css @@ -1415,7 +1415,7 @@ button:disabled:hover, button.disabled:hover, .mini-profile-actions span.disable visibility: hidden; } /* line 42, ../sass/_tabs.sass */ -.options input#tab_language:checked ~ .tab-content .language, .options input#t-2:checked ~ .tab-content .theme, .options input#t-3:checked ~ .tab-content .notifications, .options input#t-4:checked ~ .tab-content .keys, .options input#t-5:checked ~ .tab-content .appearance, .options input#t-6:checked ~ .tab-content .users, .options input#t-7:checked ~ .tab-content .webtorrent { +.options input#tab_language:checked ~ .tab-content .language, .options input#t-2:checked ~ .tab-content .theme, .options input#t-3:checked ~ .tab-content .notifications, .options input#t-4:checked ~ .tab-content .keys, .options input#t-5:checked ~ .tab-content .appearance, .options input#t-6:checked ~ .tab-content .users, .options input#t-7:checked ~ .tab-content .webtorrent, .options input#t-8:checked ~ .tab-content .DMs { position: relative; z-index: 10; opacity: 1; diff --git a/theme_nin/js/theme_option.js b/theme_nin/js/theme_option.js index fdcb3a5..95371b0 100644 --- a/theme_nin/js/theme_option.js +++ b/theme_nin/js/theme_option.js @@ -53,12 +53,8 @@ $(function(){ }); 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")); - $("label[for=t-7]").text(polyglot.t("WebTorrent")); + $('label.tabs').each(function (i, elem) { + var elem = $(elem); + elem.text(polyglot.t(elem.text())); + }); } - diff --git a/theme_nin/sass/_tabs.sass b/theme_nin/sass/_tabs.sass index c403c22..1a40dac 100644 --- a/theme_nin/sass/_tabs.sass +++ b/theme_nin/sass/_tabs.sass @@ -48,6 +48,7 @@ &#t-5:checked ~ .tab-content .appearance, &#t-6:checked ~ .tab-content .users &#t-7:checked ~ .tab-content .webtorrent + &#t-8:checked ~ .tab-content .DMs position: relative z-index: 10 opacity: 1 @@ -59,7 +60,7 @@ text-align: center width: auto display: inline-block!important - margin: 0 5px 0 0 + margin: 0 5px 0 0 padding: 5px 15px color: $main-color-light background: $background-light @@ -67,5 +68,3 @@ input:checked + label.tabs background: $bloc-background-color color: $main-color-dark - -