diff --git a/third_party/firefox_sendtophone/chrome/content/ff-overlay.js b/third_party/firefox_sendtophone/chrome/content/ff-overlay.js index d3103ff..41a5206 100644 --- a/third_party/firefox_sendtophone/chrome/content/ff-overlay.js +++ b/third_party/firefox_sendtophone/chrome/content/ff-overlay.js @@ -86,10 +86,23 @@ sendtophone.showFirefoxContextMenu = function(event) { // show or hide the menuitem based on what the context menu is on // see http://kb.mozillazine.org/Adding_items_to_menus gContextMenu.showItem("context-sendtophone-link", gContextMenu.onLink); - gContextMenu.showItem("context-sendtophone-image", gContextMenu.onImage); - var qrPat1=/^http:\/\/chart.apis.google.com\/chart\?/; - var qrPat2=/cht=qr/; - gContextMenu.showItem("context-sendtophone-qrimage", (gContextMenu.onImage & qrPat1.test(gContextMenu.imageURL) && qrPat2.test(gContextMenu.imageURL))); + + gContextMenu.showItem("context-sendtophone-image", false); + gContextMenu.showItem("context-sendtophone-qrimage", false); + if (gContextMenu.onImage) + { + var data = this.detectQR( gContextMenu.imageURL ); + if (data) + { + gContextMenu.showItem("context-sendtophone-qrimage", true); + var label = this.strings.getString("qrContextMenu"); + label = label.replace("%s", data.substring(0, 20) + "..." ); + document.getElementById("context-sendtophone-qrimage").setAttribute("label", label); + } + else + gContextMenu.showItem("context-sendtophone-image", true); + } + gContextMenu.showItem("context-sendtophone-text", gContextMenu.isTextSelected || (gContextMenu.onTextInput && gContextMenu.target.selectionEnd > gContextMenu.target.selectionStart) ); diff --git a/third_party/firefox_sendtophone/chrome/content/overlay.js b/third_party/firefox_sendtophone/chrome/content/overlay.js index 877bfb9..cb3e5a5 100644 --- a/third_party/firefox_sendtophone/chrome/content/overlay.js +++ b/third_party/firefox_sendtophone/chrome/content/overlay.js @@ -40,51 +40,54 @@ var sendtophone = { me.init(); }, + // Detect images of QR codes generated by the Google Charts API + detectQR: function( url ) + { + var match = url.match(/^http:\/\/chart.apis.google.com\/chart\?(.*)/i); + if (!match) + return false; + + var chartLink=/^chl=/; + var qrArray = match[0].split("&"); + for(var qrI=0; qrI