[Pkg-mozext-commits] [automatic-save-folder] 55/133: Add : Added hidden features for experimented users. Can be manually added and edited in about:config

David Prévot taffit at moszumanska.debian.org
Mon Apr 27 20:33:52 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 8a15a33814efeb6b3f5ac7150d7fb77b19986d9c
Author: Cyan <Cyan at d0063192-6b2e-11de-89a9-0b20f3e2dceb>
Date:   Fri Feb 5 20:47:12 2010 +0000

    Add :
    Added hidden features for experimented users.
    Can be manually added and edited in about:config
    
    Boolean :
      extension.asf.regexp_caseinsensitive
         set the case insensitivity property to all the regular expression used
         in ASF. (default true)
    
      extensions.asf.pathlist_defaultforceontop
         force the default folder define in the main filter's tab at the top the the
         drop-down path lists. (default false)
    
      extensions.asf.pathlist_alphasort
         Sort the drop-down path list in alphabetical order instead of filter's
         order. (default: true)
    
    Char :
      extensions.asf.rowmatchinghighlight
         Set the visual effect of the selected filter over a colored row.
         color = keep the colored row, system = use the system highlight color
        (default: color)
    
    git-svn-id: http://automatic-save-folder.googlecode.com/svn/trunk@55 d0063192-6b2e-11de-89a9-0b20f3e2dceb
---
 content/asf.js             | 67 +++++++++++++++++++++++++++++++---------------
 content/asf_addedit.js     | 38 +++++++++++++++++++++++---
 content/asf_download.js    | 56 +++++++++++++++++++++++++++++++-------
 content/asf_right_click.js | 33 +++++++++++++++++++----
 4 files changed, 154 insertions(+), 40 deletions(-)

diff --git a/content/asf.js b/content/asf.js
index afa2b47..75bd980 100644
--- a/content/asf.js
+++ b/content/asf.js
@@ -260,34 +260,39 @@ var automatic_save_folder = {
 				}
 			}
 			
-			// enable this to set black border to the selected colored row
-			if((tree.currentIndex > -1) && (tree.view.getItemAtIndex(tree.currentIndex).firstChild.hasAttribute('properties')) )
+			// rowmatchinghighlight : color = keep the colored row even if selected | system = revert back to system highlight color if selected
+			var rowmatchinghighlight = this.readHiddenPref("extensions.asf.rowmatchinghighlight", "char", "color");	// let the user choose in next release.
+			if (rowmatchinghighlight == "color")
 			{
-				currentitem = tree.view.getItemAtIndex(tree.currentIndex);
-				color = currentitem.firstChild.getAttribute('properties');
-				if (color == "FilterTestPass") 
+				// enable this to set black border to the selected colored row
+				if((tree.currentIndex > -1) && (tree.view.getItemAtIndex(tree.currentIndex).firstChild.hasAttribute('properties')) )
 				{
-					currentitem.firstChild.setAttribute('properties', "FilterTestPassSelected");
-					currentitem.firstChild.children[0].setAttribute('properties', "FilterTestPassSelected");
-					currentitem.firstChild.children[1].setAttribute('properties', "FilterTestPassSelected");
-					currentitem.firstChild.children[2].setAttribute('properties', "FilterTestPassSelected");
+					currentitem = tree.view.getItemAtIndex(tree.currentIndex);
+					color = currentitem.firstChild.getAttribute('properties');
+					if (color == "FilterTestPass") 
+					{
+						currentitem.firstChild.setAttribute('properties', "FilterTestPassSelected");
+						currentitem.firstChild.children[0].setAttribute('properties', "FilterTestPassSelected");
+						currentitem.firstChild.children[1].setAttribute('properties', "FilterTestPassSelected");
+						currentitem.firstChild.children[2].setAttribute('properties', "FilterTestPassSelected");
+					}
+					if (color == "FilterTestFail")
+					{
+						currentitem.firstChild.setAttribute('properties', "FilterTestFailSelected");
+						currentitem.firstChild.children[0].setAttribute('properties', "FilterTestFailSelected");
+						currentitem.firstChild.children[1].setAttribute('properties', "FilterTestFailSelected");
+						currentitem.firstChild.children[2].setAttribute('properties', "FilterTestFailSelected");
+					}
 				}
-				if (color == "FilterTestFail")
+			}
+			else // enable this to remove the color of the selected item
+			{
+				if((tree.currentIndex > -1) && (tree.view.getItemAtIndex(tree.currentIndex).firstChild.hasAttribute('properties')) )
 				{
-					currentitem.firstChild.setAttribute('properties', "FilterTestFailSelected");
-					currentitem.firstChild.children[0].setAttribute('properties', "FilterTestFailSelected");
-					currentitem.firstChild.children[1].setAttribute('properties', "FilterTestFailSelected");
-					currentitem.firstChild.children[2].setAttribute('properties', "FilterTestFailSelected");
+					currentitem = tree.view.getItemAtIndex(tree.currentIndex);
+					currentitem.firstChild.removeAttribute('properties');
 				}
-				
-
 			}
