Added code to use the plaintext/img.title of links/images dragged &dropped on the S2P icon.

This commit is contained in:
patrick.oreilly
2010-08-04 23:48:01 +00:00
parent 28bd5be8b9
commit 26c43b0bdd

View File

@@ -112,18 +112,21 @@ sendtophone.doDrop = function(event)
var supportedTypes = ["application/x-moz-file", "text/uri-list", "text/x-moz-url", "text/plain"]; var supportedTypes = ["application/x-moz-file", "text/uri-list", "text/x-moz-url", "text/plain"];
types = supportedTypes.filter(function (value) types.contains(value)); types = supportedTypes.filter(function (value) types.contains(value));
if (types.length) if (types.length)
var data = event.dataTransfer.getData(types[0]); var plainText = event.dataTransfer.getData(types[0]);
var mozUrlArray = event.dataTransfer.getData(types[1]).split("\n");
var mozUrl = mozUrlArray[0];
var mozTitle = mozUrlArray[1];
event.preventDefault(); event.preventDefault();
switch (types[0]) switch (types[0])
{ {
case "text/plain": case "text/plain":
sendtophoneCore.send("Selection", "http://google.com", data); sendtophoneCore.send("Selection", "http://google.com", plainText);
break; break;
case "text/uri-list": case "text/uri-list":
case "text/x-moz-url": case "text/x-moz-url":
sendtophoneCore.send("", data, ""); sendtophoneCore.send(mozTitle, mozUrl, "");
break; break;
case "application/x-moz-file": case "application/x-moz-file":
var file = event.dataTransfer.mozGetDataAt("application/x-moz-file", 0); var file = event.dataTransfer.mozGetDataAt("application/x-moz-file", 0);
if (file instanceof Components.interfaces.nsIFile && file.isFile() ) if (file instanceof Components.interfaces.nsIFile && file.isFile() )
@@ -152,4 +155,4 @@ sendtophone.sendFile = function()
var rv = fp.show(); var rv = fp.show();
if (rv == Ci.nsIFilePicker.returnOK) if (rv == Ci.nsIFilePicker.returnOK)
sendtophoneCore.send('', fp.fileURL.spec, ''); sendtophoneCore.send('', fp.fileURL.spec, '');
} }