[Pkg-mozext-commits] [automatic-save-folder] 82/133: Add : It's now possible to install the beta updates directly from the add-on option's tab. (Firefox 4 is needed to see the install link.)

David Prévot taffit at moszumanska.debian.org
Mon Apr 27 20:33:54 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 78c24109c62158e38ff5a76f1ab8676a470d87eb
Author: Cyan <Cyan at d0063192-6b2e-11de-89a9-0b20f3e2dceb>
Date:   Tue Aug 17 19:27:19 2010 +0000

    Add : It's now possible to install the beta updates directly from the add-on
          option's tab. (Firefox 4 is needed to see the install link.)
    
    Change : Read the current tab's data using the windows interface instead of DOM.
    
    git-svn-id: http://automatic-save-folder.googlecode.com/svn/trunk@88 d0063192-6b2e-11de-89a9-0b20f3e2dceb
---
 content/asf.js              | 51 +++++++++++++++++++++++++++++++++++----------
 content/asf_download.js     | 24 ++++++++++++---------
 content/common.dtd          |  2 +-
 content/options.xul         |  2 ++
 locale/en-US/asf.dtd        |  1 +
 locale/en-US/asf.properties |  2 ++
 locale/fr/asf.dtd           |  1 +
 locale/fr/asf.properties    |  2 ++
 locale/it/asf.dtd           |  1 +
 locale/it/asf.properties    |  2 ++
 locale/ru/asf.dtd           |  1 +
 locale/ru/asf.properties    |  2 ++
 12 files changed, 69 insertions(+), 22 deletions(-)

