[Pkg-mozext-commits] [requestpolicy] 03/65: [imp] Site Info on middle-click

David Prévot taffit at moszumanska.debian.org
Fri Mar 25 22:59:45 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository requestpolicy.

commit 069781da83fc4fdeedf99b6bac09e91861a6f060
Author: Martin Kimmerle <dev at 256k.de>
Date:   Sun Jan 3 19:47:33 2016 +0100

    [imp] Site Info on middle-click
    
    Open myWOT information in a new tab when the middle mouse button
    is clicked.
    
    Resolves #456
---
 src/content/lib/default-preferences.js    |  2 +
 src/content/models/prefs.jsm              |  1 +
 src/content/ui/menu.js                    | 99 ++++++++++++++++++++++++++++++-
 src/locale/de/requestpolicy.properties    |  2 +
 src/locale/en-US/requestpolicy.properties |  2 +
 src/locale/eo/requestpolicy.properties    |  2 +
 src/locale/es-MX/requestpolicy.properties |  2 +
 src/locale/eu/requestpolicy.properties    |  2 +
 src/locale/fr/requestpolicy.properties    |  2 +
 src/locale/it/requestpolicy.properties    |  2 +
 src/locale/ja/requestpolicy.properties    |  2 +
 src/locale/ko-KR/requestpolicy.properties |  2 +
 src/locale/lv-LV/requestpolicy.properties |  2 +
 src/locale/nl/requestpolicy.properties    |  2 +
 src/locale/pt-BR/requestpolicy.properties |  2 +
 src/locale/ru-RU/requestpolicy.properties |  2 +
 src/locale/sk-SK/requestpolicy.properties |  2 +
 src/locale/sv-SE/requestpolicy.properties |  2 +
 src/locale/tr/requestpolicy.properties    |  2 +
 src/locale/uk-UA/requestpolicy.properties |  2 +
 src/locale/zh-CN/requestpolicy.properties |  2 +
 src/locale/zh-TW/requestpolicy.properties |  2 +
 22 files changed, 138 insertions(+), 2 deletions(-)

diff --git a/src/content/lib/default-preferences.js b/src/content/lib/default-preferences.js
index 8b768b1..942620c 100644
--- a/src/content/lib/default-preferences.js
+++ b/src/content/lib/default-preferences.js
@@ -25,6 +25,8 @@ pref("extensions.requestpolicy.contextMenu", true);
 pref("extensions.requestpolicy.menu.sorting", "numRequests");
 pref("extensions.requestpolicy.menu.info.showNumRequests", true);
 
+pref("extensions.requestpolicy.confirmSiteInfo", true);
+
 pref("extensions.requestpolicy.keyboardShortcuts.openMenu.enabled", true);
 pref("extensions.requestpolicy.keyboardShortcuts.openMenu.combo", "default");
 
