[Pkg-mozext-commits] [automatic-save-folder] 47/133: Add : - Row coloration when opening the preferences from the saving dialog to see which filters are good (green) and which could be good but disabled (red), according to the current downloaded file. Works with the "Use current URL" option too.
David Prévot
taffit at moszumanska.debian.org
Mon Apr 27 20:33:51 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 d0d424e2e6f777428723ae53bf6b8a1ce7026502
Author: Cyan <Cyan at d0063192-6b2e-11de-89a9-0b20f3e2dceb>
Date: Fri Jan 29 22:36:39 2010 +0000
Add :
- Row coloration when opening the preferences from the saving dialog to see
which filters are good (green) and which could be good but disabled (red),
according to the current downloaded file.
Works with the "Use current URL" option too.
Fix :
- Week number wrongly numbered. (set to match ISO_8601)
- If "minimize or hide on disabled" was chosen, and the first radio choice was
to "open with", the sizeToContent() was buggy.
It's still buggy if the preferences window is opened from the save window and
the size of the saving window doesn't change when closing the preferences.
(It's a Firefox bug #439323, I didn't find how to get around this one).
- on the save window, the paths list wasn't hidden after choosing to hide it if
preferences window is opened from the save window.
Change :
- Removed some unused variables
- converted EOL from windows to linux (\r\n to \n)
git-svn-id: http://automatic-save-folder.googlecode.com/svn/trunk@47 d0063192-6b2e-11de-89a9-0b20f3e2dceb
---
content/about.xul | 90 +-
content/add.xul | 132 +--
content/asf.js | 1597 ++++++++++++++++--------------
content/asf_addedit.js | 1177 +++++++++++-----------
content/asf_download.js | 215 ++--
content/asf_right_click.js | 1672 ++++++++++++++++----------------
content/edit.xul | 132 +--
content/help/about.xhtml | 212 ++--
content/help/help.xhtml | 282 +++---
content/help/regexp.xhtml | 262 ++---
content/help/variables.xhtml | 192 ++--
content/options.xul | 429 ++++----
content/overlay_preferences.xul | 36 +-
content/overlay_unknownContentType.xul | 78 +-
content/regexp.xul | 48 +-
15 files changed, 3341 insertions(+), 3213 deletions(-)
diff --git a/content/about.xul b/content/about.xul
index 0f94345..2d1889e 100644
--- a/content/about.xul
+++ b/content/about.xul
@@ -1,45 +1,45 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- ***** BEGIN LICENSE BLOCK *****
- Copyright 2007-2010 Éric Cassar (Cyan)
-
- This file is part of "Automatic Save Folder".
- You may find the license in the LICENSE file
-
- ***** END LICENSE BLOCK ***** -->
-<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
-<!DOCTYPE dialog SYSTEM "chrome://asf/locale/about.dtd">
-<dialog title="&about;"
- orient="vertical"
- autostretch="always"
- onload="sizeToContent()"
- buttons="accept"
- xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
-<script type="application/javascript" src="chrome://global/content/contentAreaUtils.js"/>
-<groupbox align="center" orient="horizontal">
- <vbox>
- <hbox flex="1">
- <image src="chrome://asf/skin/asf-icon.png"/>
- <text value="Automatic save folder" style="font-weight: bold; font-size: x-large;"/>
- </hbox>
- <text value="&version; &asf.version;"/>
-
- <separator/>
- <vbox flex="1">
- <text value="&createdBy;" style="font-weight: bold;"/>
- <text value="&createdBy.name;"/>
- </vbox>
- <separator/>
- <vbox flex="1">
- <text value="&contributor;" style="font-weight: bold;"/>
- <text value="&contributor.name;"/>
- <text value="&contributor2.name;"/>
- </vbox>
-
- <separator/>
- <text value="&homepage;" style="font-weight: bold;"/>
- <text value="Automatic Save Folder" class="text-link" onclick="window.close(); openURL('http://asf.mangaheart.org');"/>
- <text value="http://mozilla.org" class="text-link" onclick="window.close(); openURL('http://addons.mozilla.org/addon/4781');"/>
- <separator class="thin"/>
- </vbox>
-</groupbox>
-</dialog>
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- ***** BEGIN LICENSE BLOCK *****
+ Copyright 2007-2010 Éric Cassar (Cyan)
+
+ This file is part of "Automatic Save Folder".
+ You may find the license in the LICENSE file
+
+ ***** END LICENSE BLOCK ***** -->
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<!DOCTYPE dialog SYSTEM "chrome://asf/locale/about.dtd">
+<dialog title="&about;"
+ orient="vertical"
+ autostretch="always"
+ onload="sizeToContent()"
+ buttons="accept"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+<script type="application/javascript" src="chrome://global/content/contentAreaUtils.js"/>
+<groupbox align="center" orient="horizontal">
+ <vbox>
+ <hbox flex="1">
+ <image src="chrome://asf/skin/asf-icon.png"/>
+ <text value="Automatic save folder" style="font-weight: bold; font-size: x-large;"/>
+ </hbox>
+ <text value="&version; &asf.version;"/>
+
+ <separator/>
+ <vbox flex="1">
+ <text value="&createdBy;" style="font-weight: bold;"/>
+ <text value="&createdBy.name;"/>
+ </vbox>
+ <separator/>
+ <vbox flex="1">
+ <text value="&contributor;" style="font-weight: bold;"/>
+ <text value="&contributor.name;"/>
+ <text value="&contributor2.name;"/>
+ </vbox>
+
+ <separator/>
+ <text value="&homepage;" style="font-weight: bold;"/>
+ <text value="Automatic Save Folder" class="text-link" onclick="window.close(); openURL('http://asf.mangaheart.org');"/>
+ <text value="http://mozilla.org" class="text-link" onclick="window.close(); openURL('http://addons.mozilla.org/addon/4781');"/>
+ <separator class="thin"/>
+ </vbox>
+</groupbox>
+</dialog>
diff --git a/content/add.xul b/content/add.xul
index baf42b5..f67c33d 100644
--- a/content/add.xul
+++ b/content/add.xul
@@ -1,67 +1,67 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- ***** BEGIN LICENSE BLOCK *****
- Copyright 2007-2010 Éric Cassar (Cyan)
-
- This file is part of "Automatic Save Folder".
- You may find the license in the LICENSE file
-
- ***** END LICENSE BLOCK ***** -->
-<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
-<!DOCTYPE dialog SYSTEM "chrome://asf/locale/asf.dtd">
-
-<dialog title="&asf.add.title;"
- orient="vertical" autostretch="always"
- onload="automatic_save_folder.add_load();"
- buttons="extra1, extra2, cancel"
- defaultButton="extra1"
- buttonlabelextra1="&buttonlabelextra1;"
- ondialogextra1="automatic_save_folder.asf_add()"
- ondialogcancel="window.opener.focus;window.close();"
- 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"/>
-<groupbox align="center" orient="horizontal">
- <caption label="&asf.addedit.filter.label;" />
- <vbox>
- <description value="&asf.addedit.domain.label;" />
- <radiogroup id="radio-addedit-domain" align="left">
- <radio id="asf-addedit-radio-domain-all" value="0" 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" 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>
- <menulist editable="true" id="asf-addedit-folder" readonly="true" width="240" onload="automatic_save_folder.read_all_filterpath()" ondblclick="automatic_save_folder.browsedir_addedit()"/>
- <button id="asf-addedit-select-folder" label="&asf.selectfolder.label;" oncommand="automatic_save_folder.browsedir_addedit()"/>
- </hbox>
-
- </vbox>
-</groupbox>
-
-<groupbox align="center" orient="horizontal">
- <caption label="&asf.addedit.help.label;"/>
- <vbox>
- <description value="&asf.addedit.inforegexp1;"/>
- <description value="&asf.addedit.inforegexp2;"/>
- <description value="&asf.addedit.inforegexp3;"/>
- <description value="&asf.addedit.inforegexp4;"/>
- </vbox>
-</groupbox>
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- ***** BEGIN LICENSE BLOCK *****
+ Copyright 2007-2010 Éric Cassar (Cyan)
+
+ This file is part of "Automatic Save Folder".
+ You may find the license in the LICENSE file
+
+ ***** END LICENSE BLOCK ***** -->
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<!DOCTYPE dialog SYSTEM "chrome://asf/locale/asf.dtd">
+
+<dialog title="&asf.add.title;"
+ orient="vertical" autostretch="always"
+ onload="automatic_save_folder.add_load();"
+ buttons="extra1, extra2, cancel"
+ defaultButton="extra1"
+ buttonlabelextra1="&buttonlabelextra1;"
+ ondialogextra1="automatic_save_folder.asf_add()"
+ ondialogcancel="window.opener.focus;window.close();"
+ 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"/>
+<groupbox align="center" orient="horizontal">
+ <caption label="&asf.addedit.filter.label;" />
+ <vbox>
+ <description value="&asf.addedit.domain.label;" />
+ <radiogroup id="radio-addedit-domain" align="left">
+ <radio id="asf-addedit-radio-domain-all" value="0" 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" 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>
+ <menulist editable="true" id="asf-addedit-folder" readonly="true" width="240" onload="automatic_save_folder.read_all_filterpath()" ondblclick="automatic_save_folder.browsedir_addedit()"/>
+ <button id="asf-addedit-select-folder" label="&asf.selectfolder.label;" oncommand="automatic_save_folder.browsedir_addedit()"/>
+ </hbox>
+
+ </vbox>
+</groupbox>
+
+<groupbox align="center" orient="horizontal">
+ <caption label="&asf.addedit.help.label;"/>
+ <vbox>
+ <description value="&asf.addedit.inforegexp1;"/>
+ <description value="&asf.addedit.inforegexp2;"/>
+ <description value="&asf.addedit.inforegexp3;"/>
+ <description value="&asf.addedit.inforegexp4;"/>
+ </vbox>
+</groupbox>
</dialog>
\ No newline at end of file
diff --git a/content/asf.js b/content/asf.js
index e144371..fd1475b 100644
--- a/content/asf.js
+++ b/content/asf.js
@@ -1,742 +1,857 @@
-/* ***** BEGIN LICENSE BLOCK *****
-Automatic Save Folder
-Copyright (C) 2007-2010 Éric Cassar (Cyan).
-
- "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),
-
- stringbundle: Components.classes["@mozilla.org/intl/stringbundle;1"]
- .getService(Components.interfaces.nsIStringBundleService)
- .createBundle("chrome://asf/locale/asf.properties"),
-
- firefoxversion : "",
-
- asf_load: function () {
-
- if(this.versionChecker.compare(this.appInfo.version, "3.0") >= 0)
- {
- this.firefoxversion = "3";
- }
- else
- {
- this.firefoxversion = "2";
- }
-
-
- // init the preference for firefox 3
- if (this.firefoxversion == "3")
- {
- // set lastdir to "enable" if the user just updated from previous version and had it disabled
- var lastdir = document.getElementById("asf-lasdir");
- lastdir.checked = true;
- lastdir.hidden = true; // hidden on FF3, as lastdir must always be true, don't allow the user to disable it.
- this.prefManager.setBoolPref("extensions.asf.lastdir", true);
- }
-
-
- this.asf_loadpref(); // Load the preferences and the filter's array content
- this.asf_treeSelected(); // set the button to disabled state because no filter is selected when openning
- this.asf_toggleradio(); // set the radio choice to the right place
- this.asf_variablemode(); // check if variable mode is on or off, and change mode if needed
- this.asf_getdomain(); // Run this to get the current domain and filename from the download window to pre-fill the fields in "add filter".
-
-
- //Detect OS
- // var OSName="Unknown OS";
- // if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
- // if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";
- // if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
- // if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";
-
- // alert('Your OS: '+OSName);
- // alert(navigator.appVersion.indexOf("Win"));
-
- },
-
-
- asf_loadpref: function () {
- var nbrRow = this.prefManager.getIntPref("extensions.asf.filtersNumber", 0);
-
- //load the default folder (I removed the preference in options.xul, unicode folder's name didn't saved at all with automatic preference management.
- // Manual saving is working, but not saving in the right encoding type in prefs.js, so we need to use get/setComplexValue)
- var default_folder = document.getElementById("asf-default-folder");
- default_folder.value = this.loadUnicodeString("extensions.asf.defaultfolder");
-
- for ( var i = 0 ; i < nbrRow ; i++)
- {
- var domain = this.loadUnicodeString("extensions.asf.filters"+ i +".domain");
- var filename = this.loadUnicodeString("extensions.asf.filters"+ i +".filename");
- var folder = this.loadUnicodeString("extensions.asf.filters"+ i +".folder");
- var active = this.prefManager.getBoolPref("extensions.asf.filters"+ i +".active");
-
- // adding into the tree
- var filter = document.getElementById('asf-filterList');
- var rules = document.getElementById('asf-filterChilds');
- var item = document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'treeitem');
- var row = document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'treerow');
- var c1 = document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'treecell');
- var c2 = document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'treecell');
- var c3 = document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'treecell');
- var c4 = document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'treecell');
- c1.setAttribute('label', domain);
- c2.setAttribute('label', filename);
- c3.setAttribute('label', folder);
- c4.setAttribute('value', active);
- c1.setAttribute('editable', false);
- c2.setAttribute('editable', false);
- c3.setAttribute('editable', false);
- row.appendChild(c1);
- row.appendChild(c2);
- row.appendChild(c3);
- row.appendChild(c4);
- item.appendChild(row);
- rules.appendChild(item);
-
- }
- },
-
-
- save_active_state: function() {
- //autosave the filterswhen clicking (anywhere) on the filter tree
- // can't detect the "active" column statut with setting an attribute. The event is set to the tree not the cell.
- var instantApply = this.prefManager.getBoolPref("browser.preferences.instantApply");
- if (instantApply)
- {
- //save the filters
- this.asf_savefilters();
- }
- },
-
-
- // Called whenever a list box is selected
- asf_treeSelected: function () {
- var deleteButton = document.getElementById("asf-delete");
- var editButton = document.getElementById("asf-edit");
- var listBox = document.getElementById("asf-filterList");
- var listchilds = document.getElementById("asf-filterChilds");
- var moveDownButton = document.getElementById("asf-move-down");
- var moveUpButton = document.getElementById("asf-move-up");
- var selectedIndex = listBox.currentIndex ; //number of the selected line in tree
-
- var nbrRow = listBox.view.rowCount;
-
-
- // If an item is selected
- if(selectedIndex >= 0)
- {
- deleteButton.disabled = false;
- deleteButton.image = "chrome://asf/skin/delete.png";
- editButton.disabled = false;
-
- // If this is the first item
- if(selectedIndex == 0)
- {
- moveUpButton.disabled = true;
- moveUpButton.image = "chrome://asf/skin/up_disabled.png";
- }
- else
- {
- moveUpButton.disabled = false;
- moveUpButton.image = "chrome://asf/skin/up.png";
- }
-
- // If this is the last item
- if(selectedIndex == nbrRow - 1)
- {
- moveDownButton.disabled = true;
- moveDownButton.image = "chrome://asf/skin/down_disabled.png";
- }
- else
- {
- moveDownButton.disabled = false;
- moveDownButton.image = "chrome://asf/skin/down.png";
- }
- }
- else
- {
- editButton.disabled = true;
- deleteButton.disabled = true;
- deleteButton.image = "chrome://asf/skin/delete_disabled.png";
- moveDownButton.disabled = true;
- moveDownButton.image = "chrome://asf/skin/down_disabled.png";
- moveUpButton.disabled = true;
- 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");
- var select_folder_input = document.getElementById("asf-default-folder");
- var select_folder_btn = document.getElementById("asf-select-folder");
- var select_keeptemp_chk = document.getElementById("asf-keeptemp-check");
- var variable_mode = document.getElementById("asf-variablemode");
-
- if(select_last_radio.selected == true)
- {
- select_folder_input.disabled = true;
- select_folder_btn.disabled = true;
- select_keeptemp_chk.disabled = true;
- }
-
- if(select_choose_radio.selected == true)
- {
- select_folder_input.disabled = false;
- this.asf_variablemode();
- select_folder_btn.disabled = false;
- select_keeptemp_chk.disabled = false;
- }
- },
-
-
- toggle_options: function () { // called whenever the Options tab is selected
- var instantApply = this.prefManager.getBoolPref("browser.preferences.instantApply");
- var viewdloption = document.getElementById("asf-viewdloption");
- var viewdloptionType = document.getElementById("asf-viewdloptionType");
- var viewpathlist = document.getElementById("asf-viewpathselect");
- var dialogaccept = document.getElementById("asf-dialogaccept");
- var dialogacceptFiltered = document.getElementById("asf-dialogacceptFiltered");
- var useDownloadDir = document.getElementById("asf-useDownloadDir");
- var asf_userightclick = document.getElementById("asf-userightclick");
- var asf_rightclicktimeout = document.getElementById("asf-rightclicktimeout");
-
- // check if autosave is selected, if not : set the saving path to "filtered" and disable the dropdown menu.
- if (useDownloadDir.checked == false)
- {
- document.getElementById("asf-folderList").value = 2;
- document.getElementById("asf-folderList").disabled = true;
- this.prefManager.setIntPref("browser.download.folderList",2);
- }
- if (useDownloadDir.checked == true)
- {
- document.getElementById("asf-folderList").disabled = false;
- }
-
-
- // set the sub-dialogaccept option to grey state
- if (dialogaccept.checked == false)
- {
- dialogacceptFiltered.checked = false;
- dialogacceptFiltered.disabled = true;
- }
- if (dialogaccept.checked == true)
- {
- dialogacceptFiltered.disabled = false;
- }
-
- // if the option window is opened from the saving window, disable the autosave feature (Not working when set from here.)
- if (window.opener.location == "chrome://mozapps/content/downloads/unknownContentType.xul")
- {
- dialogaccept.disabled = true;
- dialogacceptFiltered.disabled = true;
- }
-
-
- // set the sub-D/L option to grey state
- if (viewdloption.checked == false)
- {
- viewdloptionType.disabled = true;
- viewpathlist.checked = false;
- viewpathlist.disabled = true;
- }
- if (viewdloption.checked == true)
- {
- viewdloptionType.disabled = false;
- viewpathlist.disabled = false;
- }
-
- // set the sub-rightclick option to grey state
- if (asf_userightclick.checked == false)
- {
- asf_rightclicktimeout.disabled = true;
- }
- if (asf_userightclick.checked == true)
- {
- asf_rightclicktimeout.disabled = false;
- }
-
- // Check the right-click feature here, and prints text according to Firefox version and active addons
- // hide all the descriptions box, and unhide the needed one
- document.getElementById("asf-rightclickdesc-ff2").hidden = true; // Firefox 2, Right-click disabled message
- document.getElementById("asf-rightclickdesc-DSort").hidden = true; // Download sort conflit alert
- var Dsort_installed = this.DownloadSort();
-
- if (this.firefoxversion == 2)
- {
- document.getElementById("asf-userightclick").hidden = true; // Hide the right-click checkbox
- document.getElementById("asf-rightclicktimeout").hidden = true; // Hide the right-click timeout checkbox
- document.getElementById("asf-rightclickdesc-ff2").hidden = false; // Show right-click not working on Firefox 2.0
- }
- if (this.firefoxversion == 3)
- {
- if (Dsort_installed) // if Download sort is installed, display a message "right click disabled"
- {
-
- asf_userightclick.disabled = true;
- asf_rightclicktimeout.disabled = true;
-
- document.getElementById("asf-rightclickdesc-DSort").hidden = false;
- }
- }
-
- if (instantApply) // bug with sub-options status set by javascript
- {
- this.asf_saveoptions();
- }
- },
-
-
- toggle_userightclick: function () {
- var instantApply = this.prefManager.getBoolPref("browser.preferences.instantApply");
- var asf_userightclick = document.getElementById("asf-userightclick");
- var asf_rightclicktimeout = document.getElementById("asf-rightclicktimeout");
-
- // set the sub-rightclick option to grey state
- if (asf_userightclick.checked == false)
- {
- asf_rightclicktimeout.checked = false;
- asf_rightclicktimeout.disabled = true;
- }
- if (asf_userightclick.checked == true)
- {
- asf_rightclicktimeout.disabled = false;
- asf_rightclicktimeout.checked = true;
- }
-
- if (instantApply) // bug with sub-options status set by javascript
- {
- this.asf_saveoptions();
- }
-
- },
-
-
- toggle_rightclicktimeout: function () {
- var instantApply = this.prefManager.getBoolPref("browser.preferences.instantApply");
-
- if (instantApply)
- {
- var asf_rightclicktimeout = document.getElementById("asf-rightclicktimeout").checked;
- this.prefManager.setIntPref("browser.download.saveLinkAsFilenameTimeout", asf_rightclicktimeout == true ? 0 : 1000 );
- }
- },
-
-
- asf_selecttab: function(tabID) {
-
- // 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-help").hidden = true;
- document.getElementById("asf-tab-about").hidden = true;
-
-
- document.getElementById(tabID).hidden = false;
- if(tabID == "asf-tab-options") this.toggle_options();
- //window.sizeToContent();
- },
-
-
- asf_variablemode: function() {
- var select_variable_mode = document.getElementById("asf-variablemode");
- var select_folder_input = document.getElementById("asf-default-folder");
-
- if(select_variable_mode.checked == true)
- {
- select_folder_input.readOnly = false;
- }
- if(select_variable_mode.checked == false)
- {
- select_folder_input.readOnly = true;
- }
-
-
- },
-
-
- 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
- {
- var currentdomain = window.opener.document.getElementById("source").value;
- var currentfilename = window.opener.document.getElementById("location").value ;
-
- var domain = document.getElementById("asf-current-domain");
- var filename = document.getElementById("asf-current-filename");
-
- domain.value = currentdomain ;
- filename.value = currentfilename ;
- }
- },
-
-
- // Code from captain.at, modified by Cyan (CASSAR Eric)
- move: function (direction) {
- var instantApply = this.prefManager.getBoolPref("browser.preferences.instantApply");
- var treename = "asf-filterList";
-
- var tree = document.getElementById(treename);
- var idx = tree.currentIndex;
- if (idx == -1) return false;
- var maxidx = this.prefManager.getIntPref("extensions.asf.filtersNumber");
-
- var dir = 1;
- if ((direction == "up") || (direction == "top"))
- {
- dir = -1;
- }
- var currentitem = tree.treeBoxObject.view.getItemAtIndex(idx);
- var parent = currentitem.parentNode;
- if ((direction == "up") || (direction == "down")) // read the next or previous entry only if function is called from the button clic (not from the popup choice)
- {
- var previousitem = tree.treeBoxObject.view.getItemAtIndex(idx + dir);
- }
-
-
- if (direction == "up")
- {
- parent.insertBefore(currentitem, previousitem);
- tree.view.selection.select(idx-1); // reselect the last
- }
- else if (direction == "down")
- {
- parent.insertBefore(previousitem, currentitem);
- }
-
- if (direction == "top")
- {
- while (currentitem.previousSibling)
- {
- this.move("up");
- }
- }
- else if (direction == "bottom")
- {
- while (currentitem.nextSibling)
- {
- this.move("down");
- }
- }
-
-
- //autosave when moving filters
- if (instantApply)
- {
- //save the filters
- this.asf_savefilters();
- }
- return false;
- },
-
-
- dragstart: function(event) {
- var treename = "asf-filterList";
- var tree = document.getElementById(treename);
- var listBox = document.getElementById("asf-filterList");
- var idx = listBox.currentIndex; //number of the selected line in tree
- var currentitem = tree.treeBoxObject.view.getItemAtIndex(idx);
-
- //event.dataTransfer.setData('application/x-moz-node', currentitem); // send node data
- event.dataTransfer.setData('user/define', idx); // send index data as text (but to prevent drop on text field, let's use custom set)
- },
-
-
- dragover: function (event) {
- //var isNode = event.dataTransfer.types.contains("application/x-moz-node");
- var isDefine = event.dataTransfer.types.contains("user/define");
- if (isDefine)
- {
- event.preventDefault();
- event.dataTransfer.effectAllowed = "move";
- event.dataTransfer.dropEffect = "move";
- }
- },
-
-
- dragdrop: function (event) {
- //var currentitem = event.dataTransfer.getData("application/x-moz-node");
- //var currentitem_idx = event.dataTransfer.getData("text/plain");
- var currentitem_idx = event.dataTransfer.getData("user/define");
- if (currentitem_idx!="")
- {
- var treename = "asf-filterList";
- var tree = document.getElementById(treename);
- var currentitem = tree.treeBoxObject.view.getItemAtIndex(currentitem_idx);
-
- try
- {
- var targetitem_idx = tree.treeBoxObject.getRowAt(event.pageX, event.pageY);
- var targetitem = tree.treeBoxObject.view.getItemAtIndex(targetitem_idx);
- var parent = targetitem.parentNode;
-
- if (currentitem_idx > targetitem_idx) parent.insertBefore(currentitem, targetitem);
- if (currentitem_idx < targetitem_idx) parent.insertBefore(currentitem, targetitem.nextSibling);
- tree.view.selection.select(targetitem_idx); // reselect the moved filter
-
- // Now check is the user has InstantApply option to save the filter's order.
- var instantApply = this.prefManager.getBoolPref("browser.preferences.instantApply");
- if (instantApply)
- {
- //save the filters
- this.asf_savefilters();
- }
- }
- catch(e){} // if the user point outside of the filter tree (because using dragexit instead of dragdrop (dragdrop is not working)).
- }
- event.preventDefault();
- },
-
-
- asf_duplicate: function () {
- var treename = "asf-filterList";
-
- var tree = document.getElementById(treename);
- var idx = tree.currentIndex;
- if (idx == -1) return false;
- var originidx = idx;
- var currentitem = tree.treeBoxObject.view.getItemAtIndex(idx);
- var parent = currentitem.parentNode;
- {
- parent.appendChild(currentitem.cloneNode(true))
- }
- //select the new filter
- idx = parent.childNodes.length-1;
- tree.view.selection.select(idx);
- for (var i = idx ; i > originidx ; i--) // move the new copy 1 line above the original item
- { // so the filter auto-saving process for instantApply (present in the move() function) works
- this.move("up"); // even if the user duplicate the bottom filter, it will move from 1 step
- }
- return false;
- },
-
-
- asf_delete: function () {
- var instantApply = this.prefManager.getBoolPref("browser.preferences.instantApply");
- var filter = document.getElementById('asf-filterList');
- var rules = document.getElementById('asf-filterChilds');
- if (filter.view.selection.count > 0)
- {
- for (var i=rules.childNodes.length-1 ; i>=0 ; i--)
- {
- if (filter.view.selection.isSelected(i))
- rules.removeChild(rules.childNodes[i]);
- }
- }
-
- if (instantApply)
- {
- //save the filters
- this.asf_savefilters();
- }
-
- //detect remaining filters, unhighlight, and change right buttons states
- this.asf_treeSelected();
- },
-
-
- // next 2 functions : Code inspired from DTA (browsedir & createValidDestination)
- browsedir: function () {
- var current_folder_input = document.getElementById("asf-default-folder").value;
-
- const nsIFilePicker = Components.interfaces.nsIFilePicker;
- var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
-
- var filepickerdescription = this.stringbundle.GetStringFromName("select_default_folder");
- fp.init(window, filepickerdescription, nsIFilePicker.modeGetFolder);
- //fp.appendFilters(nsIFilePicker.filterAll | nsIFilePicker.filterText);
-
- // locate current directory
- current_folder_input = this.createValidDestination(current_folder_input);
- if (current_folder_input !== false) fp.displayDirectory = current_folder_input;
-
- var rv = fp.show();
- if (rv == nsIFilePicker.returnOK)
- {
- var asf_url = fp.file.path;
- // Set the data into the input box
- document.getElementById("asf-default-folder").value = asf_url;
- }
-
- //needed to save unicode paths using instantApply
- var instantApply = this.prefManager.getBoolPref("browser.preferences.instantApply");
- if (instantApply)
- {
- //save the default folder right after editing
- var default_folder = document.getElementById("asf-default-folder").value;
- this.saveUnicodeString("extensions.asf.defaultfolder", default_folder);
- }
- },
-
-
- createValidDestination: function (path) {
- if (!path) return false;
- if (this.trim(path).length==0) return false;
- var directory = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
-
- try {
- directory.initWithPath(path);
- if (directory.exists())
- return directory;
- } catch(e) {return false;}
- return false;
- },
-
- // removed unicodepath, unicodestring is working fine.
-/*
- loadUnicodeFolder: function (pref_place) {
- return this.prefManager.getComplexValue(pref_place, Components.interfaces.nsILocalFile).path;
- },
-
- saveUnicodeFolder: function (pref_place,path) {
- if (!path) return false;
- if (this.trim(path).length==0) return false;
- var directory = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
- directory.initWithPath(path);
- this.prefManager.setComplexValue(pref_place, Components.interfaces.nsILocalFile, directory);
- },
-*/
-
-
- loadUnicodeString: function (pref_place) {
-
- return this.prefManager.getComplexValue(pref_place, Components.interfaces.nsISupportsString).data;
- },
-
-
- saveUnicodeString: function (pref_place,pref_data) {
- if (this.trim(pref_data).length==0) return false;
- var str = Components.classes["@mozilla.org/supports-string;1"]
- .createInstance(Components.interfaces.nsISupportsString);
- str.data = this.trim(pref_data);
- this.prefManager.setComplexValue(pref_place, Components.interfaces.nsISupportsString, str);
- return false ;
- },
-
-
- trim: function (string) {
- return string.replace(/(^\s*)|(\s*$)/g,'');
- },
-
-
- DownloadSort: function() {
- // Check for Download sort add-on, if enabled return true. (works only on 3.x)
- if (this.firefoxversion == 3)
- {
- 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");
- var listBox = document.getElementById("asf-filterList");
-
- this.asf_selecttab("asf-tab-filters"); // Go back to the Filters tabs in order to read and save the Tree data (it doesn't work it it's hidden)
-
- var nbrRow = listBox.view.rowCount;
-
- // set the number of filter in the tree
- this.prefManager.setIntPref("extensions.asf.filtersNumber", nbrRow);
-
-
- for (var i=0; i < nbrRow ; i++)
- {
- var domain = tree.view.getCellText(i,tree.columns.getColumnAt("0"));
- var filename = tree.view.getCellText(i,tree.columns.getColumnAt("1"));
- var folder = tree.view.getCellText(i,tree.columns.getColumnAt("2"));
- var active = tree.view.getCellValue(i,tree.columns.getColumnAt("3"));
- active = (active == "true" ? true : false) ;
-
- this.saveUnicodeString("extensions.asf.filters"+ i +".domain", domain);
- this.saveUnicodeString("extensions.asf.filters"+ i +".filename", filename);
- this.saveUnicodeString("extensions.asf.filters"+ i +".folder", folder);
- this.prefManager.setBoolPref("extensions.asf.filters"+ i +".active", active);
-
- }
- },
-
-
- 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) && this.firefoxversion == 3) // only for firefox 3, Firefox2 doesn't use timeout option
- {
- var asf_rightclicktimeout = document.getElementById("asf-rightclicktimeout").checked;
- this.prefManager.setIntPref("browser.download.saveLinkAsFilenameTimeout", asf_rightclicktimeout == 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);
-
-
- // bug from both instantApply and non instantApply, when changing checked state with javascript the state is not saved
- // so for all the sub-option, let's save manually :
- this.prefManager.setBoolPref("extensions.asf.viewpathselect", document.getElementById("asf-viewpathselect").checked);
- this.prefManager.setBoolPref("extensions.asf.rightclicktimeout", document.getElementById("asf-rightclicktimeout").checked);
- this.prefManager.setBoolPref("extensions.asf.dialogacceptFiltered", document.getElementById("asf-dialogacceptFiltered").checked);
-
-
- },
-
-
- asf_savepref: function () {
- //save the filters
- this.asf_savefilters();
-
- //save the options
- this.asf_saveoptions();
-
- // close the preference window
- this.asf_close();
- },
-
-
- asf_close: function() {
-
- //close the options
- window.close();
- if (window.opener.location == "chrome://mozapps/content/downloads/unknownContentType.xul") // if the option is opened from the saving window
- {
- window.opener.automatic_save_folder.main(); // rescan the filters to set the good folder
- window.opener.sizeToContent();
- }
- window.opener.focus;
-
- }
-
+/* ***** BEGIN LICENSE BLOCK *****
+Automatic Save Folder
+Copyright (C) 2007-2010 Éric Cassar (Cyan).
+
+ "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),
+
+ stringbundle: Components.classes["@mozilla.org/intl/stringbundle;1"]
+ .getService(Components.interfaces.nsIStringBundleService)
+ .createBundle("chrome://asf/locale/asf.properties"),
+
+ firefoxversion : "",
+
+ asf_load: function () {
+
+ if(this.versionChecker.compare(this.appInfo.version, "3.0") >= 0)
+ {
+ this.firefoxversion = "3";
+ }
+ else
+ {
+ this.firefoxversion = "2";
+ }
+
+
+ // init the preference for firefox 3
+ if (this.firefoxversion == "3")
+ {
+ // set lastdir to "enable" if the user just updated from previous version and had it disabled
+ var lastdir = document.getElementById("asf-lasdir");
+ lastdir.checked = true;
+ lastdir.hidden = true; // hidden on FF3, as lastdir must always be true, don't allow the user to disable it.
+ this.prefManager.setBoolPref("extensions.asf.lastdir", true);
+ }
+
+
+ this.asf_getdomain(); // Run this to get the current domain and filename from the download window to pre-fill the fields in "add filter".
+ this.asf_loadpref(); // Load the preferences and the filter's array content
+ this.asf_treeSelected(); // set the button to disabled state because no filter is selected when openning
+ this.asf_toggleradio(); // set the radio choice to the right place
+ this.asf_variablemode(); // check if variable mode is on or off, and change mode if needed
+
+
+
+ //Detect OS
+ // var OSName="Unknown OS";
+ // if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
+ // if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";
+ // if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
+ // if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";
+
+ // alert('Your OS: '+OSName);
+ // alert(navigator.appVersion.indexOf("Win"));
+
+ },
+
+
+ asf_loadpref: function () {
+ var nbrRow = this.prefManager.getIntPref("extensions.asf.filtersNumber", 0);
+
+ //load the default folder (I removed the preference in options.xul, unicode folder's name didn't saved at all with automatic preference management.
+ // Manual saving is working, but not saving in the right encoding type in prefs.js, so we need to use get/setComplexValue)
+ var default_folder = document.getElementById("asf-default-folder");
+ default_folder.value = this.loadUnicodeString("extensions.asf.defaultfolder");
+
+ for ( var i = 0 ; i < nbrRow ; i++)
+ {
+ var domain = this.loadUnicodeString("extensions.asf.filters"+ i +".domain");
+ var filename = this.loadUnicodeString("extensions.asf.filters"+ i +".filename");
+ var folder = this.loadUnicodeString("extensions.asf.filters"+ i +".folder");
+ var active = this.prefManager.getBoolPref("extensions.asf.filters"+ i +".active");
+
+ // adding into the tree
+ var filter = document.getElementById('asf-filterList');
+ var rules = document.getElementById('asf-filterChilds');
+ var item = document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'treeitem');
+ var row = document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'treerow');
+ var c1 = document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'treecell');
+ var c2 = document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'treecell');
+ var c3 = document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'treecell');
+ var c4 = document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'treecell');
+ c1.setAttribute('label', domain);
+ c2.setAttribute('label', filename);
+ c3.setAttribute('label', folder);
+ c4.setAttribute('value', active);
+ c1.setAttribute('editable', false);
+ c2.setAttribute('editable', false);
+ c3.setAttribute('editable', false);
+ row.appendChild(c1);
+ row.appendChild(c2);
+ row.appendChild(c3);
+ row.appendChild(c4);
+ item.appendChild(row);
+
+ rules.appendChild(item);
+
+ }
+
+ // set the row's color
+ this.set_row_color();
+ },
+
+
+ save_active_state: function() {
+ //autosave the filters when clicking (anywhere) on the filter tree
+ // can't detect the "active" column statut with setting an attribute. The event is set to the tree not the cell.
+ var instantApply = this.prefManager.getBoolPref("browser.preferences.instantApply");
+ if (instantApply)
+ {
+ //save the filters
+ this.asf_savefilters();
+ }
+
+ // set the row's color
+ this.set_row_color();
+ },
+
+
+ // Called whenever a list box is selected
+ asf_treeSelected: function () {
+ var deleteButton = document.getElementById("asf-delete");
+ var editButton = document.getElementById("asf-edit");
+ var listBox = document.getElementById("asf-filterList");
+ var listchilds = document.getElementById("asf-filterChilds");
+ var moveDownButton = document.getElementById("asf-move-down");
+ var moveUpButton = document.getElementById("asf-move-up");
+ var selectedIndex = listBox.currentIndex ; //number of the selected line in tree
+
+ var nbrRow = listBox.view.rowCount;
+
+
+ // If an item is selected
+ if(selectedIndex >= 0)
+ {
+ deleteButton.disabled = false;
+ deleteButton.image = "chrome://asf/skin/delete.png";
+ editButton.disabled = false;
+
+ // If this is the first item
+ if(selectedIndex == 0)
+ {
+ moveUpButton.disabled = true;
+ moveUpButton.image = "chrome://asf/skin/up_disabled.png";
+ }
+ else
+ {
+ moveUpButton.disabled = false;
+ moveUpButton.image = "chrome://asf/skin/up.png";
+ }
+
+ // If this is the last item
+ if(selectedIndex == nbrRow - 1)
+ {
+ moveDownButton.disabled = true;
+ moveDownButton.image = "chrome://asf/skin/down_disabled.png";
+ }
+ else
+ {
+ moveDownButton.disabled = false;
+ moveDownButton.image = "chrome://asf/skin/down.png";
+ }
+ }
+ else
+ {
+ editButton.disabled = true;
+ deleteButton.disabled = true;
+ deleteButton.image = "chrome://asf/skin/delete_disabled.png";
+ moveDownButton.disabled = true;
+ moveDownButton.image = "chrome://asf/skin/down_disabled.png";
+ moveUpButton.disabled = true;
+ moveUpButton.image = "chrome://asf/skin/up_disabled.png";
+ }
+ },
+
+
+ set_row_color: function () {
+
+ if (window.opener.location == "chrome://mozapps/content/downloads/unknownContentType.xul")
+ {
+
+ // Load current file info (source, location and current website URL)
+ var domain = document.getElementById("asf-current-domain").value;
+ var filename = document.getElementById("asf-current-filename").value;
+ var currentURL = document.getElementById("asf-current-url").value;
+ var treename = "asf-filterList";
+ var tree = document.getElementById(treename);
+ var maxidx = tree.view.rowCount;
+ var use_currentURL = document.getElementById("asf-usecurrenturl").checked;
+ var dom, fil, fol, act, color, dom_regexp, file_regexp ;
+
+ for ( var idx = 0; idx < maxidx ; idx++)
+ {
+ // read current row data
+ dom = tree.view.getCellText(idx,tree.columns.getColumnAt(0));
+ fil = tree.view.getCellText(idx,tree.columns.getColumnAt(1));
+ fol = tree.view.getCellText(idx,tree.columns.getColumnAt(2));
+ act = tree.view.getCellValue(idx,tree.columns.getColumnAt(3));
+ act = (act == "true" ? true : false) ;
+
+ //Check filters here (see asf_download.js for source comments)
+ dom_regexp = false ; // reset the matching string for the "for" loop
+ file_regexp = false ; // same as above
+
+ dom_regexp = this.test_regexp(dom, domain); // hosted Domain
+ if (!dom_regexp && use_currentURL)
+ {
+ dom_regexp = this.test_regexp(dom, currentURL); // current URL if hosted Domain returns false
+ }
+ file_regexp = this.test_regexp(fil, filename); // Filename
+
+
+ //set or remove Attribute color
+ color = (act == true ? "FilterTestPass" : "FilterTestFail");
+ var currentitem = tree.treeBoxObject.view.getItemAtIndex(idx);
+
+
+ if (dom_regexp && file_regexp)
+ {
+ currentitem.firstChild.setAttribute('properties', color);
+ }
+ else
+ {
+ currentitem.firstChild.removeAttribute('properties');
+ }
+ }
+
+ // enable this to remove the color of the selected item (but works only with mouse-click, not keyboard arrows)
+ // if(tree.currentIndex > -1)
+ // {
+ // currentitem = tree.view.getItemAtIndex(tree.currentIndex);
+ // currentitem.firstChild.removeAttribute('properties');
+ // }
+ }
+ },
+
+
+ test_regexp: function (filters, string) {
+
+ var test_regexp = this.is_regexp(filters); // True or False
+ 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)
+
+ if (string.match(test_regexp)) // if something match
+ {
+ return(true);
+ }
+ return(false);
+ },
+
+
+ is_regexp: function (string) {
+ if ((string.substring(0,1) == "/") && (string.substr(string.length - 1, 1) == "/"))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ },
+
+
+ asf_toggleradio: function () {
+ var select_last_radio = document.getElementById("asf-last-radio");
+ var select_choose_radio = document.getElementById("asf-choose-radio");
+ var select_folder_input = document.getElementById("asf-default-folder");
+ var select_folder_btn = document.getElementById("asf-select-folder");
+ var select_keeptemp_chk = document.getElementById("asf-keeptemp-check");
+ var variable_mode = document.getElementById("asf-variablemode");
+
+ if(select_last_radio.selected == true)
+ {
+ select_folder_input.disabled = true;
+ select_folder_btn.disabled = true;
+ select_keeptemp_chk.disabled = true;
+ }
+
+ if(select_choose_radio.selected == true)
+ {
+ select_folder_input.disabled = false;
+ this.asf_variablemode();
+ select_folder_btn.disabled = false;
+ select_keeptemp_chk.disabled = false;
+ }
+ },
+
+
+ toggle_options: function () { // called whenever the Options tab is selected
+ var instantApply = this.prefManager.getBoolPref("browser.preferences.instantApply");
+ var viewdloption = document.getElementById("asf-viewdloption");
+ var viewdloptionType = document.getElementById("asf-viewdloptionType");
+ var viewpathlist = document.getElementById("asf-viewpathselect");
+ var dialogaccept = document.getElementById("asf-dialogaccept");
+ var dialogacceptFiltered = document.getElementById("asf-dialogacceptFiltered");
+ var useDownloadDir = document.getElementById("asf-useDownloadDir");
+ var asf_userightclick = document.getElementById("asf-userightclick");
+ var asf_rightclicktimeout = document.getElementById("asf-rightclicktimeout");
+
+ // check if autosave is selected, if not : set the saving path to "filtered" and disable the dropdown menu.
+ if (useDownloadDir.checked == false)
+ {
+ document.getElementById("asf-folderList").value = 2;
+ document.getElementById("asf-folderList").disabled = true;
+ this.prefManager.setIntPref("browser.download.folderList",2);
+ }
+ if (useDownloadDir.checked == true)
+ {
+ document.getElementById("asf-folderList").disabled = false;
+ }
+
+
+ // set the sub-dialogaccept option to grey state
+ if (dialogaccept.checked == false)
+ {
+ dialogacceptFiltered.checked = false;
+ dialogacceptFiltered.disabled = true;
+ }
+ if (dialogaccept.checked == true)
+ {
+ dialogacceptFiltered.disabled = false;
+ }
+
+ // if the option window is opened from the saving window, disable the autosave feature (Not working when set from here.)
+ if (window.opener.location == "chrome://mozapps/content/downloads/unknownContentType.xul")
+ {
+ dialogaccept.disabled = true;
+ dialogacceptFiltered.disabled = true;
+ }
+
+
+ // set the sub-D/L option to grey state
+ if (viewdloption.checked == false)
+ {
+ viewdloptionType.disabled = true;
+ viewpathlist.checked = false;
+ viewpathlist.disabled = true;
+ }
+ if (viewdloption.checked == true)
+ {
+ viewdloptionType.disabled = false;
+ viewpathlist.disabled = false;
+ }
+
+ // set the sub-rightclick option to grey state
+ if (asf_userightclick.checked == false)
+ {
+ asf_rightclicktimeout.disabled = true;
+ }
+ if (asf_userightclick.checked == true)
+ {
+ asf_rightclicktimeout.disabled = false;
+ }
+
+ // Check the right-click feature here, and prints text according to Firefox version and active addons
+ // hide all the descriptions box, and unhide the needed one
+ document.getElementById("asf-rightclickdesc-ff2").hidden = true; // Firefox 2, Right-click disabled message
+ document.getElementById("asf-rightclickdesc-DSort").hidden = true; // Download sort conflit alert
+ var Dsort_installed = this.DownloadSort();
+
+ if (this.firefoxversion == 2)
+ {
+ document.getElementById("asf-userightclick").hidden = true; // Hide the right-click checkbox
+ document.getElementById("asf-rightclicktimeout").hidden = true; // Hide the right-click timeout checkbox
+ document.getElementById("asf-rightclickdesc-ff2").hidden = false; // Show right-click not working on Firefox 2.0
+ }
+ if (this.firefoxversion == 3)
+ {
+ if (Dsort_installed) // if Download sort is installed, display a message "right click disabled"
+ {
+ asf_userightclick.disabled = true;
+ asf_rightclicktimeout.disabled = true;
+
+ document.getElementById("asf-rightclickdesc-DSort").hidden = false;
+ }
+ }
+
+ if (instantApply) // bug with sub-options status set by javascript
+ {
+ this.asf_saveoptions();
+ }
+ },
+
+
+ toggle_userightclick: function () {
+ var instantApply = this.prefManager.getBoolPref("browser.preferences.instantApply");
+ var asf_userightclick = document.getElementById("asf-userightclick");
+ var asf_rightclicktimeout = document.getElementById("asf-rightclicktimeout");
+
+ // set the sub-rightclick option to grey state
+ if (asf_userightclick.checked == false)
+ {
+ asf_rightclicktimeout.checked = false;
+ asf_rightclicktimeout.disabled = true;
+ }
+ if (asf_userightclick.checked == true)
+ {
+ asf_rightclicktimeout.disabled = false;
+ asf_rightclicktimeout.checked = true;
+ }
+
+ if (instantApply) // bug with sub-options status set by javascript
+ {
+ this.asf_saveoptions();
+ }
+
+ },
+
+
+ toggle_rightclicktimeout: function () {
+ var instantApply = this.prefManager.getBoolPref("browser.preferences.instantApply");
+
+ if (instantApply)
+ {
+ var asf_rightclicktimeout = document.getElementById("asf-rightclicktimeout").checked;
+ this.prefManager.setIntPref("browser.download.saveLinkAsFilenameTimeout", asf_rightclicktimeout == true ? 0 : 1000 );
+ }
+ },
+
+
+ asf_selecttab: function(tabID) {
+
+ // 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-help").hidden = true;
+ document.getElementById("asf-tab-about").hidden = true;
+
+
+ document.getElementById(tabID).hidden = false;
+ if(tabID == "asf-tab-options") this.toggle_options();
+ if(tabID == "asf-tab-filters") this.set_row_color();
+ //window.sizeToContent();
+ },
+
+
+ asf_variablemode: function() {
+ var select_variable_mode = document.getElementById("asf-variablemode");
+ var select_folder_input = document.getElementById("asf-default-folder");
+
+ if(select_variable_mode.checked == true)
+ {
+ select_folder_input.readOnly = false;
+ }
+ if(select_variable_mode.checked == false)
+ {
+ select_folder_input.readOnly = true;
+ }
+
+
+ },
+
+
+ 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
+ {
+ var currentdomain = window.opener.document.getElementById("source").value;
+ var currentfilename = window.opener.document.getElementById("location").value ;
+ var uCT = window.opener.document.getElementById("unknownContentType");
+ var currentURL = uCT.parentNode.defaultView.opener.location.host;
+
+ var domain = document.getElementById("asf-current-domain");
+ var filename = document.getElementById("asf-current-filename");
+ var URL = document.getElementById("asf-current-url");
+
+ domain.value = currentdomain ;
+ filename.value = currentfilename ;
+ URL.value = currentURL;
+ }
+ },
+
+
+ // Code from captain.at, modified by Cyan (CASSAR Eric)
+ move: function (direction) {
+ var instantApply = this.prefManager.getBoolPref("browser.preferences.instantApply");
+ var treename = "asf-filterList";
+
+ var tree = document.getElementById(treename);
+ var idx = tree.currentIndex;
+ if (idx == -1) return false;
+
+ var dir = 1;
+ if ((direction == "up") || (direction == "top"))
+ {
+ dir = -1;
+ }
+ var currentitem = tree.treeBoxObject.view.getItemAtIndex(idx);
+ var parent = currentitem.parentNode;
+ if ((direction == "up") || (direction == "down")) // read the next or previous entry only if function is called from the button clic (not from the popup choice)
+ {
+ var previousitem = tree.treeBoxObject.view.getItemAtIndex(idx + dir);
+ }
+
+
+ if (direction == "up")
+ {
+ parent.insertBefore(currentitem, previousitem);
+ tree.view.selection.select(idx-1); // reselect the last
+ }
+ else if (direction == "down")
+ {
+ parent.insertBefore(previousitem, currentitem);
+ }
+
+ if (direction == "top")
+ {
+ while (currentitem.previousSibling)
+ {
+ this.move("up");
+ }
+ }
+ else if (direction == "bottom")
+ {
+ while (currentitem.nextSibling)
+ {
+ this.move("down");
+ }
+ }
+
+
+ //autosave when moving filters
+ if (instantApply)
+ {
+ //save the filters
+ this.asf_savefilters();
+ }
+ return false;
+ },
+
+
+ dragstart: function(event) {
+ var treename = "asf-filterList";
+ var tree = document.getElementById(treename);
+ var idx = tree.currentIndex; //number of the selected line in tree
+ var currentitem = tree.treeBoxObject.view.getItemAtIndex(idx);
+
+ //event.dataTransfer.setData('application/x-moz-node', currentitem); // send node data
+ event.dataTransfer.setData('user/define', idx); // send index data as text (but to prevent drop on text field, let's use custom set)
+ },
+
+
+ dragover: function (event) {
+ //var isNode = event.dataTransfer.types.contains("application/x-moz-node");
+ var isDefine = event.dataTransfer.types.contains("user/define");
+ if (isDefine)
+ {
+ event.preventDefault();
+ event.dataTransfer.effectAllowed = "move";
+ event.dataTransfer.dropEffect = "move";
+ }
+ },
+
+
+ dragdrop: function (event) {
+ //var currentitem = event.dataTransfer.getData("application/x-moz-node");
+ //var currentitem_idx = event.dataTransfer.getData("text/plain");
+ var currentitem_idx = event.dataTransfer.getData("user/define");
+ if (currentitem_idx!="")
+ {
+ var treename = "asf-filterList";
+ var tree = document.getElementById(treename);
+ var currentitem = tree.treeBoxObject.view.getItemAtIndex(currentitem_idx);
+
+ try
+ {
+ var targetitem_idx = tree.treeBoxObject.getRowAt(event.pageX, event.pageY);
+ var targetitem = tree.treeBoxObject.view.getItemAtIndex(targetitem_idx);
+ var parent = targetitem.parentNode;
+
+ if (currentitem_idx > targetitem_idx) parent.insertBefore(currentitem, targetitem);
+ if (currentitem_idx < targetitem_idx) parent.insertBefore(currentitem, targetitem.nextSibling);
+ tree.view.selection.select(targetitem_idx); // reselect the moved filter
+
+ // Now check is the user has InstantApply option to save the filter's order.
+ var instantApply = this.prefManager.getBoolPref("browser.preferences.instantApply");
+ if (instantApply)
+ {
+ //save the filters
+ this.asf_savefilters();
+ }
+ }
+ catch(e){} // if the user point outside of the filter tree (because using dragexit instead of dragdrop (dragdrop is not working)).
+ }
+ event.preventDefault();
+ },
+
+
+ asf_duplicate: function () {
+ var treename = "asf-filterList";
+
+ var tree = document.getElementById(treename);
+ var idx = tree.currentIndex;
+ if (idx == -1) return false;
+ var originidx = idx;
+ var currentitem = tree.treeBoxObject.view.getItemAtIndex(idx);
+ var parent = currentitem.parentNode;
+ {
+ parent.appendChild(currentitem.cloneNode(true))
+ }
+ //select the new filter
+ idx = parent.childNodes.length-1;
+ tree.view.selection.select(idx);
+ for (var i = idx ; i > originidx ; i--) // move the new copy 1 line above the original item
+ { // so the filter auto-saving process for instantApply (present in the move() function) works
+ this.move("up"); // even if the user duplicate the bottom filter, it will move from 1 step
+ }
+ return false;
+ },
+
+
+ asf_delete: function () {
+ var instantApply = this.prefManager.getBoolPref("browser.preferences.instantApply");
+ var filter = document.getElementById('asf-filterList');
+ var rules = document.getElementById('asf-filterChilds');
+ if (filter.view.selection.count > 0)
+ {
+ for (var i=rules.childNodes.length-1 ; i>=0 ; i--)
+ {
+ if (filter.view.selection.isSelected(i))
+ rules.removeChild(rules.childNodes[i]);
+ }
+ }
+
+ if (instantApply)
+ {
+ //save the filters
+ this.asf_savefilters();
+ }
+
+ //detect remaining filters, unhighlight, and change right buttons states
+ this.asf_treeSelected();
+ },
+
+
+ // next 2 functions : Code inspired from DTA (browsedir & createValidDestination)
+ browsedir: function () {
+ var current_folder_input = document.getElementById("asf-default-folder").value;
+
+ const nsIFilePicker = Components.interfaces.nsIFilePicker;
+ var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
+
+ var filepickerdescription = this.stringbundle.GetStringFromName("select_default_folder");
+ fp.init(window, filepickerdescription, nsIFilePicker.modeGetFolder);
+ //fp.appendFilters(nsIFilePicker.filterAll | nsIFilePicker.filterText);
+
+ // locate current directory
+ current_folder_input = this.createValidDestination(current_folder_input);
+ if (current_folder_input !== false) fp.displayDirectory = current_folder_input;
+
+ var rv = fp.show();
+ if (rv == nsIFilePicker.returnOK)
+ {
+ var asf_url = fp.file.path;
+ // Set the data into the input box
+ document.getElementById("asf-default-folder").value = asf_url;
+ }
+
+ //needed to save unicode paths using instantApply
+ var instantApply = this.prefManager.getBoolPref("browser.preferences.instantApply");
+ if (instantApply)
+ {
+ //save the default folder right after editing
+ var default_folder = document.getElementById("asf-default-folder").value;
+ this.saveUnicodeString("extensions.asf.defaultfolder", default_folder);
+ }
+ },
+
+
+ createValidDestination: function (path) {
+ if (!path) return false;
+ if (this.trim(path).length==0) return false;
+ var directory = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
+
+ try {
+ directory.initWithPath(path);
+ if (directory.exists())
+ return directory;
+ } catch(e) {return false;}
+ return false;
+ },
+
+
+ // removed unicodepath, unicodestring is working fine.
+/*
+ loadUnicodeFolder: function (pref_place) {
+ return this.prefManager.getComplexValue(pref_place, Components.interfaces.nsILocalFile).path;
+ },
+
+ saveUnicodeFolder: function (pref_place,path) {
+ if (!path) return false;
+ if (this.trim(path).length==0) return false;
+ var directory = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
+ directory.initWithPath(path);
+ this.prefManager.setComplexValue(pref_place, Components.interfaces.nsILocalFile, directory);
+ },
+*/
+
+
+ loadUnicodeString: function (pref_place) {
+ return this.prefManager.getComplexValue(pref_place, Components.interfaces.nsISupportsString).data;
+ },
+
+
+ saveUnicodeString: function (pref_place,pref_data) {
+ if (this.trim(pref_data).length==0) return false;
+ var str = Components.classes["@mozilla.org/supports-string;1"]
+ .createInstance(Components.interfaces.nsISupportsString);
+ str.data = this.trim(pref_data);
+ this.prefManager.setComplexValue(pref_place, Components.interfaces.nsISupportsString, str);
+ return false ;
+ },
+
+
+ trim: function (string) {
+ return string.replace(/(^\s*)|(\s*$)/g,'');
+ },
+
+
+ DownloadSort: function() {
+ // Check for Download sort add-on, if enabled return true. (works only on 3.x)
+ if (this.firefoxversion == 3)
+ {
+ 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");
+ var listBox = document.getElementById("asf-filterList");
+
+ this.asf_selecttab("asf-tab-filters"); // Go back to the Filters tabs in order to read and save the Tree data (it doesn't work it it's hidden)
+
+ var nbrRow = listBox.view.rowCount;
+
+ // set the number of filter in the tree
+ this.prefManager.setIntPref("extensions.asf.filtersNumber", nbrRow);
+
+
+ for (var i=0; i < nbrRow ; i++)
+ {
+ var domain = tree.view.getCellText(i,tree.columns.getColumnAt("0"));
+ var filename = tree.view.getCellText(i,tree.columns.getColumnAt("1"));
+ var folder = tree.view.getCellText(i,tree.columns.getColumnAt("2"));
+ var active = tree.view.getCellValue(i,tree.columns.getColumnAt("3"));
+ active = (active == "true" ? true : false) ;
+
+ this.saveUnicodeString("extensions.asf.filters"+ i +".domain", domain);
+ this.saveUnicodeString("extensions.asf.filters"+ i +".filename", filename);
+ this.saveUnicodeString("extensions.asf.filters"+ i +".folder", folder);
+ this.prefManager.setBoolPref("extensions.asf.filters"+ i +".active", active);
+ }
+ },
+
+
+ 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) && this.firefoxversion == 3) // only for firefox 3, Firefox2 doesn't use timeout option
+ {
+ var asf_rightclicktimeout = document.getElementById("asf-rightclicktimeout").checked;
+ this.prefManager.setIntPref("browser.download.saveLinkAsFilenameTimeout", asf_rightclicktimeout == 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);
+
+
+ // bug from both instantApply and non instantApply, when changing checked state with javascript the state is not saved
+ // so for all the sub-option, let's save manually :
+ this.prefManager.setBoolPref("extensions.asf.viewpathselect", document.getElementById("asf-viewpathselect").checked);
+ this.prefManager.setBoolPref("extensions.asf.rightclicktimeout", document.getElementById("asf-rightclicktimeout").checked);
+ this.prefManager.setBoolPref("extensions.asf.dialogacceptFiltered", document.getElementById("asf-dialogacceptFiltered").checked);
+
+
+ },
+
+
+ asf_savepref: function () {
+ //save the filters
+ this.asf_savefilters();
+
+ //save the options
+ this.asf_saveoptions();
+
+ // close the preference window
+ this.asf_close();
+ },
+
+
+ asf_close: function() {
+
+ //close the options
+ window.close();
+ if (window.opener.location == "chrome://mozapps/content/downloads/unknownContentType.xul") // if the option is opened from the saving window
+ {
+ window.opener.automatic_save_folder.main(); // rescan the filters to set the good folder
+ window.opener.sizeToContent();
+ }
+ window.opener.focus;
+ }
+
+
};
\ No newline at end of file
diff --git a/content/asf_addedit.js b/content/asf_addedit.js
index c57b9c1..210ea47 100644
--- a/content/asf_addedit.js
+++ b/content/asf_addedit.js
@@ -1,586 +1,593 @@
-/* ***** BEGIN LICENSE BLOCK *****
-Automatic Save Folder
-Copyright (C) 2007-2010 Éric Cassar (Cyan).
-
- "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),
-
- stringbundle: Components.classes["@mozilla.org/intl/stringbundle;1"]
- .getService(Components.interfaces.nsIStringBundleService)
- .createBundle("chrome://asf/locale/asf.properties"),
-
- add_load: function () {
-
- var currentdomain = window.opener.document.getElementById("asf-current-domain").value;
- var currentfilename = window.opener.document.getElementById("asf-current-filename").value ;
-
- var radio_domain_all = window.document.getElementById("asf-addedit-radio-domain-all");
- var radio_domain_edited = window.document.getElementById("asf-addedit-radio-domain");
- var radio_filename_all = window.document.getElementById("asf-addedit-radio-filename-all");
- var radio_filename_edited = window.document.getElementById("asf-addedit-radio-filename");
-
- // enable or disable the local saving path text input
- var select_variable_mode = window.opener.document.getElementById("asf-variablemode");
- var select_folder_input = document.getElementById("asf-addedit-folder");
- if(select_variable_mode.checked == true)
- {
- select_folder_input.readOnly = false;
- }
- if(select_variable_mode.checked == false)
- {
- select_folder_input.readOnly = true;
- }
-
- // pre-filled data
- if (currentdomain != "")
- { // if opened from save window, domain and filename is autofilled, and radio need to be selected on 1 and value set to 1
-
- radio_domain_edited.checked;
- radio_filename_edited.checked;
-
- //set radio button to state 1 (if the user never clic on a radio, the value is null, even if the radio is selected at the right position)
- document.getElementById('radio-addedit-domain').value = 1 ;
- document.getElementById('radio-addedit-filename').value = 1 ;
-
- // set the data into the fields
- var domain = document.getElementById("asf-addedit-domain");
- var filename = document.getElementById("asf-addedit-filename");
-
- domain.value = currentdomain ;
- filename.value = currentfilename ;
-
- } // else, nothing to fill, radio button set to 0
- else
- {
- radio_domain_all.checked;
- radio_filename_all.checked;
-
- //set radio button to state 0 (if the user never clic on a radio, the value is null, even if the radio is not checked)
- document.getElementById('radio-addedit-domain').value = 0 ;
- document.getElementById('radio-addedit-filename').value = 0 ;
- }
-
- sizeToContent();
- this.asf_toggleradio_domain();
- this.asf_toggleradio_filename();
- },
-
-
- edit_load: function () {
-
- sizeToContent();
- this.asf_loadData();
- this.asf_toggleradio_domain();
- this.asf_toggleradio_filename();
- },
-
-
- loadUnicodeString: function (pref_place) {
- try
- {
- return this.prefManager.getComplexValue(pref_place, Components.interfaces.nsISupportsString).data;
- }
- catch (e)
- { }
- return "";
- },
-
-
- browsedir_addedit: function () {
- var current_folder_input = document.getElementById("asf-addedit-folder").value;
-
- const nsIFilePicker = Components.interfaces.nsIFilePicker;
- var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
-
- var filepickerdescription = this.stringbundle.GetStringFromName("select_folder");
- fp.init(window, filepickerdescription, nsIFilePicker.modeGetFolder);
- //fp.appendFilters(nsIFilePicker.filterAll | nsIFilePicker.filterText);
-
- // locate current directory
- current_folder_input = this.createValidDestination(current_folder_input);
- if (current_folder_input !== false) fp.displayDirectory = current_folder_input;
-
- var rv = fp.show();
- if (rv == nsIFilePicker.returnOK)
- {
- var asf_url = fp.file.path;
-
- // Set the data into the input box
- document.getElementById("asf-addedit-folder").value = asf_url;
- }
- },
-
-
- createValidDestination: function (path) {
- if (!path) return false;
- if (this.trim(path).length==0) return false;
- var directory = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
-
- try {
- directory.initWithPath(path);
- if (directory.exists())
- return directory;
- } catch(e) {return false;}
- return false;
- },
-
-
- asf_loadData: function () {
- // enable or disable the local saving path user input
- var select_variable_mode = window.opener.document.getElementById("asf-variablemode");
- var select_folder_input = document.getElementById("asf-addedit-folder");
- if (select_variable_mode.checked == true)
- {
- select_folder_input.readOnly = false;
- }
- if (select_variable_mode.checked == false)
- {
- select_folder_input.readOnly = true;
- }
-
-
- var tree = window.opener.document.getElementById("asf-filterList") ;
- var idx = tree.currentIndex;
- if (idx < 0)
- {
- return;
- }
-
- var domain = tree.view.getCellText(idx,tree.columns.getColumnAt(0));
- var filename = tree.view.getCellText(idx,tree.columns.getColumnAt(1));
- var folder = tree.view.getCellText(idx,tree.columns.getColumnAt(2));
- var radio_domain = document.getElementById("radio-addedit-domain") ;
- var radio_filename = document.getElementById("radio-addedit-filename") ;
-
- if (domain == "/.*/")
- {
- radio_domain.value = 0;
- }
- else
- {
- radio_domain.value = 1;
- document.getElementById("asf-addedit-domain").value = domain;
-
- document.getElementById("asf-addedit-domain-regexp").checked = this.is_regexp(document.getElementById("asf-addedit-domain").value);
- }
-
- if (filename == "/.*/")
- {
- radio_filename.value = 0;
- }
- else
- {
- radio_filename.value = 1;
- document.getElementById("asf-addedit-filename").value = filename;
-
- document.getElementById("asf-addedit-filename-regexp").checked = this.is_regexp(document.getElementById("asf-addedit-filename").value);
- }
-
- document.getElementById("asf-addedit-folder").value = folder ;
- },
-
-
- asf_toggleradio_domain: function () {
- var select_addedit_radio_all = document.getElementById("asf-addedit-radio-domain-all");
- var select_addedit_radio = document.getElementById("asf-addedit-radio-domain");
- var select_addedit_input = document.getElementById("asf-addedit-domain");
- var select_addedit_chk = document.getElementById("asf-addedit-domain-regexp");
-
- if (select_addedit_radio_all.selected == true)
- {
- select_addedit_input.disabled = true;
- select_addedit_chk.disabled = true;
- }
-
- if (select_addedit_radio.selected == true)
- {
- select_addedit_input.disabled = false;
- select_addedit_chk.disabled = false;
- }
- },
-
-
- asf_toggleradio_filename: function () {
- var select_addedit_radio_all = document.getElementById("asf-addedit-radio-filename-all");
- var select_addedit_radio = document.getElementById("asf-addedit-radio-filename");
- var select_addedit_input = document.getElementById("asf-addedit-filename");
- var select_addedit_chk = document.getElementById("asf-addedit-filename-regexp");
-
- if (select_addedit_radio_all.selected == true)
- {
- select_addedit_input.disabled = true;
- select_addedit_chk.disabled = true;
- }
-
- if (select_addedit_radio.selected == true)
- {
- select_addedit_input.disabled = false;
- select_addedit_chk.disabled = false;
- }
- },
-
-
- // add the / at the beginning and the end of the input_regexp if id_regexp id checked
- makeRegexp: function (id_regexp, input_regexp) {
-
- var filter = document.getElementById(input_regexp);
-
- if (document.getElementById(id_regexp).checked)
- {
- if (filter.value.substring(0,1) != "/") // let's add the /
- {
- filter.value = "/" + filter.value;
- }
- if (filter.value.substr(filter.value.length - 1, 1) != "/")
- {
- filter.value = filter.value + "/";
- }
- }
- else
- {
- if (filter.value.substring(0,1) == "/") // then delete the /
- {
- filter.value = filter.value.substring(1, filter.value.length);
- }
- if (filter.value.substr(filter.value.length - 1, 1) == "/")
- {
- filter.value = filter.value.substring(0, filter.value.length -1);
- }
- }
- document.getElementById(input_regexp).value = filter.value;
- },
-
-
- is_regexp: function (string) {
-
- if ((string.substring(0,1) == "/") && (string.substr(string.length - 1, 1) == "/"))
- {
- return true;
- }
- else
- {
- return false;
- }
- },
-
-
- // on text change, check if the text is still regexp, else unchecked the checkbox
- testRegexp: function (id_regexp, input_regexp) {
- var filter = document.getElementById(input_regexp);
-
- if ((filter.value.substring(0,1) != "/") || (filter.value.substr(filter.value.length - 1, 1) != "/"))
- {
- document.getElementById(id_regexp).checked = false;
- }
- },
-
-
- trim: function (string)
- {
- return string.replace(/(^\s*)|(\s*$)/g,'');
- },
-
-
- //
- // ADD new filter in tree
- //
- asf_add: function () {
- var instantApply = this.prefManager.getBoolPref("browser.preferences.instantApply");
- // get the domain
- //
- var domain_radio = document.getElementById('radio-addedit-domain');
- var domain = document.getElementById('asf-addedit-domain');
- var domain_regexp = document.getElementById('asf-addedit-domain-regexp');
- if (domain_radio.value == 0)
- {
- var rule = "/.*/";
- }
- else
- {
- var rule = this.trim(domain.value);
- }
-
- if (rule != "")
- {
- var domain = rule;
- }
- else
- {
- var err_domain = this.stringbundle.GetStringFromName("nodata.domain");
- alert(err_domain);
- var error = true;
- }
-
- // get the filename
- //
- var filename_radio = document.getElementById('radio-addedit-filename');
- var filename = document.getElementById('asf-addedit-filename');
- var filename_regexp = document.getElementById('asf-addedit-filename-regexp');
- if (filename_radio.value == 0)
- {
- var rule = "/.*/";
- }
- else
- {
- var rule = this.trim(filename.value);
- }
-
- if (rule != "")
- {
- var filename = rule;
- }
- else
- {
- var err_filename = this.stringbundle.GetStringFromName("nodata.filename");
- alert(err_filename);
- var error = true;
- }
-
-
- //get the foldername
- //
- var folder = document.getElementById('asf-addedit-folder');
-
- var rule = this.trim(folder.value);
- if (rule == "")
- {
- var err_folder = this.stringbundle.GetStringFromName("nodata.folder");
- alert(err_folder);
- var error = true;
- }
- else
- {
- var folder = rule;
- }
-
-
-
- if (error != true)
- {
- // adding into the tree
- var filter = window.opener.document.getElementById('asf-filterList');
- var rules = window.opener.document.getElementById('asf-filterChilds');
- var item = window.opener.document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'treeitem');
- var row = window.opener.document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'treerow');
- var c1 = window.opener.document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'treecell');
- var c2 = window.opener.document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'treecell');
- var c3 = window.opener.document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'treecell');
- var c4 = window.opener.document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'treecell');
- c1.setAttribute('label', domain);
- c2.setAttribute('label', filename);
- c3.setAttribute('label', folder);
- c4.setAttribute('value', true);
- c1.setAttribute('editable', false);
- c2.setAttribute('editable', false);
- c3.setAttribute('editable', false);
- row.appendChild(c1);
- row.appendChild(c2);
- row.appendChild(c3);
- row.appendChild(c4);
- item.appendChild(row);
- rules.appendChild(item);
-
- //select the new filter
- var idx = rules.childNodes.length-1;
- filter.view.selection.select(idx);
- filter.boxObject.ensureRowIsVisible(idx);
-
- filter.focus();
- window.close();
-
- //autosave when adding a filter
- if (instantApply)
- {
- //save the filters
- window.opener.automatic_save_folder.asf_savefilters();
- }
- }
- },
-
-
- asf_edit: function () {
- var instantApply = this.prefManager.getBoolPref("browser.preferences.instantApply");
- // get the domain
- //
- var domain_radio = document.getElementById('radio-addedit-domain');
- var domain = document.getElementById('asf-addedit-domain');
- var domain_regexp = document.getElementById('asf-addedit-domain-regexp');
- if (domain_radio.value == 0)
- {
- var rule = "/.*/";
- }
- else
- {
- var rule = this.trim(domain.value);
- }
-
- if (rule != "")
- {
- var domain = rule;
- }
- else
- {
- var err_domain = this.stringbundle.GetStringFromName("nodata.domain");
- alert(err_domain);
- var error = true;
- }
-
- // get the filename
- //
- var filename_radio = document.getElementById('radio-addedit-filename');
- var filename = document.getElementById('asf-addedit-filename');
- var filename_regexp = document.getElementById('asf-addedit-filename-regexp');
- if (filename_radio.value == 0)
- {
- var rule = "/.*/";
- }
- else
- {
- var rule = this.trim(filename.value);
- }
-
- if (rule != "")
- {
- var filename = rule;
- }
- else
- {
- var err_filename = this.stringbundle.GetStringFromName("nodata.filename");
- alert(err_filename);
- var error = true;
- }
-
-
- //get the foldername
- //
- var folder = document.getElementById('asf-addedit-folder');
-
- var rule = this.trim(folder.value);
- if (rule == "")
- {
- var err_folder = this.stringbundle.GetStringFromName("nodata.folder");
- alert(err_folder);
- var error = true;
- }
- else
- {
- var folder = rule;
- }
-
- if (error != true)
- {
- var tree = window.opener.document.getElementById("asf-filterList") ;
- var idx = tree.currentIndex;
- if (idx < 0) {
- return;
- }
-
-
- var theValue = tree.treeBoxObject.view.getItemAtIndex(idx);
- var test = theValue.firstChild.childNodes[0].getAttribute("label");
-
- theValue.firstChild.childNodes[0].setAttribute("label", domain );
- theValue.firstChild.childNodes[1].setAttribute("label", filename );
- theValue.firstChild.childNodes[2].setAttribute("label", folder );
-
- //select the edited filter
- tree.view.selection.select(idx);
- tree.boxObject.ensureRowIsVisible(idx);
-
- tree.focus();
- window.close();
-
- //autosave when editing a filter
- if (instantApply)
- {
- //save the filters
- window.opener.automatic_save_folder.asf_savefilters();
- }
- }
- },
-
-
- //
- // the 2 functions bellow are the drop-down path menu for the "add & edit" window
- //
- read_all_filterpath: function() {
- var list = document.getElementById('asf-addedit-folder');
- var menupopup = document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'menupopup');
- var tree = window.opener.document.getElementById("asf-filterList");
-
- // Check if there is any filter in list
- var nbrfilters = tree.view.rowCount;
- var path = "";
-
-
- // Delete active list before repopulating (righ-clicking the menu sends an onLoad event again)
- 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();
- var defaultfolder = window.opener.document.getElementById("asf-default-folder").value;
- pathlist[0] = defaultfolder;
- var j = 0;
- for (var i = 0; i < nbrfilters; i++)
- {
- // read the filter number i
- path = tree.view.getCellText(i,tree.columns.getColumnAt("2"));
-
- if (this.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];
-
- var menuitem = document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'menuitem');
- menuitem.setAttribute('label', path);
- menuitem.setAttribute('crop', 'center');
- menuitem.setAttribute('value', path);
- menupopup.appendChild(menuitem);
- }
-
- // Populate the path list into the menu
- list.appendChild(menupopup);
-
- },
-
-
- 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;
- }
-
-
+/* ***** BEGIN LICENSE BLOCK *****
+Automatic Save Folder
+Copyright (C) 2007-2010 Éric Cassar (Cyan).
+
+ "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),
+
+ stringbundle: Components.classes["@mozilla.org/intl/stringbundle;1"]
+ .getService(Components.interfaces.nsIStringBundleService)
+ .createBundle("chrome://asf/locale/asf.properties"),
+
+ add_load: function () {
+
+ var currentdomain = window.opener.document.getElementById("asf-current-domain").value;
+ var currentfilename = window.opener.document.getElementById("asf-current-filename").value ;
+
+ var radio_domain_all = window.document.getElementById("asf-addedit-radio-domain-all");
+ var radio_domain_edited = window.document.getElementById("asf-addedit-radio-domain");
+ var radio_filename_all = window.document.getElementById("asf-addedit-radio-filename-all");
+ var radio_filename_edited = window.document.getElementById("asf-addedit-radio-filename");
+
+ // enable or disable the local saving path text input
+ var select_variable_mode = window.opener.document.getElementById("asf-variablemode");
+ var select_folder_input = document.getElementById("asf-addedit-folder");
+ if(select_variable_mode.checked == true)
+ {
+ select_folder_input.readOnly = false;
+ }
+ if(select_variable_mode.checked == false)
+ {
+ select_folder_input.readOnly = true;
+ }
+
+ // pre-filled data
+ if (currentdomain != "")
+ { // if opened from save window, domain and filename is autofilled, and radio need to be selected on 1 and value set to 1
+
+ radio_domain_edited.checked;
+ radio_filename_edited.checked;
+
+ //set radio button to state 1 (if the user never clic on a radio, the value is null, even if the radio is selected at the right position)
+ document.getElementById('radio-addedit-domain').value = 1 ;
+ document.getElementById('radio-addedit-filename').value = 1 ;
+
+ // set the data into the fields
+ var domain = document.getElementById("asf-addedit-domain");
+ var filename = document.getElementById("asf-addedit-filename");
+
+ domain.value = currentdomain ;
+ filename.value = currentfilename ;
+
+ } // else, nothing to fill, radio button set to 0
+ else
+ {
+ radio_domain_all.checked;
+ radio_filename_all.checked;
+
+ //set radio button to state 0 (if the user never clic on a radio, the value is null, even if the radio is not checked)
+ document.getElementById('radio-addedit-domain').value = 0 ;
+ document.getElementById('radio-addedit-filename').value = 0 ;
+ }
+
+ sizeToContent();
+ this.asf_toggleradio_domain();
+ this.asf_toggleradio_filename();
+ },
+
+
+ edit_load: function () {
+ sizeToContent();
+ this.asf_loadData();
+ this.asf_toggleradio_domain();
+ this.asf_toggleradio_filename();
+ },
+
+
+ loadUnicodeString: function (pref_place) {
+ try
+ {
+ return this.prefManager.getComplexValue(pref_place, Components.interfaces.nsISupportsString).data;
+ }
+ catch (e)
+ { }
+ return "";
+ },
+
+
+ browsedir_addedit: function () {
+ var current_folder_input = document.getElementById("asf-addedit-folder").value;
+
+ const nsIFilePicker = Components.interfaces.nsIFilePicker;
+ var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
+
+ var filepickerdescription = this.stringbundle.GetStringFromName("select_folder");
+ fp.init(window, filepickerdescription, nsIFilePicker.modeGetFolder);
+ //fp.appendFilters(nsIFilePicker.filterAll | nsIFilePicker.filterText);
+
+ // locate current directory
+ current_folder_input = this.createValidDestination(current_folder_input);
+ if (current_folder_input !== false) fp.displayDirectory = current_folder_input;
+
+ var rv = fp.show();
+ if (rv == nsIFilePicker.returnOK)
+ {
+ var asf_url = fp.file.path;
+
+ // Set the data into the input box
+ document.getElementById("asf-addedit-folder").value = asf_url;
+ }
+ },
+
+
+ createValidDestination: function (path) {
+ if (!path) return false;
+ if (this.trim(path).length==0) return false;
+ var directory = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
+
+ try
+ {
+ directory.initWithPath(path);
+ if (directory.exists())
+ return directory;
+ }
+ catch(e) {return false;}
+ return false;
+ },
+
+
+ asf_loadData: function () {
+ // enable or disable the local saving path user input
+ var select_variable_mode = window.opener.document.getElementById("asf-variablemode");
+ var select_folder_input = document.getElementById("asf-addedit-folder");
+ if (select_variable_mode.checked == true)
+ {
+ select_folder_input.readOnly = false;
+ }
+ if (select_variable_mode.checked == false)
+ {
+ select_folder_input.readOnly = true;
+ }
+
+
+ var tree = window.opener.document.getElementById("asf-filterList") ;
+ var idx = tree.currentIndex;
+ if (idx < 0)
+ {
+ return;
+ }
+
+ var domain = tree.view.getCellText(idx,tree.columns.getColumnAt(0));
+ var filename = tree.view.getCellText(idx,tree.columns.getColumnAt(1));
+ var folder = tree.view.getCellText(idx,tree.columns.getColumnAt(2));
+ var radio_domain = document.getElementById("radio-addedit-domain") ;
+ var radio_filename = document.getElementById("radio-addedit-filename") ;
+
+ if (domain == "/.*/")
+ {
+ radio_domain.value = 0;
+ }
+ else
+ {
+ radio_domain.value = 1;
+ document.getElementById("asf-addedit-domain").value = domain;
+
+ document.getElementById("asf-addedit-domain-regexp").checked = this.is_regexp(document.getElementById("asf-addedit-domain").value);
+ }
+
+ if (filename == "/.*/")
+ {
+ radio_filename.value = 0;
+ }
+ else
+ {
+ radio_filename.value = 1;
+ document.getElementById("asf-addedit-filename").value = filename;
+
+ document.getElementById("asf-addedit-filename-regexp").checked = this.is_regexp(document.getElementById("asf-addedit-filename").value);
+ }
+
+ document.getElementById("asf-addedit-folder").value = folder ;
+ },
+
+
+ asf_toggleradio_domain: function () {
+ var select_addedit_radio_all = document.getElementById("asf-addedit-radio-domain-all");
+ var select_addedit_radio = document.getElementById("asf-addedit-radio-domain");
+ var select_addedit_input = document.getElementById("asf-addedit-domain");
+ var select_addedit_chk = document.getElementById("asf-addedit-domain-regexp");
+
+ if (select_addedit_radio_all.selected == true)
+ {
+ select_addedit_input.disabled = true;
+ select_addedit_chk.disabled = true;
+ }
+
+ if (select_addedit_radio.selected == true)
+ {
+ select_addedit_input.disabled = false;
+ select_addedit_chk.disabled = false;
+ }
+ },
+
+
+ asf_toggleradio_filename: function () {
+ var select_addedit_radio_all = document.getElementById("asf-addedit-radio-filename-all");
+ var select_addedit_radio = document.getElementById("asf-addedit-radio-filename");
+ var select_addedit_input = document.getElementById("asf-addedit-filename");
+ var select_addedit_chk = document.getElementById("asf-addedit-filename-regexp");
+
+ if (select_addedit_radio_all.selected == true)
+ {
+ select_addedit_input.disabled = true;
+ select_addedit_chk.disabled = true;
+ }
+
+ if (select_addedit_radio.selected == true)
+ {
+ select_addedit_input.disabled = false;
+ select_addedit_chk.disabled = false;
+ }
+ },
+
+
+ // add the / at the beginning and the end of the input_regexp if id_regexp id checked
+ makeRegexp: function (id_regexp, input_regexp) {
+
+ var filter = document.getElementById(input_regexp);
+
+ if (document.getElementById(id_regexp).checked)
+ {
+ if (filter.value.substring(0,1) != "/") // let's add the /
+ {
+ filter.value = "/" + filter.value;
+ }
+ if (filter.value.substr(filter.value.length - 1, 1) != "/")
+ {
+ filter.value = filter.value + "/";
+ }
+ }
+ else
+ {
+ if (filter.value.substring(0,1) == "/") // then delete the /
+ {
+ filter.value = filter.value.substring(1, filter.value.length);
+ }
+ if (filter.value.substr(filter.value.length - 1, 1) == "/")
+ {
+ filter.value = filter.value.substring(0, filter.value.length -1);
+ }
+ }
+ document.getElementById(input_regexp).value = filter.value;
+ },
+
+
+ is_regexp: function (string) {
+
+ if ((string.substring(0,1) == "/") && (string.substr(string.length - 1, 1) == "/"))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ },
+
+
+ // on text change, check if the text is still regexp, else unchecked the checkbox
+ testRegexp: function (id_regexp, input_regexp) {
+ var filter = document.getElementById(input_regexp);
+
+ if ((filter.value.substring(0,1) != "/") || (filter.value.substr(filter.value.length - 1, 1) != "/"))
+ {
+ document.getElementById(id_regexp).checked = false;
+ }
+ },
+
+
+ trim: function (string) {
+ return string.replace(/(^\s*)|(\s*$)/g,'');
+ },
+
+
+ //
+ // ADD new filter in tree
+ //
+ asf_add: function () {
+ var instantApply = this.prefManager.getBoolPref("browser.preferences.instantApply");
+ // get the domain
+ //
+ var domain_radio = document.getElementById('radio-addedit-domain');
+ var domain = document.getElementById('asf-addedit-domain');
+ var domain_regexp = document.getElementById('asf-addedit-domain-regexp');
+ if (domain_radio.value == 0)
+ {
+ var rule = "/.*/";
+ }
+ else
+ {
+ var rule = this.trim(domain.value);
+ }
+
+ if (rule != "")
+ {
+ var domain = rule;
+ }
+ else
+ {
+ var err_domain = this.stringbundle.GetStringFromName("nodata.domain");
+ alert(err_domain);
+ var error = true;
+ }
+
+ // get the filename
+ //
+ var filename_radio = document.getElementById('radio-addedit-filename');
+ var filename = document.getElementById('asf-addedit-filename');
+ var filename_regexp = document.getElementById('asf-addedit-filename-regexp');
+ if (filename_radio.value == 0)
+ {
+ var rule = "/.*/";
+ }
+ else
+ {
+ var rule = this.trim(filename.value);
+ }
+
+ if (rule != "")
+ {
+ var filename = rule;
+ }
+ else
+ {
+ var err_filename = this.stringbundle.GetStringFromName("nodata.filename");
+ alert(err_filename);
+ var error = true;
+ }
+
+
+ //get the foldername
+ //
+ var folder = document.getElementById('asf-addedit-folder');
+
+ var rule = this.trim(folder.value);
+ if (rule == "")
+ {
+ var err_folder = this.stringbundle.GetStringFromName("nodata.folder");
+ alert(err_folder);
+ var error = true;
+ }
+ else
+ {
+ var folder = rule;
+ }
+
+
+
+ if (error != true)
+ {
+ // adding into the tree
+ var filter = window.opener.document.getElementById('asf-filterList');
+ var rules = window.opener.document.getElementById('asf-filterChilds');
+ var item = window.opener.document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'treeitem');
+ var row = window.opener.document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'treerow');
+ var c1 = window.opener.document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'treecell');
+ var c2 = window.opener.document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'treecell');
+ var c3 = window.opener.document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'treecell');
+ var c4 = window.opener.document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'treecell');
+ c1.setAttribute('label', domain);
+ c2.setAttribute('label', filename);
+ c3.setAttribute('label', folder);
+ c4.setAttribute('value', true);
+ c1.setAttribute('editable', false);
+ c2.setAttribute('editable', false);
+ c3.setAttribute('editable', false);
+ row.appendChild(c1);
+ row.appendChild(c2);
+ row.appendChild(c3);
+ row.appendChild(c4);
+ item.appendChild(row);
+ rules.appendChild(item);
+
+ //select the new filter
+ var idx = rules.childNodes.length-1;
+ filter.view.selection.select(idx);
+ filter.boxObject.ensureRowIsVisible(idx);
+
+ filter.focus();
+ window.close();
+
+ //autosave when adding a filter
+ if (instantApply)
+ {
+ //save the filters
+ window.opener.automatic_save_folder.asf_savefilters();
+ }
+
+ // set the row's color
+ window.opener.automatic_save_folder.set_row_color();
+ }
+ },
+
+
+ asf_edit: function () {
+ var instantApply = this.prefManager.getBoolPref("browser.preferences.instantApply");
+ // get the domain
+ //
+ var domain_radio = document.getElementById('radio-addedit-domain');
+ var domain = document.getElementById('asf-addedit-domain');
+ var domain_regexp = document.getElementById('asf-addedit-domain-regexp');
+ if (domain_radio.value == 0)
+ {
+ var rule = "/.*/";
+ }
+ else
+ {
+ var rule = this.trim(domain.value);
+ }
+
+ if (rule != "")
+ {
+ var domain = rule;
+ }
+ else
+ {
+ var err_domain = this.stringbundle.GetStringFromName("nodata.domain");
+ alert(err_domain);
+ var error = true;
+ }
+
+ // get the filename
+ //
+ var filename_radio = document.getElementById('radio-addedit-filename');
+ var filename = document.getElementById('asf-addedit-filename');
+ var filename_regexp = document.getElementById('asf-addedit-filename-regexp');
+ if (filename_radio.value == 0)
+ {
+ var rule = "/.*/";
+ }
+ else
+ {
+ var rule = this.trim(filename.value);
+ }
+
+ if (rule != "")
+ {
+ var filename = rule;
+ }
+ else
+ {
+ var err_filename = this.stringbundle.GetStringFromName("nodata.filename");
+ alert(err_filename);
+ var error = true;
+ }
+
+
+ //get the foldername
+ //
+ var folder = document.getElementById('asf-addedit-folder');
+
+ var rule = this.trim(folder.value);
+ if (rule == "")
+ {
+ var err_folder = this.stringbundle.GetStringFromName("nodata.folder");
+ alert(err_folder);
+ var error = true;
+ }
+ else
+ {
+ var folder = rule;
+ }
+
+ if (error != true)
+ {
+ var tree = window.opener.document.getElementById("asf-filterList") ;
+ var idx = tree.currentIndex;
+ if (idx < 0)
+ {
+ return;
+ }
+
+
+ var theValue = tree.treeBoxObject.view.getItemAtIndex(idx);
+ var test = theValue.firstChild.childNodes[0].getAttribute("label");
+
+ theValue.firstChild.childNodes[0].setAttribute("label", domain );
+ theValue.firstChild.childNodes[1].setAttribute("label", filename );
+ theValue.firstChild.childNodes[2].setAttribute("label", folder );
+
+ //select the edited filter
+ tree.view.selection.select(idx);
+ tree.boxObject.ensureRowIsVisible(idx);
+
+ tree.focus();
+ window.close();
+
+ //autosave when editing a filter
+ if (instantApply)
+ {
+ //save the filters
+ window.opener.automatic_save_folder.asf_savefilters();
+ }
+
+ // set the row's color
+ window.opener.automatic_save_folder.set_row_color();
+ }
+ },
+
+
+ //
+ // the 2 functions bellow are the drop-down path menu for the "add & edit" window
+ //
+ read_all_filterpath: function() {
+ var list = document.getElementById('asf-addedit-folder');
+ var menupopup = document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'menupopup');
+ var tree = window.opener.document.getElementById("asf-filterList");
+
+ // Check if there is any filter in list
+ var nbrfilters = tree.view.rowCount;
+ var path = "";
+
+
+ // Delete active list before repopulating (righ-clicking the menu sends an onLoad event again)
+ 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();
+ var defaultfolder = window.opener.document.getElementById("asf-default-folder").value;
+ pathlist[0] = defaultfolder;
+ var j = 0;
+ for (var i = 0; i < nbrfilters; i++)
+ {
+ // read the filter number i
+ path = tree.view.getCellText(i,tree.columns.getColumnAt("2"));
+
+ if (this.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];
+
+ var menuitem = document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'menuitem');
+ menuitem.setAttribute('label', path);
+ menuitem.setAttribute('crop', 'center');
+ menuitem.setAttribute('value', path);
+ menupopup.appendChild(menuitem);
+ }
+
+ // Populate the path list into the menu
+ list.appendChild(menupopup);
+
+ },
+
+
+ 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;
+ }
+
+
};
\ No newline at end of file
diff --git a/content/asf_download.js b/content/asf_download.js
index fb55b20..1c782ee 100644
--- a/content/asf_download.js
+++ b/content/asf_download.js
@@ -1,7 +1,7 @@
/* ***** BEGIN LICENSE BLOCK *****
Automatic Save Folder
Copyright (C) 2007-2010 Éric Cassar (Cyan).
- 2009 Ted Gifford - Dynamic variable capturing
+ 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
@@ -30,31 +30,31 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
firefoxversion : "",
main: function () {
-
-
+
+
// Setting private variables usable in this function
- var prefManager = automatic_save_folder.prefManager;
+ var prefManager = automatic_save_folder.prefManager;
var versionChecker = automatic_save_folder.versionChecker;
var appInfo = automatic_save_folder.appInfo;
- if(this.versionChecker.compare(this.appInfo.version, "3.0") >= 0)
+ if(this.versionChecker.compare(this.appInfo.version, "3.0") >= 0)
{
this.firefoxversion = "3";
}
- else
+ else
{
this.firefoxversion = "2";
}
// Enable Private Browsing support with filepicker - Thanks to Ehsan Akhgari at http://ehsanakhgari.org/
- if (this.versionChecker.compare(this.appInfo.version, "3.5") >= 0)
+ if (this.versionChecker.compare(this.appInfo.version, "3.5") >= 0)
{
Components.utils.import("resource://gre/modules/DownloadLastDir.jsm");
}
// Check if there is any filter in list
- var nbrfilters = prefManager.getIntPref("extensions.asf.filtersNumber");
-
-
+ 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 ;
@@ -68,18 +68,18 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
// load prefmanager data
- var savetype = prefManager.getIntPref("extensions.asf.savetype");
+ var savetype = prefManager.getIntPref("extensions.asf.savetype");
var lastdir = prefManager.getBoolPref("extensions.asf.lastdir"); // for Firefox2 : set save as Ctrl+S too
- var defaultfolder = this.loadUnicodeString("extensions.asf.defaultfolder");
+ var defaultfolder = this.loadUnicodeString("extensions.asf.defaultfolder");
var keeptemp = prefManager.getBoolPref("extensions.asf.keeptemp");
var tempdomain = this.loadUnicodeString("extensions.asf.tempdomain"); // hosted domain from last saved file
var variable_mode = prefManager.getBoolPref("extensions.asf.variablemode"); // enable Variables in folder creation (dynamic Folders)
- var dialogaccept = prefManager.getBoolPref("extensions.asf.dialogaccept");
- var dialogacceptFiltered = prefManager.getBoolPref("extensions.asf.dialogacceptFiltered");
- var use_currentURL = prefManager.getBoolPref("extensions.asf.usecurrenturl");
+ var dialogaccept = prefManager.getBoolPref("extensions.asf.dialogaccept");
+ var dialogacceptFiltered = prefManager.getBoolPref("extensions.asf.dialogacceptFiltered");
+ var use_currentURL = prefManager.getBoolPref("extensions.asf.usecurrenturl");
// If variable/Dynamic folders mode is ON, let's replace the variables to create the new defaultfolder
- if (variable_mode == true)
+ if (variable_mode == true)
{
defaultfolder = this.createfolder(defaultfolder);
}
@@ -97,19 +97,19 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
// load filters data from prefmanager into filters[]
- // filters[filternumber][label]
+ // filters[filternumber][label]
var filters = new Array();
for ( var i = 0 ; i < nbrfilters ; i++)
{
var dom = this.loadUnicodeString("extensions.asf.filters"+ i +".domain");
- var fil = this.loadUnicodeString("extensions.asf.filters"+ i +".filename");
- var fol = this.loadUnicodeString("extensions.asf.filters"+ i +".folder");
- var act = prefManager.getBoolPref("extensions.asf.filters"+ i +".active");
+ var fil = this.loadUnicodeString("extensions.asf.filters"+ i +".filename");
+ var fol = this.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 ;
@@ -121,7 +121,7 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
{
dom_regexp = false ; // reset the matching string for the "for" loop
file_regexp = false ; // same as above
- // Check the domain
+ // Check the domain
dom_regexp = this.test_regexp(filters[i][0], domain); // hosted Domain
// Check the current website URL if hosted domain checking returned false.
@@ -133,10 +133,10 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
var currentURL = uCT.parentNode.defaultView.opener.location.host; // look for the current website URL in the DOM.
dom_regexp = this.test_regexp(filters[i][0], currentURL); // check the filter domain with the current website URL only if the hosted domain doesn't match
}
- catch (e) { } // if there is no location.host data (tab is closed or script redirection), use the default folder as there are no filter's domain or current URL domain.
+ catch (e) { } // if there is no location.host data (tab is closed or script redirection), use the default folder as there are no filter's domain or current URL domain.
}
- // Check the filename
+ // Check the filename
file_regexp = this.test_regexp(filters[i][1], filename); // Filename
// debug
@@ -145,7 +145,7 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
{
var idx = i;
break;
- }
+ }
}
} // end filters loop
@@ -156,7 +156,7 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
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
this.set_savepath(defaultfolder);
- }
+ }
else // else, if domain is the same as the last, and the user checked "use the same folder if same domain"
{
if (this.firefoxversion == "3")
@@ -193,12 +193,12 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
this.set_savepath(lastpath);
}
}
- else // if a filter is found
+ 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)
+ if (variable_mode == true)
{
folder = this.createfolder(folder, idx);
}
@@ -229,40 +229,40 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
if (dialogaccept)
{
window.close();
- return dialog.onOK();
+ return dialog.onOK();
}
else
{
// show or hide the asf option on saving window
this.show_dloptions();
- this.check_uCTOption();
+ this.check_uCTOption(true);
}
-
+
return false;
},
set_savepath: function(path) {
- var folderList = this.prefManager.getIntPref("browser.download.folderList");
+ var folderList = this.prefManager.getIntPref("browser.download.folderList");
var lastdir = this.prefManager.getBoolPref("extensions.asf.lastdir"); // for Firefox2 : set save as Ctrl+S too
- var useDownloadDir = this.prefManager.getBoolPref("browser.download.useDownloadDir");
+ var useDownloadDir = this.prefManager.getBoolPref("browser.download.useDownloadDir");
var folderList = this.prefManager.getIntPref("browser.download.folderList");
var directory = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
directory.initWithPath(path);
// Check if the user use the "do not show file explorer" to automatically save to "desktop" or "downloads" and force the suggested path to those folders instead of filtered path
- if (useDownloadDir == true)
+ if (useDownloadDir == true)
{
var desk = Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties)
.get("Desk", Components.interfaces.nsILocalFile);
-
- if (this.firefoxversion == 3)
+
+ if (this.firefoxversion == 3)
{
var dnldMgr = Components.classes["@mozilla.org/download-manager;1"]
.getService(Components.interfaces.nsIDownloadManager);
- var supportDownloadLabel = !dnldMgr.defaultDownloadsDirectory.equals(desk);
+ var supportDownloadLabel = !dnldMgr.defaultDownloadsDirectory.equals(desk);
if ( (folderList == 0) || (folderList == 1 && !supportDownloadLabel) ) // if desktop or if OS doesn't support default Download dir
{
@@ -281,12 +281,12 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
this.saveUnicodeString("browser.download.dir", directory.path);
if (lastdir)
- this.saveUnicodeString("browser.download.lastDir", directory.path);
+ this.saveUnicodeString("browser.download.lastDir", directory.path);
}
if (this.firefoxversion == 3)
{
-
+
var inPrivateBrowsing = false;
try {
var pbs = Components.classes["@mozilla.org/privatebrowsing;1"]
@@ -301,18 +301,18 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
gDownloadLastDir.file = directory;
}
else
- {
+ {
this.saveUnicodeString("browser.download.lastDir", directory.path);
if (folderList == 2)
this.saveUnicodeString("browser.download.dir", directory.path);
}
- }
+ }
},
loadUnicodeString: function (pref_place) {
- try
+ try
{
return this.prefManager.getComplexValue(pref_place, Components.interfaces.nsISupportsString).data;
}
@@ -327,7 +327,7 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
.createInstance(Components.interfaces.nsISupportsString);
str.data = pref_data;
this.prefManager.setComplexValue(pref_place, Components.interfaces.nsISupportsString, str);
- },
+ },
createfolder: function (path, idx) {
@@ -338,16 +338,18 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
Date.prototype.getWeek = function() // Add the getWeek() function do date()
{
var onejan = new Date(this.getFullYear(),0,1);
- return Math.ceil((((this - onejan) / 86400000) + onejan.getDay()+1)/7);
- }
+ var week = Math.ceil((((this - onejan) / 86400000) + onejan.getDay()+1)/7);
+ if (onejan.getDay() > 4) week--; // if the first week does not contain a thrusday, it's not the first week (and return as week 0)
+ return week;
+ }
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(Components.interfaces.nsIStringBundleService).
+ getService(Components.interfaces.nsIStringBundleService).
createBundle('chrome://asf/locale/asf.properties');
-
+
var fullmonthname = new Array();
var abbrmonthname = new Array();
var fulldayname = new Array();
@@ -366,20 +368,20 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
const ZERO = "0"; // leading zero
- // load the domain and the filename of the saved file
+ // 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 = "";
+ var asf_filename = "";
if (idx) // If a filter match, idx is true
- {
+ {
asf_domain = this.loadUnicodeString("extensions.asf.filters"+ idx +".domain");
asf_filename = this.loadUnicodeString("extensions.asf.filters"+ idx +".filename");
}
@@ -390,10 +392,10 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
}
- var dom_regexp = this.test_regexp(asf_domain, document.getElementById("source").value);
- var file_regexp = this.test_regexp(asf_filename, filename);
-
-// Ted Gifford, start block
+ var dom_regexp = this.test_regexp(asf_domain, document.getElementById("source").value);
+ var file_regexp = this.test_regexp(asf_filename, filename);
+
+// Ted Gifford, start block
// String capture in filename with $<1-9>f
try {
//alert(file_regexp.length);
@@ -423,7 +425,7 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
{
asf_domain = asf_domain.substring(1, asf_domain.length);
asf_domain = asf_domain.substring(0, asf_domain.length -1);
- }
+ }
// Trim the / / if filename is regexp
if (this.is_regexp(asf_filename))
{
@@ -444,14 +446,14 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
var datareg = "";
var result = new Array();
var matchreplace = new Array();
- for (var i = 0, len = matches.length; i < len; i++)
+ 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)
+ if (result == null)
{
matchreplace[i] = ""; // if no result, replace with nothing instead of null
}
@@ -461,13 +463,13 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
}
//alert("matchreplace["+i+"]="+matchreplace[i]);
}
- for (var i = 0, len = matches.length; i < len; 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 )
@@ -479,14 +481,14 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
var datareg = "";
var result = new Array();
var matchreplace = new Array();
- for (var i = 0, len = matches.length; i < len; i++)
+ 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)
+ if (result == null)
{
matchreplace[i] = ""; // if no result, replace with nothing instead of null
}
@@ -496,7 +498,7 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
}
//alert("matchreplace["+i+"]="+matchreplace[i]);
}
- for (var i = 0, len = matches.length; i < len; i++)
+ for (var i = 0, len = matches.length; i < len; i++)
{
path = path.replace(matches[i], matchreplace[i]); // replace each variable in the path
}
@@ -506,7 +508,7 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
// remove special characters from filters :
- // forbidden on windows \ / : * ? " < > |
+ // forbidden on windows \ / : * ? " < > |
if (navigator.appVersion.indexOf("Win")!=-1) // = Windows
{
asf_domain = asf_domain.replace(/[\/\:\*\?\"\<\>\|]/g,'');
@@ -519,7 +521,7 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
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
@@ -551,23 +553,23 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
// 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)
-/*
+/*
var directory = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
directory.initWithPath(path);
- if (directory.exists())
+ if (directory.exists())
{
return path;
}
else // if it doesn't exist, create it
- {
- if( !directory.exists() || !directory.isDirectory() )
- {
+ {
+ if( !directory.exists() || !directory.isDirectory() )
+ {
directory.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0777);
}
return path;
}
-*/
+*/
},
@@ -603,7 +605,7 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
}
if (this.firefoxversion == 3)
{
-
+
var inPrivateBrowsing = false;
try {
var pbs = Components.classes["@mozilla.org/privatebrowsing;1"]
@@ -618,11 +620,11 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
folder = gDownloadLastDir.file.path;
}
else
- {
+ {
folder = this.loadUnicodeString("browser.download.lastDir");
}
- }
+ }
@@ -650,11 +652,11 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
//now, if the user checked the option to view asf on saving window, set it to visible
- if(asf_viewdloption == true)
+ if(asf_viewdloption == true)
{
if(asf_viewdloptionType == 0) asf_dloptions.style.visibility = "visible";
- if(asf_viewdloptionType == 1)
+ if(asf_viewdloptionType == 1)
{
asf_dloptions.style.visibility = "visible";
document.getElementById('asf_dloptions_content').style.visibility = "collapse";
@@ -668,6 +670,10 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
this.read_all_filterpath();
asf_radiogroup_pathselect.style.visibility = "visible";
}
+ else
+ {
+ asf_radiogroup_pathselect.style.visibility = "collapse";
+ }
// Check if the user use the "do not show file explorer" to automatically save to "desktop" or "downloads" and force the suggested path to those folders instead of found filters
if((useDownloadDir == true) && (folderList != 2)) // if set to desktop or Download
@@ -681,12 +687,12 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
asf_radio_savepath.disabled = false;
asf_radiogroup_pathselect.disabled = false;
asf_folder_list.disabled = false;
- }
-
+ }
+
// 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";
+ asf_dloptions.style.maxWidth = screen.width -200 +"px";
}
},
@@ -698,13 +704,13 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
},
- check_uCTOption: function () {
+ check_uCTOption: function (FirstTime) {
// Check if the user change the unkownContentType option (open with, save as, save with a download manager, etc.)
var save = document.getElementById("save").selected;
var asf_radio_savepath = document.getElementById('asf_radio_savepath');
var asf_radiogroup_pathselect = document.getElementById('asf_radiogroup_pathselect');
var asf_folder_list = document.getElementById('asf_folder_list');
- var asf_viewdloption = this.prefManager.getBoolPref("extensions.asf.viewdloption");
+ var asf_viewdloption = this.prefManager.getBoolPref("extensions.asf.viewdloption");
var asf_viewdloptionType = this.prefManager.getIntPref("extensions.asf.viewdloptionType");
// Workaround for bug 439323 (if call when not needed, dosen't work anymore)
@@ -741,7 +747,7 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
}
}
- if (initialState != document.getElementById('asf_dloptions_content').style.visibility)
+ if ( (initialState != document.getElementById('asf_dloptions_content').style.visibility) && (FirstTime != true) ) // FirstTime is also a workaround of sizeToContent bug (which is called onLoad uCT)
{
window.sizeToContent();
}
@@ -753,7 +759,7 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
val = val.replace(/\\/g,'\\\\');
var test_regexp = new RegExp("^"+val+"$");
var data = "";
- for(var i=0;i<arr.length;i++)
+ for(var i=0;i<arr.length;i++)
{
if(test_regexp.test(arr[i])) return i;
}
@@ -771,7 +777,7 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
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--)
+ for (var i=list.childNodes.length-1 ; i>=0 ; i--)
{
list.removeChild(list.childNodes[i]);
}
@@ -787,14 +793,14 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
path = this.loadUnicodeString("extensions.asf.filters"+ i +".folder");
path = variable_mode == true? this.createfolder(path, i) : path;
- if (this.indexInArray(pathlist, path) < 0)
- {
+ if (this.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();
+ if (pathlist_sort_alpha) pathlist.sort();
for (var i = 0; i < pathlist.length; i++)
@@ -816,7 +822,7 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
asf_toggle_savepath: function () {
-
+
var asf_savefolder = document.getElementById('asf_savefolder');
var asf_lastpath = document.getElementById('asf_lastpath');
var asf_pathselect = document.getElementById('asf_pathselect');
@@ -840,12 +846,12 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
}
this.set_savepath(userchoice);
-
+
},
- asf_select_savepath: function () {
-
+ asf_select_savepath: function () {
+
// check the third radio choice
var asf_radio_savepath = document.getElementById('asf_radio_savepath');
var asf_pathselect = document.getElementById('asf_pathselect');
@@ -902,13 +908,13 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
// }
// return(false);
-
-// Ted Gifford, start block
- var res = string.match(test_regexp);
- if (res) return res;
- return false
-// Ted Gifford, end block
-
+
+// Ted Gifford, start block
+ var res = string.match(test_regexp);
+ if (res) return res;
+ return false
+// Ted Gifford, end block
+
},
@@ -925,16 +931,15 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
};
-
+
addEventListener( // Autoload
"load", // After OnLoad from overlay_unknownContentType.xul file
function(){ automatic_save_folder.main(); }, // Run main from automatic_save_folder to check the filters
false
- );
-
+ );
+
addEventListener(
"command", // After a click in the unknownContentType.xul, check if the user changed the saving option (save, open, etc.)
function(){ automatic_save_folder.check_uCTOption(); }, // Run main from automatic_save_folder to check the filters
false
- );
-
\ No newline at end of file
+ );
diff --git a/content/asf_right_click.js b/content/asf_right_click.js
index 55d24b2..e29590f 100644
--- a/content/asf_right_click.js
+++ b/content/asf_right_click.js
@@ -1,837 +1,837 @@
-/* ***** BEGIN LICENSE BLOCK *****
-Automatic Save Folder
-Copyright (C) 2007-2010 Éric 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;
-// alert (ORIG_getTargetFile); // uncomment to get the Firefox's getTargetFile current version in an alert box at Firefox launch. Can be copy/pasted.
- // or can be found in install folder : Mozilla Firefox\chrome\toolkit.jar\content\global\contentAreaUtils.js
-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),
-
- firefoxversion : "",
-
- rightclick_init: function() {
- if (!asf_rightclick_loaded)
- {
- asf_rightclick_loaded = true;
-
- // Right-click feature doesn't work on Firefox 2 (Can't detect installed add-on and prevent conflict with Download Sort)
- if (this.versionChecker.compare(this.appInfo.version, "3.0") >= 0)
- {
- //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 = this.prefManager.getCharPref("extensions.enabledItems");
- var dsort_GUUID = "{D9808C4D-1CF5-4f67-8DB2-12CF78BBA23F}";
- var DownloadSort = enabledItems.indexOf(dsort_GUUID,0);
-
- if (DownloadSort == -1) // Download Sort is not enabled, load ASF rightclick replacement && Firefox 2.0 min
- {
- // 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. (original from Firefox 3.5.4)
- window.getTargetFile = this.asf_getTargetFile;
-
- // Starting from firefox 3.0 there is a timeout when downloading with right-click to read header(Content-Disposition:) to rename the file in the file_explorer suggested filename.
- // When timeout is set to 1000 ms (default), ASF right-click filtering is not working.
- // When timeout is set to 0ms, ASF right-click filtering is working, but header renaming is not working anymore.
- // And when set to ~8ms, Header renaming is working but ASF is filtering on the previous filename (before the renaming).
-
- // Set to 0 only when the user want to use it
- var asf_rightclicktimeout = this.prefManager.getBoolPref("extensions.asf.rightclicktimeout");
- this.prefManager.setIntPref("browser.download.saveLinkAsFilenameTimeout", asf_rightclicktimeout == true ? 0 : 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_main(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_main: function(aFpP) {
-
- //check if the rightclick filtering is enabled
- var userightclick = this.prefManager.getBoolPref("extensions.asf.userightclick");
- if (userightclick)
- {
- //alert ("debug full uri : "+aFpP.fileInfo.uri.spec);
- //alert("ok");
-
- // Setting private variables usable in this function
- var prefManager = this.prefManager;
- var versionChecker = this.versionChecker;
- var appInfo = this.appInfo;
-
- if(this.versionChecker.compare(this.appInfo.version, "3.0") >= 0)
- {
- this.firefoxversion = "3";
- }
- else
- {
- this.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 ;
-
- try
- {
- var domain = aFpP.fileInfo.uri.scheme+"://"+aFpP.fileInfo.uri.host ;
- }
- catch(e) // If the saved data is not from an URL, use the current website URL (example : Abduction! add-on screenshot function saving the current page into image)
- {
- var domain = document.getElementById("urlbar").value;
- domain = domain.match(/^(.*?:\/\/)?.*?[^\/]+/);
- domain = domain[0];
- }
- var filename = aFpP.fileInfo.fileName
-
- // For Ctrl+S, if pagename.ext is not on the URL document.title is used as filename, add .htm to the filename
- var page_title = document.title.replace(" - Mozilla Firefox", "");
- if (filename == page_title) filename = filename+".htm";
-
-
- // load prefmanager data
- var savetype = prefManager.getIntPref("extensions.asf.savetype");
- var lastdir = prefManager.getBoolPref("extensions.asf.lastdir");
- var defaultfolder = this.loadUnicodeString("extensions.asf.defaultfolder");
- var keeptemp = prefManager.getBoolPref("extensions.asf.keeptemp");
- var tempdomain = this.loadUnicodeString("extensions.asf.tempdomain");
- var variable_mode = prefManager.getBoolPref("extensions.asf.variablemode");
- var dialogaccept = prefManager.getBoolPref("extensions.asf.dialogaccept");
- var use_currentURL = prefManager.getBoolPref("extensions.asf.usecurrenturl");
-
- // If variable/Dynamic folders mode is ON, let's check the variables and replace to create the new defaultfolder
- if (variable_mode == true)
- {
- defaultfolder = this.createfolder(aFpP, defaultfolder);
- }
-
- // set the last folder path used into asf.lastpath
- if (this.firefoxversion == "3") // take the download.lastDir if it's FF3
- {
- var folder = this.loadUnicodeString("browser.download.lastDir");
- }
- else // else if it's not FF3 (it's 1.5 or 2), read Download.dir
- {
- var folder = this.loadUnicodeString("browser.download.dir");
- }
- this.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 = this.loadUnicodeString("extensions.asf.filters"+ i +".domain");
- var fil = this.loadUnicodeString("extensions.asf.filters"+ i +".filename");
- var fol = this.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 = this.test_regexp(filters[i][0], domain); // hosted Domain
-
- // Check the current website URL if hosted domain checking returned false.
- if (!dom_regexp && use_currentURL)
- {
-
- try
- {
- var currentURL = document.getElementById("urlbar").value;
- dom_regexp = this.test_regexp(filters[i][0], currentURL); // check the filter domain with the current website URL only if the hosted domain doesn't match
- }
- catch (e) { } // if there is no location.host data (tab is closed or script redirection), use the default folder as there are no filter's domain or current URL domain.
- }
-
- // Check the filename
- file_regexp = this.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
- this.set_savepath(defaultfolder);
- }
- else // else, if domain is the same as the last, and the user checked "use the same folder if same domain"
- {
- if (this.firefoxversion == "3")
- {
- var lastpath = this.loadUnicodeString("browser.download.lastDir");
- }
- if (this.firefoxversion == "2")
- {
- var lastpath = this.loadUnicodeString("browser.download.dir");
- }
-
- if (lastpath == "") // if no path is returned (first time using lastDir, or the user reseted the content manually in about:config)
- {
- lastpath = defaultfolder;
- }
- this.set_savepath(lastpath);
- }
- }
- else // else, if savetype == 0 (folder is set to last folder)
- {
- if (this.firefoxversion == "3")
- {
- var lastpath = this.loadUnicodeString("browser.download.lastDir");
- }
- if (this.firefoxversion == "2")
- {
- var lastpath = this.loadUnicodeString("browser.download.dir");
- }
-
- if (lastpath == "") // if no path is returned (first time using lastDir, or the user reseted the content manually in about:config)
- {
- lastpath = defaultfolder;
- }
- this.set_savepath(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)
- {
- folder = this.createfolder(aFpP, folder, idx);
- }
-
- this.set_savepath(folder);
- }
-
- // in every case, set the new file hosted domain to tempdomain if not in private browsing
- var inPrivateBrowsing = false;
- if (this.firefoxversion == 3)
- {
- try {
- var pbs = Components.classes["@mozilla.org/privatebrowsing;1"]
- .getService(Components.interfaces.nsIPrivateBrowsingService);
- inPrivateBrowsing = pbs.privateBrowsingEnabled;
- }
- catch (e) { // nsIPrivateBrowsingService not working on FF2 and 3.0
- }
- }
- if (!inPrivateBrowsing)
- {
- this.saveUnicodeString("extensions.asf.tempdomain", domain);
- }
- }
-
- },
-
-
- set_savepath: function(path) {
- var folderList = this.prefManager.getIntPref("browser.download.folderList");
- var lastdir = this.prefManager.getBoolPref("extensions.asf.lastdir"); // for Firefox2 : set save as Ctrl+S too
-
- var directory = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
- directory.initWithPath(path);
-
-
- if (this.firefoxversion == 2)
- {
-
- this.saveUnicodeString("browser.download.dir", directory.path);
- if (lastdir)
- this.saveUnicodeString("browser.download.lastDir", directory.path);
- }
-
- if (this.firefoxversion == 3)
- {
-
- var inPrivateBrowsing = false;
- try {
- var pbs = Components.classes["@mozilla.org/privatebrowsing;1"]
- .getService(Components.interfaces.nsIPrivateBrowsingService);
- inPrivateBrowsing = pbs.privateBrowsingEnabled;
- }
- catch (e) { // nsIPrivateBrowsingService not working on FF2 and 3.0
- }
-
- if (inPrivateBrowsing && directory)
- {
- gDownloadLastDir.file = directory;
- }
- else
- {
- this.saveUnicodeString("browser.download.lastDir", directory.path);
- if (folderList == 2)
- this.saveUnicodeString("browser.download.dir", directory.path);
- }
-
- }
- },
-
-
- 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;
-
- Date.prototype.getWeek = function() // Add the getWeek() function do date()
- {
- var onejan = new Date(this.getFullYear(),0,1);
- return Math.ceil((((this - onejan) / 86400000) + onejan.getDay()+1)/7);
- }
- 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();
- var fulldayname = new Array();
- var abbrdayname = 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");
- }
- for (var i = 0 ; i<= 6 ; i++)
- {
- fulldayname[i] = stringbundle.GetStringFromName("day"+i+"_full");
- abbrdayname[i] = stringbundle.GetStringFromName("day"+i+"_abbr");
- }
-
-
- const ZERO = "0"; // leading zero
-
- // load the domain and the filename of the saved file
- try
- {
- var domain = aFpP.fileInfo.uri.host ;
- var scheme = aFpP.fileInfo.uri.scheme ;
- }
- catch(e) // If the saved data is not from an URL, use the current website URL (example : Abduction! add-on screenshot function saving the current page into image)
- {
- var domain = document.getElementById("urlbar").value;
- domain = domain.match(/^(.*?:\/\/)?.*?[^\/]+/);
- var scheme = domain[1];
- domain = domain[0];
- }
- var filename = aFpP.fileInfo.fileName ;
- var file_name = aFpP.fileInfo.fileBaseName ;
- var extension = aFpP.fileInfo.fileExt ;
-
- //alert ("domain = "+scheme+"://"+domain);
-
- // 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");
- asf_filename = this.loadUnicodeString("extensions.asf.filters"+ idx +".filename");
- }
- else // no filter is found, use actual Domain and filename without extension
- {
- asf_domain = domain;
- asf_filename = file_name;
- }
-
-
- var dom_regexp = this.test_regexp(asf_domain, scheme+"://"+domain);
- var file_regexp = this.test_regexp(asf_filename, filename);
-
-// Ted Gifford, start block
- // String capture in filename with $<1-9>f
- try {
- //alert(file_regexp.length);
- if (file_regexp.length > 1)
- {
- //alert('munging path: ' + path);
- for (var replace_index = 1; replace_index < file_regexp.length; ++replace_index)
- path = path.replace("$"+replace_index+"f", file_regexp[replace_index]);
- //alert('munged path: ' + path);
- }
- } catch (e) {alert(e);}
- // String capture in domain with $<1-9>d
- try {
- //alert(dom_regexp.length);
- if (dom_regexp.length > 1)
- {
- //alert('munging path: ' + path);
- for (var replace_index = 1; replace_index < dom_regexp.length; ++replace_index)
- path = path.replace("$"+replace_index+"d", dom_regexp[replace_index]);
- //alert('munged path: ' + path);
- }
- } catch (e) {alert(e);}
-// Ted Gifford, end block
-
- // 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);
- }
- // 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);
- }
-
- // 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 = scheme+"://"+domain ;
-
- // 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
- // Week
- .replace(/%W%/g, ((objdate.getWeek()) <10) ? (ZERO + (objdate.getWeek())) : objdate.getWeek()) // = number of the week : 01 to 54
- .replace(/%w%/g, objdate.getDay()) // = Day of the week, from 0 (sunday) to 6 (saturday)
- .replace(/%l%/g, fulldayname[objdate.getDay()]) // = Full day name
- .replace(/%D%/g, abbrdayname[objdate.getDay()]) // = Abbreviated day 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);
- 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)
-/*
- var directory = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
-
- directory.initWithPath(path);
- 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;
- }
- }
-
-
- }
-
- addEventListener( // Autoload
- "load", // After OnLoad from overlay_unknownContentType.xul file
- function(){ automatic_save_folder.rightclick_init(); }, // Run main from automatic_save_folder to check the filters
- false
+/* ***** BEGIN LICENSE BLOCK *****
+Automatic Save Folder
+Copyright (C) 2007-2010 Éric 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;
+// alert (ORIG_getTargetFile); // uncomment to get the Firefox's getTargetFile current version in an alert box at Firefox launch. Can be copy/pasted.
+ // or can be found in install folder : Mozilla Firefox\chrome\toolkit.jar\content\global\contentAreaUtils.js
+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),
+
+ firefoxversion : "",
+
+ rightclick_init: function() {
+ if (!asf_rightclick_loaded)
+ {
+ asf_rightclick_loaded = true;
+
+ // Right-click feature doesn't work on Firefox 2 (Can't detect installed add-on and prevent conflict with Download Sort)
+ if (this.versionChecker.compare(this.appInfo.version, "3.0") >= 0)
+ {
+ //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 = this.prefManager.getCharPref("extensions.enabledItems");
+ var dsort_GUUID = "{D9808C4D-1CF5-4f67-8DB2-12CF78BBA23F}";
+ var DownloadSort = enabledItems.indexOf(dsort_GUUID,0);
+
+ if (DownloadSort == -1) // Download Sort is not enabled, load ASF rightclick replacement && Firefox 2.0 min
+ {
+ // 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. (original from Firefox 3.5.4)
+ window.getTargetFile = this.asf_getTargetFile;
+
+ // Starting from firefox 3.0 there is a timeout when downloading with right-click to read header(Content-Disposition:) to rename the file in the file_explorer suggested filename.
+ // When timeout is set to 1000 ms (default), ASF right-click filtering is not working.
+ // When timeout is set to 0ms, ASF right-click filtering is working, but header renaming is not working anymore.
+ // And when set to ~8ms, Header renaming is working but ASF is filtering on the previous filename (before the renaming).
+
+ // Set to 0 only when the user want to use it
+ var asf_rightclicktimeout = this.prefManager.getBoolPref("extensions.asf.rightclicktimeout");
+ this.prefManager.setIntPref("browser.download.saveLinkAsFilenameTimeout", asf_rightclicktimeout == true ? 0 : 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_main(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_main: function(aFpP) {
+
+ //check if the rightclick filtering is enabled
+ var userightclick = this.prefManager.getBoolPref("extensions.asf.userightclick");
+ if (userightclick)
+ {
+ //alert ("debug full uri : "+aFpP.fileInfo.uri.spec);
+ //alert("ok");
+
+ // Setting private variables usable in this function
+ var prefManager = this.prefManager;
+ var versionChecker = this.versionChecker;
+ var appInfo = this.appInfo;
+
+ if(this.versionChecker.compare(this.appInfo.version, "3.0") >= 0)
+ {
+ this.firefoxversion = "3";
+ }
+ else
+ {
+ this.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 ;
+
+ try
+ {
+ var domain = aFpP.fileInfo.uri.scheme+"://"+aFpP.fileInfo.uri.host ;
+ }
+ catch(e) // If the saved data is not from an URL, use the current website URL (example : Abduction! add-on screenshot function saving the current page into image)
+ {
+ var domain = document.getElementById("urlbar").value;
+ domain = domain.match(/^(.*?:\/\/)?.*?[^\/]+/);
+ domain = domain[0];
+ }
+ var filename = aFpP.fileInfo.fileName
+
+ // For Ctrl+S, if pagename.ext is not on the URL document.title is used as filename, add .htm to the filename
+ var page_title = document.title.replace(" - Mozilla Firefox", "");
+ if (filename == page_title) filename = filename+".htm";
+
+
+ // load prefmanager data
+ var savetype = prefManager.getIntPref("extensions.asf.savetype");
+ var lastdir = prefManager.getBoolPref("extensions.asf.lastdir");
+ var defaultfolder = this.loadUnicodeString("extensions.asf.defaultfolder");
+ var keeptemp = prefManager.getBoolPref("extensions.asf.keeptemp");
+ var tempdomain = this.loadUnicodeString("extensions.asf.tempdomain");
+ var variable_mode = prefManager.getBoolPref("extensions.asf.variablemode");
+ var dialogaccept = prefManager.getBoolPref("extensions.asf.dialogaccept");
+ var use_currentURL = prefManager.getBoolPref("extensions.asf.usecurrenturl");
+
+ // If variable/Dynamic folders mode is ON, let's check the variables and replace to create the new defaultfolder
+ if (variable_mode == true)
+ {
+ defaultfolder = this.createfolder(aFpP, defaultfolder);
+ }
+
+ // set the last folder path used into asf.lastpath
+ if (this.firefoxversion == "3") // take the download.lastDir if it's FF3
+ {
+ var folder = this.loadUnicodeString("browser.download.lastDir");
+ }
+ else // else if it's not FF3 (it's 1.5 or 2), read Download.dir
+ {
+ var folder = this.loadUnicodeString("browser.download.dir");
+ }
+ this.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 = this.loadUnicodeString("extensions.asf.filters"+ i +".domain");
+ var fil = this.loadUnicodeString("extensions.asf.filters"+ i +".filename");
+ var fol = this.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 = this.test_regexp(filters[i][0], domain); // hosted Domain
+
+ // Check the current website URL if hosted domain checking returned false.
+ if (!dom_regexp && use_currentURL)
+ {
+
+ try
+ {
+ var currentURL = document.getElementById("urlbar").value;
+ dom_regexp = this.test_regexp(filters[i][0], currentURL); // check the filter domain with the current website URL only if the hosted domain doesn't match
+ }
+ catch (e) { } // if there is no location.host data (tab is closed or script redirection), use the default folder as there are no filter's domain or current URL domain.
+ }
+
+ // Check the filename
+ file_regexp = this.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
+ this.set_savepath(defaultfolder);
+ }
+ else // else, if domain is the same as the last, and the user checked "use the same folder if same domain"
+ {
+ if (this.firefoxversion == "3")
+ {
+ var lastpath = this.loadUnicodeString("browser.download.lastDir");
+ }
+ if (this.firefoxversion == "2")
+ {
+ var lastpath = this.loadUnicodeString("browser.download.dir");
+ }
+
+ if (lastpath == "") // if no path is returned (first time using lastDir, or the user reseted the content manually in about:config)
+ {
+ lastpath = defaultfolder;
+ }
+ this.set_savepath(lastpath);
+ }
+ }
+ else // else, if savetype == 0 (folder is set to last folder)
+ {
+ if (this.firefoxversion == "3")
+ {
+ var lastpath = this.loadUnicodeString("browser.download.lastDir");
+ }
+ if (this.firefoxversion == "2")
+ {
+ var lastpath = this.loadUnicodeString("browser.download.dir");
+ }
+
+ if (lastpath == "") // if no path is returned (first time using lastDir, or the user reseted the content manually in about:config)
+ {
+ lastpath = defaultfolder;
+ }
+ this.set_savepath(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)
+ {
+ folder = this.createfolder(aFpP, folder, idx);
+ }
+
+ this.set_savepath(folder);
+ }
+
+ // in every case, set the new file hosted domain to tempdomain if not in private browsing
+ var inPrivateBrowsing = false;
+ if (this.firefoxversion == 3)
+ {
+ try {
+ var pbs = Components.classes["@mozilla.org/privatebrowsing;1"]
+ .getService(Components.interfaces.nsIPrivateBrowsingService);
+ inPrivateBrowsing = pbs.privateBrowsingEnabled;
+ }
+ catch (e) { // nsIPrivateBrowsingService not working on FF2 and 3.0
+ }
+ }
+ if (!inPrivateBrowsing)
+ {
+ this.saveUnicodeString("extensions.asf.tempdomain", domain);
+ }
+ }
+
+ },
+
+
+ set_savepath: function(path) {
+ var folderList = this.prefManager.getIntPref("browser.download.folderList");
+ var lastdir = this.prefManager.getBoolPref("extensions.asf.lastdir"); // for Firefox2 : set save as Ctrl+S too
+
+ var directory = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
+ directory.initWithPath(path);
+
+
+ if (this.firefoxversion == 2)
+ {
+
+ this.saveUnicodeString("browser.download.dir", directory.path);
+ if (lastdir)
+ this.saveUnicodeString("browser.download.lastDir", directory.path);
+ }
+
+ if (this.firefoxversion == 3)
+ {
+
+ var inPrivateBrowsing = false;
+ try {
+ var pbs = Components.classes["@mozilla.org/privatebrowsing;1"]
+ .getService(Components.interfaces.nsIPrivateBrowsingService);
+ inPrivateBrowsing = pbs.privateBrowsingEnabled;
+ }
+ catch (e) { // nsIPrivateBrowsingService not working on FF2 and 3.0
+ }
+
+ if (inPrivateBrowsing && directory)
+ {
+ gDownloadLastDir.file = directory;
+ }
+ else
+ {
+ this.saveUnicodeString("browser.download.lastDir", directory.path);
+ if (folderList == 2)
+ this.saveUnicodeString("browser.download.dir", directory.path);
+ }
+
+ }
+ },
+
+
+ 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;
+
+ Date.prototype.getWeek = function() // Add the getWeek() function do date()
+ {
+ var onejan = new Date(this.getFullYear(),0,1);
+ return Math.ceil((((this - onejan) / 86400000) + onejan.getDay()+1)/7);
+ }
+ 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();
+ var fulldayname = new Array();
+ var abbrdayname = 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");
+ }
+ for (var i = 0 ; i<= 6 ; i++)
+ {
+ fulldayname[i] = stringbundle.GetStringFromName("day"+i+"_full");
+ abbrdayname[i] = stringbundle.GetStringFromName("day"+i+"_abbr");
+ }
+
+
+ const ZERO = "0"; // leading zero
+
+ // load the domain and the filename of the saved file
+ try
+ {
+ var domain = aFpP.fileInfo.uri.host ;
+ var scheme = aFpP.fileInfo.uri.scheme ;
+ }
+ catch(e) // If the saved data is not from an URL, use the current website URL (example : Abduction! add-on screenshot function saving the current page into image)
+ {
+ var domain = document.getElementById("urlbar").value;
+ domain = domain.match(/^(.*?:\/\/)?.*?[^\/]+/);
+ var scheme = domain[1];
+ domain = domain[0];
+ }
+ var filename = aFpP.fileInfo.fileName ;
+ var file_name = aFpP.fileInfo.fileBaseName ;
+ var extension = aFpP.fileInfo.fileExt ;
+
+ //alert ("domain = "+scheme+"://"+domain);
+
+ // 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");
+ asf_filename = this.loadUnicodeString("extensions.asf.filters"+ idx +".filename");
+ }
+ else // no filter is found, use actual Domain and filename without extension
+ {
+ asf_domain = domain;
+ asf_filename = file_name;
+ }
+
+
+ var dom_regexp = this.test_regexp(asf_domain, scheme+"://"+domain);
+ var file_regexp = this.test_regexp(asf_filename, filename);
+
+// Ted Gifford, start block
+ // String capture in filename with $<1-9>f
+ try {
+ //alert(file_regexp.length);
+ if (file_regexp.length > 1)
+ {
+ //alert('munging path: ' + path);
+ for (var replace_index = 1; replace_index < file_regexp.length; ++replace_index)
+ path = path.replace("$"+replace_index+"f", file_regexp[replace_index]);
+ //alert('munged path: ' + path);
+ }
+ } catch (e) {alert(e);}
+ // String capture in domain with $<1-9>d
+ try {
+ //alert(dom_regexp.length);
+ if (dom_regexp.length > 1)
+ {
+ //alert('munging path: ' + path);
+ for (var replace_index = 1; replace_index < dom_regexp.length; ++replace_index)
+ path = path.replace("$"+replace_index+"d", dom_regexp[replace_index]);
+ //alert('munged path: ' + path);
+ }
+ } catch (e) {alert(e);}
+// Ted Gifford, end block
+
+ // 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);
+ }
+ // 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);
+ }
+
+ // 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 = scheme+"://"+domain ;
+
+ // 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
+ // Week
+ .replace(/%W%/g, ((objdate.getWeek()) <10) ? (ZERO + (objdate.getWeek())) : objdate.getWeek()) // = number of the week : 01 to 54
+ .replace(/%w%/g, objdate.getDay()) // = Day of the week, from 0 (sunday) to 6 (saturday)
+ .replace(/%l%/g, fulldayname[objdate.getDay()]) // = Full day name
+ .replace(/%D%/g, abbrdayname[objdate.getDay()]) // = Abbreviated day 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);
+ 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)
+/*
+ var directory = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
+
+ directory.initWithPath(path);
+ 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;
+ }
+ }
+
+
+ }
+
+ addEventListener( // Autoload
+ "load", // After OnLoad from overlay_unknownContentType.xul file
+ function(){ automatic_save_folder.rightclick_init(); }, // Run main from automatic_save_folder to check the filters
+ false
);
\ No newline at end of file
diff --git a/content/edit.xul b/content/edit.xul
index 2d15582..fd564b7 100644
--- a/content/edit.xul
+++ b/content/edit.xul
@@ -1,67 +1,67 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- ***** BEGIN LICENSE BLOCK *****
- Copyright 2007-2010 Éric Cassar (Cyan)
-
- This file is part of "Automatic Save Folder".
- You may find the license in the LICENSE file
-
- ***** END LICENSE BLOCK ***** -->
-<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
-<!DOCTYPE dialog SYSTEM "chrome://asf/locale/asf.dtd">
-
-<dialog title="&asf.edit.title;"
- orient="vertical" autostretch="always"
- onload="automatic_save_folder.edit_load();"
- buttons="extra1, extra2, cancel"
- defaultButton="extra1"
- buttonlabelextra1="&buttonlabelextra1;"
- ondialogextra1="automatic_save_folder.asf_edit()"
- ondialogcancel="window.opener.focus;window.close();"
- 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"/>
-<groupbox align="center" orient="horizontal">
- <caption label="&asf.addedit.filter.label;"/>
- <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>
- </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>
- </radiogroup>
- <separator class="thin"/>
-
- <description value="&asf.addedit.folder.label;"/>
- <hbox>
- <menulist editable="true" id="asf-addedit-folder" readonly="true" width="240" onload="automatic_save_folder.read_all_filterpath()" ondblclick="automatic_save_folder.browsedir_addedit()"/>
- <button id="asf-addedit-select-folder" label="&asf.selectfolder.label;" oncommand="automatic_save_folder.browsedir_addedit()"/>
- </hbox>
-
- </vbox>
-</groupbox>
-
-<groupbox align="center" orient="horizontal">
- <caption label="&asf.addedit.help.label;"/>
- <vbox>
- <description value="&asf.addedit.inforegexp1;"/>
- <description value="&asf.addedit.inforegexp2;"/>
- <description value="&asf.addedit.inforegexp3;"/>
- <description value="&asf.addedit.inforegexp4;"/>
- </vbox>
-</groupbox>
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- ***** BEGIN LICENSE BLOCK *****
+ Copyright 2007-2010 Éric Cassar (Cyan)
+
+ This file is part of "Automatic Save Folder".
+ You may find the license in the LICENSE file
+
+ ***** END LICENSE BLOCK ***** -->
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<!DOCTYPE dialog SYSTEM "chrome://asf/locale/asf.dtd">
+
+<dialog title="&asf.edit.title;"
+ orient="vertical" autostretch="always"
+ onload="automatic_save_folder.edit_load();"
+ buttons="extra1, extra2, cancel"
+ defaultButton="extra1"
+ buttonlabelextra1="&buttonlabelextra1;"
+ ondialogextra1="automatic_save_folder.asf_edit()"
+ ondialogcancel="window.opener.focus;window.close();"
+ 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"/>
+<groupbox align="center" orient="horizontal">
+ <caption label="&asf.addedit.filter.label;"/>
+ <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>
+ </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>
+ </radiogroup>
+ <separator class="thin"/>
+
+ <description value="&asf.addedit.folder.label;"/>
+ <hbox>
+ <menulist editable="true" id="asf-addedit-folder" readonly="true" width="240" onload="automatic_save_folder.read_all_filterpath()" ondblclick="automatic_save_folder.browsedir_addedit()"/>
+ <button id="asf-addedit-select-folder" label="&asf.selectfolder.label;" oncommand="automatic_save_folder.browsedir_addedit()"/>
+ </hbox>
+
+ </vbox>
+</groupbox>
+
+<groupbox align="center" orient="horizontal">
+ <caption label="&asf.addedit.help.label;"/>
+ <vbox>
+ <description value="&asf.addedit.inforegexp1;"/>
+ <description value="&asf.addedit.inforegexp2;"/>
+ <description value="&asf.addedit.inforegexp3;"/>
+ <description value="&asf.addedit.inforegexp4;"/>
+ </vbox>
+</groupbox>
</dialog>
\ No newline at end of file
diff --git a/content/help/about.xhtml b/content/help/about.xhtml
index 0438490..a44ed86 100644
--- a/content/help/about.xhtml
+++ b/content/help/about.xhtml
@@ -1,106 +1,106 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
- "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" [
-<!ENTITY % aboutDTD SYSTEM "chrome://asf/locale/about.dtd" >
-%aboutDTD;
-]>
-<html xmlns="http://www.w3.org/1999/xhtml">
-<!-- ***** BEGIN LICENSE BLOCK *****
- Copyright 2007-2010 Éric Cassar (Cyan)
-
- This file is part of "Automatic Save Folder".
- You may find the license in the LICENSE file
-
- ***** END LICENSE BLOCK ***** -->
-<body style="background-color:#FFFFFF;">
-<center><font size="+1"><strong>Automatic Save Folder Version &asf.version;</strong></font></center>
-<center>&about.madeby_authorname;</center>
-
-<p>
- <strong>&about.links.mainwebsite.title;</strong><br />
- <a href="http://asf.mangaheart.org" target="_blank">http://asf.mangaheart.org</a><br />
- <br />
- <strong>&about.links.mozilla.title;</strong><br />
- <a href="http://addons.mozilla.org/addon/4781" target="_blank">http://addons.mozilla.org/addon/4781</a>
-</p>
-
-<br />
-<h3>&about.history.title;</h3>
-<pre>+ &about.add;
-- &about.delete;
-* &about.change;
-! &about.fix;
-
-
-<strong>&about.version.title; 0.9.4 :</strong> (2010 xx xx)
-&about.version.094;
-
-
-<strong>&about.version.title; 0.9.3 :</strong> (2009 07 05)
-&about.version.093;
-
-
-<strong>&about.version.title; 0.9.2 :</strong> (2009 01 26)
-&about.version.092;
-
-
-<strong>&about.version.title; 0.9.1 :</strong> (2008 11 01)
-&about.version.091;
-
-
-<strong>&about.version.title; 0.9.0 :</strong> (2008 06 28)
-&about.version.090;
-
-
-<strong>&about.version.title; 0.8.7 :</strong> (2008 01 06)
-&about.version.087;
-
-
-<strong>&about.version.title; 0.8.6 - Linux fix :</strong> (2008 01 04)
-&about.version.086fix;
-
-
-<strong>&about.version.title; 0.8.6 :</strong> (2007 07 09)
-&about.version.086;
-
-
-<strong>&about.version.title; 0.8.5 :</strong> (2007 04 01)
-&about.version.085;
-
-
-<strong>&about.version.title; 0.8.4 :</strong> (2007 02 24)
-&about.version.084;
-
-
-<strong>&about.version.title; 0.8.3 :</strong> (2007 02 17)
-&about.version.083;
-
-
-<strong>&about.version.title; 0.8.2 :</strong> (2007 02 15)
-&about.version.082;
-
-
-<strong>&about.version.title; 0.8.1 :</strong>
-&about.version.081;
-
-
-<strong>&about.version.title; 0.8.0 :</strong>
-&about.version.080;
-</pre>
-<br />
-<h3>&about.thanks.title;</h3>
-<p>
-<strong>&about.programmation.title;</strong><br />
-&about.programmation.content;
-<br />
-<br />
-<strong>&about.bugreport.title;</strong><br />
-&about.bugreport.content;
-<br />
-<br />
-<strong>&about.translation.title;</strong><br />
-&about.translation.content;
-</p>
-<br />
-</body>
-</html>
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" [
+<!ENTITY % aboutDTD SYSTEM "chrome://asf/locale/about.dtd" >
+%aboutDTD;
+]>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!-- ***** BEGIN LICENSE BLOCK *****
+ Copyright 2007-2010 Éric Cassar (Cyan)
+
+ This file is part of "Automatic Save Folder".
+ You may find the license in the LICENSE file
+
+ ***** END LICENSE BLOCK ***** -->
+<body style="background-color:#FFFFFF;">
+<center><font size="+1"><strong>Automatic Save Folder Version &asf.version;</strong></font></center>
+<center>&about.madeby_authorname;</center>
+
+<p>
+ <strong>&about.links.mainwebsite.title;</strong><br />
+ <a href="http://asf.mangaheart.org" target="_blank">http://asf.mangaheart.org</a><br />
+ <br />
+ <strong>&about.links.mozilla.title;</strong><br />
+ <a href="http://addons.mozilla.org/addon/4781" target="_blank">http://addons.mozilla.org/addon/4781</a>
+</p>
+
+<br />
+<h3>&about.history.title;</h3>
+<pre>+ &about.add;
+- &about.delete;
+* &about.change;
+! &about.fix;
+
+
+<strong>&about.version.title; 0.9.4 :</strong> (2010 xx xx)
+&about.version.094;
+
+
+<strong>&about.version.title; 0.9.3 :</strong> (2009 07 05)
+&about.version.093;
+
+
+<strong>&about.version.title; 0.9.2 :</strong> (2009 01 26)
+&about.version.092;
+
+
+<strong>&about.version.title; 0.9.1 :</strong> (2008 11 01)
+&about.version.091;
+
+
+<strong>&about.version.title; 0.9.0 :</strong> (2008 06 28)
+&about.version.090;
+
+
+<strong>&about.version.title; 0.8.7 :</strong> (2008 01 06)
+&about.version.087;
+
+
+<strong>&about.version.title; 0.8.6 - Linux fix :</strong> (2008 01 04)
+&about.version.086fix;
+
+
+<strong>&about.version.title; 0.8.6 :</strong> (2007 07 09)
+&about.version.086;
+
+
+<strong>&about.version.title; 0.8.5 :</strong> (2007 04 01)
+&about.version.085;
+
+
+<strong>&about.version.title; 0.8.4 :</strong> (2007 02 24)
+&about.version.084;
+
+
+<strong>&about.version.title; 0.8.3 :</strong> (2007 02 17)
+&about.version.083;
+
+
+<strong>&about.version.title; 0.8.2 :</strong> (2007 02 15)
+&about.version.082;
+
+
+<strong>&about.version.title; 0.8.1 :</strong>
+&about.version.081;
+
+
+<strong>&about.version.title; 0.8.0 :</strong>
+&about.version.080;
+</pre>
+<br />
+<h3>&about.thanks.title;</h3>
+<p>
+<strong>&about.programmation.title;</strong><br />
+&about.programmation.content;
+<br />
+<br />
+<strong>&about.bugreport.title;</strong><br />
+&about.bugreport.content;
+<br />
+<br />
+<strong>&about.translation.title;</strong><br />
+&about.translation.content;
+</p>
+<br />
+</body>
+</html>
diff --git a/content/help/help.xhtml b/content/help/help.xhtml
index 26da6f7..469c13a 100644
--- a/content/help/help.xhtml
+++ b/content/help/help.xhtml
@@ -1,141 +1,141 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
- "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" [
-<!ENTITY % helpDTD SYSTEM "chrome://asf/locale/help.dtd" >
-%helpDTD;
-]>
-<html xmlns="http://www.w3.org/1999/xhtml">
-<!-- ***** BEGIN LICENSE BLOCK *****
- Copyright 2007-2010 Éric Cassar (Cyan)
-
- This file is part of "Automatic Save Folder".
- You may find the license in the LICENSE file
-
- ***** END LICENSE BLOCK ***** -->
-<body style="background-color:#FFFFFF;">
-
-<h3>&info.important.title;</h3>
-<p>
- &info.important.text1;<br />
- <br/><img src="chrome://asf/skin/&info.important.pict1;" />
- <br />&info.important.text2;
-</p>
-<ol>
- <li>&info.important.text3;</li>
- <li>&info.important.text4;</li>
- <li>&info.important.text5;</li>
-</ol><img src="chrome://asf/skin/&info.important.pict2;" />
-<br />
-<br />
-<br />
-<br />
-
-<h3>&info.howtouse.title;</h3>
-
-<p>&info.howtouse.text1;</p>
-<strong>&info.filterrules.title;</strong>
-<ul>
- <li>&info.filterrules.rule1;</li>
- <li>&info.filterrules.rule2;</li>
- <li>&info.filterrules.rule3;</li>
- <li>&info.filterrules.rule4;</li>
- <li>&info.filterrules.rule5;</li>
- <li>&info.filterrules.rule6;</li>
- <li>&info.filterrules.rule7;</li>
-</ul>
-<p>
-
-<br />&info.howtouse.text2;
-<br />&info.howtouse.text3;
-<br />
-<br />&info.howtouse.text4;
-<br />
-<br />
-<br />
-</p>
-<strong>&info.basicexample.title;</strong>
-<br />
-<ol>
- <li>
- &info.basicexample.text1;<br />
- <strong>&info.domain;</strong> &info.all;<br />
- <strong>&info.filename;</strong> .exe<br />
- <strong>&info.folder;</strong> &info.basicexample.text2;<br />
- <br /><br />
- </li>
- <li>
- &info.basicexample.text3;<br />
- <strong>&info.domain;</strong> mozilla.org<br />
- <strong>&info.filename;</strong> &info.all;<br />
- <strong>&info.folder;</strong> &info.basicexample.text4;<br />
- <br /><br />
- </li>
- <li>
- &info.basicexample.text5;<br />
- <strong>&info.domain;</strong> mozilla.org<br />
- <strong>&info.filename;</strong> .zip<br />
- <strong>&info.folder;</strong> &info.basicexample.text6;<br />
- &info.basicexample.text7;<br />
- <br /><br />
- </li>
- <li>
- &info.basicexample.text8;<br />
- <strong>&info.domain;</strong> &info.all;<br />
- <strong>&info.filename;</strong> firefox*.exe<br />
- <strong>&info.folder;</strong> &info.basicexample.text9;<br />
- <br /><br />
- </li>
-</ol>
-
-<strong>&info.advancedexample.title;</strong>
-<br />&info.advancedexample.text1;
-<br />
-<ol>
- <li>
- <strong>&info.dynamicfilter;</strong><br />
- &info.advancedexample.text2;<br />
- <strong>&info.domain;</strong> &info.all;<br />
- <strong>&info.filename;</strong> firefox*pre<br />
- <strong>&info.folder;</strong> &info.advancedexample.text3;<br />
- &info.advancedexample.text4;<br />
- <br /><br />
- </li>
- <li>
- <strong>&info.dynamicfilter;</strong><br />
- &info.advancedexample.text5;<br />
- <strong>&info.domain;</strong> &info.all;<br />
- <strong>&info.filename;</strong> &info.all;<br />
- <strong>&info.folder;</strong> &info.advancedexample.text6;<br />
- &info.advancedexample.text7;<br />
- <br /><br />
- </li>
- <li>
- <strong>&info.capturefilter;</strong><br />
- &info.advancedexample.text8;<br />
- <strong>&info.domain;</strong> &info.all;<br />
- <strong>&info.filename;</strong> Firefox Setup (*).exe<br />
- <strong>&info.folder;</strong> &info.advancedexample.text9;<br />
- &info.advancedexample.text10;<br />
- <br /><br />
- </li>
- <li>
- <strong>&info.capturefilter;</strong><br />
- &info.advancedexample.text11;<br />&info.advancedexample.text12;<br />
- <br />
- <strong>&info.domain;</strong> &info.all;<br />
- <strong>&info.filename;</strong> &info.advancedexample.text13;<br />
- <strong>&info.folder;</strong> &info.advancedexample.text14;<br />
- <br />
- &info.advancedexample.text15;<br />
- <br />
- &info.advancedexample.text16;
- <br />
- &info.advancedexample.text17;
- </li>
-</ol>
-<br />
-<br />
-<br />
-<br />
-</body>
-</html>
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" [
+<!ENTITY % helpDTD SYSTEM "chrome://asf/locale/help.dtd" >
+%helpDTD;
+]>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!-- ***** BEGIN LICENSE BLOCK *****
+ Copyright 2007-2010 Éric Cassar (Cyan)
+
+ This file is part of "Automatic Save Folder".
+ You may find the license in the LICENSE file
+
+ ***** END LICENSE BLOCK ***** -->
+<body style="background-color:#FFFFFF;">
+
+<h3>&info.important.title;</h3>
+<p>
+ &info.important.text1;<br />
+ <br/><img src="chrome://asf/skin/&info.important.pict1;" />
+ <br />&info.important.text2;
+</p>
+<ol>
+ <li>&info.important.text3;</li>
+ <li>&info.important.text4;</li>
+ <li>&info.important.text5;</li>
+</ol><img src="chrome://asf/skin/&info.important.pict2;" />
+<br />
+<br />
+<br />
+<br />
+
+<h3>&info.howtouse.title;</h3>
+
+<p>&info.howtouse.text1;</p>
+<strong>&info.filterrules.title;</strong>
+<ul>
+ <li>&info.filterrules.rule1;</li>
+ <li>&info.filterrules.rule2;</li>
+ <li>&info.filterrules.rule3;</li>
+ <li>&info.filterrules.rule4;</li>
+ <li>&info.filterrules.rule5;</li>
+ <li>&info.filterrules.rule6;</li>
+ <li>&info.filterrules.rule7;</li>
+</ul>
+<p>
+
+<br />&info.howtouse.text2;
+<br />&info.howtouse.text3;
+<br />
+<br />&info.howtouse.text4;
+<br />
+<br />
+<br />
+</p>
+<strong>&info.basicexample.title;</strong>
+<br />
+<ol>
+ <li>
+ &info.basicexample.text1;<br />
+ <strong>&info.domain;</strong> &info.all;<br />
+ <strong>&info.filename;</strong> .exe<br />
+ <strong>&info.folder;</strong> &info.basicexample.text2;<br />
+ <br /><br />
+ </li>
+ <li>
+ &info.basicexample.text3;<br />
+ <strong>&info.domain;</strong> mozilla.org<br />
+ <strong>&info.filename;</strong> &info.all;<br />
+ <strong>&info.folder;</strong> &info.basicexample.text4;<br />
+ <br /><br />
+ </li>
+ <li>
+ &info.basicexample.text5;<br />
+ <strong>&info.domain;</strong> mozilla.org<br />
+ <strong>&info.filename;</strong> .zip<br />
+ <strong>&info.folder;</strong> &info.basicexample.text6;<br />
+ &info.basicexample.text7;<br />
+ <br /><br />
+ </li>
+ <li>
+ &info.basicexample.text8;<br />
+ <strong>&info.domain;</strong> &info.all;<br />
+ <strong>&info.filename;</strong> firefox*.exe<br />
+ <strong>&info.folder;</strong> &info.basicexample.text9;<br />
+ <br /><br />
+ </li>
+</ol>
+
+<strong>&info.advancedexample.title;</strong>
+<br />&info.advancedexample.text1;
+<br />
+<ol>
+ <li>
+ <strong>&info.dynamicfilter;</strong><br />
+ &info.advancedexample.text2;<br />
+ <strong>&info.domain;</strong> &info.all;<br />
+ <strong>&info.filename;</strong> firefox*pre<br />
+ <strong>&info.folder;</strong> &info.advancedexample.text3;<br />
+ &info.advancedexample.text4;<br />
+ <br /><br />
+ </li>
+ <li>
+ <strong>&info.dynamicfilter;</strong><br />
+ &info.advancedexample.text5;<br />
+ <strong>&info.domain;</strong> &info.all;<br />
+ <strong>&info.filename;</strong> &info.all;<br />
+ <strong>&info.folder;</strong> &info.advancedexample.text6;<br />
+ &info.advancedexample.text7;<br />
+ <br /><br />
+ </li>
+ <li>
+ <strong>&info.capturefilter;</strong><br />
+ &info.advancedexample.text8;<br />
+ <strong>&info.domain;</strong> &info.all;<br />
+ <strong>&info.filename;</strong> Firefox Setup (*).exe<br />
+ <strong>&info.folder;</strong> &info.advancedexample.text9;<br />
+ &info.advancedexample.text10;<br />
+ <br /><br />
+ </li>
+ <li>
+ <strong>&info.capturefilter;</strong><br />
+ &info.advancedexample.text11;<br />&info.advancedexample.text12;<br />
+ <br />
+ <strong>&info.domain;</strong> &info.all;<br />
+ <strong>&info.filename;</strong> &info.advancedexample.text13;<br />
+ <strong>&info.folder;</strong> &info.advancedexample.text14;<br />
+ <br />
+ &info.advancedexample.text15;<br />
+ <br />
+ &info.advancedexample.text16;
+ <br />
+ &info.advancedexample.text17;
+ </li>
+</ol>
+<br />
+<br />
+<br />
+<br />
+</body>
+</html>
diff --git a/content/help/regexp.xhtml b/content/help/regexp.xhtml
index c5b6387..37727a0 100644
--- a/content/help/regexp.xhtml
+++ b/content/help/regexp.xhtml
@@ -1,132 +1,132 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
- "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" [
-<!ENTITY % regexpDTD SYSTEM "chrome://asf/locale/regexp.dtd" >
-%regexpDTD;
-]>
-<html xmlns="http://www.w3.org/1999/xhtml">
-<!-- ***** BEGIN LICENSE BLOCK *****
- Copyright 2007-2010 Éric Cassar (Cyan)
-
- This file is part of "Automatic Save Folder".
- You may find the license in the LICENSE file
-
- ***** END LICENSE BLOCK ***** -->
-<body style="background-color:#FFFFFF;">
-<p>&Intro_1;</p>
-<p>&Intro_2;</p>
-
-<p>
- <strong>&Note1.title;</strong> : &Note1.text;<br />
- <strong>&Note2.title;</strong> : &Note2.text;
-</p>
-
-<br />
-<br />
-
-<h2>&Title_1;</h2>
-<p>&Intro_3;</p>
-
-<ul>
- <li><strong>&The.dot.title;</strong><br />
- &The.dot.text;
- <br /><br />
- </li>
- <li><strong>&The.asterisk.title;</strong><br />
- &The.asterisk.text;
- <br /><br />
- </li>
- <li><strong>&The.caret.title;</strong><br />
- &The.caret.text;
- <br /><br />
- </li>
- <li><strong>&The.dollar.title;</strong><br />
- &The.dollar.text;
- <br /><br />
- </li>
- <li><strong>&The.braces.title;</strong><br />
- &The.braces.text;
- <br /><br />
- </li>
- <li><strong>&The.parenthesis.title;</strong><br />
- &The.parenthesis.text;
- <br /><br />
- </li>
- <li><strong>&The.question.title;</strong><br />
- &The.question.text;
- <br /><br />
- </li>
- <li><strong>&The.bracket.title;</strong><br />
- &The.bracket.text;
- <br /><br />
- </li>
- <li><strong>&The.backslash.title;</strong><br />
- &The.backslash.text;
- <br /><br />
- </li>
-</ul>
-<br />
-<br />
-<p>&The.backslash.info;</p>
-<table border="0" style="width:400px; border-collapse:collapse;">
- <tr>
- <td>\ → \\
- </td>
- <td>. → \.
- </td>
- <td>* → \*
- </td>
- <td>? → \?
- </td>
- <td>^ → \^
- </td>
- </tr>
- <tr>
- <td>$ → \$
- </td>
- <td>( → \(
- </td>
- <td>) → \)
- </td>
- <td>{ → \{
- </td>
- <td>} → \}
- </td>
- </tr>
- <tr>
- <td>[ → \[
- </td>
- <td>] → \]
- </td>
- <td> / → \/
- </td>
- <td>
- </td>
- <td>
- </td>
- </tr>
-</table>
-<br />
-<br />
-<br />
-<p>&Regexp.links;</p>
-<br />
-<br />
-<br />
-<h2>&Example_1.title;</h2>
-<p>&Example_1.text;</p>
-<br />
-<h3>&Example_2.title;</h3>
-<p>&Example_2.text;</p>
-<br />
-<br />
-<h2>&Example_3.title;</h2>
-<p>&Example_3.text;</p>
-<br />
-<br />
-<h2>&Conclusion.title;</h2>
-<p>&Conclusion.text;</p>
-<br />
-<br />
-</body>
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" [
+<!ENTITY % regexpDTD SYSTEM "chrome://asf/locale/regexp.dtd" >
+%regexpDTD;
+]>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!-- ***** BEGIN LICENSE BLOCK *****
+ Copyright 2007-2010 Éric Cassar (Cyan)
+
+ This file is part of "Automatic Save Folder".
+ You may find the license in the LICENSE file
+
+ ***** END LICENSE BLOCK ***** -->
+<body style="background-color:#FFFFFF;">
+<p>&Intro_1;</p>
+<p>&Intro_2;</p>
+
+<p>
+ <strong>&Note1.title;</strong> : &Note1.text;<br />
+ <strong>&Note2.title;</strong> : &Note2.text;
+</p>
+
+<br />
+<br />
+
+<h2>&Title_1;</h2>
+<p>&Intro_3;</p>
+
+<ul>
+ <li><strong>&The.dot.title;</strong><br />
+ &The.dot.text;
+ <br /><br />
+ </li>
+ <li><strong>&The.asterisk.title;</strong><br />
+ &The.asterisk.text;
+ <br /><br />
+ </li>
+ <li><strong>&The.caret.title;</strong><br />
+ &The.caret.text;
+ <br /><br />
+ </li>
+ <li><strong>&The.dollar.title;</strong><br />
+ &The.dollar.text;
+ <br /><br />
+ </li>
+ <li><strong>&The.braces.title;</strong><br />
+ &The.braces.text;
+ <br /><br />
+ </li>
+ <li><strong>&The.parenthesis.title;</strong><br />
+ &The.parenthesis.text;
+ <br /><br />
+ </li>
+ <li><strong>&The.question.title;</strong><br />
+ &The.question.text;
+ <br /><br />
+ </li>
+ <li><strong>&The.bracket.title;</strong><br />
+ &The.bracket.text;
+ <br /><br />
+ </li>
+ <li><strong>&The.backslash.title;</strong><br />
+ &The.backslash.text;
+ <br /><br />
+ </li>
+</ul>
+<br />
+<br />
+<p>&The.backslash.info;</p>
+<table border="0" style="width:400px; border-collapse:collapse;">
+ <tr>
+ <td>\ → \\
+ </td>
+ <td>. → \.
+ </td>
+ <td>* → \*
+ </td>
+ <td>? → \?
+ </td>
+ <td>^ → \^
+ </td>
+ </tr>
+ <tr>
+ <td>$ → \$
+ </td>
+ <td>( → \(
+ </td>
+ <td>) → \)
+ </td>
+ <td>{ → \{
+ </td>
+ <td>} → \}
+ </td>
+ </tr>
+ <tr>
+ <td>[ → \[
+ </td>
+ <td>] → \]
+ </td>
+ <td> / → \/
+ </td>
+ <td>
+ </td>
+ <td>
+ </td>
+ </tr>
+</table>
+<br />
+<br />
+<br />
+<p>&Regexp.links;</p>
+<br />
+<br />
+<br />
+<h2>&Example_1.title;</h2>
+<p>&Example_1.text;</p>
+<br />
+<h3>&Example_2.title;</h3>
+<p>&Example_2.text;</p>
+<br />
+<br />
+<h2>&Example_3.title;</h2>
+<p>&Example_3.text;</p>
+<br />
+<br />
+<h2>&Conclusion.title;</h2>
+<p>&Conclusion.text;</p>
+<br />
+<br />
+</body>
</html>
\ No newline at end of file
diff --git a/content/help/variables.xhtml b/content/help/variables.xhtml
index ebaa31f..4baa181 100644
--- a/content/help/variables.xhtml
+++ b/content/help/variables.xhtml
@@ -1,97 +1,97 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
- "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" [
-<!ENTITY % variablesDTD SYSTEM "chrome://asf/locale/variables.dtd" >
-%variablesDTD;
-]>
-<html xmlns="http://www.w3.org/1999/xhtml">
-<!-- ***** BEGIN LICENSE BLOCK *****
- Copyright 2007-2010 Éric Cassar (Cyan)
-
- This file is part of "Automatic Save Folder".
- You may find the license in the LICENSE file
-
- ***** END LICENSE BLOCK ***** -->
-<body>
-<table border="0" style="font-size:12px; margin-top:0px;">
- <tr>
- <td align="left" valign="top">
- <u style="font-size:15px">&Year;</u><br/>
- <b>%Y%</b> = 2009, 2012<br/>
- <b>%y%</b> = 09, 12<br/>
-
- </td>
- <td align="left" valign="top">
- <u style="font-size:15px">&Month;</u><br/>
- <b>%m%</b> = &Month.wleadingzero;<br/>
- <b>%n%</b> = &Month.woleadingzero;<br/>
- <b>%F%</b> = &Month.fullname;<br/>
- <b>%M%</b> = &Month.abbr;<br/>
- </td>
- <td align="left" valign="top">
- <u style="font-size:15px">&Week;</u><br/>
- <b>%W%</b> = &Week.wleadingzero;<br/>
- </td>
- <td align="left" valign="top">
- <u style="font-size:15px">&Day;</u><br/>
- <b>%d%</b> = &Day.wleadingzero;<br/>
- <b>%j%</b> = &Day.woleadingzero;<br/>
- <b>%w%</b> = &DayOfTheWeek;<br/>
- <b>%l%</b> = &DayOfTheWeek.fullname;<br/>
- <b>%D%</b> = &DayOfTheWeek.abbr;<br/>
- </td>
- </tr>
- <tr>
- <td colspan="4" valign="top">
- <br/>
- <u style="font-size:15px">&Special.tags;</u> :<br/>
- <table style="font-size:12px;">
- <tr>
- <td valign="top"><b>%asf_D%</b></td><td>= &asf_D;</td>
- </tr>
- <tr>
- <td valign="top"><b>%asf_F%</b></td><td>= &asf_F;</td>
- </tr>
- <tr>
- <td valign="top"><b>%asf_Fx%</b></td><td>= &asf_Fx;</td>
- </tr>
- <tr>
- <td valign="top"><b>%asf_d%</b></td><td>= &asf_d;</td>
- </tr>
- <tr>
- <td valign="top"><b>%asf_f%</b></td><td>= &asf_f;</td>
- </tr>
- <tr>
- <td valign="top"><b>%asf_x%</b></td><td>= &asf_x;</td>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <td colspan="4" valign="top">
- <br/>
- <u style="font-size:15px">&Capture.tags;</u> :<br/>
-
- <b>$<&number;>d</b> = &Capture.d;
- <br/>
- <br/>
- <b>$<&number;>f</b> = &Capture.f;
- <br/>&Capture.example;
- <br/>
- <br/>
- <b>%asf_rd%</b><u>&Regexp;</u><b>%asf_rd%</b><br/>
- &Capture.rd;
- <br/>
- <br/>
- <b>%asf_rf%</b><u>&Regexp;</u><b>%asf_rf%</b><br/>
- &Capture.rf;
- <br/>
- </td>
- </tr>
- <tr>
- <td colspan="4" valign="top">
- <br/>
- <b>&Attention;</b> : &Attention.text;<br/>
- </td>
- </tr>
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" [
+<!ENTITY % variablesDTD SYSTEM "chrome://asf/locale/variables.dtd" >
+%variablesDTD;
+]>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!-- ***** BEGIN LICENSE BLOCK *****
+ Copyright 2007-2010 Éric Cassar (Cyan)
+
+ This file is part of "Automatic Save Folder".
+ You may find the license in the LICENSE file
+
+ ***** END LICENSE BLOCK ***** -->
+<body>
+<table border="0" style="font-size:12px; margin-top:0px;">
+ <tr>
+ <td align="left" valign="top">
+ <u style="font-size:15px">&Year;</u><br/>
+ <b>%Y%</b> = 2009, 2012<br/>
+ <b>%y%</b> = 09, 12<br/>
+
+ </td>
+ <td align="left" valign="top">
+ <u style="font-size:15px">&Month;</u><br/>
+ <b>%m%</b> = &Month.wleadingzero;<br/>
+ <b>%n%</b> = &Month.woleadingzero;<br/>
+ <b>%F%</b> = &Month.fullname;<br/>
+ <b>%M%</b> = &Month.abbr;<br/>
+ </td>
+ <td align="left" valign="top">
+ <u style="font-size:15px">&Week;</u><br/>
+ <b>%W%</b> = &Week.wleadingzero;<br/>
+ </td>
+ <td align="left" valign="top">
+ <u style="font-size:15px">&Day;</u><br/>
+ <b>%d%</b> = &Day.wleadingzero;<br/>
+ <b>%j%</b> = &Day.woleadingzero;<br/>
+ <b>%w%</b> = &DayOfTheWeek;<br/>
+ <b>%l%</b> = &DayOfTheWeek.fullname;<br/>
+ <b>%D%</b> = &DayOfTheWeek.abbr;<br/>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="4" valign="top">
+ <br/>
+ <u style="font-size:15px">&Special.tags;</u> :<br/>
+ <table style="font-size:12px;">
+ <tr>
+ <td valign="top"><b>%asf_D%</b></td><td>= &asf_D;</td>
+ </tr>
+ <tr>
+ <td valign="top"><b>%asf_F%</b></td><td>= &asf_F;</td>
+ </tr>
+ <tr>
+ <td valign="top"><b>%asf_Fx%</b></td><td>= &asf_Fx;</td>
+ </tr>
+ <tr>
+ <td valign="top"><b>%asf_d%</b></td><td>= &asf_d;</td>
+ </tr>
+ <tr>
+ <td valign="top"><b>%asf_f%</b></td><td>= &asf_f;</td>
+ </tr>
+ <tr>
+ <td valign="top"><b>%asf_x%</b></td><td>= &asf_x;</td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="4" valign="top">
+ <br/>
+ <u style="font-size:15px">&Capture.tags;</u> :<br/>
+
+ <b>$<&number;>d</b> = &Capture.d;
+ <br/>
+ <br/>
+ <b>$<&number;>f</b> = &Capture.f;
+ <br/>&Capture.example;
+ <br/>
+ <br/>
+ <b>%asf_rd%</b><u>&Regexp;</u><b>%asf_rd%</b><br/>
+ &Capture.rd;
+ <br/>
+ <br/>
+ <b>%asf_rf%</b><u>&Regexp;</u><b>%asf_rf%</b><br/>
+ &Capture.rf;
+ <br/>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="4" valign="top">
+ <br/>
+ <b>&Attention;</b> : &Attention.text;<br/>
+ </td>
+ </tr>
</table></body></html>
\ No newline at end of file
diff --git a/content/options.xul b/content/options.xul
index ef9e240..41166ea 100644
--- a/content/options.xul
+++ b/content/options.xul
@@ -1,215 +1,216 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- ***** BEGIN LICENSE BLOCK *****
- Copyright 2007-2010 Éric Cassar (Cyan)
-
- This file is part of "Automatic Save Folder".
- You may find the license in the LICENSE file
-
- ***** END LICENSE BLOCK ***** -->
-<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
-<?xml-stylesheet href="chrome://asf/skin/style.css" type="text/css"?>
-<!DOCTYPE dialog SYSTEM "chrome://asf/locale/asf.dtd">
-
-<prefwindow
- id="asf_pref"
- autostretch="always"
- persist="screenX screenY"
- buttons="accept, cancel"
- defaultButton="accept"
- onload="automatic_save_folder.asf_load();"
- ondialogaccept="automatic_save_folder.asf_savepref();"
- ondialogcancel="automatic_save_folder.asf_close();"
- xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" title="&prefwindow.title; (&asf.version;)"
->
-<prefpane id="asf-options" style="padding:1px !important" flex="1" >
- <script type="application/x-javascript" src="chrome://asf/content/asf.js"/>
- <preferences>
- <preference id="asf_lastdir" name="extensions.asf.lastdir" type="bool"/>
- <preference id="asf_keeptemp" name="extensions.asf.keeptemp" type="bool"/>
- <preference id="asf_viewdloption" name="extensions.asf.viewdloption" type="bool"/>
- <preference id="asf_viewpathselect" name="extensions.asf.viewpathselect" type="bool"/>
- <preference id="asf_viewdloptionType" name="extensions.asf.viewdloptionType" type="int"/>
- <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_dialogacceptFiltered" name="extensions.asf.dialogacceptFiltered" type="bool"/>
- <preference id="asf_userightclick" name="extensions.asf.userightclick" type="bool"/>
- <preference id="asf_rightclicktimeout" name="extensions.asf.rightclicktimeout" type="bool"/>
- <preference id="asf_usecurrenturl" name="extensions.asf.usecurrenturl" type="bool"/>
- <preference id="asf_useDownloadDir" name="browser.download.useDownloadDir" type="bool"/>
- <preference id="asf_folderList" name="browser.download.folderList" type="int"/>
- </preferences>
- <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();"/>
- <menuitem label="&asf.delete.popup;" oncommand="automatic_save_folder.asf_delete();"/>
- <menuitem label="&asf.bottom.popup;" oncommand="automatic_save_folder.move('bottom');"/>
- </menupopup>
- <tooltip id="tooltip_folderList" orient="vertical" style="background-color: #33DD00;" noautohide="true">
- <description value="&asf.folderList.tooltip;"/>
- </tooltip>
- <tooltip id="tooltip_viewdloption" style="background-color: #33DD00;" noautohide="true">
- <description value="&asf.viewdloption.tooltip;"/>
- </tooltip>
- <tooltip id="tooltip_viewpathselect" style="background-color: #33DD00;" noautohide="true">
- <description value="&asf.viewpathselect.tooltip;"/>
- </tooltip>
- <tooltip id="tooltip_userightclick" orient="vertical" style="background-color: #33DD00;" noautohide="true">
- <description value="&asf.userightclick.tooltip;"/>
- </tooltip>
- <tooltip id="tooltip_rightclicktimeout" orient="vertical" style="background-color: #33DD00;" noautohide="true">
- <description value="&asf.rightclicktimeout.tooltip1;"/>
- <description value="&asf.rightclicktimeout.tooltip2;"/>
- <description value="&asf.rightclicktimeout.tooltip3;"/>
- <description value="&asf.rightclicktimeout.tooltip4;"/>
- </tooltip>
- <tooltip id="tooltip_variablemode" orient="vertical" style="background-color: #33DD00;" noautohide="true">
- <description value="&asf.variablemode.tooltip1;"/>
- <description value="&asf.variablemode.tooltip2;"/>
- </tooltip>
- <tooltip id="tooltip_dialogacceptFiltered" orient="vertical" style="background-color: #33DD00;" noautohide="true">
- <description value="&asf.dialogacceptFiltered.tooltip;"/>
- </tooltip>
- <vbox>
- <tabbox>
- <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-helptab" style="-moz-appearance: none" orient="vertical" label="&asf.help.label;" oncommand="automatic_save_folder.asf_selecttab('asf-tab-help');" />
- <tab id="asf-abouttab" style="-moz-appearance: none" orient="vertical" label="&asf.about.label;" oncommand="automatic_save_folder.asf_selecttab('asf-tab-about');" />
- </tabs>
- <tabpanels hidden="true">
- <tabpanel />
- <tabpanel />
- <tabpanel />
- <tabpanel />
- <tabpanel />
- </tabpanels>
- </tabbox>
- </vbox>
- <vbox id="asf-tab-filters" hidden="false" flex="1000" >
- <groupbox flex="1" >
- <caption label="&asf.filters.label;"/>
- <hbox flex="1" >
- <tree flex="1" id="asf-filterList" width="376" height="200" seltype="single" hidecolumnpicker="false"
- enableColumnDrag="true" disableKeyNavigation="true" editable="true"
- onselect="automatic_save_folder.asf_treeSelected();">
- <treecols >
- <treecol id="asf-column-Domain" label="&asf.tree.column.domain;" flex="1" persist="width ordinal hidden"/>
- <splitter class="tree-splitter"/>
- <treecol id="asf-column-filename" label="&asf.tree.column.filename;" flex="1" persist="width ordinal hidden"/>
- <splitter class="tree-splitter"/>
- <treecol id="asf-column-LocalFolder" label="&asf.tree.column.localfolder;" flex="1" persist="width ordinal hidden"/>
- <splitter class="tree-splitter"/>
- <treecol id="asf-column-Enabled" label="&asf.tree.column.enabled;" flex="0" persist="width ordinal hidden" type="checkbox" editable="true" hidden="true" />
- </treecols>
- <treechildren
- ondragstart="automatic_save_folder.dragstart(event)"
- ondragover="automatic_save_folder.dragover(event)"
- ondragexit="automatic_save_folder.dragdrop(event)"
- onclick="automatic_save_folder.save_active_state()"
- id="asf-filterChilds" context="contextpopup" ondblclick="event.preventDefault();window.openDialog('chrome://asf/content/edit.xul','asf_addedit','chrome, centerscreen, resizable=no, dialog=no, modal=yes');"/>
- </tree>
- <vbox>
- <button id="asf-move-up" label="&asf.options.move.up;" oncommand="automatic_save_folder.move('up')"/>
- <button id="asf-add" image="chrome://asf/skin/add.png" label="&asf.options.add;" onclick="window.openDialog('chrome://asf/content/add.xul','asf_addedit','chrome, centerscreen, resizable=no, dialog=no, modal=yes');"/>
- <button id="asf-edit" label="&asf.options.edit;" oncommand="window.openDialog('chrome://asf/content/edit.xul','asf_addedit','chrome, centerscreen, resizable=no, dialog=no, modal=yes');"/>
- <button id="asf-delete" label="&asf.options.delete;" oncommand="automatic_save_folder.asf_delete()"/>
- <button id="asf-move-down" label="&asf.options.move.down;" oncommand="automatic_save_folder.move('down')"/>
- </vbox>
- </hbox>
- </groupbox>
- <groupbox flex="0">
- <caption label="&asf.default.label;"/>
- <radiogroup id="radio-savetype" align="left" preference="asf_savetype">
- <radio id="asf-last-radio" value="0" label="&asf.lastselected.label;" oncommand="automatic_save_folder.asf_toggleradio()"/>
- <hbox>
- <radio id="asf-choose-radio" value="1" label="&asf.defaultfolder.label;" oncommand="automatic_save_folder.asf_toggleradio()"/>
- <textbox id="asf-default-folder" width="350" ondblclick="automatic_save_folder.browsedir()"/>
- <button id="asf-select-folder" label="&asf.selectfolder.label;" oncommand="automatic_save_folder.browsedir()"/>
- </hbox>
- <hbox pack="end"><description value=" " /><checkbox id="asf-keeptemp-check" preference="asf_keeptemp" label="&asf.keeptemp.label;"/>
- </hbox>
- </radiogroup>
- </groupbox>
- <groupbox hidden="true">
- <textbox id="asf-current-domain" value="" />
- <textbox id="asf-current-filename" value="" />
- </groupbox>
- </vbox>
- <vbox id="asf-tab-options" hidden="true" flex="1000">
- <groupbox id="asf-options" flex="1">
- <caption label="&asf.options.label;"/>
- <separator class="thin"/>
- <hbox>
- <checkbox id="asf-useDownloadDir" preference="asf_useDownloadDir" label="&asf.useDownloadDir.bool;" oncommand="automatic_save_folder.toggle_options();"/>
- <menulist id="asf-folderList" preference="asf_folderList" tooltip="tooltip_folderList">
- <menupopup>
- <menuitem value="0" label="&asf.desktop.label;"></menuitem>
- <menuitem value="1" label="&asf.systemdownload.label;"></menuitem>
- <menuitem value="2" label="&asf.filteredfolder.label;"></menuitem>
- </menupopup>
- </menulist>
- </hbox>
- <checkbox id="asf-dialogaccept" preference="asf_dialogaccept" label="&asf.dialogaccept.bool;" oncommand="automatic_save_folder.toggle_options();"/>
- <checkbox id="asf-dialogacceptFiltered" preference="asf_dialogacceptFiltered" label="&asf.dialogacceptFiltered.bool;" tooltip="tooltip_dialogacceptFiltered" style="margin-left:25px;"/>
- <hbox>
- <checkbox id="asf-viewdloption" preference="asf_viewdloption" label="&asf.viewdloption.bool;" tooltip="tooltip_viewdloption" oncommand="automatic_save_folder.toggle_options();"/>
- <menulist id="asf-viewdloptionType" preference="asf_viewdloptionType">
- <menupopup>
- <menuitem value="0" label="&asf.viewdloptionType0.label;"></menuitem>
- <menuitem value="1" label="&asf.viewdloptionType1.label;"></menuitem>
- <menuitem value="2" label="&asf.viewdloptionType2.label;"></menuitem>
- <menuitem value="3" label="&asf.viewdloptionType3.label;"></menuitem>
- </menupopup>
- </menulist>
- </hbox>
- <checkbox id="asf-viewpathselect" preference="asf_viewpathselect" label="&asf.viewpathselect.bool;" tooltip="tooltip_viewpathselect" style="margin-left:25px;white-space:pre-wrap"/>
- <separator class="thin"/>
- <checkbox id="asf-usecurrenturl" preference="asf_usecurrenturl" label="&asf.usecurrenturl.bool;"/>
- <checkbox id="asf-lasdir" preference="asf_lastdir" label="&asf.lastdir.bool;"/>
- <separator class="thin"/>
- <checkbox id="asf-userightclick" preference="asf_userightclick" label="&asf.userightclick.bool;" tooltip="tooltip_userightclick" oncommand="automatic_save_folder.toggle_userightclick();"/>
- <checkbox id="asf-rightclicktimeout" preference="asf_rightclicktimeout" label="&asf.rightclicktimeout.bool;" tooltip="tooltip_rightclicktimeout" style="margin-left:25px;" oncommand="automatic_save_folder.toggle_rightclicktimeout();"/>
- <description id="asf-rightclickdesc-DSort" style="margin-left:25px;white-space:pre-wrap;color:red;">&asf.rightclick.DSort.label;</description>
- <description id="asf-rightclickdesc-ff2" style="margin-left:25px;white-space:pre-wrap;color:red;">&asf.rightclick.ff2.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;" tooltip="tooltip_variablemode" oncommand="automatic_save_folder.asf_variablemode()"/>
- <description id="asf-variablemodedesc" style="vertical-align:top;margin-left:25px;white-space:pre-wrap" >&asf.variablemode.label;</description>
- <separator class="thin"/>
- <hbox flex="1">
- <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:120px;"
- src="chrome://asf/content/help/variables.xhtml"
- />
- </groupbox>
- </hbox>
- </groupbox>
- </vbox>
- <vbox id="asf-tab-help" hidden="true" flex="1000" >
- <groupbox id="asf-help" flex="1" >
- <caption label="&asf.help.title;"/>
- <iframe flex="1" id="iframe_info" class="plain" style="background-color:#FFFFFF; min-height:305px;"
- width="580"
- src="chrome://asf/content/help/help.xhtml"
- />
- </groupbox>
- </vbox>
- <vbox id="asf-tab-about" hidden="true" flex="1000" >
- <groupbox id="asf-about" flex="1" >
- <caption label="&asf.about.title;"/>
- <iframe flex="1" id="iframe_info" class="plain" style="background-color:#FFFFFF; min-height:305px;"
- width="580"
- src="chrome://asf/content/help/about.xhtml"
- />
- </groupbox>
- </vbox>
-</prefpane>
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- ***** BEGIN LICENSE BLOCK *****
+ Copyright 2007-2010 Éric Cassar (Cyan)
+
+ This file is part of "Automatic Save Folder".
+ You may find the license in the LICENSE file
+
+ ***** END LICENSE BLOCK ***** -->
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="chrome://asf/skin/style.css" type="text/css"?>
+<!DOCTYPE dialog SYSTEM "chrome://asf/locale/asf.dtd">
+
+<prefwindow
+ id="asf_pref"
+ autostretch="always"
+ persist="screenX screenY"
+ buttons="accept, cancel"
+ defaultButton="accept"
+ onload="automatic_save_folder.asf_load();"
+ ondialogaccept="automatic_save_folder.asf_savepref();"
+ ondialogcancel="automatic_save_folder.asf_close();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" title="&prefwindow.title; (&asf.version;)"
+>
+<prefpane id="asf-options" style="padding:1px !important" flex="1" >
+ <script type="application/x-javascript" src="chrome://asf/content/asf.js"/>
+ <preferences>
+ <preference id="asf_lastdir" name="extensions.asf.lastdir" type="bool"/>
+ <preference id="asf_keeptemp" name="extensions.asf.keeptemp" type="bool"/>
+ <preference id="asf_viewdloption" name="extensions.asf.viewdloption" type="bool"/>
+ <preference id="asf_viewpathselect" name="extensions.asf.viewpathselect" type="bool"/>
+ <preference id="asf_viewdloptionType" name="extensions.asf.viewdloptionType" type="int"/>
+ <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_dialogacceptFiltered" name="extensions.asf.dialogacceptFiltered" type="bool"/>
+ <preference id="asf_userightclick" name="extensions.asf.userightclick" type="bool"/>
+ <preference id="asf_rightclicktimeout" name="extensions.asf.rightclicktimeout" type="bool"/>
+ <preference id="asf_usecurrenturl" name="extensions.asf.usecurrenturl" type="bool"/>
+ <preference id="asf_useDownloadDir" name="browser.download.useDownloadDir" type="bool"/>
+ <preference id="asf_folderList" name="browser.download.folderList" type="int"/>
+ </preferences>
+ <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();"/>
+ <menuitem label="&asf.delete.popup;" oncommand="automatic_save_folder.asf_delete();"/>
+ <menuitem label="&asf.bottom.popup;" oncommand="automatic_save_folder.move('bottom');"/>
+ </menupopup>
+ <tooltip id="tooltip_folderList" orient="vertical" style="background-color: #33DD00;" noautohide="true">
+ <description value="&asf.folderList.tooltip;"/>
+ </tooltip>
+ <tooltip id="tooltip_viewdloption" style="background-color: #33DD00;" noautohide="true">
+ <description value="&asf.viewdloption.tooltip;"/>
+ </tooltip>
+ <tooltip id="tooltip_viewpathselect" style="background-color: #33DD00;" noautohide="true">
+ <description value="&asf.viewpathselect.tooltip;"/>
+ </tooltip>
+ <tooltip id="tooltip_userightclick" orient="vertical" style="background-color: #33DD00;" noautohide="true">
+ <description value="&asf.userightclick.tooltip;"/>
+ </tooltip>
+ <tooltip id="tooltip_rightclicktimeout" orient="vertical" style="background-color: #33DD00;" noautohide="true">
+ <description value="&asf.rightclicktimeout.tooltip1;"/>
+ <description value="&asf.rightclicktimeout.tooltip2;"/>
+ <description value="&asf.rightclicktimeout.tooltip3;"/>
+ <description value="&asf.rightclicktimeout.tooltip4;"/>
+ </tooltip>
+ <tooltip id="tooltip_variablemode" orient="vertical" style="background-color: #33DD00;" noautohide="true">
+ <description value="&asf.variablemode.tooltip1;"/>
+ <description value="&asf.variablemode.tooltip2;"/>
+ </tooltip>
+ <tooltip id="tooltip_dialogacceptFiltered" orient="vertical" style="background-color: #33DD00;" noautohide="true">
+ <description value="&asf.dialogacceptFiltered.tooltip;"/>
+ </tooltip>
+ <vbox>
+ <tabbox>
+ <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-helptab" style="-moz-appearance: none" orient="vertical" label="&asf.help.label;" oncommand="automatic_save_folder.asf_selecttab('asf-tab-help');" />
+ <tab id="asf-abouttab" style="-moz-appearance: none" orient="vertical" label="&asf.about.label;" oncommand="automatic_save_folder.asf_selecttab('asf-tab-about');" />
+ </tabs>
+ <tabpanels hidden="true">
+ <tabpanel />
+ <tabpanel />
+ <tabpanel />
+ <tabpanel />
+ <tabpanel />
+ </tabpanels>
+ </tabbox>
+ </vbox>
+ <vbox id="asf-tab-filters" hidden="false" flex="1000" >
+ <groupbox flex="1" >
+ <caption label="&asf.filters.label;"/>
+ <hbox flex="1" >
+ <tree flex="1" id="asf-filterList" width="376" height="200" seltype="single" hidecolumnpicker="false"
+ enableColumnDrag="true" disableKeyNavigation="true" editable="true"
+ onselect="automatic_save_folder.asf_treeSelected();">
+ <treecols >
+ <treecol id="asf-column-Domain" label="&asf.tree.column.domain;" flex="1" persist="width ordinal hidden"/>
+ <splitter class="tree-splitter"/>
+ <treecol id="asf-column-filename" label="&asf.tree.column.filename;" flex="1" persist="width ordinal hidden"/>
+ <splitter class="tree-splitter"/>
+ <treecol id="asf-column-LocalFolder" label="&asf.tree.column.localfolder;" flex="1" persist="width ordinal hidden"/>
+ <splitter class="tree-splitter"/>
+ <treecol id="asf-column-Enabled" label="&asf.tree.column.enabled;" flex="0" persist="width ordinal hidden" type="checkbox" editable="true" hidden="true" />
+ </treecols>
+ <treechildren
+ ondragstart="automatic_save_folder.dragstart(event)"
+ ondragover="automatic_save_folder.dragover(event)"
+ ondragexit="automatic_save_folder.dragdrop(event)"
+ onclick="automatic_save_folder.save_active_state()"
+ id="asf-filterChilds" context="contextpopup" ondblclick="event.preventDefault();window.openDialog('chrome://asf/content/edit.xul','asf_addedit','chrome, centerscreen, resizable=no, dialog=no, modal=yes');"/>
+ </tree>
+ <vbox>
+ <button id="asf-move-up" label="&asf.options.move.up;" oncommand="automatic_save_folder.move('up')"/>
+ <button id="asf-add" image="chrome://asf/skin/add.png" label="&asf.options.add;" onclick="window.openDialog('chrome://asf/content/add.xul','asf_addedit','chrome, centerscreen, resizable=no, dialog=no, modal=yes');"/>
+ <button id="asf-edit" label="&asf.options.edit;" oncommand="window.openDialog('chrome://asf/content/edit.xul','asf_addedit','chrome, centerscreen, resizable=no, dialog=no, modal=yes');"/>
+ <button id="asf-delete" label="&asf.options.delete;" oncommand="automatic_save_folder.asf_delete()"/>
+ <button id="asf-move-down" label="&asf.options.move.down;" oncommand="automatic_save_folder.move('down')"/>
+ </vbox>
+ </hbox>
+ </groupbox>
+ <groupbox flex="0">
+ <caption label="&asf.default.label;"/>
+ <radiogroup id="radio-savetype" align="left" preference="asf_savetype">
+ <radio id="asf-last-radio" value="0" label="&asf.lastselected.label;" oncommand="automatic_save_folder.asf_toggleradio()"/>
+ <hbox>
+ <radio id="asf-choose-radio" value="1" label="&asf.defaultfolder.label;" oncommand="automatic_save_folder.asf_toggleradio()"/>
+ <textbox id="asf-default-folder" width="350" ondblclick="automatic_save_folder.browsedir()"/>
+ <button id="asf-select-folder" label="&asf.selectfolder.label;" oncommand="automatic_save_folder.browsedir()"/>
+ </hbox>
+ <hbox pack="end"><description value=" " /><checkbox id="asf-keeptemp-check" preference="asf_keeptemp" label="&asf.keeptemp.label;"/>
+ </hbox>
+ </radiogroup>
+ </groupbox>
+ <groupbox hidden="true">
+ <textbox id="asf-current-domain" value="" />
+ <textbox id="asf-current-filename" value="" />
+ <textbox id="asf-current-url" value="" />
+ </groupbox>
+ </vbox>
+ <vbox id="asf-tab-options" hidden="true" flex="1000">
+ <groupbox id="asf-options" flex="1">
+ <caption label="&asf.options.label;"/>
+ <separator class="thin"/>
+ <hbox>
+ <checkbox id="asf-useDownloadDir" preference="asf_useDownloadDir" label="&asf.useDownloadDir.bool;" oncommand="automatic_save_folder.toggle_options();"/>
+ <menulist id="asf-folderList" preference="asf_folderList" tooltip="tooltip_folderList">
+ <menupopup>
+ <menuitem value="0" label="&asf.desktop.label;"></menuitem>
+ <menuitem value="1" label="&asf.systemdownload.label;"></menuitem>
+ <menuitem value="2" label="&asf.filteredfolder.label;"></menuitem>
+ </menupopup>
+ </menulist>
+ </hbox>
+ <checkbox id="asf-dialogaccept" preference="asf_dialogaccept" label="&asf.dialogaccept.bool;" oncommand="automatic_save_folder.toggle_options();"/>
+ <checkbox id="asf-dialogacceptFiltered" preference="asf_dialogacceptFiltered" label="&asf.dialogacceptFiltered.bool;" tooltip="tooltip_dialogacceptFiltered" style="margin-left:25px;"/>
+ <hbox>
+ <checkbox id="asf-viewdloption" preference="asf_viewdloption" label="&asf.viewdloption.bool;" tooltip="tooltip_viewdloption" oncommand="automatic_save_folder.toggle_options();"/>
+ <menulist id="asf-viewdloptionType" preference="asf_viewdloptionType">
+ <menupopup>
+ <menuitem value="0" label="&asf.viewdloptionType0.label;"></menuitem>
+ <menuitem value="1" label="&asf.viewdloptionType1.label;"></menuitem>
+ <menuitem value="2" label="&asf.viewdloptionType2.label;"></menuitem>
+ <menuitem value="3" label="&asf.viewdloptionType3.label;"></menuitem>
+ </menupopup>
+ </menulist>
+ </hbox>
+ <checkbox id="asf-viewpathselect" preference="asf_viewpathselect" label="&asf.viewpathselect.bool;" tooltip="tooltip_viewpathselect" style="margin-left:25px;white-space:pre-wrap"/>
+ <separator class="thin"/>
+ <checkbox id="asf-usecurrenturl" preference="asf_usecurrenturl" label="&asf.usecurrenturl.bool;"/>
+ <checkbox id="asf-lasdir" preference="asf_lastdir" label="&asf.lastdir.bool;"/>
+ <separator class="thin"/>
+ <checkbox id="asf-userightclick" preference="asf_userightclick" label="&asf.userightclick.bool;" tooltip="tooltip_userightclick" oncommand="automatic_save_folder.toggle_userightclick();"/>
+ <checkbox id="asf-rightclicktimeout" preference="asf_rightclicktimeout" label="&asf.rightclicktimeout.bool;" tooltip="tooltip_rightclicktimeout" style="margin-left:25px;" oncommand="automatic_save_folder.toggle_rightclicktimeout();"/>
+ <description id="asf-rightclickdesc-DSort" style="margin-left:25px;white-space:pre-wrap;color:red;">&asf.rightclick.DSort.label;</description>
+ <description id="asf-rightclickdesc-ff2" style="margin-left:25px;white-space:pre-wrap;color:red;">&asf.rightclick.ff2.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;" tooltip="tooltip_variablemode" oncommand="automatic_save_folder.asf_variablemode()"/>
+ <description id="asf-variablemodedesc" style="vertical-align:top;margin-left:25px;white-space:pre-wrap" >&asf.variablemode.label;</description>
+ <separator class="thin"/>
+ <hbox flex="1">
+ <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:120px;"
+ src="chrome://asf/content/help/variables.xhtml"
+ />
+ </groupbox>
+ </hbox>
+ </groupbox>
+ </vbox>
+ <vbox id="asf-tab-help" hidden="true" flex="1000" >
+ <groupbox id="asf-help" flex="1" >
+ <caption label="&asf.help.title;"/>
+ <iframe flex="1" id="iframe_info" class="plain" style="background-color:#FFFFFF; min-height:305px;"
+ width="580"
+ src="chrome://asf/content/help/help.xhtml"
+ />
+ </groupbox>
+ </vbox>
+ <vbox id="asf-tab-about" hidden="true" flex="1000" >
+ <groupbox id="asf-about" flex="1" >
+ <caption label="&asf.about.title;"/>
+ <iframe flex="1" id="iframe_info" class="plain" style="background-color:#FFFFFF; min-height:305px;"
+ width="580"
+ src="chrome://asf/content/help/about.xhtml"
+ />
+ </groupbox>
+ </vbox>
+</prefpane>
</prefwindow>
\ No newline at end of file
diff --git a/content/overlay_preferences.xul b/content/overlay_preferences.xul
index b3ba71c..a26a1d1 100644
--- a/content/overlay_preferences.xul
+++ b/content/overlay_preferences.xul
@@ -1,18 +1,18 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- ***** BEGIN LICENSE BLOCK *****
- Copyright 2007-2010 Éric Cassar (Cyan)
-
- This file is part of "Automatic Save Folder".
- You may find the license in the LICENSE file
-
- ***** END LICENSE BLOCK ***** -->
-<?xml-stylesheet href="chrome://asf/skin/overlay.css" type="text/css"?>
-<!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');" />
- </menupopup>
-</overlay>
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- ***** BEGIN LICENSE BLOCK *****
+ Copyright 2007-2010 Éric Cassar (Cyan)
+
+ This file is part of "Automatic Save Folder".
+ You may find the license in the LICENSE file
+
+ ***** END LICENSE BLOCK ***** -->
+<?xml-stylesheet href="chrome://asf/skin/overlay.css" type="text/css"?>
+<!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');" />
+ </menupopup>
+</overlay>
diff --git a/content/overlay_unknownContentType.xul b/content/overlay_unknownContentType.xul
index 8f25565..267fcb7 100644
--- a/content/overlay_unknownContentType.xul
+++ b/content/overlay_unknownContentType.xul
@@ -1,40 +1,40 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- ***** BEGIN LICENSE BLOCK *****
- Copyright 2007-2010 Éric Cassar (Cyan)
-
- This file is part of "Automatic Save Folder".
- You may find the license in the LICENSE file
-
- ***** END LICENSE BLOCK ***** -->
-<?xml-stylesheet href="chrome://asf/skin/overlay.css" type="text/css"?>
-<!DOCTYPE overlay SYSTEM "chrome://asf/locale/asf.dtd">
-<overlay id="asf-overlay-download"
- xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
-
-<script type="application/x-javascript" src="chrome://asf/content/asf_download.js" />
-
-<vbox id="container">
- <groupbox id="asf_dloptions" style="visibility: collapse;" flex="1">
- <caption label="Automatic Save Folder" onclick="automatic_save_folder.toggle_dloptionsContent();"/>
- <vbox id="asf_dloptions_content" style="visibility: visible;" >
- <radiogroup id="asf_radio_savepath" align="left">
- <radio id="asf_savefolder" value="0" width="280" crop="center" label="folder" class="small-indent" oncommand="automatic_save_folder.asf_toggle_savepath()"/>
- <radio id="asf_lastpath" value="1" width="280" crop="center" label="folder" class="small-indent" oncommand="automatic_save_folder.asf_toggle_savepath()"/>
- <vbox id="asf_radiogroup_pathselect" style="visibility: collapse;">
- <radio id="asf_pathselect" value="2" width="280" crop="center" label="&asf.pathselect.label;" class="small-indent" oncommand="automatic_save_folder.asf_toggle_savepath()"/>
- <hbox>
- <description value=" "/><menulist id="asf_folder_list" width="280">
- </menulist>
- </hbox>
- </vbox>
- </radiogroup>
- <separator class="thin"/>
- <hbox>
- <image src="chrome://asf/skin/add.png" onclick="window.openDialog('chrome://asf/content/options.xul','asf_option','chrome, centerscreen, resizable=yes, dialog=no, modal=no');" />
- <description onclick="window.openDialog('chrome://asf/content/options.xul','asf_option','chrome, centerscreen, resizable=yes, dialog=no, modal=no');">&asf.addedit.label;</description>
- </hbox>
- </vbox>
-
- </groupbox>
-</vbox>
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- ***** BEGIN LICENSE BLOCK *****
+ Copyright 2007-2010 Éric Cassar (Cyan)
+
+ This file is part of "Automatic Save Folder".
+ You may find the license in the LICENSE file
+
+ ***** END LICENSE BLOCK ***** -->
+<?xml-stylesheet href="chrome://asf/skin/overlay.css" type="text/css"?>
+<!DOCTYPE overlay SYSTEM "chrome://asf/locale/asf.dtd">
+<overlay id="asf-overlay-download"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+<script type="application/x-javascript" src="chrome://asf/content/asf_download.js" />
+
+<vbox id="container">
+ <groupbox id="asf_dloptions" style="visibility: collapse;" flex="1">
+ <caption label="Automatic Save Folder" onclick="automatic_save_folder.toggle_dloptionsContent();"/>
+ <vbox id="asf_dloptions_content" style="visibility: visible;" >
+ <radiogroup id="asf_radio_savepath" align="left">
+ <radio id="asf_savefolder" value="0" width="280" crop="center" label="folder" class="small-indent" oncommand="automatic_save_folder.asf_toggle_savepath()"/>
+ <radio id="asf_lastpath" value="1" width="280" crop="center" label="folder" class="small-indent" oncommand="automatic_save_folder.asf_toggle_savepath()"/>
+ <vbox id="asf_radiogroup_pathselect" style="visibility: collapse;">
+ <radio id="asf_pathselect" value="2" width="280" crop="center" label="&asf.pathselect.label;" class="small-indent" oncommand="automatic_save_folder.asf_toggle_savepath()"/>
+ <hbox>
+ <description value=" "/><menulist id="asf_folder_list" width="280">
+ </menulist>
+ </hbox>
+ </vbox>
+ </radiogroup>
+ <separator class="thin"/>
+ <hbox>
+ <image src="chrome://asf/skin/add.png" onclick="window.openDialog('chrome://asf/content/options.xul','asf_option','chrome, centerscreen, resizable=yes, dialog=no, modal=no');" />
+ <description onclick="window.openDialog('chrome://asf/content/options.xul','asf_option','chrome, centerscreen, resizable=yes, dialog=no, modal=no');">&asf.addedit.label;</description>
+ </hbox>
+ </vbox>
+
+ </groupbox>
+</vbox>
</overlay>
\ No newline at end of file
diff --git a/content/regexp.xul b/content/regexp.xul
index 905fe96..63b6b24 100644
--- a/content/regexp.xul
+++ b/content/regexp.xul
@@ -1,25 +1,25 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- ***** BEGIN LICENSE BLOCK *****
- Copyright 2007-2010 Éric Cassar (Cyan)
-
- This file is part of "Automatic Save Folder".
- You may find the license in the LICENSE file
-
- ***** END LICENSE BLOCK ***** -->
-<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
-<!DOCTYPE dialog SYSTEM "chrome://asf/locale/asf.dtd">
-
-<dialog flex="1000" title="&asf.regexp.title;"
- orient="vertical"
- buttons="accept"
- ondialogaccept="window.opener.focus;window.close();"
- xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
-<groupbox flex="1" >
- <caption label="&asf.regexp.label;"/>
-
- <iframe flex="1" id="mytextbox" class="plain" style="background-color:#FFFFFF; min-height:300px;"
- width="580"
- src="chrome://asf/content/help/regexp.xhtml"
- />
-</groupbox>
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- ***** BEGIN LICENSE BLOCK *****
+ Copyright 2007-2010 Éric Cassar (Cyan)
+
+ This file is part of "Automatic Save Folder".
+ You may find the license in the LICENSE file
+
+ ***** END LICENSE BLOCK ***** -->
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<!DOCTYPE dialog SYSTEM "chrome://asf/locale/asf.dtd">
+
+<dialog flex="1000" title="&asf.regexp.title;"
+ orient="vertical"
+ buttons="accept"
+ ondialogaccept="window.opener.focus;window.close();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+<groupbox flex="1" >
+ <caption label="&asf.regexp.label;"/>
+
+ <iframe flex="1" id="mytextbox" class="plain" style="background-color:#FFFFFF; min-height:300px;"
+ width="580"
+ src="chrome://asf/content/help/regexp.xhtml"
+ />
+</groupbox>
</dialog>
\ 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