diff options
Diffstat (limited to 'files/fr/mozilla/add-ons/webextensions/api/downloads/onchanged/index.html')
| -rw-r--r-- | files/fr/mozilla/add-ons/webextensions/api/downloads/onchanged/index.html | 150 |
1 files changed, 150 insertions, 0 deletions
diff --git a/files/fr/mozilla/add-ons/webextensions/api/downloads/onchanged/index.html b/files/fr/mozilla/add-ons/webextensions/api/downloads/onchanged/index.html new file mode 100644 index 0000000000..eced6b4bae --- /dev/null +++ b/files/fr/mozilla/add-ons/webextensions/api/downloads/onchanged/index.html @@ -0,0 +1,150 @@ +--- +title: downloads.onChanged +slug: Mozilla/Add-ons/WebExtensions/API/downloads/onChanged +tags: + - API + - Add-ons + - Event + - Extensions + - Non-standard + - Reference + - Téléchargement + - WebExtensions + - downloads + - onChanged +translation_of: Mozilla/Add-ons/WebExtensions/API/downloads/onChanged +--- +<div>{{AddonSidebar()}}</div> + +<p>L'événement <code><strong>onChanged</strong></code><strong><code>()</code></strong> de l'API {{WebExtAPIRef("downloads")}} est déclenché lorsque l'une des propriétés de {{WebExtAPIRef('downloads.DownloadItem')}} change (à l'exception de <code>bytesReceived</code>).</p> + +<p>L'écouteur reçoit un fichier <code>downloadDelta</code> en tant que paramètre — un objet contenant le <code>downloadId</code> de l'objet {{WebExtAPIRef('downloads.DownloadItem')}} en question, plus le statut de toutes les propriétés qui ont changé.</p> + +<h2 id="Syntaxe">Syntaxe</h2> + +<pre class="syntaxbox brush:js">browser.downloads.onChanged.addListener(listener) +browser.downloads.onChanged.removeListener(listener) +browser.downloads.onChanged.hasListener(listener) +</pre> + +<p>Les événements ont trois fonctions :</p> + +<dl> + <dt><code>addListener(callback)</code></dt> + <dd>Ajoute un écouteur à cet événement.</dd> + <dt><code>removeListener(listener)</code></dt> + <dd>Arrêtez d'écouter cet événement. L'argument <code>listener</code> est l'écouteur à supprimer.</dd> + <dt><code>hasListener(listener)</code></dt> + <dd>Vérifiez si un <code>listener</code> donné est enregistré pour cet événement. Renvoie <code>true</code> s'il écoute, sinon <code>false</code>.</dd> +</dl> + +<h2 id="Syntaxe_addListener">Syntaxe addListener</h2> + +<h3 id="Parameters">Parameters</h3> + +<dl> + <dt><code>callback</code></dt> + <dd> + <p>Une fonction de rappel qui sera appelée lorsque cet événement se produira. Cette fonction recevra les arguments suivants :</p> + + <dl class="reference-values"> + <dt><code>downloadDelta</code></dt> + <dd>Un <a href="#downloadDelta"><code>objet</code></a> représentant l'objet {{WebExtAPIRef('downloads.DownloadItem')}} qui a été modifié, ainsi que l'état de toutes les propriétés qui y ont été modifiées.</dd> + </dl> + </dd> +</dl> + +<h2 id="Objets_supplémentaires">Objets supplémentaires</h2> + +<h3 id="downloadDelta">downloadDelta</h3> + +<p>L'objet <code>downloadDelta</code> a les propriétés suivantes disponibles :</p> + +<dl class="reference-values"> + <dt><code>id</code></dt> + <dd>Un <code>integer</code> représentant l'identifiant de l'<code>id</code> {{WebExtAPIRef('downloads.DownloadItem')}} qui a changé.</dd> + <dt><code>url</code>{{optional_inline}}</dt> + <dd>Un objet {{WebExtAPIRef('downloads.StringDelta')}} décrivant une modification d'une <code>url</code> {{WebExtAPIRef('downloads.DownloadItem')}}.</dd> + <dt><code>filename</code>{{optional_inline}}</dt> + <dd>Un objet {{WebExtAPIRef('downloads.StringDelta')}} décrivant un changement dans un <code>filename</code> {{WebExtAPIRef('downloads.DownloadItem')}}</dd> + <dt><code>danger</code>{{optional_inline}}</dt> + <dd>Un objet {{WebExtAPIRef('downloads.StringDelta')}} décrivant un changement dans un <code>danger</code> {{WebExtAPIRef('downloads.DownloadItem')}}.</dd> + <dt><code>mime</code>{{optional_inline}}</dt> + <dd>Un objet {{WebExtAPIRef('downloads.StringDelta')}} décrivant un changement dans un <code>mime</code> {{WebExtAPIRef('downloads.DownloadItem')}}</dd> + <dt><code>startTime</code>{{optional_inline}}</dt> + <dd>Un objet {{WebExtAPIRef('downloads.StringDelta')}} décrivant un changement dans un <code>startTime</code> {{WebExtAPIRef('downloads.DownloadItem')}}.</dd> + <dt><code>endTime</code>{{optional_inline}}</dt> + <dd>Un objet {{WebExtAPIRef('downloads.StringDelta')}} décrivant un changement dans un <code>endTime</code> {{WebExtAPIRef('downloads.DownloadItem')}}.</dd> + <dt><code>state</code>{{optional_inline}}</dt> + <dd>Un objet {{WebExtAPIRef('downloads.StringDelta')}} décrivant un changement dans un <code>état</code> {{WebExtAPIRef('downloads.DownloadItem')}}</dd> + <dt><code>canResume</code>{{optional_inline}}</dt> + <dd>Un objet {{WebExtAPIRef('downloads.BooleanDelta')}} décrivant un changement dans un état {{WebExtAPIRef('downloads.DownloadItem')}} <code>canResume</code>.</dd> + <dt><code>paused</code>{{optional_inline}}</dt> + <dd>Un objet {{WebExtAPIRef('downloads.BooleanDelta')}} décrivant un changement dans un état en <code>pause</code> {{WebExtAPIRef('downloads.DownloadItem')}}.</dd> + <dt><code>error</code>{{optional_inline}}</dt> + <dd>Un objet {{WebExtAPIRef('downloads.StringDelta')}} décrivant un changement dans un état d'<code>erreur</code> {{WebExtAPIRef('downloads.DownloadItem')}}.</dd> + <dt><code>totalBytes</code>{{optional_inline}}</dt> + <dd>Un objet {{WebExtAPIRef('downloads.DoubleDelta')}} décrivant un changement dans un <code>totalBytes</code> {{WebExtAPIRef('downloads.DownloadItem')}}.</dd> + <dt><code>fileSize</code>{{optional_inline}}</dt> + <dd>Un objet {{WebExtAPIRef('downloads.DoubleDelta')}} décrivant une modification d'un <code>fileSize</code> {{WebExtAPIRef('downloads.DownloadItem')}}.</dd> + <dt><code>exists</code>{{optional_inline}}</dt> + <dd>Un objet {{WebExtAPIRef('downloads.BooleanDelta')}} décrivant un changement dans un état {{WebExtAPIRef('downloads.DownloadItem')}}.</dd> +</dl> + +<h2 id="Compatibilité_du_navigateur">Compatibilité du navigateur</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("webextensions.api.downloads.onChanged")}}</p> + +<h2 id="Exemples">Exemples</h2> + +<p>Enregistrez un message lorsque les téléchargements sont terminés :</p> + +<pre class="brush: js">function handleChanged(delta) { + if (delta.state && delta.state.current === "complete") { + console.log(`Download ${delta.id} has completed.`); + } +} + +browser.downloads.onChanged.addListener(handleChanged);</pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Acknowledgements</strong> + +<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/downloads#event-onChanged"><code>chrome.downloads</code></a> API.</p> + +<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> |
