Added context menu item for QR codes generated by the Google Charts API

Changed title to Fox To Phone and updated icon asset.
This commit is contained in:
patrick.oreilly
2010-08-11 22:06:41 +00:00
parent 74f93bf4f6
commit a2e6fc5342
18 changed files with 92 additions and 32 deletions

View File

@@ -87,6 +87,9 @@ sendtophone.showFirefoxContextMenu = function(event) {
// 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-text", gContextMenu.isTextSelected ||
(gContextMenu.onTextInput && gContextMenu.target.selectionEnd > gContextMenu.target.selectionStart) );

View File

@@ -43,6 +43,12 @@
accesskey="&sendtophoneContextImage.accesskey;"
insertafter="context-sendimage"
oncommand="sendtophone.onMenuItemCommand(event, 'image')"/>
<menuitem id="context-sendtophone-qrimage" label="&sendtophoneContextQrImage.label;"
class="menuitem-iconic"
accesskey="&sendtophoneContextQrImage.accesskey;"
insertafter="context-sendimage"
oncommand="sendtophone.onMenuItemCommand(event, 'qr')"/>
<menuitem id="context-sendtophone-text" label="&sendtophoneContextText.label;"
class="menuitem-iconic"
accesskey="&sendtophoneContextText.accesskey;"

View File

