diff --git a/third_party/firefox_sendtophone/chrome/content/ff-overlay.js b/third_party/firefox_sendtophone/chrome/content/ff-overlay.js index 69b0673..c5941b6 100644 --- a/third_party/firefox_sendtophone/chrome/content/ff-overlay.js +++ b/third_party/firefox_sendtophone/chrome/content/ff-overlay.js @@ -1,4 +1,4 @@ -/* +/* Copyright 2010 Alfonso Martínez de Lizarrondo & Patrick O'Reilly Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,8 +23,8 @@ sendtophone.init = function() this.prefs.setBoolPref( "installedButton", true ) ; } - document.getElementById("contentAreaContextMenu") - .addEventListener("popupshowing", function (e){ sendtophone.showFirefoxContextMenu(e); }, false); + document.getElementById("contentAreaContextMenu"). + addEventListener("popupshowing", function (e){ sendtophone.showFirefoxContextMenu(e); }, false); } sendtophone.installToolbarButton = function() @@ -74,7 +74,7 @@ sendtophone.onOptionsShowing= function(popup) var option = child.getAttribute("option"); if (option) { - var checked = this.prefs.getBoolPref("protocols."+option); + var checked = this.prefs.getBoolPref("protocols."+option); child.setAttribute("checked", checked); } } @@ -102,11 +102,11 @@ sendtophone.showFirefoxContextMenu = function(event) { gContextMenu.showItem("context-sendtophone-image", true); } - gContextMenu.showItem("context-sendtophone-text", gContextMenu.isTextSelected || + gContextMenu.showItem("context-sendtophone-text", gContextMenu.isTextSelected || (gContextMenu.onTextInput && gContextMenu.target.selectionEnd > gContextMenu.target.selectionStart) ); gContextMenu.showItem("context-sendtophone-page", !( gContextMenu.inDirList || gContextMenu.isContentSelected || gContextMenu.onTextInput || gContextMenu.onLink || gContextMenu.onImage )); - + }; @@ -119,9 +119,9 @@ sendtophone.checkDrag = function(event) var types = event.dataTransfer.types; if (types.contains("text/plain") || types.contains("text/uri-list") || types.contains("text/x-moz-url")) event.preventDefault(); - + if (this.prefs.getCharPref( "fileServerUrl" ) && types.contains("application/x-moz-file") ) - event.preventDefault(); + event.preventDefault(); } sendtophone.doDrop = function(event) @@ -129,8 +129,8 @@ sendtophone.doDrop = function(event) var dt = event.dataTransfer; var types = dt.types; 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(); switch (types[0]) { @@ -138,7 +138,7 @@ sendtophone.doDrop = function(event) var plainText = dt.getData(types[0]); sendtophoneCore.send("Selection", "http://google.com", plainText); break; - + case "text/x-moz-url": var mozUrlArray = dt.getData(types[1]).split("\n"); var mozUrl = mozUrlArray[0]; @@ -173,16 +173,16 @@ sendtophone.pickFile = function(folder) fp.init(window, this.getString("SendFolderToPhone"), Ci.nsIFilePicker.modeGetFolder); else { - fp.init(window, this.getString("SendFileToPhone"), Ci.nsIFilePicker.modeOpenMultiple); + fp.init(window, this.getString("SendFileToPhone"), Ci.nsIFilePicker.modeOpenMultiple); fp.appendFilters(Ci.nsIFilePicker.filterAll | Ci.nsIFilePicker.filterImages); } - + var rv = fp.show(); - if (rv == Ci.nsIFilePicker.returnOK) + if (rv == Ci.nsIFilePicker.returnOK) { var files = fp.files; - while (files.hasMoreElements()) + while (files.hasMoreElements()) { var file = files.getNext().QueryInterface(Ci.nsILocalFile); sendtophoneCore.sendFile( file ); diff --git a/third_party/firefox_sendtophone/chrome/content/overlay.js b/third_party/firefox_sendtophone/chrome/content/overlay.js index fe4c13c..cc9a87f 100644 --- a/third_party/firefox_sendtophone/chrome/content/overlay.js +++ b/third_party/firefox_sendtophone/chrome/content/overlay.js @@ -1,4 +1,4 @@ -/* +/* Copyright 2010 Alfonso Martínez de Lizarrondo & Patrick O'Reilly Licensed under the Apache License, Version 2.0 (the "License"); @@ -51,7 +51,7 @@ var sendtophone = { 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 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); + } }; @@ -139,22 +147,22 @@ function performCommand(aCmd, aItem) gUploadViewController.doCommand(aCmd, elm); } -function updateStatus(aItem) +function updateStatus(aItem) { let currBytes = Number(aItem.getAttribute("currBytes")); let maxBytes = Number(aItem.getAttribute("maxBytes")); - + let elapsedTime = (Date.now() - Number(aItem.getAttribute("startTime"))) / 1000; // If we don't have an active upload, assume 0 bytes/sec let speed = (currBytes>0) ? currBytes/elapsedTime : 0; let lastSec = Number(aItem.getAttribute("lastSeconds")); - + let status, newLast; [status, newLast] = DownloadUtils.getDownloadStatus(currBytes, maxBytes, speed, lastSec); - + // Update lastSeconds to be the new value aItem.setAttribute("lastSeconds", newLast); - + aItem.setAttribute("status", status); } diff --git a/third_party/firefox_sendtophone/modules/uploadsManager.js b/third_party/firefox_sendtophone/modules/uploadsManager.js index e239499..b501294 100644 --- a/third_party/firefox_sendtophone/modules/uploadsManager.js +++ b/third_party/firefox_sendtophone/modules/uploadsManager.js @@ -220,7 +220,7 @@ function initShowTest() return; // 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); } @@ -235,9 +235,9 @@ function cancelShowTimer() // https://developer.mozilla.org/en/Code_snippets/Tabbed_browser#Reusing_tabs function openAndReuseOneTabPerURL(url) { - var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] - .getService(Components.interfaces.nsIWindowMediator); - var browserEnumerator = wm.getEnumerator("navigator:browser"); + var wm = Cc["@mozilla.org/appshell/window-mediator;1"] + .getService(Ci.nsIWindowMediator); + var browserEnumerator = wm.getEnumerator("navigator:browser"); // Check each browser instance for our URL var found = false;