-			// enable this to remove the color of the selected item
-			// if((tree.currentIndex > -1) && (tree.view.getItemAtIndex(tree.currentIndex).firstChild.hasAttribute('properties')) )
-			// {
-				// currentitem = tree.view.getItemAtIndex(tree.currentIndex);
-				// currentitem.firstChild.removeAttribute('properties');
-			// }
 		}
 	},
 
@@ -809,6 +814,24 @@ var automatic_save_folder = {
 	},
 
 
+	readHiddenPref: function(pref_place, type, ret) {
+		try 
+		{
+			switch (type)
+			{
+				case "bool": return this.prefManager.getBoolPref(pref_place);
+				case "int" : return this.prefManager.getIntPref(pref_place);
+				case "char": return this.prefManager.getCharPref(pref_place);
+				case "complex": return this.prefManager.getComplexValue(pref_place, Components.interfaces.nsISupportsString).data;
+			}
+		} 
+		catch(e) 
+		{
+			return ret; // return default value if pref doesn't exist
+		} 
+	},
+
+
 	asf_savefilters: function () {
 	//save the filters list	
 		var tree = document.getElementById("asf-filterList");
diff --git a/content/asf_addedit.js b/content/asf_addedit.js
index 81bc355..23b9c2e 100644
--- a/content/asf_addedit.js
+++ b/content/asf_addedit.js
@@ -545,9 +545,23 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
 		
 		// Write each path to the menupopup
 		var pathlist = new Array();
+		var pathlist_defaultforceontop = this.readHiddenPref("extensions.asf.pathlist_defaultforceontop", "bool", false); // let the user choose in next release.
 		var defaultfolder = window.opener.document.getElementById("asf-default-folder").value;
-		pathlist[0] = defaultfolder;
 		var j = 0;
+		if (pathlist_defaultforceontop)
+		{
+			var menuitem = document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'menuitem');
+			menuitem.setAttribute('label', defaultfolder);
+			menuitem.setAttribute('crop', 'center');
+			menuitem.setAttribute('value', defaultfolder);
+			menupopup.appendChild(menuitem);
+		}
+		else
+		{
+			pathlist[0] = defaultfolder;
+			j++;
+		}
+		
 		for (var i = 0; i < nbrfilters; i++)
 		{
 			// read the filter number i
@@ -555,11 +569,11 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
 			
 			if (this.indexInArray(pathlist, path) < 0)
 			{ 
-				pathlist[++j]= path;
+				pathlist[j++]= path;
 			}
 		}
 		
-		var pathlist_sort_alpha = true;   // let the user choose in next release.
+		var pathlist_sort_alpha = this.readHiddenPref("extensions.asf.pathlist_alphasort", "bool", true); // let the user choose in next release.
 		if (pathlist_sort_alpha) pathlist.sort(); 
 		
 		