diff --git a/src/content/models/prefs.jsm b/src/content/models/prefs.jsm
index 50af705..7e2be58 100644
--- a/src/content/models/prefs.jsm
+++ b/src/content/models/prefs.jsm
@@ -47,6 +47,7 @@ var Prefs = (function() {
   self.branches = {
     rp: new PrefBranch("extensions.requestpolicy.", {
       "autoReload": "BoolPref",
+      "confirmSiteInfo": "BoolPref",
       "contextMenu": "BoolPref",
       "defaultPolicy.allow": "BoolPref",
       "defaultPolicy.allowSameDomain": "BoolPref",
diff --git a/src/content/ui/menu.js b/src/content/ui/menu.js
index e45b5d5..9623e42 100644
--- a/src/content/ui/menu.js
+++ b/src/content/ui/menu.js
@@ -27,6 +27,9 @@ window.rpcontinued.menu = (function() {
   /* global Components */
   const {utils: Cu} = Components;
 
+  let {Services} = Cu.import("resource://gre/modules/Services.jsm", {});
+  let {console} = Cu.import("resource://gre/modules/devtools/Console.jsm", {});
+
   let {ScriptLoader: {importModule}} = Cu.import(
       "chrome://rpcontinued/content/lib/script-loader.jsm", {});
 
@@ -104,6 +107,43 @@ window.rpcontinued.menu = (function() {
     }
   };
 
+  //----------------------------------------------------------------------------
+  // utilities
+  //----------------------------------------------------------------------------
+
+  /**
+   * Show a dialog with "OK" and "Cancel" buttons, as well as with a
+   * checkbox labeled "always ask?".
+   *
+   * @return {boolean} If the question has been confirmed or not.
+   */
+  function confirm(dialogMessage, alwaysAskPrefName, params={}) {
+    let shouldAsk = Prefs.get(alwaysAskPrefName);
+    if (shouldAsk === false) {
+      // never ask
+      return true;
+    }
+
+    let dialogTitle = params.dialogTitle || "RequestPolicy";
+    let checkboxObj = {value: shouldAsk};
+    let checkboxText = StringUtils.$str("alwaysAsk");
+
+    if (typeof params.onBeforeDialog === "function") {
+      params.onBeforeDialog.call();
+    }
+
+    let confirmed = Services.prompt.confirmCheck(window, dialogTitle,
+        dialogMessage, checkboxText, checkboxObj);
+
+    if (confirmed) {
+      // "OK" has been pressed
+      Prefs.set(alwaysAskPrefName, checkboxObj.value);
+      return true;
+    }
+    // "Cancel" has been pressed
+    return false;
+  }
+
   /**
    * Remove all children from a list, and remove all event listeners.
    *
@@ -126,6 +166,10 @@ window.rpcontinued.menu = (function() {
     DOMUtils.removeChildren(aList);
   }
 
+  //----------------------------------------------------------------------------
+  //----------------------------------------------------------------------------
+  //----------------------------------------------------------------------------
+
   self.prepareMenu = function() {
     try {
       var disabled = Prefs.isBlockingDisabled();
@@ -205,6 +249,10 @@ window.rpcontinued.menu = (function() {
     }
   };
 
+  self.close = function() {
+    $id("rpc-popup").hidePopup();
+  };
+
   self._populateMenuForUncontrollableOrigin = function() {
     self._originDomainnameItem.setAttribute("value",
         StringUtils.$str("noOrigin"));
@@ -561,6 +609,45 @@ window.rpcontinued.menu = (function() {
     self._populateDetails();
   };
 
+  function openSiteInfoTab(domain) {
+    let url = "https://www.mywot.com/en/scorecard/" + domain;
+    window.openUILinkIn(url, "tab", {
+      relatedToCurrent: true,
+      inBackground: true
+    });
+  }
+
+  function maybeOpenSiteInfoTab(item) {
+    let domain = null;
+
+    if (item.value) {
+      domain = item.value;
+    } else {
+      let domainLabel = item.querySelector(".domainname");
+
+      if (domainLabel !== null) {
+        domain = domainLabel.value;
+      }
+    }
+
+    if (domain === null) {
+      console.error("Failed to determine the domain under the mouse button " +
+                    "after the middle-click.");
+      return;
+    }
+
+    let dialogMessage = StringUtils.$str("siteInfo.confirm",
+        [domain, "https://www.mywot.com"]);
+    let alwaysAskPrefName = "confirmSiteInfo";
+    let confirmed = confirm(dialogMessage, alwaysAskPrefName, {
+      // close the menu if the dialog needs to be shown
+      onBeforeDialog: self.close
+    });
+    if (confirmed) {
+      openSiteInfoTab(domain);
+    }
+  }
+
   self.itemSelected = function(event) {
     var item = event.target;
     // TODO: rather than compare IDs, this should probably compare against
@@ -572,11 +659,19 @@ window.rpcontinued.menu = (function() {
     }
     if (item.id === "rpc-origin" ||
         item.parentNode.id === "rpc-other-origins-list") {
-      self._activateOriginItem(item);
+      if (event.button === 1) {
+        maybeOpenSiteInfoTab(item);
+      } else {
+        self._activateOriginItem(item);
+      }
     } else if (item.parentNode.id === "rpc-blocked-destinations-list" ||
                item.parentNode.id === "rpc-mixed-destinations-list" ||
                item.parentNode.id === "rpc-allowed-destinations-list") {
-      self._activateDestinationItem(item);
+      if (event.button === 1) {
+        maybeOpenSiteInfoTab(item);
+      } else {
+        self._activateDestinationItem(item);
+      }
     } else if (item.parentNode.id === "rpc-rules-remove" ||
                item.parentNode.id === "rpc-rules-add") {
       self._processRuleSelection(item);
diff --git a/src/locale/de/requestpolicy.properties b/src/locale/de/requestpolicy.properties
index d1b29a4..2d87c1f 100644
--- a/src/locale/de/requestpolicy.properties
+++ b/src/locale/de/requestpolicy.properties
@@ -121,3 +121,5 @@ rp.menu.preferences=Einstellungen
 rp.menu.managePolicies=Regeln verwalten
 rp.requestLog.title=Anfragenchronik
 rp.requestLog.clear=Löschen
+alwaysAsk=Diese Meldung immer anzeigen
+siteInfo.confirm=Sie haben Informationen über die Site "%1$S"\ndurch Stellen einer Anfrage bei %2$S angefordert.\nSoll dieser Vorgang wirklich fortgesetzt werden?
diff --git a/src/locale/en-US/requestpolicy.properties b/src/locale/en-US/requestpolicy.properties
index 41828a2..7d158b9 100644
--- a/src/locale/en-US/requestpolicy.properties
+++ b/src/locale/en-US/requestpolicy.properties
@@ -121,3 +121,5 @@ rp.menu.preferences=Preferences
 rp.menu.managePolicies=Manage Policies
 rp.requestLog.title=Request Log
 rp.requestLog.clear=Clear
+alwaysAsk=Always ask for confirmation
+siteInfo.confirm=You're about to ask for information about the "%1$S" site\nby submitting a query to %2$S.\nDo you want to continue?
diff --git a/src/locale/eo/requestpolicy.properties b/src/locale/eo/requestpolicy.properties
index 50f4214..b8e6157 100644
--- a/src/locale/eo/requestpolicy.properties
+++ b/src/locale/eo/requestpolicy.properties
@@ -121,3 +121,5 @@ rp.menu.preferences=Preferoj
 rp.menu.managePolicies=Manage Policies
 rp.requestLog.title=Protokolo de petoj
 rp.requestLog.clear=Forviŝi
+alwaysAsk=Ĉiam peti konfirmon
+siteInfo.confirm=Vi estas petonta informojn pri la retejo «%1$S»\nper sendo de peto al %2$S.\nĈu vi volas fari tion?
diff --git a/src/locale/es-MX/requestpolicy.properties b/src/locale/es-MX/requestpolicy.properties
index 936118c..c61d8a7 100644
--- a/src/locale/es-MX/requestpolicy.properties
+++ b/src/locale/es-MX/requestpolicy.properties
@@ -121,3 +121,5 @@ rp.menu.preferences=Preferencias
 rp.menu.managePolicies=Manage Policies
 rp.requestLog.title=Registro de peticiones
 rp.requestLog.clear=Limpiar
+alwaysAsk=Always ask for confirmation
+siteInfo.confirm=You're about to ask for information about the "%1$S" site\nby submitting a query to %2$S.\nDo you want to continue?
diff --git a/src/locale/eu/requestpolicy.properties b/src/locale/eu/requestpolicy.properties
index 23f1b30..addaa7b 100644
--- a/src/locale/eu/requestpolicy.properties
+++ b/src/locale/eu/requestpolicy.properties
@@ -121,3 +121,5 @@ rp.menu.preferences=Hobespenak
 rp.menu.managePolicies=Politikak kudeatu
 rp.requestLog.title=Eskaeren erregistroa
 rp.requestLog.clear=Garbitu
+alwaysAsk=Beti eskatu berrespena
+siteInfo.confirm=You're about to ask for information about the "%1$S" site\nby submitting a query to %2$S.\nDo you want to continue?
diff --git a/src/locale/fr/requestpolicy.properties b/src/locale/fr/requestpolicy.properties
index fb00d60..dff262a 100644
--- a/src/locale/fr/requestpolicy.properties
+++ b/src/locale/fr/requestpolicy.properties
@@ -121,3 +121,5 @@ rp.menu.preferences=Préférences
 rp.menu.managePolicies=Manage Policies
 rp.requestLog.title=Journal des requêtes
 rp.requestLog.clear=Effacer
+alwaysAsk=Toujours demander confirmation
+siteInfo.confirm=Vous allez demander des informations à propos du site "%1$S" en soumettant un requête à %2$S.\nVoulez-vous continuer ?
diff --git a/src/locale/it/requestpolicy.properties b/src/locale/it/requestpolicy.properties
index 1765742..13a6b5a 100644
--- a/src/locale/it/requestpolicy.properties
+++ b/src/locale/it/requestpolicy.properties
@@ -121,3 +121,5 @@ rp.menu.preferences=Preferenze
 rp.menu.managePolicies=Gestisci Regole
 rp.requestLog.title=Log Richieste
 rp.requestLog.clear=Svuota
+alwaysAsk=Chiedi sempre conferma
+siteInfo.confirm=Stai per chiedere informazioni sul sito "%1$S"\neffettuando una richiesta a %2$S.\nVuoi continuare?
diff --git a/src/locale/ja/requestpolicy.properties b/src/locale/ja/requestpolicy.properties
index f2f1cee..8295266 100644
--- a/src/locale/ja/requestpolicy.properties
+++ b/src/locale/ja/requestpolicy.properties
@@ -121,3 +121,5 @@ rp.menu.preferences=設定
 rp.menu.managePolicies=ポリシーの管理
 rp.requestLog.title=リクエストログ
 rp.requestLog.clear=消去
+alwaysAsk=Always ask for confirmation
+siteInfo.confirm=You're about to ask for information about the "%1$S" site\nby submitting a query to %2$S.\nDo you want to continue?
diff --git a/src/locale/ko-KR/requestpolicy.properties b/src/locale/ko-KR/requestpolicy.properties
index d66d68e..9a66c91 100644
--- a/src/locale/ko-KR/requestpolicy.properties
+++ b/src/locale/ko-KR/requestpolicy.properties
@@ -121,3 +121,5 @@ rp.menu.preferences=환경 설정
 rp.menu.managePolicies=Manage Policies
 rp.requestLog.title=요청 기록
 rp.requestLog.clear=Clear
+alwaysAsk=항상 확인
+siteInfo.confirm=You're about to ask for information about the "%1$S" site\nby submitting a query to %2$S.\nDo you want to continue?
diff --git a/src/locale/lv-LV/requestpolicy.properties b/src/locale/lv-LV/requestpolicy.properties
index 228da32..93bc1fd 100644
--- a/src/locale/lv-LV/requestpolicy.properties
+++ b/src/locale/lv-LV/requestpolicy.properties
@@ -121,3 +121,5 @@ rp.menu.preferences=Iestatījumi
 rp.menu.managePolicies=Pārvaldīt politikas
 rp.requestLog.title=Pieprasījumu žurnāls
 rp.requestLog.clear=Notīrīt
+alwaysAsk=Always ask for confirmation
+siteInfo.confirm=You're about to ask for information about the "%1$S" site\nby submitting a query to %2$S.\nDo you want to continue?
diff --git a/src/locale/nl/requestpolicy.properties b/src/locale/nl/requestpolicy.properties
index 79572f8..a8e0c2b 100644
--- a/src/locale/nl/requestpolicy.properties
+++ b/src/locale/nl/requestpolicy.properties
@@ -121,3 +121,5 @@ rp.menu.preferences=Voorkeuren
 rp.menu.managePolicies=Manage Policies
 rp.requestLog.title=Logbestand verzoeken
 rp.requestLog.clear=Wissen
+alwaysAsk=Altijd om een bevestiging vragen
+siteInfo.confirm=Je staat op het punt informatie te vragen over de "%1$S" site\ndoor een verzoek te sturen naar %2$S.\nWil je hiermee doorgaan?
diff --git a/src/locale/pt-BR/requestpolicy.properties b/src/locale/pt-BR/requestpolicy.properties
index 019f843..d2949f6 100644
--- a/src/locale/pt-BR/requestpolicy.properties
+++ b/src/locale/pt-BR/requestpolicy.properties
@@ -121,3 +121,5 @@ rp.menu.preferences=Preferências…
 rp.menu.managePolicies=Manage Policies
 rp.requestLog.title=Pedidos nesta página
 rp.requestLog.clear=Limpar
+alwaysAsk=Sempre pedir confirmação
+siteInfo.confirm=Você está prestes a pedir informações sobre o site "%1$S"\nao fazer uma consulta ao %2$S.\nDeseja continuar?
diff --git a/src/locale/ru-RU/requestpolicy.properties b/src/locale/ru-RU/requestpolicy.properties
index cccb9a6..decd4cf 100644
--- a/src/locale/ru-RU/requestpolicy.properties
+++ b/src/locale/ru-RU/requestpolicy.properties
@@ -121,3 +121,5 @@ rp.menu.preferences=Настройки
 rp.menu.managePolicies=Manage Policies
 rp.requestLog.title=Журнал Запросов
 rp.requestLog.clear=Очистить
+alwaysAsk=Всегда спрашивать подтверждение
+siteInfo.confirm=Вы собираетесь узнать информацию о сайте «%1$S»,\nотправив запрос к %2$S.\nПродолжить?
diff --git a/src/locale/sk-SK/requestpolicy.properties b/src/locale/sk-SK/requestpolicy.properties
index a912c06..29594a2 100644
--- a/src/locale/sk-SK/requestpolicy.properties
+++ b/src/locale/sk-SK/requestpolicy.properties
@@ -121,3 +121,5 @@ rp.menu.preferences=Nastavenia
 rp.menu.managePolicies=Manage Policies
 rp.requestLog.title=Protokol požiadaviek
 rp.requestLog.clear=Vyčistiť
+alwaysAsk=Vždy sa opýtať na potvrdenie
+siteInfo.confirm=Chystáte sa požiadať o informácie o stránke "%1$S"\nodoslaním požiadavky na %2$S.\nChcete pokračovať?
diff --git a/src/locale/sv-SE/requestpolicy.properties b/src/locale/sv-SE/requestpolicy.properties
index 0a7c7f6..9207871 100644
--- a/src/locale/sv-SE/requestpolicy.properties
+++ b/src/locale/sv-SE/requestpolicy.properties
@@ -121,3 +121,5 @@ rp.menu.preferences=Alternativ
 rp.menu.managePolicies=Manage Policies
 rp.requestLog.title=Förfrågningslogg
 rp.requestLog.clear=Rensa
+alwaysAsk=Fråga alltid
+siteInfo.confirm=Du är på väg att be om information om platsen \"%1$S\"\n genom att skicka en förfrågan till %2$S.\nVill du fortsätta?
diff --git a/src/locale/tr/requestpolicy.properties b/src/locale/tr/requestpolicy.properties
index a18fdb2..cc7511f 100644
--- a/src/locale/tr/requestpolicy.properties
+++ b/src/locale/tr/requestpolicy.properties
@@ -121,3 +121,5 @@ rp.menu.preferences=Seçenekler
 rp.menu.managePolicies=Manage Policies
 rp.requestLog.title=Kayıtlar
 rp.requestLog.clear=Temizle
+alwaysAsk=Herzaman onay iste
+siteInfo.confirm=%2$S sorgusunu yaparak \n"%1$S" sitesi hakkında bilgi istemek üzeresiniz.\nDevam etmek istiyor musunuz?
diff --git a/src/locale/uk-UA/requestpolicy.properties b/src/locale/uk-UA/requestpolicy.properties
index 0f33c8c..441eb8d 100644
--- a/src/locale/uk-UA/requestpolicy.properties
+++ b/src/locale/uk-UA/requestpolicy.properties
@@ -121,3 +121,5 @@ rp.menu.preferences=Вподобання
 rp.menu.managePolicies=Manage Policies
 rp.requestLog.title=Request Log
 rp.requestLog.clear=Clear
+alwaysAsk=Always ask for confirmation
+siteInfo.confirm=You're about to ask for information about the "%1$S" site\nby submitting a query to %2$S.\nDo you want to continue?
diff --git a/src/locale/zh-CN/requestpolicy.properties b/src/locale/zh-CN/requestpolicy.properties
index 15bb487..bee913e 100644
--- a/src/locale/zh-CN/requestpolicy.properties
+++ b/src/locale/zh-CN/requestpolicy.properties
@@ -121,3 +121,5 @@ rp.menu.preferences=设置
 rp.menu.managePolicies=管理策略
 rp.requestLog.title=请求日志
 rp.requestLog.clear=清除
+alwaysAsk=总是需要确认
+siteInfo.confirm=您正准备向%2$S提交一个查询以查看"%1$S"站点信息。您要继续吗?
diff --git a/src/locale/zh-TW/requestpolicy.properties b/src/locale/zh-TW/requestpolicy.properties
index 698116d..166b8d7 100644
--- a/src/locale/zh-TW/requestpolicy.properties
+++ b/src/locale/zh-TW/requestpolicy.properties
@@ -121,3 +121,5 @@ rp.menu.preferences=偏好設定
 rp.menu.managePolicies=Manage Policies
 rp.requestLog.title=請求記錄
 rp.requestLog.clear=Clear
+alwaysAsk=總是要求確認
+siteInfo.confirm=您可能透過一個查詢給 %2$S 來索取關於 %1$S 網站的資訊,是否要繼續?

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/requestpolicy.git



More information about the Pkg-mozext-commits mailing list