[Pkg-mozext-commits] [automatic-save-folder] 12/133: New : + Right-Click Feature finally added ! Thanks to Download sort Extension for the right-click timeout information. Download Sort conflict is resolved by setting priority to Download Sort over ASF.
David Prévot
taffit at moszumanska.debian.org
Mon Apr 27 20:33:47 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 6e0b09e5960d99d55cd997d631d9af58ef4f527f
Author: Cyan <Cyan at d0063192-6b2e-11de-89a9-0b20f3e2dceb>
Date: Mon Sep 21 16:40:12 2009 +0000
New :
+ Right-Click Feature finally added !
Thanks to Download sort Extension for the right-click timeout information.
Download Sort conflict is resolved by setting priority to Download Sort
over ASF.
Change :
* StringBundle modification to use only javascript instead of xul references
Fix :
* InstantApply correction for "view path list"
* Corrected a text reference error in edit.xul
git-svn-id: http://automatic-save-folder.googlecode.com/svn/trunk@12 d0063192-6b2e-11de-89a9-0b20f3e2dceb
---
content/add.xul | 5 +-
content/asf.js | 111 +-
content/asf_addedit.js | 6 +-
content/asf_download.js | 8 +-
content/{asf_download.js => asf_right_click.js} | 1511 ++++++++++++-----------
content/edit.xul | 34 +-
content/options.xul | 18 +-
content/overlay_preferences.xul | 2 +-
content/overlay_unknownContentType.xul | 3 -
defaults/preferences/asf.js | 3 +-
locale/en-US/asf.dtd | 10 +-
locale/fr-FR/asf.dtd | 8 +-
locale/it-IT/asf.dtd | 8 +-
locale/it-IT/to translate.txt | 11 +
14 files changed, 942 insertions(+), 796 deletions(-)
diff --git a/content/add.xul b/content/add.xul
index e2af77a..00d6408 100644
--- a/content/add.xul
+++ b/content/add.xul
@@ -21,9 +21,6 @@
ondialogextra2="window.openDialog('chrome://asf/content/regexp.xul','asf_regexp_help','chrome, centerscreen, resizable=yes, dialog=no');"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript" src="chrome://asf/content/asf_addedit.js"/>
-<stringbundleset id="automatic_save_folder_bundleset">
- <stringbundle id="automatic_save_folder_bundles" src="chrome://asf/locale/asf.properties"/>
-</stringbundleset>
<groupbox align="center" orient="horizontal">
<caption label="&asf.addedit.filter.label;" />
<vbox>
@@ -51,7 +48,7 @@
<description value="&asf.addedit.folder.label;"/>
<hbox>
- <textbox id="asf-addedit-folder" readonly="true" width="240" ondblclick="automatic_save_folder.browsedir_addedit()"/>
+ <textbox id="asf-addedit-folder" readonly="true" width="240" ondblclick="automatic_save_folder.browsedir_addedit()"/>
<button id="asf-addedit-select-folder" label="&asf.selectfolder.label;" oncommand="automatic_save_folder.browsedir_addedit()"/>
</hbox>
diff --git a/content/asf.js b/content/asf.js
index c617782..4bf9c56 100644
--- a/content/asf.js
+++ b/content/asf.js
@@ -25,6 +25,11 @@ var automatic_save_folder = {
versionChecker: Components.classes["@mozilla.org/xpcom/version-comparator;1"]
.getService(Components.interfaces.nsIVersionComparator),
+
+ stringbundle: Components.classes["@mozilla.org/intl/stringbundle;1"]
+ .getService(Components.interfaces.nsIStringBundleService)
+ .createBundle("chrome://asf/locale/asf.properties"),
+
asf_load: function () {
@@ -72,8 +77,8 @@ var automatic_save_folder = {
// alert(navigator.appVersion.indexOf("Win"));
},
-
-
+
+
asf_loadpref: function () {
var nbrRow = this.prefManager.getIntPref("extensions.asf.filtersNumber", 0);
@@ -114,8 +119,8 @@ var automatic_save_folder = {
}
},
-
-
+
+
// Called whenever a list box is selected
asf_treeSelected: function () {
var deleteButton = document.getElementById("asf-delete");
@@ -171,8 +176,8 @@ var automatic_save_folder = {
moveUpButton.image = "chrome://asf/skin/up_disabled.png";
}
},
-
-
+
+
asf_toggleradio: function () {
var select_last_radio = document.getElementById("asf-last-radio");
var select_choose_radio = document.getElementById("asf-choose-radio");
@@ -196,9 +201,9 @@ var automatic_save_folder = {
select_keeptemp_chk.disabled = false;
}
},
-
- toggle_options: function () {
+
+ toggle_options: function () { // called whenever the Options tab is selected
var select_option = document.getElementById("asf-viewdloption");
var select_list = document.getElementById("asf-viewpathselect");
var dialogaccept = document.getElementById("asf-dialogaccept");
@@ -210,13 +215,37 @@ var automatic_save_folder = {
{
select_list.checked = false;
select_list.disabled = true;
- this.prefManager.setBoolPref("extensions.asf.viewpathselect",false)
}
if (select_option.checked == true)
{
select_list.disabled = false;
}
+
+ // Print informations about Download sort conflict with right-click
+ // And disable the checkbox
+ document.getElementById("asf-rightclickdesc-DSort").hidden = true;
+ var Dsort_installed = this.DownloadSort();
+ if (Dsort_installed)
+ {
+ var asf_rightclick = document.getElementById("asf-rightclick");
+ asf_rightclick.disabled = true;
+
+ document.getElementById("asf-rightclickdesc").hidden = true;
+ document.getElementById("asf-rightclickdesc-DSort").hidden = false;
+ }
+
+ },
+
+ toggle_rightclick: function () {
+ var instantApply = this.prefManager.getBoolPref("browser.preferences.instantApply");
+
+ if (instantApply)
+ {
+ var status = document.getElementById("asf-rightclick").checked;
+ this.prefManager.setIntPref("browser.download.saveLinkAsFilenameTimeout", status == true ? 0 : 1000 );
+ }
+
},
@@ -225,15 +254,16 @@ var automatic_save_folder = {
// Use this system for tab, because css for tab is not the same color as config window color, and I don't want to force any color by default so user can use new firefox theme's colors.
document.getElementById("asf-tab-filters").hidden = true;
document.getElementById("asf-tab-options").hidden = true;
+ document.getElementById("asf-tab-dynamics").hidden = true;
document.getElementById("asf-tab-informations").hidden = true;
document.getElementById(tabID).hidden = false;
if(tabID == "asf-tab-options") this.toggle_options();
- window.sizeToContent();
+ //window.sizeToContent();
},
-
-
+
+
asf_variablemode: function() {
var select_variable_mode = document.getElementById("asf-variablemode");
var select_folder_input = document.getElementById("asf-default-folder");
@@ -249,7 +279,7 @@ var automatic_save_folder = {
},
-
+
asf_getdomain: function () { // Save the domain and filename in a hidden field, to be used by the "add" button for auto-complete field.
if (window.opener.location == "chrome://mozapps/content/downloads/unknownContentType.xul") // if the option is opened from the saving window
@@ -265,7 +295,7 @@ var automatic_save_folder = {
}
},
-
+
// Code from captain.at, modified by Cyan (CASSAR Eric)
move: function (direction) {
var instantApply = this.prefManager.getBoolPref("browser.preferences.instantApply");
@@ -433,12 +463,11 @@ var automatic_save_folder = {
// next 2 functions : Code inspired from DTA (browsedir & createValidDestination)
browsedir: function () {
var current_folder_input = document.getElementById("asf-default-folder").value;
- var stringbundle = document.getElementById('automatic_save_folder_bundles');
const nsIFilePicker = Components.interfaces.nsIFilePicker;
var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
- var filepickerdescription = stringbundle.getString("select_default_folder");
+ var filepickerdescription = this.stringbundle.GetStringFromName("select_default_folder");
fp.init(window, filepickerdescription, nsIFilePicker.modeGetFolder);
//fp.appendFilters(nsIFilePicker.filterAll | nsIFilePicker.filterText);
@@ -455,6 +484,7 @@ var automatic_save_folder = {
}
//needed to save unicode paths using instantApply
+ var instantApply = this.prefManager.getBoolPref("browser.preferences.instantApply");
if (instantApply)
{
//save the default folder right after editing
@@ -462,8 +492,8 @@ var automatic_save_folder = {
this.saveUnicodeString("extensions.asf.defaultfolder", default_folder);
}
},
-
-
+
+
createValidDestination: function (path) {
if (!path) return false;
if (this.trim(path).length==0) return false;
@@ -476,7 +506,7 @@ var automatic_save_folder = {
} catch(e) {return false;}
return directory;
},
-
+
// removed unicodepath, unicodestring is working fine.
/*
loadUnicodeFolder: function (pref_place) {
@@ -491,8 +521,8 @@ var automatic_save_folder = {
this.prefManager.setComplexValue(pref_place, Components.interfaces.nsILocalFile, directory);
},
*/
-
-
+
+
loadUnicodeString: function (pref_place) {
return this.prefManager.getComplexValue(pref_place, Components.interfaces.nsISupportsString).data;
@@ -514,6 +544,17 @@ var automatic_save_folder = {
},
+ DownloadSort: function() {
+ // Check for Download sort add-on, if enabled return true. (works only on 3.x ?)
+ var enabledItems = this.prefManager.getCharPref("extensions.enabledItems");
+ var dsort_GUUID = "{D9808C4D-1CF5-4f67-8DB2-12CF78BBA23F}";
+ var DownloadSort = enabledItems.indexOf(dsort_GUUID,0);
+
+ if (DownloadSort >= 0) return true;
+ return false;
+ },
+
+
asf_savefilters: function () {
//save the filters list
var tree = document.getElementById("asf-filterList");
@@ -542,15 +583,37 @@ var automatic_save_folder = {
}
},
+
+
+ asf_saveoptions: function() {
+ //Save the View_path_list options
+ var view_list = document.getElementById("asf-viewpathselect").checked;
+ this.prefManager.setBoolPref("extensions.asf.viewpathselect",view_list)
+
+
+ //save the rightclick (set timeout for header(Content-Disposition:) true = 0, false = 1000)
+ // Only if DownloadSort is not enabled (prevent conflict)
+ var Dsort_installed = this.DownloadSort();
+ if (Dsort_installed == false)
+ {
+ var rightclick = document.getElementById("asf-rightclick").checked;
+ this.prefManager.setIntPref("browser.download.saveLinkAsFilenameTimeout", rightclick == true ? 0 : 1000);
+ }
+
+
+ //save the default folder (filters tab)
+ var default_folder = document.getElementById("asf-default-folder").value;
+ this.saveUnicodeString("extensions.asf.defaultfolder", default_folder);
+ },
+
asf_savepref: function () {
//save the filters
this.asf_savefilters();
- //save the default folder
- var default_folder = document.getElementById("asf-default-folder").value;
- this.saveUnicodeString("extensions.asf.defaultfolder", default_folder);
+ //save the options
+ this.asf_saveoptions();
//close the options
window.close();
diff --git a/content/asf_addedit.js b/content/asf_addedit.js
index bdba93c..ad6e613 100644
--- a/content/asf_addedit.js
+++ b/content/asf_addedit.js
@@ -89,12 +89,14 @@ Copyright (C) 2007-2009 Eric Cassar (Cyan).
browsedir_addedit: function () {
var current_folder_input = document.getElementById("asf-addedit-folder").value;
- var stringbundle = document.getElementById('automatic_save_folder_bundles');
+ var stringbundle = Components.classes['@mozilla.org/intl/stringbundle;1'].
+ getService(Ci.nsIStringBundleService).
+ createBundle('chrome://asf/locale/asf.properties');
const nsIFilePicker = Components.interfaces.nsIFilePicker;
var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
- var filepickerdescription = stringbundle.getString("select_folder");
+ var filepickerdescription = stringbundle.GetStringFromName("select_folder");
fp.init(window, filepickerdescription, nsIFilePicker.modeGetFolder);
//fp.appendFilters(nsIFilePicker.filterAll | nsIFilePicker.filterText);
diff --git a/content/asf_download.js b/content/asf_download.js
index 17014a5..859c9f5 100644
--- a/content/asf_download.js
+++ b/content/asf_download.js
@@ -281,14 +281,16 @@ Copyright (C) 2007-2009 Eric Cassar (Cyan).
// make the array with the month's name in the stringbundle of the locale language path.
- var stringbundle = document.getElementById('automatic_save_folder_bundles');
+ var stringbundle = Components.classes['@mozilla.org/intl/stringbundle;1'].
+ getService(Ci.nsIStringBundleService).
+ createBundle('chrome://asf/locale/asf.properties');
var fullmonthname = new Array();
var abbrmonthname = new Array();
for (var i = 1 ; i<= 12 ; i++)
{
- fullmonthname[i-1] = stringbundle.getString("month"+i+"_full");
- abbrmonthname[i-1] = stringbundle.getString("month"+i+"_abbr");
+ fullmonthname[i-1] = stringbundle.GetStringFromName("month"+i+"_full");
+ abbrmonthname[i-1] = stringbundle.GetStringFromName("month"+i+"_abbr");
}
diff --git a/content/asf_download.js b/content/asf_right_click.js
similarity index 62%
copy from content/asf_download.js
copy to content/asf_right_click.js
index 17014a5..f870bdf 100644
--- a/content/asf_download.js
+++ b/content/asf_right_click.js
@@ -1,731 +1,780 @@
-/* ***** BEGIN LICENSE BLOCK *****
-Automatic Save Folder
-Copyright (C) 2007-2009 Eric Cassar (Cyan).
- 2009 Ted Gifford - Dynamic variable capturing
-
- "Automatic Save Folder" is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
-
- "Automatic Save Folder" is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with "Automatic Save Folder". If not, see <http://www.gnu.org/licenses/>.
-
- * ***** END LICENSE BLOCK ***** */
- var automatic_save_folder = {
- prefManager: Components.classes["@mozilla.org/preferences-service;1"]
- .getService(Components.interfaces.nsIPrefBranch),
-
- appInfo: Components.classes["@mozilla.org/xre/app-info;1"]
- .getService(Components.interfaces.nsIXULAppInfo),
-
- versionChecker: Components.classes["@mozilla.org/xpcom/version-comparator;1"]
- .getService(Components.interfaces.nsIVersionComparator),
-
- asf_setdir: function () {
- // I don't understand why "this".function_name doesn't work with addEventListener even using "with" method, only onclick from the Xul events works.
- // So I use this tweak to call functions and properties from its name "automatic_save_folder" instead of "this"
-
- // Setting private variables usable in this function
- var prefManager = automatic_save_folder.prefManager;
- var versionChecker = automatic_save_folder.versionChecker;
- var appInfo = automatic_save_folder.appInfo;
- var ASF = automatic_save_folder; // ASF is just a shortcut to automatic_save_folder
-
- var firefoxversion = "";
- if(versionChecker.compare(appInfo.version, "3.0") >= 0)
- {
- firefoxversion = "3";
- }
- else
- {
- firefoxversion = "2";
- }
-
-
- // Check if there is any filter in list
- var nbrfilters = prefManager.getIntPref("extensions.asf.filtersNumber");
-
-
- // load the domain and the filename of the saved file (copy the data from the firefox saving window)
- var domain = document.getElementById("source").value ;
- var filename = document.getElementById("location").value ;
-
- // debug : show the full downloaded link http://abc.xyz/def/file.ext
- // Can use this new function to get free from the need of the download window.
- //var url = dialog.mLauncher.source.spec;
- //alert(url);
-
-
-
-
- // load prefmanager data
- var savetype = prefManager.getIntPref("extensions.asf.savetype");
- var lastdir = prefManager.getBoolPref("extensions.asf.lastdir");
- var defaultfolder = ASF.loadUnicodeString("extensions.asf.defaultfolder");
- var keeptemp = prefManager.getBoolPref("extensions.asf.keeptemp");
- var tempdomain = ASF.loadUnicodeString("extensions.asf.tempdomain");
- var variable_mode = prefManager.getBoolPref("extensions.asf.variablemode");
- var dialogaccept = prefManager.getBoolPref("extensions.asf.dialogaccept");
-
- // If variable/Advanced mode is ON, let's check the variables and replace to create the new defaultfolder
- if (variable_mode == true)
- {
- defaultfolder = ASF.createfolder(defaultfolder);
- }
-
- // set the last folder path used into asf.lastpath
- if (firefoxversion == "3") // take the download.lastDir if it's FF3
- {
- var folder = ASF.loadUnicodeString("browser.download.lastDir");
- if (folder == "")
- { // it's when lastDir doesn't exist yet, ff3 bug ?
- }
- }
- else // else if it's not FF3 (it's 1.5 or 2), read Download.dir
- {
- var folder = ASF.loadUnicodeString("browser.download.dir");
- }
- ASF.saveUnicodeString("extensions.asf.lastpath", folder); // And set it to asf.lastpath to be compared later with the new path the filters will set to lastDir (or dir)
-
-
-
-
- // load filters data from prefmanager into filters[]
- // filters[filternumber][label]
- var filters = new Array();
- for ( var i = 0 ; i < nbrfilters ; i++)
- {
- var dom = ASF.loadUnicodeString("extensions.asf.filters"+ i +".domain");
- var fil = ASF.loadUnicodeString("extensions.asf.filters"+ i +".filename");
- var fol = ASF.loadUnicodeString("extensions.asf.filters"+ i +".folder");
- var act = prefManager.getBoolPref("extensions.asf.filters"+ i +".active");
- filters[i] = [dom, fil, fol, act];
- }
-
-
- //
- // Start checking the filters with the downloaded file
- //
- var idx = -1 ;
- var dom_regexp = false;
- var file_regexp = false;
- for ( var i = 0 ; i < filters.length ; i++)
- {
- if (filters[i][3] == true) // if not temporary deactivated
- {
- dom_regexp = false ; // reset the matching string for the "for" loop
- file_regexp = false ; // same as above
- // Check the domain
- dom_regexp = ASF.test_regexp(filters[i][0], "source"); // hosted Domain
-
- // Check the referer domain name if hosted domain checking returned false. In next releases, will be a proper option
- if (dom_regexp == false)
- {
- dom_regexp = ASF.test_regexp(filters[i][0], "referer"); // check the filter domain with the Referer domain only if the hosted domain doesn't match
- }
-
- // Check the filename
- file_regexp = ASF.test_regexp(filters[i][1], "location"); // Filename
-
- // debug
- // alert ("i = "+i+"\n domain match = "+dom_regexp+"\n file match = "+file_regexp);
- if (dom_regexp && file_regexp)
- {
- var idx = i;
- break;
- }
- }
- } // end filters loop
-
- if (idx < 0) // if no filters matched
- {
- if(savetype == 1) // and folder is set to user choice
- {
- if ( (keeptemp == false) || ((keeptemp == true) && ( tempdomain != domain )) ) // and, if [same domain not checked] OR [ if same domain (keeptemp) is checked and domain not same as previous one]
- { // then change the destination folder to user choice
- ASF.saveUnicodeString("browser.download.dir", defaultfolder);
- if (lastdir == true) // set it for "save as..." on FF1.5 and FF2, on FF3 lastdir is always true
- {
- ASF.saveUnicodeString("browser.download.lastDir", defaultfolder);
- }
- }
- else // else, if domain is the same as the last, set the download.dir to the last folder used (else viewDownloadOption will not show the correct save path and will use the default folder)
- { // only affect Firefox3 which update download.lastDir instead of download.dir, so taking download.lastDir data to set download.dir,
- // FF1.5 or FF2 automatically update download.dir, not download.lastDir
- if (firefoxversion == "3")
- {
- var lastpath = ASF.loadUnicodeString("browser.download.lastDir"); // this one is the one that will open
- if (lastpath == "") // if no path is returned (first time using lastDir, or the user reseted the content manually in about:config)
- {
- ASF.saveUnicodeString("browser.download.lastDir", defaultfolder);
- lastpath = defaultfolder;
- }
- ASF.saveUnicodeString("browser.download.dir", lastpath); // this one is the one that will be shown in ASF save option
- }
- }
- }
- else // else, if savetype == 0 (folder is set to last folder)
- {
- // set the download.dir to the last folder used (else viewDownloadOption will not show the correct save path and will use the default folder)
- // only affect Firefox3 which update download.lastDir instead of download.dir, so we are taking download.lastDir data to set download.dir,
- // FF1.5 or FF2 automatically update download.dir, not download.lastDir
- if (firefoxversion == "3")
- {
- var lastpath = ASF.loadUnicodeString("browser.download.lastDir");
- if (lastpath == "") // if no path is returned (first time using lastDir, or the user reseted the content manually in about:config)
- {
- ASF.saveUnicodeString("browser.download.lastDir", defaultfolder);
- lastpath = defaultfolder;
- }
- ASF.saveUnicodeString("browser.download.dir", lastpath);
- }
-
- }
- }
- else // if a filter is found
- {
-
- var folder = filters[idx][2];
-
-
- // If Advanced mode is ON, let's check the variables and create the folder
- if (variable_mode == true)
- {
-
-// Ted Gifford, start block
- // String capture in filename with $f<1-9>
- try {
- //alert(file_regexp.length);
- if (file_regexp.length > 1)
- {
- //alert('munging folder: ' + folder);
- for (var replace_index = 1; replace_index < file_regexp.length; ++replace_index)
- folder = folder.replace("$"+replace_index+"f", file_regexp[replace_index]);
- //alert('munged folder: ' + folder);
- }
- } catch (e) {alert(e);}
- // String capture in domain with $d<1-9>
- try {
- //alert(dom_regexp.length);
- if (dom_regexp.length > 1)
- {
- //alert('munging folder: ' + folder);
- for (var replace_index = 1; replace_index < dom_regexp.length; ++replace_index)
- folder = folder.replace("$"+replace_index+"d", dom_regexp[replace_index]);
- //alert('munged folder: ' + folder);
- }
- } catch (e) {alert(e);}
-// Ted Gifford, end block
-
-
-
- folder = ASF.createfolder(folder, idx);
- }
-
- ASF.saveUnicodeString("browser.download.dir", folder);
- if (lastdir == true) // set it for "save as..." on FF1.5 and FF2, on FF3 lastdir is always true
- {
- ASF.saveUnicodeString("browser.download.lastDir", folder);
- }
- }
-
- // in every case, set the new file hosted domain to tempdomain
- ASF.saveUnicodeString("extensions.asf.tempdomain", domain);
-
- // Automatic saving when clicking on a link. The save dialog still flash onscreen very quicly.
- if (dialogaccept)
- {
- window.close();
- return dialog.onOK();
- }
- else
- {
- // show or hide the asf option on saving window
- ASF.show_dloptions();
- }
-
- },
-
-
- loadUnicodeString: function (pref_place) {
- try
- {
- return this.prefManager.getComplexValue(pref_place, Components.interfaces.nsISupportsString).data;
- }
- catch (e)
- { }
- return "";
- },
-
-
- saveUnicodeString: function (pref_place,pref_data) {
- var str = Components.classes["@mozilla.org/supports-string;1"]
- .createInstance(Components.interfaces.nsISupportsString);
- str.data = pref_data;
- this.prefManager.setComplexValue(pref_place, Components.interfaces.nsISupportsString, str);
- },
-
-
- createfolder: function (path, idx) {
-
- if (!path) return false;
- if (this.trim(path).length==0) return false;
-
- var objdate = new Date();
-
- // make the array with the month's name in the stringbundle of the locale language path.
-
- var stringbundle = document.getElementById('automatic_save_folder_bundles');
-
- var fullmonthname = new Array();
- var abbrmonthname = new Array();
- for (var i = 1 ; i<= 12 ; i++)
- {
- fullmonthname[i-1] = stringbundle.getString("month"+i+"_full");
- abbrmonthname[i-1] = stringbundle.getString("month"+i+"_abbr");
- }
-
-
- const ZERO = "0"; // leading zero
-
- // load the domain and the filename of the saved file
- var domain = document.getElementById("source").value ;
- domain = domain.replace(/^.*:\/\//g,''); // remove the protocol name from the domain
- 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)
-
-
-
-
-
- // check the filter's data
- var asf_domain = "";
- var asf_filename = "";
- if (idx) { // If a filter match, idx is true
- asf_domain = this.loadUnicodeString("extensions.asf.filters"+ idx +".domain");
- // Trim the / / if domain is regexp
- if (this.is_regexp(asf_domain))
- {
- asf_domain = asf_domain.substring(1, asf_domain.length);
- asf_domain = asf_domain.substring(0, asf_domain.length -1);
- }
- asf_filename = this.loadUnicodeString("extensions.asf.filters"+ idx +".filename");
- // Trim the / / if filename is regexp
- if (this.is_regexp(asf_filename))
- {
- asf_filename = asf_filename.substring(1, asf_filename.length);
- asf_filename = asf_filename.substring(0, asf_filename.length -1);
- }
- }
- else // no filter is found, use actual Domain and filename without extension
- {
- asf_domain = domain;
- asf_filename = file_name;
- }
-
- // Check if asf_rd is present and process asf_rd = Regexp the domain
- if (path.search("%asf_rd%") != -1)
- {
- // get the domain with the protocol
- var domainp = document.getElementById("source").value ;
-
- // extract the filter part
- var matches = path.match(/%asf_rd%.*?%asf_rd%/g); // matches is an array
- if (matches != null)
- {
- var datareg = "";
- var result = new Array();
- var matchreplace = new Array();
- for (var i = 0, len = matches.length; i < len; i++)
- {
- datareg = matches[i].replace(/%asf_rd%/g, ''); // remove the %asf_rf% to keep only the regexp
- datareg = new RegExp(datareg, 'i'); // create the regexp
- //alert("reg="+datareg);
- result = domainp.match(datareg); // Check it on the domain with protocol
-
- if (result == null)
- {
- matchreplace[i] = ""; // if no result, replace with nothing instead of null
- }
- else
- {
- matchreplace[i] = result[0];
- }
- //alert("matchreplace["+i+"]="+matchreplace[i]);
- }
- for (var i = 0, len = matches.length; i < len; i++)
- {
- path = path.replace(matches[i], matchreplace[i]); // replace each variable in the path
- }
- }
- }
-
-
- // Check if asf_rf is present and process asf_rf = Regexp the filename
- if (path.search("%asf_rf%") != -1 )
- {
- // extract the filter part
- var matches = path.match(/%asf_rf%.*?%asf_rf%/g); // matches is an array
- if (matches != null)
- {
- var datareg = "";
- var result = new Array();
- var matchreplace = new Array();
- for (var i = 0, len = matches.length; i < len; i++)
- {
- datareg = matches[i].replace(/%asf_rf%/g, ''); // remove the %asf_rf% to keep only the regexp
- datareg = new RegExp(datareg, 'i'); // create the regexp
- //alert("reg="+datareg);
- result = filename.match(datareg); // Check it
-
- if (result == null)
- {
- matchreplace[i] = ""; // if no result, replace with nothing instead of null
- }
- else
- {
- matchreplace[i] = result[0];
- }
- //alert("matchreplace["+i+"]="+matchreplace[i]);
- }
- for (var i = 0, len = matches.length; i < len; i++)
- {
- path = path.replace(matches[i], matchreplace[i]); // replace each variable in the path
- }
- }
- }
-
-
-
- // remove special characters from filters :
- // forbidden on windows \ / : * ? " < > |
- if (navigator.appVersion.indexOf("Win")!=-1) // = Windows
- {
- asf_domain = asf_domain.replace(/[\/\:\*\?\"\<\>\|]/g,'');
- asf_filename = asf_filename.replace(/[\/\:\*\?\"\<\>\|]/g,'');
- file_name = file_name.replace(/[\/\:\*\?\"\<\>\|]/g,'');
- path = path.replace(/[\/\*\?\"\<\>\|]/g,'');
- }
- else // MacOS and linux, replace only / :
- {
- asf_domain = asf_domain.replace(/[\/\:]/g,'');
- asf_filename = asf_filename.replace(/[\/\:]/g,'');
- file_name = file_name.replace(/[\/\:]/g,'');
- }
-
- // replace the string here // Year
- path = path .replace(/%Y%/g, objdate.getFullYear()) // full year format = 2009
- .replace(/%y%/g, ((objdate.getYear()-100) <10) ? (ZERO + (objdate.getYear()-100)) : objdate.getYear()-100) // year in YY format : 08, 09, 10
- // .replace(/%<to define>/g, objdate.getYear()-100) // 8, 9, 10, (no leading 0)
- // Month
- .replace(/%m%/g, ((objdate.getMonth()+1) <10) ? (ZERO + (objdate.getMonth()+1)) : objdate.getMonth()+1) // = number of the month : 01 to 12
- .replace(/%n%/g, objdate.getMonth()+1) // 8, 9, 10, (no leading 0)
- .replace(/%F%/g, fullmonthname[objdate.getMonth()]) // full month name
- .replace(/%M%/g, abbrmonthname[objdate.getMonth()]) // abbreviated month name
- // Day
- .replace(/%d%/g, ((objdate.getDate()) <10) ? (ZERO + (objdate.getDate())) : objdate.getDate()) // = number of the day : 01 to 31
- .replace(/%j%/g, objdate.getDate()) // = number of the day 1 to 31 (no leading 0)
- // ASF
- .replace(/%asf_D%/g, domain) // downloaded File's domain
- .replace(/%asf_F%/g, filename) // downloaded File's filename with extension
- .replace(/%asf_Fx%/g, file_name) // downloaded File's filename without extension
- .replace(/%asf_d%/g, asf_domain) // matching filter's Domain (without special chars used by regexp)
- .replace(/%asf_f%/g, asf_filename) // mathching filter's filename (without special chars used by regexp)
- .replace(/%asf_x%/g, extension[0]); // match the filename extension (without the dot)
- // debug
- // alert (path);
- var directory = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
-
- directory.initWithPath(path);
- return path;
-
-// Canceled the folder creation script, so the folder will not be created if the user cancel the download
-// Firefox will create it automatically when accepting the download... under windows XP and Linux Ubuntu at least (not tested under Vista, MacOS, or any other operating system)
-/*
- if (directory.exists())
- {
- return path;
- }
- else // if it doesn't exist, create it
- {
- if( !directory.exists() || !directory.isDirectory() )
- {
- directory.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0777);
- }
- return path;
- }
-*/
- },
-
-
- trim: function (string) {
- return string.replace(/(^\s*)|(\s*$)/g,'');
- },
-
-
- show_dloptions: function () {
-
- var asf_dloptions = document.getElementById('asf_dloptions');
- var asf_radiogroup_pathselect = document.getElementById('asf_radiogroup_pathselect');
- var asf_savefolder = document.getElementById('asf_savefolder');
- var asf_viewdloption = this.prefManager.getBoolPref("extensions.asf.viewdloption");
- var asf_viewpathselect = this.prefManager.getBoolPref("extensions.asf.viewpathselect");
- var folder = this.loadUnicodeString("browser.download.dir");
-
- // check the lastpath, if different than current folder, then print radio choice to user
- // so he can choose from found filters, or last used path.
- var lastpath = this.loadUnicodeString("extensions.asf.lastpath");
- var asf_lastpath = document.getElementById('asf_lastpath');
-
- if ( (lastpath == folder) || (lastpath == "") ) // if same or empty (first time using ASF), do not show radio for lastpath choice
- {
- asf_lastpath.hidden = true;
- }
- else // else, if last path is different than folder found in filter, show a choice
- {
- asf_lastpath.hidden = false;
- }
-
- //set the text to be written on the Radio comment
- asf_savefolder.label = folder;
- asf_lastpath.label = lastpath;
-
- // Force check the first radio choice (needed on linux + ff2.x) (linux has blank radio choices on loading, this is only visual, it doesn't affect anything here, the value are set to the new path by default until the user change the radio choice)
- var asf_radio_savepath = document.getElementById('asf_radio_savepath');
- asf_radio_savepath.value = 0;
-
-
- //now, if the user checked the option to view asf on saving window, set it to visible
- if(asf_viewdloption == true) asf_dloptions.style.visibility = "visible";
-
- //and last, if the user checked the option to view asf on saving window, set it to visible
- if((asf_viewpathselect == true) && (this.prefManager.getIntPref("extensions.asf.filtersNumber") > 0) )
- {
- this.read_all_filterpath();
- asf_radiogroup_pathselect.style.visibility = "visible";
- }
-
-
-
-
- // Set the max width to the size of the screen minus 200px. Added for Mac OSX users with long path choice.
- // alert("first screen : " + screen.width + "x" + screen.height);
- asf_dloptions.style.maxWidth = screen.width -200 +"px";
-
- },
-
- indexInArray: function (arr,val){
- val = val.replace(/\\/g,'\\\\');
- var test_regexp = new RegExp("^"+val+"$");
- var data = "";
- for(var i=0;i<arr.length;i++)
- {
- if(test_regexp.test(arr[i])) return i;
- }
- return -1;
- } ,
-
- read_all_filterpath: function() {
- var ASF = automatic_save_folder; // ASF is just a shortcut to automatic_save_folder
- var variable_mode = ASF.prefManager.getBoolPref("extensions.asf.variablemode");
- var list = document.getElementById('asf_folder_list');
- var menupopup = document.createElement('menupopup');
-
- // Check if there is any filter in list
- var nbrfilters = this.prefManager.getIntPref("extensions.asf.filtersNumber");
- var path = "";
-
- // Delete active list before repopulating (if editing filter and coming back to saving window)
- for (var i=list.childNodes.length-1 ; i>=0 ; i--)
- {
- list.removeChild(list.childNodes[i]);
- }
-
- // Write each path to the menupopup
- var pathlist = new Array();
- pathlist[0] = this.loadUnicodeString("extensions.asf.defaultfolder");
- var j = 0;
- for (var i = 0; i < nbrfilters; i++)
- {
- // read the filter number x
- path = this.loadUnicodeString("extensions.asf.filters"+ i +".folder");
-
- if ( ASF.indexInArray(pathlist, path) < 0) { pathlist[++j]= path;}
- }
-
- var pathlist_sort_alpha = true; // let the user choose in next release.
- if (pathlist_sort_alpha) pathlist.sort();
-
- for (var i = 0; i < pathlist.length; i++)
- {
- path = pathlist[i];
- path = variable_mode == true? ASF.createfolder(path) : path;
- var menuitem = document.createElement('menuitem');
- menuitem.setAttribute('label', path);
- menuitem.setAttribute('crop', 'center');
- menuitem.setAttribute('value', path);
- menuitem.setAttribute('oncommand', "automatic_save_folder.asf_select_savepath(this)");
- menupopup.appendChild(menuitem);
- }
-
- // Populate the path list into the menu
- list.appendChild(menupopup);
-
- },
-
-
- asf_toggle_savepath: function () {
-
- var lastdir = this.prefManager.getBoolPref("extensions.asf.lastdir");
-
- var asf_savefolder = document.getElementById('asf_savefolder');
- var asf_lastpath = document.getElementById('asf_lastpath');
- var asf_pathselect = document.getElementById('asf_pathselect');
- var userchoice = "";
-
- if(asf_savefolder.selected == true)
- {
- userchoice = asf_savefolder.label ;
- }
-
- if(asf_lastpath.selected == true)
- {
- userchoice = asf_lastpath.label ;
- }
-
- if(asf_pathselect.selected == true)
- {
- // read the current selected item value
- var asf_folder_list = document.getElementById('asf_folder_list');
- userchoice = asf_folder_list.value ;
- }
-
-
- this.saveUnicodeString("browser.download.dir", userchoice);
- if (lastdir == true) // set it for "save as..." on FF1.5 and FF2, on FF3 lastdir is always true
- {
- this.saveUnicodeString("browser.download.lastDir", userchoice);
- }
-
- },
-
-
- asf_select_savepath: function () {
-
- var lastdir = this.prefManager.getBoolPref("extensions.asf.lastdir");
-
- // check the third radio choice
- var asf_radio_savepath = document.getElementById('asf_radio_savepath');
- asf_radio_savepath.value = 2;
-
- // read the selected item value
- var asf_folder_list = document.getElementById('asf_folder_list');
-
- this.saveUnicodeString("browser.download.dir", asf_folder_list.value);
- if (lastdir == true) // set it for "save as..." on FF1.5 and FF2, on FF3 lastdir is always true
- {
- this.saveUnicodeString("browser.download.lastDir", asf_folder_list.value);
- }
- },
-
- test_regexp: function (filters, input) {
-
- // input can be "source" for domain name, "location" for file name, ...
- if ( (input == "source") || (input == "location") )
- {
- var string = document.getElementById(input).value ;
- }
- // ... or "referer" for referer's domain name (the place where the link is, and not the file)
- else // if (input == "referer")
- {
- var uCT = document.getElementById("unknownContentType");
- var string = uCT.parentNode.defaultView.opener.location.host; // look for the referer host name in the DOM.
- }
-
- // Steps :
- // 1 - Check if the filter is a regular expression
- // 2 - if not regexp : add the backslah to special characters and .* to the start and end of the string to convert it into a regexp form
- // if it's already regexp : delete the / / for new regexp() to handle it
- // 3 - when all is ready in regexp, test the data with the filters
- // 4 - if the data match the filter --> return true
-
- // 3 & 4 replaced with Ted script, now it returns the matching result's array, or false if nothing matched.
-
-
- // step 1
- var test_regexp = this.is_regexp(filters); // True or False
-
- // step 2
- if (test_regexp == false) // replace simple wildcard and special characters with corresponding regexp
- {
- filters = filters.replace(/\./gi, "\\.")
- .replace(/\*/gi, "(.)*")
- .replace(/\$/gi, "\\$")
- .replace(/\^/gi, "\\^")
- .replace(/\+/gi, "\\+")
- .replace(/\?/gi, ".")
- .replace(/\|/gi, "\\|")
- .replace(/\[/gi, "\\[")
- .replace(/\//gi,'\\/');
- filters = ".*"+filters+".*";
- }
- else // remove the first and last slash
- {
- filters = filters.substring(1, filters.length);
- filters = filters.substring(0, filters.length -1);
- }
-
- // initialize the regular expression search
- var test_regexp = new RegExp(filters, "i"); // put the slash back and the gi option (g = global seach, i = case insensitive)
- // Edited to only "i" option by Ted.
-
- // Step 3 & 4
- // if (string.match(test_regexp)) // if something match
- // {
- // return(true);
- // }
-
- // return(false);
-
-// Ted Gifford, start block
- var res = string.match(test_regexp);
- if (res) return res;
- return false
-// Ted Gifford, end block
-
- },
-
-
- is_regexp: function (string) {
- if ((string.substring(0,1) == "/") && (string.substr(string.length - 1, 1) == "/"))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
-
-
-};
- // addEventListener( // Autoload
- // "load", // After OnLoad from overlay_unknownContentType.xul file
- // automatic_save_folder.asf_setdir, // Run asf_setdir from automatic_save_folder to check the filters
- // true
- // );
-
- with(automatic_save_folder){
- addEventListener( // Autoload
- "load", // After OnLoad from overlay_unknownContentType.xul file
- asf_setdir, // Run asf_setdir from automatic_save_folder to check the filters
- false
- );
- }
\ No newline at end of file
+/* ***** BEGIN LICENSE BLOCK *****
+Automatic Save Folder
+Copyright (C) 2007-2009 Eric Cassar (Cyan).
+ 2009 Ted Gifford - Dynamic variable capturing
+
+ "Automatic Save Folder" is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ "Automatic Save Folder" is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with "Automatic Save Folder". If not, see <http://www.gnu.org/licenses/>.
+
+ * ***** END LICENSE BLOCK ***** */
+var ORIG_getTargetFile = window.getTargetFile;
+var asf_rightclick_loaded;
+
+var automatic_save_folder = {
+ prefManager: Components.classes["@mozilla.org/preferences-service;1"]
+ .getService(Components.interfaces.nsIPrefBranch),
+
+ appInfo: Components.classes["@mozilla.org/xre/app-info;1"]
+ .getService(Components.interfaces.nsIXULAppInfo),
+
+ versionChecker: Components.classes["@mozilla.org/xpcom/version-comparator;1"]
+ .getService(Components.interfaces.nsIVersionComparator),
+
+
+ rightclick_init: function() {
+ if (!asf_rightclick_loaded)
+ {
+ asf_rightclick_loaded = true;
+
+ var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
+
+ //replace original Rightclick menu with ASF Rightclick menu
+ // Not compatible with Download Sort extension (same function modification, it will conflict).
+ // Detect if Download Sort is installed and enabled, and activate ASF rightclick only if DSort is not already loaded.
+ var enabledItems = prefs.getCharPref("extensions.enabledItems");
+ var dsort_GUUID = "{D9808C4D-1CF5-4f67-8DB2-12CF78BBA23F}";
+ var DownloadSort = enabledItems.indexOf(dsort_GUUID,0);
+
+ if (DownloadSort >= 0)
+ {
+ // alert ("Download sort extension detected")
+ }
+ else // Download Sort is not enabled, load ASF rightclick replacement.
+ {
+
+ // Not working like I would like :(
+ /*
+ // Replace first line of ORIGinal firefox rightclick function, to add ASF function to it. might Works with every firefox version :)
+ var asf_getTargetFile = ORIG_getTargetFile.toString().replace("const prefSvcContractID","automatic_save_folder.rightclick_setdir(aFpP);const prefSvcContractID");
+ asf_getTargetFile = new Function("aFpP","aSkipPrompt", asf_getTargetFile);
+ alert(asf_getTargetFile);
+ window.getTargetFile = asf_getTargetFile;
+ */
+
+ // replace the ORIGinal firefox function with the custom one. (only working on 3.x ?)
+ window.getTargetFile = automatic_save_folder.asf_getTargetFile;
+
+ // only "save image as..." is working until right click timeout set to 0
+ // But timeout=0 prevent firefox from reading header(Content-Disposition:)
+ // So let's put to 0 only when the user want to use it
+ // and set it back to 1000 (default) when exiting Firefox to prevent blocking the user to 0
+ // if add-on is removed without reseting the timeout first.
+ var asf_rightclick = prefs.getBoolPref("extensions.asf.rightclick");
+ prefs.setIntPref("browser.download.saveLinkAsFilenameTimeout", asf_rightclick == true ? 0 : 1000);
+
+ var obsSvc = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
+ obsSvc.addObserver(automatic_save_folder.asf_quitObserver, "quit-application-requested", false);
+ }
+ }
+
+ },
+
+
+ // reset Timelimit=0 to =1000 when closing Firefox
+ // it will reset to 1000 even if closing firefox is canceled.
+ // It will cause ASF right-click to stop working until the user accept any changes in ASF main preferences.
+ // I think it's very unlikly to happen to a lot of people, and is easily corrected by checking the preferences.
+ asf_quitObserver: {
+ observe: function(subject, topic, state) {
+
+ //alert(topic);
+ if(topic == "quit-application-requested") {
+ var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
+ prefs.setIntPref("browser.download.saveLinkAsFilenameTimeout", 1000);
+ }
+ }
+ },
+
+
+
+ // Original from firefox 3.5.3
+ // I tried to "live-patch" the user function, using
+ // asf_getTargetFile = ORIG_getTargetFile.toString().replace("first line","first line + ASF")
+ // But there's no way to revert it to a function, asf_getTargetFile = asf_getTargetFile.toFunction() is not working (it wrap it into an anonymous function).
+ // See lines ~40 for the test
+ asf_getTargetFile: function (aFpP, /* optional */ aSkipPrompt)
+ {
+
+ automatic_save_folder.rightclick_setdir(aFpP);
+
+ const prefSvcContractID = "@mozilla.org/preferences-service;1";
+ const prefSvcIID = Components.interfaces.nsIPrefService;
+ var prefs = Components.classes[prefSvcContractID]
+ .getService(prefSvcIID).getBranch("browser.download.");
+
+ const nsILocalFile = Components.interfaces.nsILocalFile;
+
+ var inPrivateBrowsing = false;
+ try
+ {
+ var pbs = Components.classes["@mozilla.org/privatebrowsing;1"]
+ .getService(Components.interfaces.nsIPrivateBrowsingService);
+ inPrivateBrowsing = pbs.privateBrowsingEnabled;
+ }
+ catch (e) { }
+
+ // For information on download folder preferences, see
+ // mozilla/browser/components/preferences/main.js
+
+ var useDownloadDir = prefs.getBoolPref("useDownloadDir");
+ var dir = null;
+
+ // Default to lastDir if useDownloadDir is false, and lastDir
+ // is configured and valid. Otherwise, use the user's default
+ // downloads directory configured through download prefs.
+ var dnldMgr = Components.classes["@mozilla.org/download-manager;1"]
+ .getService(Components.interfaces.nsIDownloadManager);
+ try
+ {
+ var lastDir;
+ if (inPrivateBrowsing && gDownloadLastDir.file)
+ lastDir = gDownloadLastDir.file;
+ else
+ lastDir = prefs.getComplexValue("lastDir", nsILocalFile);
+ if ((!aSkipPrompt || !useDownloadDir) && lastDir.exists())
+ dir = lastDir;
+ else
+ dir = dnldMgr.userDownloadsDirectory;
+ } catch(ex) {
+ dir = dnldMgr.userDownloadsDirectory;
+ }
+
+ if (!aSkipPrompt || !useDownloadDir || !dir || (dir && !dir.exists()))
+ {
+ if (!dir || (dir && !dir.exists()))
+ {
+ // Default to desktop.
+ var fileLocator = Components.classes["@mozilla.org/file/directory_service;1"]
+ .getService(Components.interfaces.nsIProperties);
+ dir = fileLocator.get("Desk", nsILocalFile);
+ }
+
+ var fp = makeFilePicker();
+ var titleKey = aFpP.fpTitleKey || "SaveLinkTitle";
+ var bundle = getStringBundle();
+ fp.init(window, bundle.GetStringFromName(titleKey),
+ Components.interfaces.nsIFilePicker.modeSave);
+
+ fp.defaultExtension = aFpP.fileInfo.fileExt;
+ fp.defaultString = getNormalizedLeafName(aFpP.fileInfo.fileName,
+ aFpP.fileInfo.fileExt);
+ appendFiltersForContentType(fp, aFpP.contentType, aFpP.fileInfo.fileExt,
+ aFpP.saveMode);
+
+ if (dir)
+ fp.displayDirectory = dir;
+
+ if (aFpP.isDocument)
+ {
+ try {
+ fp.filterIndex = prefs.getIntPref("save_converter_index");
+ }
+ catch (e) {}
+ }
+
+ if (fp.show() == Components.interfaces.nsIFilePicker.returnCancel || !fp.file)
+ return false;
+
+ // Do not store the last save directory as a pref inside the private browsing mode
+ var directory = fp.file.parent.QueryInterface(nsILocalFile);
+ if (inPrivateBrowsing)
+ gDownloadLastDir.file = directory;
+ else
+ prefs.setComplexValue("lastDir", nsILocalFile, directory);
+
+ fp.file.leafName = validateFileName(fp.file.leafName);
+ aFpP.saveAsType = fp.filterIndex;
+ aFpP.file = fp.file;
+ aFpP.fileURL = fp.fileURL;
+
+ if (aFpP.isDocument)
+ prefs.setIntPref("save_converter_index", aFpP.saveAsType);
+ }
+ else
+ {
+ dir.append(getNormalizedLeafName(aFpP.fileInfo.fileName,
+ aFpP.fileInfo.fileExt));
+ var file = dir;
+
+ // Since we're automatically downloading, we don't get the file picker's
+ // logic to check for existing files, so we need to do that here.
+ //
+ // Note - this code is identical to that in
+ // mozilla/toolkit/mozapps/downloads/src/nsHelperAppDlg.js.in
+ // If you are updating this code, update that code too! We can't share code
+ // here since that code is called in a js component.
+ var collisionCount = 0;
+ while (file.exists())
+ {
+ collisionCount++;
+ if (collisionCount == 1)
+ {
+ // Append "(2)" before the last dot in (or at the end of) the filename
+ // special case .ext.gz etc files so we don't wind up with .tar(2).gz
+ if (file.leafName.match(/\.[^\.]{1,3}\.(gz|bz2|Z)$/i))
+ file.leafName = file.leafName.replace(/\.[^\.]{1,3}\.(gz|bz2|Z)$/i, "(2)$&");
+ else
+ file.leafName = file.leafName.replace(/(\.[^\.]*)?$/, "(2)$&");
+ }
+ else
+ {
+ // replace the last (n) in the filename with (n+1)
+ file.leafName = file.leafName.replace(/^(.*\()\d+\)/, "$1" + (collisionCount+1) + ")");
+ }
+ }
+ aFpP.file = file;
+ }
+
+ return true;
+ },
+
+
+
+ rightclick_setdir: function(aFpP) {
+
+ //alert ("debug full uri : "+aFpP.fileInfo.uri.spec);
+ //alert("ok");
+
+ // Setting private variables usable in this function
+ var prefManager = automatic_save_folder.prefManager;
+ var versionChecker = automatic_save_folder.versionChecker;
+ var appInfo = automatic_save_folder.appInfo;
+ var ASF = automatic_save_folder; // ASF is just a shortcut to automatic_save_folder
+
+ var firefoxversion = "";
+ if(versionChecker.compare(appInfo.version, "3.0") >= 0)
+ {
+ firefoxversion = "3";
+ }
+ else
+ {
+ firefoxversion = "2";
+ }
+
+
+ // Check if there is any filter in list
+ var nbrfilters = prefManager.getIntPref("extensions.asf.filtersNumber");
+
+
+ // load the domain and the filename of the saved file (copy the data from the firefox saving window)
+ // var domain = document.getElementById("source").value ;
+ // var filename = document.getElementById("location").value ;
+
+ var domain = aFpP.fileInfo.uri.scheme+"://"+aFpP.fileInfo.uri.host ;
+ var filename = aFpP.fileInfo.fileName
+
+
+ // debug : show the full downloaded link http://abc.xyz/def/file.ext
+ // Can use this new function to get free from the need of the download window.
+ //var url = dialog.mLauncher.source.spec;
+ //alert(url);
+
+
+
+
+ // load prefmanager data
+ var savetype = prefManager.getIntPref("extensions.asf.savetype");
+ var lastdir = prefManager.getBoolPref("extensions.asf.lastdir");
+ var defaultfolder = ASF.loadUnicodeString("extensions.asf.defaultfolder");
+ var keeptemp = prefManager.getBoolPref("extensions.asf.keeptemp");
+ var tempdomain = ASF.loadUnicodeString("extensions.asf.tempdomain");
+ var variable_mode = prefManager.getBoolPref("extensions.asf.variablemode");
+ var dialogaccept = prefManager.getBoolPref("extensions.asf.dialogaccept");
+
+ // If variable/Advanced mode is ON, let's check the variables and replace to create the new defaultfolder
+ if (variable_mode == true)
+ {
+ defaultfolder = ASF.createfolder(aFpP, defaultfolder);
+ }
+
+ // set the last folder path used into asf.lastpath
+ if (firefoxversion == "3") // take the download.lastDir if it's FF3
+ {
+ var folder = ASF.loadUnicodeString("browser.download.lastDir");
+ if (folder == "")
+ { // it's when lastDir doesn't exist yet, ff3 bug ?
+ }
+ }
+ else // else if it's not FF3 (it's 1.5 or 2), read Download.dir
+ {
+ var folder = ASF.loadUnicodeString("browser.download.dir");
+ }
+ ASF.saveUnicodeString("extensions.asf.lastpath", folder); // And set it to asf.lastpath to be compared later with the new path the filters will set to lastDir (or dir)
+
+
+ // load filters data from prefmanager into filters[]
+ // filters[filternumber][label]
+ var filters = new Array();
+ for ( var i = 0 ; i < nbrfilters ; i++)
+ {
+ var dom = ASF.loadUnicodeString("extensions.asf.filters"+ i +".domain");
+ var fil = ASF.loadUnicodeString("extensions.asf.filters"+ i +".filename");
+ var fol = ASF.loadUnicodeString("extensions.asf.filters"+ i +".folder");
+ var act = prefManager.getBoolPref("extensions.asf.filters"+ i +".active");
+ filters[i] = [dom, fil, fol, act];
+ }
+
+
+ //
+ // Start checking the filters with the downloaded file
+ //
+ var idx = -1 ;
+ var dom_regexp = false;
+ var file_regexp = false;
+ for ( var i = 0 ; i < filters.length ; i++)
+ {
+ if (filters[i][3] == true) // if not temporary deactivated
+ {
+ dom_regexp = false ; // reset the matching string for the "for" loop
+ file_regexp = false ; // same as above
+ // Check the domain
+ dom_regexp = ASF.test_regexp(filters[i][0], domain); // hosted Domain
+
+ // Check the referer domain name if hosted domain checking returned false. In next releases, will be a proper option
+ if (dom_regexp == false)
+ {
+ dom_regexp = ASF.test_regexp(filters[i][0], "referer"); // check the filter domain with the Referer domain only if the hosted domain doesn't match
+ }
+
+ // Check the filename
+ file_regexp = ASF.test_regexp(filters[i][1], filename); // Filename
+
+ // debug
+ // alert ("i = "+i+"\n domain match = "+dom_regexp+"\n file match = "+file_regexp);
+ if (dom_regexp && file_regexp)
+ {
+ var idx = i;
+ break;
+ }
+ }
+ } // end filters loop
+
+ if (idx < 0) // if no filters matched
+ {
+ if(savetype == 1) // and folder is set to user choice
+ {
+ if ( (keeptemp == false) || ((keeptemp == true) && ( tempdomain != domain )) ) // and, if [same domain not checked] OR [ if same domain (keeptemp) is checked and domain not same as previous one]
+ { // then change the destination folder to user choice
+ ASF.saveUnicodeString("browser.download.dir", defaultfolder);
+ if (lastdir == true) // set it for "save as..." on FF1.5 and FF2, on FF3 lastdir is always true
+ {
+ ASF.saveUnicodeString("browser.download.lastDir", defaultfolder);
+ }
+ }
+ else // else, if domain is the same as the last, set the download.dir to the last folder used (else viewDownloadOption will not show the correct save path and will use the default folder)
+ { // only affect Firefox3 which update download.lastDir instead of download.dir, so taking download.lastDir data to set download.dir,
+ // FF1.5 or FF2 automatically update download.dir, not download.lastDir
+ if (firefoxversion == "3")
+ {
+ var lastpath = ASF.loadUnicodeString("browser.download.lastDir"); // this one is the one that will open
+ if (lastpath == "") // if no path is returned (first time using lastDir, or the user reseted the content manually in about:config)
+ {
+ ASF.saveUnicodeString("browser.download.lastDir", defaultfolder);
+ lastpath = defaultfolder;
+ }
+ ASF.saveUnicodeString("browser.download.dir", lastpath); // this one is the one that will be shown in ASF save option
+ }
+ }
+ }
+ else // else, if savetype == 0 (folder is set to last folder)
+ {
+ // set the download.dir to the last folder used (else viewDownloadOption will not show the correct save path and will use the default folder)
+ // only affect Firefox3 which update download.lastDir instead of download.dir, so we are taking download.lastDir data to set download.dir,
+ // FF1.5 or FF2 automatically update download.dir, not download.lastDir
+ if (firefoxversion == "3")
+ {
+ var lastpath = ASF.loadUnicodeString("browser.download.lastDir");
+ if (lastpath == "") // if no path is returned (first time using lastDir, or the user reseted the content manually in about:config)
+ {
+ ASF.saveUnicodeString("browser.download.lastDir", defaultfolder);
+ lastpath = defaultfolder;
+ }
+ ASF.saveUnicodeString("browser.download.dir", lastpath);
+ }
+
+ }
+ }
+ else // if a filter is found
+ {
+
+ var folder = filters[idx][2];
+
+
+ // If Advanced mode is ON, let's check the variables and create the folder
+ if (variable_mode == true)
+ {
+
+// Ted Gifford, start block
+ // String capture in filename with $f<1-9>
+ try {
+ //alert(file_regexp.length);
+ if (file_regexp.length > 1)
+ {
+ //alert('munging folder: ' + folder);
+ for (var replace_index = 1; replace_index < file_regexp.length; ++replace_index)
+ folder = folder.replace("$"+replace_index+"f", file_regexp[replace_index]);
+ //alert('munged folder: ' + folder);
+ }
+ } catch (e) {alert(e);}
+ // String capture in domain with $d<1-9>
+ try {
+ //alert(dom_regexp.length);
+ if (dom_regexp.length > 1)
+ {
+ //alert('munging folder: ' + folder);
+ for (var replace_index = 1; replace_index < dom_regexp.length; ++replace_index)
+ folder = folder.replace("$"+replace_index+"d", dom_regexp[replace_index]);
+ //alert('munged folder: ' + folder);
+ }
+ } catch (e) {alert(e);}
+// Ted Gifford, end block
+
+
+
+ folder = ASF.createfolder(aFpP, folder, idx);
+ }
+
+ ASF.saveUnicodeString("browser.download.dir", folder);
+ if (lastdir == true) // set it for "save as..." on FF1.5 and FF2, on FF3 lastdir is always true
+ {
+ ASF.saveUnicodeString("browser.download.lastDir", folder);
+ }
+ }
+
+ // in every case, set the new file hosted domain to tempdomain
+ ASF.saveUnicodeString("extensions.asf.tempdomain", domain);
+
+
+ },
+
+
+ loadUnicodeString: function (pref_place) {
+ try
+ {
+ return this.prefManager.getComplexValue(pref_place, Components.interfaces.nsISupportsString).data;
+ }
+ catch (e)
+ { }
+ return "";
+ },
+
+
+ saveUnicodeString: function (pref_place,pref_data) {
+ var str = Components.classes["@mozilla.org/supports-string;1"]
+ .createInstance(Components.interfaces.nsISupportsString);
+ str.data = pref_data;
+ this.prefManager.setComplexValue(pref_place, Components.interfaces.nsISupportsString, str);
+ },
+
+
+ createfolder: function (aFpP, path, idx) {
+
+ if (!path) return false;
+ if (this.trim(path).length==0) return false;
+
+ var objdate = new Date();
+
+ // make the array with the month's name in the stringbundle of the locale language path.
+
+ var stringbundle = Components.classes['@mozilla.org/intl/stringbundle;1'].
+ getService(Ci.nsIStringBundleService).
+ createBundle('chrome://asf/locale/asf.properties');
+
+ var fullmonthname = new Array();
+ var abbrmonthname = new Array();
+ for (var i = 1 ; i<= 12 ; i++)
+ {
+ fullmonthname[i-1] = stringbundle.GetStringFromName("month"+i+"_full");
+ abbrmonthname[i-1] = stringbundle.GetStringFromName("month"+i+"_abbr");
+ }
+
+
+ const ZERO = "0"; // leading zero
+
+ // load the domain and the filename of the saved file
+ // var domain = document.getElementById("source").value ;
+ // domain = domain.replace(/^.*:\/\//g,''); // remove the protocol name from the domain
+ // 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)
+
+ var domain = aFpP.fileInfo.uri.host ;
+ var filename = aFpP.fileInfo.fileName ;
+ var file_name = aFpP.fileInfo.fileBaseName ;
+ var extension = aFpP.fileInfo.fileExt ;
+
+
+
+ // check the filter's data
+ var asf_domain = "";
+ var asf_filename = "";
+ if (idx) { // If a filter match, idx is true
+ asf_domain = this.loadUnicodeString("extensions.asf.filters"+ idx +".domain");
+ // Trim the / / if domain is regexp
+ if (this.is_regexp(asf_domain))
+ {
+ asf_domain = asf_domain.substring(1, asf_domain.length);
+ asf_domain = asf_domain.substring(0, asf_domain.length -1);
+ }
+ asf_filename = this.loadUnicodeString("extensions.asf.filters"+ idx +".filename");
+ // Trim the / / if filename is regexp
+ if (this.is_regexp(asf_filename))
+ {
+ asf_filename = asf_filename.substring(1, asf_filename.length);
+ asf_filename = asf_filename.substring(0, asf_filename.length -1);
+ }
+ }
+ else // no filter is found, use actual Domain and filename without extension
+ {
+ asf_domain = domain;
+ asf_filename = file_name;
+ }
+
+ // Check if asf_rd is present and process asf_rd = Regexp the domain
+ if (path.search("%asf_rd%") != -1)
+ {
+ // get the domain with the protocol
+ var domainp = document.getElementById("source").value ;
+
+ // extract the filter part
+ var matches = path.match(/%asf_rd%.*?%asf_rd%/g); // matches is an array
+ if (matches != null)
+ {
+ var datareg = "";
+ var result = new Array();
+ var matchreplace = new Array();
+ for (var i = 0, len = matches.length; i < len; i++)
+ {
+ datareg = matches[i].replace(/%asf_rd%/g, ''); // remove the %asf_rf% to keep only the regexp
+ datareg = new RegExp(datareg, 'i'); // create the regexp
+ //alert("reg="+datareg);
+ result = domainp.match(datareg); // Check it on the domain with protocol
+
+ if (result == null)
+ {
+ matchreplace[i] = ""; // if no result, replace with nothing instead of null
+ }
+ else
+ {
+ matchreplace[i] = result[0];
+ }
+ //alert("matchreplace["+i+"]="+matchreplace[i]);
+ }
+ for (var i = 0, len = matches.length; i < len; i++)
+ {
+ path = path.replace(matches[i], matchreplace[i]); // replace each variable in the path
+ }
+ }
+ }
+
+
+ // Check if asf_rf is present and process asf_rf = Regexp the filename
+ if (path.search("%asf_rf%") != -1 )
+ {
+ // extract the filter part
+ var matches = path.match(/%asf_rf%.*?%asf_rf%/g); // matches is an array
+ if (matches != null)
+ {
+ var datareg = "";
+ var result = new Array();
+ var matchreplace = new Array();
+ for (var i = 0, len = matches.length; i < len; i++)
+ {
+ datareg = matches[i].replace(/%asf_rf%/g, ''); // remove the %asf_rf% to keep only the regexp
+ datareg = new RegExp(datareg, 'i'); // create the regexp
+ //alert("reg="+datareg);
+ result = filename.match(datareg); // Check it
+
+ if (result == null)
+ {
+ matchreplace[i] = ""; // if no result, replace with nothing instead of null
+ }
+ else
+ {
+ matchreplace[i] = result[0];
+ }
+ //alert("matchreplace["+i+"]="+matchreplace[i]);
+ }
+ for (var i = 0, len = matches.length; i < len; i++)
+ {
+ path = path.replace(matches[i], matchreplace[i]); // replace each variable in the path
+ }
+ }
+ }
+
+
+
+ // remove special characters from filters :
+ // forbidden on windows \ / : * ? " < > |
+ if (navigator.appVersion.indexOf("Win")!=-1) // = Windows
+ {
+ asf_domain = asf_domain.replace(/[\/\:\*\?\"\<\>\|]/g,'');
+ asf_filename = asf_filename.replace(/[\/\:\*\?\"\<\>\|]/g,'');
+ file_name = file_name.replace(/[\/\:\*\?\"\<\>\|]/g,'');
+ path = path.replace(/[\/\*\?\"\<\>\|]/g,'');
+ }
+ else // MacOS and linux, replace only / :
+ {
+ asf_domain = asf_domain.replace(/[\/\:]/g,'');
+ asf_filename = asf_filename.replace(/[\/\:]/g,'');
+ file_name = file_name.replace(/[\/\:]/g,'');
+ }
+
+ // replace the string here // Year
+ path = path .replace(/%Y%/g, objdate.getFullYear()) // full year format = 2009
+ .replace(/%y%/g, ((objdate.getYear()-100) <10) ? (ZERO + (objdate.getYear()-100)) : objdate.getYear()-100) // year in YY format : 08, 09, 10
+ // .replace(/%<to define>/g, objdate.getYear()-100) // 8, 9, 10, (no leading 0)
+ // Month
+ .replace(/%m%/g, ((objdate.getMonth()+1) <10) ? (ZERO + (objdate.getMonth()+1)) : objdate.getMonth()+1) // = number of the month : 01 to 12
+ .replace(/%n%/g, objdate.getMonth()+1) // 8, 9, 10, (no leading 0)
+ .replace(/%F%/g, fullmonthname[objdate.getMonth()]) // full month name
+ .replace(/%M%/g, abbrmonthname[objdate.getMonth()]) // abbreviated month name
+ // Day
+ .replace(/%d%/g, ((objdate.getDate()) <10) ? (ZERO + (objdate.getDate())) : objdate.getDate()) // = number of the day : 01 to 31
+ .replace(/%j%/g, objdate.getDate()) // = number of the day 1 to 31 (no leading 0)
+ // ASF
+ .replace(/%asf_D%/g, domain) // downloaded File's domain
+ .replace(/%asf_F%/g, filename) // downloaded File's filename with extension
+ .replace(/%asf_Fx%/g, file_name) // downloaded File's filename without extension
+ .replace(/%asf_d%/g, asf_domain) // matching filter's Domain (without special chars used by regexp)
+ .replace(/%asf_f%/g, asf_filename) // mathching filter's filename (without special chars used by regexp)
+ .replace(/%asf_x%/g, extension[0]); // match the filename extension (without the dot)
+ // debug
+ // alert (path);
+ var directory = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
+
+ directory.initWithPath(path);
+ return path;
+
+// Canceled the folder creation script, so the folder will not be created if the user cancel the download
+// Firefox will create it automatically when accepting the download... under windows XP and Linux Ubuntu at least (not tested under Vista, MacOS, or any other operating system)
+/*
+ if (directory.exists())
+ {
+ return path;
+ }
+ else // if it doesn't exist, create it
+ {
+ if( !directory.exists() || !directory.isDirectory() )
+ {
+ directory.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0777);
+ }
+ return path;
+ }
+*/
+ },
+
+
+ trim: function (string) {
+ return string.replace(/(^\s*)|(\s*$)/g,'');
+ },
+
+
+
+
+
+
+ indexInArray: function (arr,val){
+ val = val.replace(/\\/g,'\\\\');
+ var test_regexp = new RegExp("^"+val+"$");
+ var data = "";
+ for(var i=0;i<arr.length;i++)
+ {
+ if(test_regexp.test(arr[i])) return i;
+ }
+ return -1;
+ } ,
+
+
+
+ test_regexp: function (filters, string) {
+
+
+ // Steps :
+ // 1 - Check if the filter is a regular expression
+ // 2 - if not regexp : add the backslah to special characters and .* to the start and end of the string to convert it into a regexp form
+ // if it's already regexp : delete the / / for new regexp() to handle it
+ // 3 - when all is ready in regexp, test the data with the filters
+ // 4 - if the data match the filter --> return true
+
+ // 3 & 4 replaced with Ted script, now it returns the matching result's array, or false if nothing matched.
+
+
+ // step 1
+ var test_regexp = this.is_regexp(filters); // True or False
+
+ // step 2
+ if (test_regexp == false) // replace simple wildcard and special characters with corresponding regexp
+ {
+ filters = filters.replace(/\./gi, "\\.")
+ .replace(/\*/gi, "(.)*")
+ .replace(/\$/gi, "\\$")
+ .replace(/\^/gi, "\\^")
+ .replace(/\+/gi, "\\+")
+ .replace(/\?/gi, ".")
+ .replace(/\|/gi, "\\|")
+ .replace(/\[/gi, "\\[")
+ .replace(/\//gi,'\\/');
+ filters = ".*"+filters+".*";
+ }
+ else // remove the first and last slash
+ {
+ filters = filters.substring(1, filters.length);
+ filters = filters.substring(0, filters.length -1);
+ }
+
+ // initialize the regular expression search
+ var test_regexp = new RegExp(filters, "i"); // put the slash back and the gi option (g = global seach, i = case insensitive)
+ // Edited to only "i" option by Ted.
+
+ // Step 3 & 4
+ // if (string.match(test_regexp)) // if something match
+ // {
+ // return(true);
+ // }
+
+ // return(false);
+
+// Ted Gifford, start block
+ var res = string.match(test_regexp);
+ if (res) return res;
+ return false
+// Ted Gifford, end block
+
+ },
+
+
+ is_regexp: function (string) {
+ if ((string.substring(0,1) == "/") && (string.substr(string.length - 1, 1) == "/"))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+ }
+window.addEventListener("load", automatic_save_folder.rightclick_init, true);
diff --git a/content/edit.xul b/content/edit.xul
index d6969ad..a1c58e9 100644
--- a/content/edit.xul
+++ b/content/edit.xul
@@ -17,42 +17,38 @@
buttonlabelextra1="&buttonlabelextra1;"
ondialogextra1="automatic_save_folder.asf_edit()"
ondialogcancel="window.opener.focus;window.close();"
- buttonlabelextra2="regexp help"
+ buttonlabelextra2="&asf.addedit.regexphelp.label;"
ondialogextra2="window.openDialog('chrome://asf/content/regexp.xul','asf_regexp_help','chrome, centerscreen, resizable=yes, dialog=no');"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript" src="chrome://asf/content/asf_addedit.js"/>
-<stringbundleset id="automatic_save_folder_bundleset">
- <stringbundle id="automatic_save_folder_bundles" src="chrome://asf/locale/asf.properties"/>
-</stringbundleset>
<groupbox align="center" orient="horizontal">
<caption label="&asf.addedit.filter.label;"/>
- <vbox>
-
+ <vbox>
<description value="&asf.addedit.domain.label;"/>
<radiogroup id="radio-addedit-domain" align="left">
- <radio id="asf-addedit-radio-domain-all" value="0" selected="true" label="&asf.addedit.all;" oncommand="automatic_save_folder.asf_toggleradio_domain()"/>
- <hbox>
- <radio id="asf-addedit-radio-domain" value="1" label="=" oncommand="automatic_save_folder.asf_toggleradio_domain()"/>
- <textbox id="asf-addedit-domain" width="200" onchange="automatic_save_folder.testRegexp('asf-addedit-domain-regexp', 'asf-addedit-domain');"/>
- <checkbox id="asf-addedit-domain-regexp" label="&asf.addedit.regexp;" oncommand="automatic_save_folder.makeRegexp('asf-addedit-domain-regexp', 'asf-addedit-domain');"/>
- </hbox>
+ <radio id="asf-addedit-radio-domain-all" value="0" selected="true" label="&asf.addedit.all;" oncommand="automatic_save_folder.asf_toggleradio_domain()"/>
+ <hbox>
+ <radio id="asf-addedit-radio-domain" value="1" label="=" oncommand="automatic_save_folder.asf_toggleradio_domain()"/>
+ <textbox id="asf-addedit-domain" width="200" onchange="automatic_save_folder.testRegexp('asf-addedit-domain-regexp', 'asf-addedit-domain');"/>
+ <checkbox id="asf-addedit-domain-regexp" label="&asf.addedit.regexp;" oncommand="automatic_save_folder.makeRegexp('asf-addedit-domain-regexp', 'asf-addedit-domain');"/>
+ </hbox>
</radiogroup>
<separator class="thin"/>
<description value="&asf.addedit.filename.label;"/>
<radiogroup id="radio-addedit-filename" align="left">
- <radio id="asf-addedit-radio-filename-all" value="0" selected="true" label="&asf.addedit.all;" oncommand="automatic_save_folder.asf_toggleradio_filename()"/>
- <hbox>
- <radio id="asf-addedit-radio-filename" value="1" label="=" oncommand="automatic_save_folder.asf_toggleradio_filename()"/>
- <textbox id="asf-addedit-filename" width="200" onchange="automatic_save_folder.testRegexp('asf-addedit-filename-regexp', 'asf-addedit-filename')"/>
- <checkbox id="asf-addedit-filename-regexp" label="&asf.addedit.regexp;" oncommand="automatic_save_folder.makeRegexp('asf-addedit-filename-regexp', 'asf-addedit-filename');"/>
- </hbox>
+ <radio id="asf-addedit-radio-filename-all" value="0" selected="true" label="&asf.addedit.all;" oncommand="automatic_save_folder.asf_toggleradio_filename()"/>
+ <hbox>
+ <radio id="asf-addedit-radio-filename" value="1" label="=" oncommand="automatic_save_folder.asf_toggleradio_filename()"/>
+ <textbox id="asf-addedit-filename" width="200" onchange="automatic_save_folder.testRegexp('asf-addedit-filename-regexp', 'asf-addedit-filename')"/>
+ <checkbox id="asf-addedit-filename-regexp" label="&asf.addedit.regexp;" oncommand="automatic_save_folder.makeRegexp('asf-addedit-filename-regexp', 'asf-addedit-filename');"/>
+ </hbox>
</radiogroup>
<separator class="thin"/>
<description value="&asf.addedit.folder.label;"/>
<hbox>
- <textbox id="asf-addedit-folder" readonly="true" width="230" ondblclick="automatic_save_folder.browsedir_addedit()"/>
+ <textbox id="asf-addedit-folder" readonly="true" width="240" ondblclick="automatic_save_folder.browsedir_addedit()"/>
<button id="asf-addedit-select-folder" label="&asf.selectfolder.label;" oncommand="automatic_save_folder.browsedir_addedit()"/>
</hbox>
diff --git a/content/options.xul b/content/options.xul
index e8017c8..91e979a 100644
--- a/content/options.xul
+++ b/content/options.xul
@@ -29,10 +29,8 @@
<preference id="asf_savetype" name="extensions.asf.savetype" type="int"/>
<preference id="asf_variablemode" name="extensions.asf.variablemode" type="bool"/>
<preference id="asf_dialogaccept" name="extensions.asf.dialogaccept" type="bool"/>
+ <preference id="asf_rightclick" name="extensions.asf.rightclick" type="bool"/>
</preferences>
- <stringbundleset id="automatic_save_folder_bundleset">
- <stringbundle id="automatic_save_folder_bundles" src="chrome://asf/locale/asf.properties"/>
- </stringbundleset>
<menupopup id="contextpopup">
<menuitem label="&asf.top.popup;" oncommand="automatic_save_folder.move('top');"/>
<menuitem label="&asf.copy.popup;" oncommand="automatic_save_folder.asf_duplicate();"/>
@@ -44,12 +42,14 @@
<tabs>
<tab id="asf-filterstab" style="-moz-appearance: none" orient="vertical" selected="true" label="&asf.filters.label;" oncommand="automatic_save_folder.asf_selecttab('asf-tab-filters');" />
<tab id="asf-optionstab" style="-moz-appearance: none" orient="vertical" label="&asf.options.label;" oncommand="automatic_save_folder.asf_selecttab('asf-tab-options');" />
+ <tab id="asf-dynamicstab" style="-moz-appearance: none" orient="vertical" label="&asf.dynamics.label;" oncommand="automatic_save_folder.asf_selecttab('asf-tab-dynamics');" />
<tab id="asf-informationstab" style="-moz-appearance: none" orient="vertical" label="&asf.info.label;" oncommand="automatic_save_folder.asf_selecttab('asf-tab-informations');" />
</tabs>
<tabpanels hidden="true">
<tabpanel />
<tabpanel />
<tabpanel />
+ <tabpanel />
</tabpanels>
</tabbox>
</vbox>
@@ -113,15 +113,25 @@
<hbox><description value=" " /><checkbox id="asf-viewpathselect" preference="asf_viewpathselect" label="&asf.viewpathselect.bool;"/></hbox>
<hbox><description value=" " /><description id="asf-viewpathselectdesc" >&asf.viewpathselect.label;</description></hbox>
<separator />
+ <checkbox id="asf-rightclick" preference="asf_rightclick" label="&asf.rightclick.bool;" oncommand="automatic_save_folder.toggle_rightclick();"/>
+ <description id="asf-rightclickdesc" style="margin-left:25px;white-space: pre-wrap">&asf.rightclick.label;</description>
+ <description id="asf-rightclickdesc-DSort" style="margin-left:25px;white-space:pre-wrap;color:red;">&asf.rightclick.DSort.label;</description>
+ </groupbox>
+ </vbox>
+ <vbox id="asf-tab-dynamics" hidden="true" flex="1000">
+ <groupbox id="asf-dynamics" flex="1">
+ <caption label="&asf.dynamics.label;"/>
+ <separator class="thin"/>
<checkbox id="asf-variablemode" preference="asf_variablemode" label="&asf.variablemode.bool;" oncommand="automatic_save_folder.asf_variablemode()"/>
<hbox><description value=" " /><description id="asf-variablemodedesc1" >&asf.variablemode1.label;</description></hbox>
<hbox><description value=" " /><description id="asf-variablemodedesc2" >&asf.variablemode2.label;</description></hbox>
<hbox><description value=" " /><description id="asf-variablemodedesc3" >&asf.variablemode3.label;</description></hbox>
+ <separator />
<hbox flex="1">
<description value=" " />
<groupbox flex="1" style="padding:0px !important;">
<caption label="&asf.variables.label;"/>
- <iframe flex="1" id="iframe_tab" class="plain" style="padding:0px !important; background-color:transparent; min-height:90px;"
+ <iframe flex="1" id="iframe_tab" class="plain" style="padding:0px !important; background-color:transparent; min-height:120px;"
src="chrome://asf/locale/variables.html"
/>
</groupbox>
diff --git a/content/overlay_preferences.xul b/content/overlay_preferences.xul
index d81e242..a6d855e 100644
--- a/content/overlay_preferences.xul
+++ b/content/overlay_preferences.xul
@@ -10,7 +10,7 @@
<!DOCTYPE overlay SYSTEM "chrome://asf/locale/asf.dtd">
<overlay id="asf-overlay-preferences"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
-
+ <script type="application/x-javascript" src="chrome://asf/content/asf_right_click.js"/>
<menupopup id="menu_ToolsPopup">
<menuitem insertafter="sanitizeItem" id="asf-option" label="&asf.label;"
oncommand="window.openDialog('chrome://asf/content/options.xul','Automatic_Save_Folder_Preferences','chrome,centerscreen,resizable=yes, dialog=no');" />
diff --git a/content/overlay_unknownContentType.xul b/content/overlay_unknownContentType.xul
index 9482691..eb2e57c 100644
--- a/content/overlay_unknownContentType.xul
+++ b/content/overlay_unknownContentType.xul
@@ -14,9 +14,6 @@
<script type="application/x-javascript" src="chrome://asf/content/asf_download.js" />
<vbox id="container">
-<stringbundleset id="automatic_save_folder_bundleset">
- <stringbundle id="automatic_save_folder_bundles" src="chrome://asf/locale/asf.properties"/>
-</stringbundleset>
<groupbox id="asf_dloptions" style="visibility: collapse;" flex="1">
<caption label="Automatic Save Folder"/>
<vbox>
diff --git a/defaults/preferences/asf.js b/defaults/preferences/asf.js
index d0e5982..26c16b7 100644
--- a/defaults/preferences/asf.js
+++ b/defaults/preferences/asf.js
@@ -14,4 +14,5 @@ pref("extensions.asf at mangaheart.org.description", "chrome://asf/locale/asf.prope
// it make automatic saving to the right folder - 0= desktop, 1= system download dir, 2= user define
// does only affect the user if useDownloadDir = true ---- if "always ask the destination folder" is selected in FF options, it has no effect on the user.
pref("browser.download.folderList", 2);
- pref("extensions.asf.dialogaccept", false);
\ No newline at end of file
+ pref("extensions.asf.dialogaccept", false);
+ pref("extensions.asf.rightclick", true);
\ No newline at end of file
diff --git a/locale/en-US/asf.dtd b/locale/en-US/asf.dtd
index 42cd818..e8dfd84 100644
--- a/locale/en-US/asf.dtd
+++ b/locale/en-US/asf.dtd
@@ -39,8 +39,14 @@
<!ENTITY asf.viewdloption.label "Allow you to see the last two destination folders and a link to add or edit the filters">
<!ENTITY asf.viewpathselect.bool "View the list of folders">
<!ENTITY asf.viewpathselect.label "Activate a drop-down menu with all the filter's path.">
-<!ENTITY asf.dialogaccept.bool "Automatically accept the download (no need to click the 'OK' button).">
-<!ENTITY asf.variablemode.bool "Advanced mode :">
+<!ENTITY asf.dialogaccept.bool "Automatically accept the download.">
+<!ENTITY asf.rightclick.bool "Right-Click enabled">
+<!ENTITY asf.rightclick.label "Right-click 'save as...' functionnality doesn't work with downloading redirection scripts. 
Firefox proposed filename will stay as 'script_name.php' instead of the real target filename. 
Disable this feature if you need the right-click to save a redirection link. Single left-click is not affected.">
+<!ENTITY asf.rightclick.DSort.label "Download sort extension has beed detected. 
Automatic Save Folder's right-click feature will not work until you disable Download Sort in your Add-on manager.">
+
+<!-- Dynamics tab-->
+<!ENTITY asf.dynamics.label "Dynamic folders">
+<!ENTITY asf.variablemode.bool "Enabled">
<!ENTITY asf.variablemode1.label "Allow you to edit the filters saving path manually and add dynamic variables, like the date of the day ">
<!ENTITY asf.variablemode2.label "or the file name.">
<!ENTITY asf.variablemode3.label "Note : Attention to uppercase and lowercase.">
diff --git a/locale/fr-FR/asf.dtd b/locale/fr-FR/asf.dtd
index e817148..80b1f40 100644
--- a/locale/fr-FR/asf.dtd
+++ b/locale/fr-FR/asf.dtd
@@ -40,7 +40,13 @@
<!ENTITY asf.viewpathselect.bool "Afficher la liste des filtres">
<!ENTITY asf.viewpathselect.label "Active le menu déroulant contenant le chemin de chaque filtre.">
<!ENTITY asf.dialogaccept.bool "Accepter le téléchargement automatiquement (Pas besoin de cliquer sur le bouton 'OK').">
-<!ENTITY asf.variablemode.bool "Mode avancé :">
+<!ENTITY asf.rightclick.bool "Clic-droit activé">
+<!ENTITY asf.rightclick.label "La fonction clic-droit 'enregistrer la cible sous...' ne fonctionne pas avec les script de redirection de fichiers. 
Le nom de fichier proposé par Firefox reste 'nom_du_script.php' au lieu du vrai nom du fichier téléchargé. 
Désactivez temporairement cette option si vous devez utiliser le clic-droit pour sauvegarder un fichier provenant d'un script de redirection. Le clic-gauche n'est pas affecté.">
+<!ENTITY asf.rightclick.DSort.label "L'extension Download Sort à été détectée. 
La fonction clic-droit d'Automatic Save Folder est temporairement indisponible. Désactivez l'extension Download Sort dans le menu 'outils/modules complémentaires...' afin de pouvoir utiliser le clic-droit avec Automatic Save Folder.">
+
+<!-- Dynamics tab-->
+<!ENTITY asf.dynamics.label "Dossiers dynamiques">
+<!ENTITY asf.variablemode.bool "Activés">
<!ENTITY asf.variablemode1.label "Permet d'éditer le chemin d'enregistrement des filtres manuellement et d'ajouter des variables dynamiques,">
<!ENTITY asf.variablemode2.label "comme la date du jour ou le domaine d'hébergement.">
<!ENTITY asf.variablemode3.label "Note : Attention aux majuscules et minuscules.">
diff --git a/locale/it-IT/asf.dtd b/locale/it-IT/asf.dtd
index f8a67ee..d41cb76 100644
--- a/locale/it-IT/asf.dtd
+++ b/locale/it-IT/asf.dtd
@@ -39,7 +39,13 @@
<!ENTITY asf.viewdloption.label "(permette di vedere le due ultime cartelle di destinazione e un collegamento per aggiungere o modificare filtri)">
<!ENTITY asf.viewpathselect.bool "Vedi la lista dei filtri">
<!ENTITY asf.viewpathselect.label "Visualizza un menu con la lista di tutti i percorsi dei filtri.">
-<!ENTITY asf.dialogaccept.bool "Automatically accept the download (no need to click the 'OK' button).">
+<!ENTITY asf.dialogaccept.bool "Automatically accept the download.">
+<!ENTITY asf.rightclick.bool "Right-Click enabled">
+<!ENTITY asf.rightclick.label "Right click 'save as...' functionnality doesn't work with downloading redirection scripts. 
Firefox proposed filename will stay as 'script_name.php' instead of the real target filename. 
Disable this feature if you need the right-click to save a redirection link. Single left-click is not affected.">
+<!ENTITY asf.rightclick.DSort.label "Download sort extension has beed detected. 
Automatic Save Folder's right-click feature will not work until you disable Download Sort in your Add-on manager.">
+
+<!-- Dynamics tab-->
+<!ENTITY asf.dynamics.label "Dynamic folders">
<!ENTITY asf.variablemode.bool "Modalità avanzata :">
<!ENTITY asf.variablemode1.label "Permette di editare i percorsi di salvataggi manualmente e aggiungere variabili dinamiche,">
<!ENTITY asf.variablemode2.label "come la data del giorno o il nome del file.">
diff --git a/locale/it-IT/to translate.txt b/locale/it-IT/to translate.txt
new file mode 100644
index 0000000..0d12816
--- /dev/null
+++ b/locale/it-IT/to translate.txt
@@ -0,0 +1,11 @@
+
+asf.properties :
+2 to end
+
+asf.dtd :
+42-48
+
+Variables.html :
+
+22-23
+62-66
\ No newline at end of file
--
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