@@ -589,7 +603,23 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
 			if(test_regexp.test(arr[i])) return i;
 		}
 		return -1;
-	}
+	},
 
 
+	readHiddenPref: function(pref_place, type, ret) {
+		try 
+		{
+			switch (type)
+			{
+				case "bool": return this.prefManager.getBoolPref(pref_place);
+				case "int" : return this.prefManager.getIntPref(pref_place);
+				case "char": return this.prefManager.getCharPref(pref_place);
+				case "complex": return this.prefManager.getComplexValue(pref_place, Components.interfaces.nsISupportsString).data;
+			}
+		} 
+		catch(e) 
+		{
+			return ret; // return default value if pref doesn't exist
+		} 
+	}
 };
\ No newline at end of file
diff --git a/content/asf_download.js b/content/asf_download.js
index 5021ed7..393bf4b 100644
--- a/content/asf_download.js
+++ b/content/asf_download.js
@@ -433,6 +433,11 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
 			asf_filename = asf_filename.substring(0, asf_filename.length -1);
 		}
 		
+		// read the userpref to define if regexp is case insensitive (default true)
+		var param = "";
+		var regexp_caseinsensitive = this.readHiddenPref("extensions.asf.regexp_caseinsensitive", "bool", true); // let the user choose in next release.
+		if (regexp_caseinsensitive) param = "i";
+		
 		// Check if asf_rd is present and process     asf_rd = Regexp the domain
 		if (path.search("%asf_rd%") != -1)
 		{
@@ -449,7 +454,7 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
 				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
+					datareg = new RegExp(datareg, param);			//  create the regexp
 					//alert("reg="+datareg);
 					result = domainp.match(datareg);    // Check it on the domain with protocol
 					
@@ -484,7 +489,7 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
 				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
+					datareg = new RegExp(datareg, param);			//  create the regexp
 					//alert("reg="+datareg);
 					result = filename.match(datareg);    // Check it
 					
@@ -797,9 +802,23 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
 		
 		// Write each path to the menupopup
 		var pathlist = new Array();
+		var pathlist_defaultforceontop = this.readHiddenPref("extensions.asf.pathlist_defaultforceontop", "bool", false); // let the user choose in next release.
 		var defaultfolder = this.loadUnicodeString("extensions.asf.defaultfolder");
-		pathlist[0] =  variable_mode == true? this.createfolder(defaultfolder) : defaultfolder;
 		var j = 0;
+		if (pathlist_defaultforceontop)
+		{
+			var menuitem = document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'menuitem');
+			menuitem.setAttribute('label', defaultfolder);
+			menuitem.setAttribute('crop', 'center');
+			menuitem.setAttribute('value', defaultfolder);
+			menupopup.appendChild(menuitem);
+		}
+		else
+		{
+			pathlist[0] =  variable_mode == true? this.createfolder(defaultfolder) : defaultfolder;
+			j++;
+		}
+		
 		for (var i = 0; i < nbrfilters; i++)
 		{
 			// read the filter number x
@@ -807,12 +826,12 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
 			path = variable_mode == true? this.createfolder(path, i) : path;
 			
 			if (this.indexInArray(pathlist, path) < 0)
-			{
-				pathlist[++j]= path;
+			{ 
+				pathlist[j++]= path;
 			}
 		}
 		
-		var pathlist_sort_alpha = true;   // let the user choose in next release.
+		var pathlist_sort_alpha = this.readHiddenPref("extensions.asf.pathlist_alphasort", "bool", true); // let the user choose in next release.
 		if (pathlist_sort_alpha) pathlist.sort();
 		
 		
@@ -876,7 +895,7 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
 	
 	
 	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
@@ -911,7 +930,10 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
 		}
 		
 		// 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)