@@ -54,29 +54,33 @@ var sendtophone = {
title = gContextMenu.target.title || gContextMenu.target.alt;
url = gContextMenu.imageURL;
selection = '';
break;
case 'qr':
title = gContextMenu.target.title || gContextMenu.target.alt;
url = gContextMenu.imageURL;
// Detect images of QR codes generated by the Google Charts API
// Extract the URI if valid and sendtophone
var qrPref = this.prefs.getBoolPref( "qrlink" ) ;
var chartType="cht=qr";
var chartLink="chl=";
var chartUrl="http://chart.apis.google.com/chart?";
if(!url.indexOf(chartUrl)&&url.match(chartType)&&qrPref){
qrUrl=url.replace(chartUrl, '');
qrArray = qrUrl.split("&");
for(qrI=0;qrI<qrArray.length;qrI++){
if(!qrArray[qrI].indexOf(chartLink)){
//Decode and Unescape any URL encoded in the QR Image Link
qrUrl=decodeURI(unescape(qrArray[qrI].replace(chartLink, '')));
if(this.validURI(qrUrl)){
url=qrUrl;
}
var chartLink=/^chl=/;
var chartUrl=/^http:\/\/chart.apis.google.com\/chart\?/;
url=url.replace(chartUrl, '');
qrArray = url.split("&");
for(qrI=0;qrI<qrArray.length;qrI++){
if(chartLink.test(qrArray[qrI])){
//Decode and Unescape any URL encoded in the QR Image Link
url=decodeURI(unescape(qrArray[qrI].replace(chartLink, '')));
if(this.validURI(url)){
url=url;
}
}
if(!title){
title=this.strings.getString("qrTitle");
}
}
//If the QR Image has no title text, give it one.
if(!title){
title=this.strings.getString("qrTitle");
}
selection = '';
break;
case 'text':
title = "Selection";
@@ -147,6 +151,11 @@ var sendtophone = {
return url.match("http://maps\\.google\\.[a-z]{2,3}(\\.[a-z]{2})?[/?].*") || url.match("http://www\\.google\\.[a-z]{2,3}(\\.[a-z]{2})?/maps.*");
},
validURI: function(uri)
{
return (/^(https?|market|tel|sms(to)?|mms(to)?|mailto|ftp):/i).test( uri );
},
initPopup: function()
{
var fileServerUrl = this.prefs.getCharPref( "fileServerUrl" );

View File

@@ -12,5 +12,9 @@
<!ENTITY sendtophoneContextLogout.accesskey "L">
<!ENTITY sendtophoneOptions.title "Send to Phone Preferences">
<!ENTITY sendtophoneProtocols.label "Protocols">
<!ENTITY sendtophoneContextSendFile.label "Send file...">
<!ENTITY sendtophoneContextSendFile.label "Send files...">
<!ENTITY sendtophoneContextSendFile.accesskey "S">
<!ENTITY sendtophoneContextSendFolder.label "Send folder...">
<!ENTITY sendtophoneContextSendFolder.accesskey "F">
<!ENTITY sendtophoneContextQrImage.label "Send decoded QR Link to Android">
<!ENTITY sendtophoneContextQrImage.accesskey "Q">

View File

@@ -1,4 +1,4 @@
<!ENTITY sendtophoneToolbarButton.label "Send to Phone">
<!ENTITY sendtophoneToolbarButton.label "Fox to Phone">
<!ENTITY sendtophoneToolbarButton.tooltip "Send this page to your Android Phone">
<!ENTITY sendtophoneContext.label "Send this link to Android">
<!ENTITY sendtophoneContext.accesskey "A">
@@ -16,3 +16,5 @@
<!ENTITY sendtophoneContextSendFile.accesskey "S">
<!ENTITY sendtophoneContextSendFolder.label "Send folder...">
<!ENTITY sendtophoneContextSendFolder.accesskey "F">
<!ENTITY sendtophoneContextQrImage.label "Send decoded QR Link to Android">
<!ENTITY sendtophoneContextQrImage.accesskey "Q">

View File

@@ -16,3 +16,5 @@
<!ENTITY sendtophoneContextSendFile.accesskey "E">
<!ENTITY sendtophoneContextSendFolder.label "Enviar carpeta...">
<!ENTITY sendtophoneContextSendFolder.accesskey "C">
<!ENTITY sendtophoneContextQrImage.label "Enviar imagen QR a Android">
<!ENTITY sendtophoneContextQrImage.accesskey "Q">

View File

@@ -12,5 +12,9 @@
<!ENTITY sendtophoneContextLogout.accesskey "L">
<!ENTITY sendtophoneOptions.title "Send to Phone Preferences">
<!ENTITY sendtophoneProtocols.label "Protocols">
<!ENTITY sendtophoneContextSendFile.label "Send file...">
<!ENTITY sendtophoneContextSendFile.label "Send files...">
<!ENTITY sendtophoneContextSendFile.accesskey "S">
<!ENTITY sendtophoneContextSendFolder.label "Send folder...">
<!ENTITY sendtophoneContextSendFolder.accesskey "F">
<!ENTITY sendtophoneContextQrImage.label "Send decoded QR Link to Android">
<!ENTITY sendtophoneContextQrImage.accesskey "Q">

View File

@@ -12,5 +12,9 @@
<!ENTITY sendtophoneContextLogout.accesskey "L">
<!ENTITY sendtophoneOptions.title "Send to Phone Preferences">
<!ENTITY sendtophoneProtocols.label "Protocols">
<!ENTITY sendtophoneContextSendFile.label "Send file...">
<!ENTITY sendtophoneContextSendFile.label "Send files...">
<!ENTITY sendtophoneContextSendFile.accesskey "S">
<!ENTITY sendtophoneContextSendFolder.label "Send folder...">
<!ENTITY sendtophoneContextSendFolder.accesskey "F">
<!ENTITY sendtophoneContextQrImage.label "Send decoded QR Link to Android">
<!ENTITY sendtophoneContextQrImage.accesskey "Q">

View File

@@ -12,5 +12,9 @@
<!ENTITY sendtophoneContextLogout.accesskey "L">
<!ENTITY sendtophoneOptions.title "Send to Phone Preferences">
<!ENTITY sendtophoneProtocols.label "Protocols">
<!ENTITY sendtophoneContextSendFile.label "Send file...">
<!ENTITY sendtophoneContextSendFile.label "Send files...">
<!ENTITY sendtophoneContextSendFile.accesskey "S">
<!ENTITY sendtophoneContextSendFolder.label "Send folder...">
<!ENTITY sendtophoneContextSendFolder.accesskey "F">
<!ENTITY sendtophoneContextQrImage.label "Send decoded QR Link to Android">
<!ENTITY sendtophoneContextQrImage.accesskey "Q">

View File

@@ -12,5 +12,9 @@
<!ENTITY sendtophoneContextLogout.accesskey "L">
<!ENTITY sendtophoneOptions.title "Send to Phone Preferences">
<!ENTITY sendtophoneProtocols.label "Protocols">
<!ENTITY sendtophoneContextSendFile.label "Send file...">
<!ENTITY sendtophoneContextSendFile.label "Send files...">
<!ENTITY sendtophoneContextSendFile.accesskey "S">
<!ENTITY sendtophoneContextSendFolder.label "Send folder...">
<!ENTITY sendtophoneContextSendFolder.accesskey "F">
<!ENTITY sendtophoneContextQrImage.label "Send decoded QR Link to Android">
<!ENTITY sendtophoneContextQrImage.accesskey "Q">

View File

@@ -12,5 +12,9 @@
<!ENTITY sendtophoneContextLogout.accesskey "L">
<!ENTITY sendtophoneOptions.title "Send to Phone Preferences">
<!ENTITY sendtophoneProtocols.label "Protocols">
<!ENTITY sendtophoneContextSendFile.label "Send file...">
<!ENTITY sendtophoneContextSendFile.label "Send files...">
<!ENTITY sendtophoneContextSendFile.accesskey "S">
<!ENTITY sendtophoneContextSendFolder.label "Send folder...">
<!ENTITY sendtophoneContextSendFolder.accesskey "F">
<!ENTITY sendtophoneContextQrImage.label "Send decoded QR Link to Android">
<!ENTITY sendtophoneContextQrImage.accesskey "Q">

View File

@@ -12,5 +12,9 @@
<!ENTITY sendtophoneContextLogout.accesskey "L">
<!ENTITY sendtophoneOptions.title "Send to Phone Preferences">
<!ENTITY sendtophoneProtocols.label "Protocols">
<!ENTITY sendtophoneContextSendFile.label "Send file...">
<!ENTITY sendtophoneContextSendFile.label "Send files...">
<!ENTITY sendtophoneContextSendFile.accesskey "S">
<!ENTITY sendtophoneContextSendFolder.label "Send folder...">
<!ENTITY sendtophoneContextSendFolder.accesskey "F">
<!ENTITY sendtophoneContextQrImage.label "Send decoded QR Link to Android">
<!ENTITY sendtophoneContextQrImage.accesskey "Q">

View File

@@ -12,5 +12,9 @@
<!ENTITY sendtophoneContextLogout.accesskey "L">
<!ENTITY sendtophoneOptions.title "Send to Phone Preferences">
<!ENTITY sendtophoneProtocols.label "Protocols">
<!ENTITY sendtophoneContextSendFile.label "Send file...">
<!ENTITY sendtophoneContextSendFile.label "Send files...">
<!ENTITY sendtophoneContextSendFile.accesskey "S">
<!ENTITY sendtophoneContextSendFolder.label "Send folder...">
<!ENTITY sendtophoneContextSendFolder.accesskey "F">
<!ENTITY sendtophoneContextQrImage.label "Send decoded QR Link to Android">
<!ENTITY sendtophoneContextQrImage.accesskey "Q">

View File

@@ -12,5 +12,9 @@
<!ENTITY sendtophoneContextLogout.accesskey "L">
<!ENTITY sendtophoneOptions.title "Send to Phone Preferences">
<!ENTITY sendtophoneProtocols.label "Protocols">
<!ENTITY sendtophoneContextSendFile.label "Send file...">
<<!ENTITY sendtophoneContextSendFile.label "Send files...">
<!ENTITY sendtophoneContextSendFile.accesskey "S">
<!ENTITY sendtophoneContextSendFolder.label "Send folder...">
<!ENTITY sendtophoneContextSendFolder.accesskey "F">
<!ENTITY sendtophoneContextQrImage.label "Send decoded QR Link to Android">
<!ENTITY sendtophoneContextQrImage.accesskey "Q">

View File

@@ -12,5 +12,9 @@
<!ENTITY sendtophoneContextLogout.accesskey "L">
<!ENTITY sendtophoneOptions.title "Send to Phone Preferences">
<!ENTITY sendtophoneProtocols.label "Protocols">
<!ENTITY sendtophoneContextSendFile.label "Send file...">
<!ENTITY sendtophoneContextSendFile.label "Send files...">
<!ENTITY sendtophoneContextSendFile.accesskey "S">
<!ENTITY sendtophoneContextSendFolder.label "Send folder...">
<!ENTITY sendtophoneContextSendFolder.accesskey "F">
<!ENTITY sendtophoneContextQrImage.label "Send decoded QR Link to Android">
<!ENTITY sendtophoneContextQrImage.accesskey "Q">

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

@@ -12,7 +12,5 @@ pref("extensions.sendtophone.protocols.mms", false); // conflicts with http://en
pref("extensions.sendtophone.protocols.mmsto", true);
pref("extensions.sendtophone.protocols.tel", true);
pref("extensions.sendtophone.qrlink", true);
// https://developer.mozilla.org/en/Localizing_extension_descriptions
pref("extensions.sendtophone@martinezdelizarrondo.com.description", "chrome://sendtophone/locale/overlay.properties");

View File

@@ -3,7 +3,7 @@
<Description about="urn:mozilla:install-manifest">
<em:id>sendtophone@martinezdelizarrondo.com</em:id>
<em:type>2</em:type>
<em:name>Send To Phone</em:name>
<em:name>Fox To Phone</em:name>
<em:version>1.1</em:version>
<em:creator>Alfonso &amp; Patrick</em:creator>
<em:description>Send links to your Android 2.2 phone using the new C2DM service. Based on the ChromeToPhone extension.</em:description>