Minor adjustments

This commit is contained in:
amla70
2010-08-13 18:06:18 +00:00
parent 0249229eb7
commit fa688468dc
4 changed files with 68 additions and 59 deletions

View File

@@ -1,4 +1,4 @@
/* /*
Copyright 2010 Alfonso Martínez de Lizarrondo & Patrick O'Reilly Copyright 2010 Alfonso Martínez de Lizarrondo & Patrick O'Reilly
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,8 +23,8 @@ sendtophone.init = function()
this.prefs.setBoolPref( "installedButton", true ) ; this.prefs.setBoolPref( "installedButton", true ) ;
} }
document.getElementById("contentAreaContextMenu") document.getElementById("contentAreaContextMenu").
.addEventListener("popupshowing", function (e){ sendtophone.showFirefoxContextMenu(e); }, false); addEventListener("popupshowing", function (e){ sendtophone.showFirefoxContextMenu(e); }, false);
} }
sendtophone.installToolbarButton = function() sendtophone.installToolbarButton = function()
@@ -129,7 +129,7 @@ sendtophone.doDrop = function(event)
var dt = event.dataTransfer; var dt = event.dataTransfer;
var types = dt.types; var types = dt.types;
var supportedTypes = ["application/x-moz-file", "text/x-moz-url", "text/uri-list", "text/plain"]; var supportedTypes = ["application/x-moz-file", "text/x-moz-url", "text/uri-list", "text/plain"];
types = supportedTypes.filter(function (value) types.contains(value)); types = supportedTypes.filter(function (value) {return types.contains(value)});
event.preventDefault(); event.preventDefault();
switch (types[0]) switch (types[0])

View File

@@ -1,4 +1,4 @@
/* /*
Copyright 2010 Alfonso Martínez de Lizarrondo & Patrick O'Reilly Copyright 2010 Alfonso Martínez de Lizarrondo & Patrick O'Reilly
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
@@ -111,16 +111,17 @@ var sendtophone = {
var images = gBrowser.contentDocument.getElementsByTagName( "img" ); var images = gBrowser.contentDocument.getElementsByTagName( "img" );
// 0: search and prompt, 1: search and launch automatically, 2: don't search // 0: search and prompt, 1: search and launch automatically, 2: don't search
var pref = this.prefs.getIntPref("SearchQR") var pref = this.prefs.getIntPref("SearchQR");
if (pref!=2) if (pref!=2)
{ {
var QRs = []; var QRs = [];
for( var i=0; i<images.length; i++) for( var i=0; i<images.length; i++)
{ {
var data = this.detectQR( images[i].src ); var imgData = this.detectQR( images[i].src );
if (data) if (imgData)
QRs.push({data: data, img: images[i]}); QRs.push({data: data, img: images[i]});
} }
if (QRs.length==1) if (QRs.length==1)
{ {
var data = QRs[0].data; var data = QRs[0].data;
@@ -257,13 +258,13 @@ var sendtophone = {
// https://developer.mozilla.org/en/using_the_clipboard // https://developer.mozilla.org/en/using_the_clipboard
// Access Clipboard // Access Clipboard
var clip = Cc["@mozilla.org/widget/clipboard;1"].getService(Ci.nsIClipboard); var clip = Cc["@mozilla.org/widget/clipboard;1"].getService(Ci.nsIClipboard);
if (!clip) return false; if (!clip) return;
if (!clip.hasDataMatchingFlavors(["text/unicode"], 1, clip.kGlobalClipboard)) if (!clip.hasDataMatchingFlavors(["text/unicode"], 1, clip.kGlobalClipboard))
return false; return;
var trans = Cc["@mozilla.org/widget/transferable;1"].createInstance(Ci.nsITransferable); var trans = Cc["@mozilla.org/widget/transferable;1"].createInstance(Ci.nsITransferable);
if (!trans) return false; if (!trans) return;
trans.addDataFlavor("text/unicode"); trans.addDataFlavor("text/unicode");
// Get the data // Get the data

View File

@@ -31,10 +31,16 @@ function addFile(upload)
gUploadsView.appendChild( dl ); gUploadsView.appendChild( dl );
} }
function checkPendingUploads() var checkTimerEvent =
{ {
if (gUploadsView.children.length==0) notify: function(timer)
window.close(); {
if (sendtophoneUploadsManager.isWindowNeeded())
{
if (gUploadsView.children.length==0)
window.close();
}
}
} }
function cancelUpload(item) function cancelUpload(item)
@@ -66,7 +72,9 @@ let gUploadListener = {
// If no more pending uploads, close the tab. // If no more pending uploads, close the tab.
// Use a 0 ms timeout to avoid flicker while compress -> upload a folder // Use a 0 ms timeout to avoid flicker while compress -> upload a folder
window.setTimeout( checkPendingUploads, 0); let checkTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
checkTimer.initWithCallback(checkTimerEvent, 0, Ci.nsITimer.TYPE_ONE_SHOT);
} }
}; };

View File

@@ -220,7 +220,7 @@ function initShowTest()
return; return;
// Now it is time to create the timer... // Now it is time to create the timer...
showTimer = Components.classes["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); showTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
showTimer.initWithCallback(showTimerEvent, 400, Ci.nsITimer.TYPE_REPEATING_SLACK); showTimer.initWithCallback(showTimerEvent, 400, Ci.nsITimer.TYPE_REPEATING_SLACK);
} }
@@ -235,9 +235,9 @@ function cancelShowTimer()
// https://developer.mozilla.org/en/Code_snippets/Tabbed_browser#Reusing_tabs // https://developer.mozilla.org/en/Code_snippets/Tabbed_browser#Reusing_tabs
function openAndReuseOneTabPerURL(url) { function openAndReuseOneTabPerURL(url) {
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] var wm = Cc["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator); .getService(Ci.nsIWindowMediator);
var browserEnumerator = wm.getEnumerator("navigator:browser"); var browserEnumerator = wm.getEnumerator("navigator:browser");
// Check each browser instance for our URL // Check each browser instance for our URL
var found = false; var found = false;