+		var param = "";
+		var regexp_caseinsensitive = this.readHiddenPref("extensions.asf.regexp_caseinsensitive", "bool", true); // let the user choose in next release.
+		if (regexp_caseinsensitive) param = "i";
+		var test_regexp = new RegExp(filters, param);  // put the slash back and the gi option (g = global seach, i = case insensitive)
 		// Edited to only "i" option by Ted.
 		
 		// Step 3 & 4
@@ -940,9 +962,25 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
 		{
 			return false;
 		}
-	}
+	},
 	
 	
+	readHiddenPref: function(pref_place, type, ret) {
+		try 
+		{
+			switch (type)
+			{
+				case "bool": return this.prefManager.getBoolPref(pref_place);
+				case "int" : return this.prefManager.getIntPref(pref_place);
+				case "char": return this.prefManager.getCharPref(pref_place);
+				case "complex": return this.prefManager.getComplexValue(pref_place, Components.interfaces.nsISupportsString).data;
+			}
+		} 
+		catch(e) 
+		{
+			return ret; // return default value if pref doesn't exist
+		} 
+	}
 };
 
 	addEventListener( // Autoload
diff --git a/content/asf_right_click.js b/content/asf_right_click.js
index 2f7d0e1..8b1bf2b 100644
--- a/content/asf_right_click.js
+++ b/content/asf_right_click.js
@@ -460,6 +460,11 @@ var automatic_save_folder = {
 			asf_filename = asf_filename.substring(0, asf_filename.length -1);
 		}		
 		
+		// read the userpref to define if regexp is case insensitive (default true)
+		var param = "";
+		var regexp_caseinsensitive = this.readHiddenPref("extensions.asf.regexp_caseinsensitive", "bool", true); // let the user choose in next release.
+		if (regexp_caseinsensitive) param = "i";
+		
 		// Check if asf_rd is present and process     asf_rd = Regexp the domain
 		if (path.search("%asf_rd%") != -1)
 		{
@@ -476,7 +481,7 @@ var automatic_save_folder = {
 				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
+					datareg = new RegExp(datareg, param);			//  create the regexp
 					//alert("reg="+datareg);
 					result = domainp.match(datareg);    // Check it on the domain with protocol
 					
@@ -511,7 +516,7 @@ var automatic_save_folder = {
 				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
+					datareg = new RegExp(datareg, param);			//  create the regexp
 					//alert("reg="+datareg);
 					result = filename.match(datareg);    // Check it
 					
@@ -618,7 +623,6 @@ var automatic_save_folder = {
 	
 	
 	test_regexp: function (filters, string) {
-
 		
 		// Steps :
 		// 1 - Check if the filter is a regular expression
@@ -654,7 +658,10 @@ var automatic_save_folder = {
 		}
 		
 		// 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)
+		var param = "";
+		var regexp_caseinsensitive = this.readHiddenPref("extensions.asf.regexp_caseinsensitive", "bool", true); // let the user choose in next release.
+		if (regexp_caseinsensitive) param = "i";
+		var test_regexp = new RegExp(filters, param);  // put the slash back and the gi option (g = global seach, i = case insensitive)
 		// Edited to only "i" option by Ted.
 		
 		// Step 3 & 4
@@ -683,10 +690,26 @@ var automatic_save_folder = {
 		{
 			return false;
 		}
-	}
+	},
 	
 	
+	readHiddenPref: function(pref_place, type, ret) {
+		try 
+		{
+			switch (type)
+			{
+				case "bool": return this.prefManager.getBoolPref(pref_place);
+				case "int" : return this.prefManager.getIntPref(pref_place);
+				case "char": return this.prefManager.getCharPref(pref_place);
+				case "complex": return this.prefManager.getComplexValue(pref_place, Components.interfaces.nsISupportsString).data;
+			}
+		} 
+		catch(e) 
+		{
+			return ret; // return default value if pref doesn't exist
+		} 
 	}
+}
 	
 	addEventListener( // Autoload
 	"load",			// After OnLoad from overlay_unknownContentType.xul 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