diff --git a/content/asf.js b/content/asf.js
index e993b49..1d16197 100644
--- a/content/asf.js
+++ b/content/asf.js
@@ -591,20 +591,22 @@ var automatic_save_folder = {
 	asf_getdomain: function () {  // Save the domain and filename in a hidden field, to be used by the "add" button for auto-complete field.
 		if (window.opener.location == "chrome://mozapps/content/downloads/unknownContentType.xul")  // if the option is opened from the saving window
 		{
-			var uCT = window.opener.document.getElementById("unknownContentType");
+			var tBrowser = Components.classes["@mozilla.org/appshell/window-mediator;1"]
+				 .getService(Components.interfaces.nsIWindowMediator).getMostRecentWindow("navigator:browser").getBrowser();
+			var tabLocation = tBrowser.mCurrentTab.linkedBrowser.contentDocument.location;
 			var filename = 			window.opener.document.getElementById("location").value ;
 			var domain = 			window.opener.document.getElementById("source").value ;
 			var fileURL = 			window.opener.document.getElementById("source").getAttribute("tooltiptext");
 			var fileURLAndFilename= window.opener.document.getElementById("source").getAttribute("tooltiptext") + filename;
-			try
+			var currentDomain, currentURL = "";
+			try 
 			{
-				var currentDomain, currentURL = "";
-				currentDomain = 	uCT.parentNode.defaultView.opener.location.protocol + "//" + uCT.parentNode.defaultView.opener.location.host; // look for the current website URL in the DOM.
-				currentURL = 		uCT.parentNode.defaultView.opener.location.href; // look for the current website URL in the DOM.
+				currentDomain = 	tabLocation.protocol + "//" + tabLocation.host; // look for the current website URL in the DOM.
+				currentURL = 		tabLocation.href; // look for the current website URL in the DOM.
 			}
-			catch(e) // if there is no data (The tab is closed or it's a script redirection), use the file's data.
+			catch (e) // if there is no data (The tab is closed or it's a script redirection), use the file's data.
 			{
-				currentDomain = domain; 
+				currentDomain = domain;
 				currentURL = fileURL;
 			}
 			
@@ -925,16 +927,23 @@ var automatic_save_folder = {
 		{
 			if (XhrObj.readyState == 4 && XhrObj.status == 200)
 			{
-				latest_version = XhrObj.responseText ;
+				latest_version = XhrObj.responseText.split("\n") ;
 				if(automatic_save_folder.versionChecker.compare(latest_version, current_version) > 0)
 				{
 					document.getElementById('asf-checkBetaUpdate').hidden = true;
 					document.getElementById('asf-betaVersionAvailable').hidden = false;
-					document.getElementById('asf-version').value = latest_version;
+					document.getElementById('asf-version').value = latest_version[0];
 					document.getElementById('asf-version').hidden = false;
+					document.getElementById('asf-betaUpdate-URL').value = latest_version[1];
+					
+					if (automatic_save_folder.firefoxversion == 4)
+					{
+						document.getElementById('asf-betaVersionUpdateNow').hidden = false;
+					}
 					if(showalert)
 					{
-						alert(document.getElementById('asf-betaVersionAvailable').textContent + "\nAutomatic Save Folder v" + document.getElementById('asf-version').value);
+						var message = automatic_save_folder.stringbundle.formatStringFromName("checkForUpdates.updateAvailable", latest_version, 1);
+						alert(message);
 					}
 				}
 				else
@@ -947,7 +956,27 @@ var automatic_save_folder = {
 		
 		XhrObj.open("POST", "http://asf.mangaheart.org/latestBetaVersion.php");
 		XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
-		XhrObj.send("version="+current_version);
+		XhrObj.send("version="+current_version+"&link=true");
+	},
+
+
+	updateASF: function(location) {
+		
+		var location = document.getElementById("asf-betaUpdate-URL").value;
+		//location = "http://asf.mangaheart.org/xpi/beta/automatic_save_folder-1.0.2bRev0086.xpi";
+		if (this.firefoxversion == 4) // update to new version
+		{
+			Components.utils.import("resource://gre/modules/AddonManager.jsm");  
+			
+			AddonManager.getInstallForURL(location, function(aInstall) {  
+			
+			// aInstall is an instance of {{AMInterface("AddonInstall")}}  
+			aInstall.install(); 
+			alert("install finish, you need to reboot now");
+			document.getElementById('asf-betaVersionUpdateNow').hidden = true;
+			}, "application/x-xpinstall");  
+		}
+		
 	},
 
 
diff --git a/content/asf_download.js b/content/asf_download.js
index f0092a4..4f2403d 100644
--- a/content/asf_download.js
+++ b/content/asf_download.js
@@ -65,17 +65,19 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
 		
 		
 		// load the domain and the filename of the saved file (copy the data from the firefox saving window)
-		var uCT = 				document.getElementById("unknownContentType");
+		var tBrowser = Components.classes["@mozilla.org/appshell/window-mediator;1"]
+				 .getService(Components.interfaces.nsIWindowMediator).getMostRecentWindow("navigator:browser").getBrowser();
+		var tabLocation = tBrowser.mCurrentTab.linkedBrowser.contentDocument.location;
 		var filename = 			document.getElementById("location").value ;
 		var domain = 			document.getElementById("source").value ;
 		var	domainWithoutProtocol = domain.replace(/^.*:\/\//g,'');  // remove the protocol name from the domain
 		var fileURL = 			document.getElementById("source").getAttribute("tooltiptext");
 		var fileURLAndFilename= document.getElementById("source").getAttribute("tooltiptext") + filename;
+		var currentDomain, currentURL = "";
 		try
 		{
-			var currentDomain, currentURL = "";
-			currentDomain = 	uCT.parentNode.defaultView.opener.location.protocol + "//" + uCT.parentNode.defaultView.opener.location.host; // look for the current website URL in the DOM.
-			currentURL = 		uCT.parentNode.defaultView.opener.location.href; // look for the current website URL in the DOM.
+			currentDomain = 	tabLocation.protocol + "//" + tabLocation.host; // look for the current website URL in the DOM.
+			currentURL = 		tabLocation.href; // look for the current website URL in the DOM.
 		}
 		catch (e) // if there is no data (The tab is closed or it's a script redirection), use the file's data.
 		{
@@ -445,7 +447,9 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
 		const ZERO = "0";  // leading zero
 		
 		// load the domain and the filename of the saved file
-		var uCT =				document.getElementById("unknownContentType");
+		var tBrowser = Components.classes["@mozilla.org/appshell/window-mediator;1"]
+				 .getService(Components.interfaces.nsIWindowMediator).getMostRecentWindow("navigator:browser").getBrowser();
+		var tabLocation = tBrowser.mCurrentTab.linkedBrowser.contentDocument.location;
 		var 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)
@@ -453,15 +457,15 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
 		var	domainWithoutProtocol = domain.replace(/^.*:\/\//g,'');  // remove the protocol name from the domain
 		var fileURL =			document.getElementById("source").getAttribute("tooltiptext");
 		var fileURLAndFilename= document.getElementById("source").getAttribute("tooltiptext") + filename;
-		try
+		var currentDomain, currentURL = "";
+		try 
 		{
-			var currentDomain, currentURL = "";
-			currentDomain = 	uCT.parentNode.defaultView.opener.location.protocol + "//" + uCT.parentNode.defaultView.opener.location.host; // look for the current website URL in the DOM.
-			currentURL = 		uCT.parentNode.defaultView.opener.location.href; // look for the current website URL in the DOM.
+			currentDomain = 	tabLocation.protocol + "//" + tabLocation.host; // look for the current website URL in the DOM.
+			currentURL = 		tabLocation.href; // look for the current website URL in the DOM.
 		}
 		catch (e) // if there is no data (The tab is closed or it's a script redirection), use the file's data.
 		{
-			currentDomain = domain; 
+			currentDomain = domain;
 			currentURL = fileURL;
 		}
 		
diff --git a/content/common.dtd b/content/common.dtd
index f7d7877..b3c2388 100644
--- a/content/common.dtd
+++ b/content/common.dtd
@@ -1,5 +1,5 @@
 <!-- Current version -->
-<!ENTITY asf.version "1.0.2bRev87">
+<!ENTITY asf.version "1.0.2bRev88">
 
 <!ENTITY about.translators "
 - en-US : Cyan, Narayan<br />
diff --git a/content/options.xul b/content/options.xul
index d904d2c..a4045ae 100644
--- a/content/options.xul
+++ b/content/options.xul
@@ -145,6 +145,7 @@
 			<textbox id="asf-currentDL-fileURLAndFilename" value="" />
 			<textbox id="asf-currentDL-currentDomain" value="" />
 			<textbox id="asf-currentDL-currentURL" value="" />
+			<textbox id="asf-betaUpdate-URL" value="" />
 			<textbox id="asf-preferences-window-resize" value="&asf.preferences_window.resize;" />
 			<textbox id="asf-preferences-window-width" value="&asf.preferences_window.width;" />
 			<textbox id="asf-preferences-window-height" value="&asf.preferences_window.height;" />
@@ -207,6 +208,7 @@
 									<description id="asf-betaVersionAvailable" hidden="true">&asf.betaVersionAvailable.label;</description>
 									<description id="asf-betaVersionNotAvailable" hidden="true">&asf.betaVersionNotAvailable.label;</description>
 									<label id="asf-version" href="http://asf.mangaheart.org/?menu=2&sub=2" class="text-link" hidden="true" value="&asf.version;" />
+									<label id="asf-betaVersionUpdateNow" class="text-link" hidden="true" value="&asf.betaVersionUpdateNow.label;" onclick="automatic_save_folder.updateASF();"/>
 								</hbox>
 								<checkbox id="asf-autoCheckBetaUpdate" preference="asf_autoCheckBetaUpdate" label="&asf.autoCheckBetaUpdate.bool;" />
 							</groupbox>
diff --git a/locale/en-US/asf.dtd b/locale/en-US/asf.dtd
index 72b87dc..4c7dde9 100644
--- a/locale/en-US/asf.dtd
+++ b/locale/en-US/asf.dtd
@@ -76,6 +76,7 @@
 <!ENTITY asf.betaVersionAvailable.label "A new version is available:">
 <!ENTITY asf.betaVersionNotAvailable.label "No new version available.">
 <!ENTITY asf.autoCheckBetaUpdate.bool "Automatically check when opening the preferences window.">
+<!ENTITY asf.betaVersionUpdateNow.label "Update now">
 
 <!ENTITY asf.options.groupbox3.label "Filtering options">
 <!ENTITY asf.lastdir.bool "Affect the folder for the 'save as...' command when a filter matches">
diff --git a/locale/en-US/asf.properties b/locale/en-US/asf.properties
index 161ab22..07f8c26 100644
--- a/locale/en-US/asf.properties
+++ b/locale/en-US/asf.properties
@@ -43,3 +43,5 @@ select_folder=Please select the destination folder for this filter.
 nodata.domain=The domain is empty. Please choose 'All' or enter a filter for the domain.
 nodata.filename=The filename is empty. Please choose 'All' or enter a filter for the filename.
 nodata.folder=The folder is empty. Please select the destination folder for this filter.
+checkForUpdates.updateAvailable=Update notification\nAutomatic Save Folder %S is available.\nYou can install this version from the option's tab.
+checkForUpdates.updated=The new version has been installed.\nYou need to restart Firefox to see the changes.
\ No newline at end of file
diff --git a/locale/fr/asf.dtd b/locale/fr/asf.dtd
index 2fd4bf7..423d219 100644
--- a/locale/fr/asf.dtd
+++ b/locale/fr/asf.dtd
@@ -76,6 +76,7 @@
 <!ENTITY asf.betaVersionAvailable.label "Une nouvelle version est disponible :">
 <!ENTITY asf.betaVersionNotAvailable.label "Pas de nouvelle version disponible.">
 <!ENTITY asf.autoCheckBetaUpdate.bool "Vérifier automatiquement à l'ouverture des préférences.">
+<!ENTITY asf.betaVersionUpdateNow.label "Mettre à jour maintenant">
 
 <!ENTITY asf.options.groupbox3.label "Pendant le filtrage">
 <!ENTITY asf.lastdir.bool "Modifier aussi le dossier d'enregistrement utilisé par le menu 'Enregistrer sous... (Ctrl+S)'">
diff --git a/locale/fr/asf.properties b/locale/fr/asf.properties
index 20bbea5..820ac23 100644
--- a/locale/fr/asf.properties
+++ b/locale/fr/asf.properties
@@ -43,3 +43,5 @@ select_folder=Sélectionnez le dossier de destination pour ce filtre.
 nodata.domain=Le domaine est vide. Veuillez sélectionner 'Tous' ou entrer un filtre pour le domaine
 nodata.filename=Le nom de fichier est vide. Veuillez sélectionner 'Tous' ou entrer un filtre pour le nom de fichier
 nodata.folder=Le dossier n'est pas défini. Veuillez sélectionner le dossier de destination pour ce filtre
+checkForUpdates.updateAvailable=Alerte de mise à jour\nAutomatic Save Folder %S est disponible.\nVous pouvez l'installer en allant dans l'onglet des options.
+checkForUpdates.updated=La nouvelle version à été installée.\nVous devez redémarrer Firefox pour appliquer les changements.
\ No newline at end of file
diff --git a/locale/it/asf.dtd b/locale/it/asf.dtd
index e7ce1d3..3e3ddfe 100644
--- a/locale/it/asf.dtd
+++ b/locale/it/asf.dtd
@@ -76,6 +76,7 @@
 <!ENTITY asf.betaVersionAvailable.label "A new version is available:">
 <!ENTITY asf.betaVersionNotAvailable.label "No new version available.">
 <!ENTITY asf.autoCheckBetaUpdate.bool "Automatically check when opening the preferences window.">
+<!ENTITY asf.betaVersionUpdateNow.label "Update now">
 
 <!ENTITY asf.options.groupbox3.label "Filtering options">
 <!ENTITY asf.lastdir.bool "Ha effetto sulla cartella per il comando 'Salva come...' quando un filtro corrisponde">
diff --git a/locale/it/asf.properties b/locale/it/asf.properties
index 0283771..f858c5d 100644
--- a/locale/it/asf.properties
+++ b/locale/it/asf.properties
@@ -43,3 +43,5 @@ select_folder=Scegli una cartella di destinazione per questo filtro.
 nodata.domain=Il campo dominio è vuoto. Scegli 'tutti' o inserisci un filtro per il dominio
 nodata.filename=Il campo Nome File è vuoto. Scegli 'tutti' o inserisci un filtro per il nome file
 nodata.folder=La cartella è vuota. Scegli una cartella di destinazione per questo filtro
+checkForUpdates.updateAvailable=Update notification\nAutomatic Save Folder %S is available.\nYou can install this version from the option's tab.
+checkForUpdates.updated=The new version has been installed.\nYou need to restart Firefox to see the changes.
\ No newline at end of file
diff --git a/locale/ru/asf.dtd b/locale/ru/asf.dtd
index a0c485c..fa9c6f5 100644
--- a/locale/ru/asf.dtd
+++ b/locale/ru/asf.dtd
@@ -76,6 +76,7 @@
 <!ENTITY asf.betaVersionAvailable.label "A new version is available:">
 <!ENTITY asf.betaVersionNotAvailable.label "No new version available.">
 <!ENTITY asf.autoCheckBetaUpdate.bool "Automatically check when opening the preferences window.">
+<!ENTITY asf.betaVersionUpdateNow.label "Update now">
 
 <!ENTITY asf.options.groupbox3.label "Настройки фильтров">
 <!ENTITY asf.lastdir.bool "Изменять папку для команды "сохранить как..." когда есть подходящий фильтр">
diff --git a/locale/ru/asf.properties b/locale/ru/asf.properties
index da7d5d8..a7860b0 100644
--- a/locale/ru/asf.properties
+++ b/locale/ru/asf.properties
@@ -43,3 +43,5 @@ select_folder=Пожалуйста укажите папку назначени
 nodata.domain=Имя домена пустое. Пожалуйста выберите "Все" или введите имя домена.
 nodata.filename=Имя файла пустое. Пожалуйста выберите "Все" или введите имя файла.
 nodata.folder=Папка назначения пустая. Пожалуйста укажите папку назначения для фильтра.
+checkForUpdates.updateAvailable=Update notification\nAutomatic Save Folder %S is available.\nYou can install this version from the option's tab.
+checkForUpdates.updated=The new version has been installed.\nYou need to restart Firefox to see the changes.
\ 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