[Pkg-mozext-commits] [automatic-save-folder] 108/133: Fix : Fix dynamic folder creation with Domain Type 6 and 7 (Thanks hiteshsathawane)
David Prévot
taffit at moszumanska.debian.org
Mon Apr 27 20:33:57 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch wip
in repository automatic-save-folder.
commit 395b28b90e72506fc93b715f8e2a7fb6875b3bb8
Author: Cyan <Cyan at d0063192-6b2e-11de-89a9-0b20f3e2dceb>
Date: Mon Feb 20 18:05:57 2012 +0000
Fix : Fix dynamic folder creation with Domain Type 6 and 7 (Thanks hiteshsathawane)
I removed some error catching, reading the current page's URL should always return a value, but if you encounter some problem with other saving add-ons (like Abduction), let me know on the forum. Thanks.
git-svn-id: http://automatic-save-folder.googlecode.com/svn/trunk@117 d0063192-6b2e-11de-89a9-0b20f3e2dceb
---
content/asf_download.js | 49 ++++++++++++++++++++-------------------
content/asf_right_click.js | 58 ++++++++++++++++++++++------------------------
content/common.dtd | 2 +-
locale/fr/asf.dtd | 6 ++---
4 files changed, 57 insertions(+), 58 deletions(-)
diff --git a/content/asf_download.js b/content/asf_download.js
index f64df21..bc70796 100644
--- a/content/asf_download.js
+++ b/content/asf_download.js
@@ -86,17 +86,10 @@ Copyright (C) 2007-2012 Éric Cassar (Cyan).
var fileURL = document.getElementById("source").getAttribute("tooltiptext");
var fileURLAndFilename= document.getElementById("source").getAttribute("tooltiptext") + filename;
var currentDomain, currentURL = "";
- try
- {
- currentDomain = tabLocation.protocol + "//" + tabLocation.host; // look for the current website URL in the DOM.
- currentURL = tabLocation.href; // look for the current website URL in the DOM.
- if (currentDomain == "about://") currentDomain = "";
- }
- catch (e) // if there is no data (The tab is closed or it's a script redirection), use the file's data.
- {
- currentDomain = domain;
- currentURL = fileURL;
- }
+ currentDomain = tabLocation.protocol + "//" + tabLocation.host; // look for the current website URL in the DOM.
+ currentURL = tabLocation.href; // look for the current website URL in the DOM.
+ if (currentDomain == "about://") currentDomain = "";
+
if (this.firefoxversion >= 7.01)
{
this.current_uri = domain.replace(/^.*:\/\//g,'');
@@ -524,9 +517,16 @@ Copyright (C) 2007-2012 Éric Cassar (Cyan).
const ZERO = "0"; // leading zero
// load the domain and the filename of the saved file
- var tBrowser = Components.classes["@mozilla.org/appshell/window-mediator;1"]
- .getService(Components.interfaces.nsIWindowMediator).getMostRecentWindow("navigator:browser").getBrowser();
- var tabLocation = tBrowser.mCurrentTab.linkedBrowser.contentDocument.location;
+ var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
+ .getService(Components.interfaces.nsIWindowMediator);
+ var mainWindow = wm.getMostRecentWindow("navigator:browser");
+
+ var currentTab = mainWindow.gBrowser.getBrowserAtIndex(mainWindow.gBrowser.tabContainer.selectedIndex);
+ // var tabLocation = currentTab.currentURI.spec;
+ var tabLocation = mainWindow.gBrowser.mCurrentTab.linkedBrowser.contentDocument.location;
+ var tabURL = mainWindow.gURLBar.value;
+ var currentReferrer = mainWindow.gBrowser.mCurrentTab.linkedBrowser.contentDocument.referrer;
+
var filename = document.getElementById("location").value ;
var file_name = filename.replace (/\.(?!.*\.).*$/i, ""); // Trim from the last dot to the end of the file = remove extension
var extension = filename.match(/([^\.]*)$/i); // take out the extension (anything not containing a dot, with an ending line)
@@ -535,16 +535,9 @@ Copyright (C) 2007-2012 Éric Cassar (Cyan).
var fileURL = document.getElementById("source").getAttribute("tooltiptext");
var fileURLAndFilename= document.getElementById("source").getAttribute("tooltiptext") + filename;
var currentDomain, currentURL = "";
- try
- {
- currentDomain = tabLocation.protocol + "//" + tabLocation.host; // look for the current website URL in the DOM.
- currentURL = tabLocation.href; // look for the current website URL in the DOM.
- }
- catch (e) // if there is no data (The tab is closed or it's a script redirection), use the file's data.
- {
- currentDomain = domain;
- currentURL = fileURL;
- }
+ currentDomain = tabLocation.protocol + "//" + tabLocation.host; // look for the current website URL in the DOM.
+ currentURL = tabLocation.href; // look for the current website URL in the DOM.
+ if (currentDomain == "about://") currentDomain = "";
// check the filter's data
var asf_domain = "";
@@ -591,6 +584,14 @@ Copyright (C) 2007-2012 Éric Cassar (Cyan).
case "5":
dom_regexp = this.test_regexp(asf_domain, currentURL, idx, "domain");
used_domain_string = currentURL;
+ break;
+ case "6":
+ dom_regexp = this.test_regexp(asf_domain, currentReferrer, idx, "domain");
+ used_domain_string = currentReferrer;
+ break;
+ case "7":
+ dom_regexp = this.test_regexp(asf_domain, tabURL, idx, "domain");
+ used_domain_string = tabURL;
default:
}
diff --git a/content/asf_right_click.js b/content/asf_right_click.js
index 80591c5..72b9918 100644
--- a/content/asf_right_click.js
+++ b/content/asf_right_click.js
@@ -120,32 +120,21 @@ var automatic_save_folder = {
.getService(Components.interfaces.nsIWindowMediator);
var mainWindow = wm.getMostRecentWindow("navigator:browser");
- var currentTab = mainWindow.gBrowser.getBrowserAtIndex(mainWindow.gBrowser.tabContainer.selectedIndex);
- // var tabLocation = currentTab.currentURI.spec;
- var tabLocation = mainWindow.gBrowser.mCurrentTab.linkedBrowser.contentDocument.location;
var tabURL = mainWindow.gURLBar.value;
var currentReferrer = mainWindow.gBrowser.mCurrentTab.linkedBrowser.contentDocument.referrer;
+ var tabLocation = mainWindow.gBrowser.mCurrentTab.linkedBrowser.contentDocument.location;
+ var currentDomain = tabLocation.protocol + "//" + tabLocation.host; // look for the current website URL in the DOM.
+ var currentURL = tabLocation.href; // look for the current website URL in the DOM.
var filename = aFpP.fileInfo.fileName; // filename or tab's name if no filename specified.
-
- var domain = aFpP.fileInfo.uri.scheme+"://"+aFpP.fileInfo.uri.host;
- var domainWithoutProtocol = aFpP.fileInfo.uri.host;
- var fileURL = aFpP.fileInfo.uri.prePath+aFpP.fileInfo.uri.directory;
- var fileURLAndFilename= aFpP.fileInfo.uri.prePath+aFpP.fileInfo.uri.path;
-
- var currentDomain, currentURL = "";
- try
- {
- currentDomain = tabLocation.protocol + "//" + tabLocation.host; // look for the current website URL in the DOM.
- currentURL = tabLocation.href; // look for the current website URL in the DOM.
- }
- catch (e) // if there is no data (The tab is closed or it's a script redirection), use the file's data.
+ if (typeof(aFpP.fileInfo.uri.fileName) != "undefined") // if the download is from an URL
{
- currentDomain = domain;
- currentURL = fileURL;
+ var domain = aFpP.fileInfo.uri.scheme+"://"+aFpP.fileInfo.uri.host;
+ var domainWithoutProtocol = aFpP.fileInfo.uri.host;
+ var fileURL = aFpP.fileInfo.uri.prePath+aFpP.fileInfo.uri.directory;
+ var fileURLAndFilename= aFpP.fileInfo.uri.prePath+aFpP.fileInfo.uri.path;
}
-
- if (typeof(aFpP.fileInfo.uri.fileName) == "undefined") // If the saved data is not from an URL (example : old Abduction! add-on)
+ else // If the saved data is not from an URL (example : Abduction! add-on), use current URL and tab's name.
{
var domain = currentDomain;
var domainWithoutProtocol = domain.replace(/^.*:\/\//g,''); // remove the protocol name from the domain
@@ -469,6 +458,16 @@ var automatic_save_folder = {
const ZERO = "0"; // leading zero
// load the domain and the filename of the saved file
+ var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
+ .getService(Components.interfaces.nsIWindowMediator);
+ var mainWindow = wm.getMostRecentWindow("navigator:browser");
+
+ var tabURL = mainWindow.gURLBar.value;
+ var currentReferrer = mainWindow.gBrowser.mCurrentTab.linkedBrowser.contentDocument.referrer;
+
+ var tabLocation = mainWindow.gBrowser.mCurrentTab.linkedBrowser.contentDocument.location;
+ var currentDomain = tabLocation.protocol + "//" + tabLocation.host; // look for the current website URL in the DOM.
+ var currentURL = tabLocation.href; // look for the current website URL in the DOM.
var filename = aFpP.fileInfo.fileName; // filename or tab's name if no filename specified.
var file_name = aFpP.fileInfo.fileBaseName ;
var extension = filename.match(/([^\.]*)$/i); // take out the extension (anything not containing a dot, with an ending line)
@@ -478,22 +477,13 @@ var automatic_save_folder = {
var domainWithoutProtocol = aFpP.fileInfo.uri.host;
var fileURL = aFpP.fileInfo.uri.prePath+aFpP.fileInfo.uri.directory;
var fileURLAndFilename= aFpP.fileInfo.uri.prePath+aFpP.fileInfo.uri.path;
- var currentDomain = document.getElementById("urlbar").value; // look for the current website URL in the DOM.
- currentDomain = currentDomain.match(/^(.*?:\/\/)?.*?[^\/]+/);
- currentDomain = currentDomain[0];
- var currentURL = document.getElementById("urlbar").value;
-
}
else // If the saved data is not from an URL (example : Abduction! add-on), use current URL and tab's name.
{
- var domain = document.getElementById("urlbar").value;
- domain = domain.match(/^(.*?:\/\/)?.*?[^\/]+/);
- domain = domain[0];
+ var domain = currentDomain;
var domainWithoutProtocol = domain.replace(/^.*:\/\//g,''); // remove the protocol name from the domain
var fileURL = "";
var fileURLAndFilename = domain+"/"+filename;
- var currentDomain = domain;
- var currentURL = document.getElementById("urlbar").value;
}
@@ -541,6 +531,14 @@ var automatic_save_folder = {
case "5":
dom_regexp = this.test_regexp(asf_domain, currentURL, idx, "domain");
used_domain_string = currentURL;
+ break;
+ case "6":
+ dom_regexp = this.test_regexp(asf_domain, currentReferrer, idx, "domain");
+ used_domain_string = currentReferrer;
+ break;
+ case "7":
+ dom_regexp = this.test_regexp(asf_domain, tabURL, idx, "domain");
+ used_domain_string = tabURL;
default:
}
diff --git a/content/common.dtd b/content/common.dtd
index 5171009..9dc3c96 100644
--- a/content/common.dtd
+++ b/content/common.dtd
@@ -1,5 +1,5 @@
<!-- Current version -->
-<!ENTITY asf.version "1.0.5bRev116">
+<!ENTITY asf.version "1.0.5bRev117">
<!ENTITY about.translators "
- cs : Stanislav Horáček<br />
diff --git a/locale/fr/asf.dtd b/locale/fr/asf.dtd
index 26a8f8c..07a377d 100644
--- a/locale/fr/asf.dtd
+++ b/locale/fr/asf.dtd
@@ -12,9 +12,9 @@
<!ENTITY asf.label "Automatic Save Folder...">
<!ENTITY asf.addedit.label "Ajouter ou éditer un filtre">
<!ENTITY asf.pathselect.label "Liste des filtres :">
-<!ENTITY asf.saveFromFilter.label "Dossier provenant d'un filtre">
-<!ENTITY asf.savePreviousFolder.label "Dossier précédant">
-<!ENTITY asf.savePreviousFolderSite.label "Dossier précédemment utilisé pour ce site">
+<!ENTITY asf.saveFromFilter.label "Dossier provenant d'un filtre.">
+<!ENTITY asf.savePreviousFolder.label "Dossier précédant.">
+<!ENTITY asf.savePreviousFolderSite.label "Dossier précédemment utilisé pour ce site.">
<!-- Filters tab - top -->
<!ENTITY asf.filters.label "Filtres">
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/automatic-save-folder.git
More information about the Pkg-mozext-commits
mailing list