aboutsummaryrefslogtreecommitdiff
path: root/files/pt-br/web/api/windoworworkerglobalscope
diff options
context:
space:
mode:
authorMDN <actions@users.noreply.github.com>2021-09-01 00:52:00 +0000
committerMDN <actions@users.noreply.github.com>2021-09-01 00:52:00 +0000
commitaf3288b106f44aaaa2c80d499ec669383d6f7203 (patch)
tree6d5a402249e4e8a83820c2592887062ec9202d79 /files/pt-br/web/api/windoworworkerglobalscope
parent1768b43f574673545e1f2a20e92a27b050a2bb53 (diff)
downloadtranslated-content-af3288b106f44aaaa2c80d499ec669383d6f7203.tar.gz
translated-content-af3288b106f44aaaa2c80d499ec669383d6f7203.tar.bz2
translated-content-af3288b106f44aaaa2c80d499ec669383d6f7203.zip
[CRON] sync translated content
Diffstat (limited to 'files/pt-br/web/api/windoworworkerglobalscope')
-rw-r--r--files/pt-br/web/api/windoworworkerglobalscope/atob/index.html73
-rw-r--r--files/pt-br/web/api/windoworworkerglobalscope/cleartimeout/index.html101
-rw-r--r--files/pt-br/web/api/windoworworkerglobalscope/fetch/index.html305
-rw-r--r--files/pt-br/web/api/windoworworkerglobalscope/setinterval/index.html629
4 files changed, 0 insertions, 1108 deletions
diff --git a/files/pt-br/web/api/windoworworkerglobalscope/atob/index.html b/files/pt-br/web/api/windoworworkerglobalscope/atob/index.html
deleted file mode 100644
index 4448a8b31f..0000000000
--- a/files/pt-br/web/api/windoworworkerglobalscope/atob/index.html
+++ /dev/null
@@ -1,73 +0,0 @@
----
-title: WindowBase64.atob()
-slug: Web/API/WindowOrWorkerGlobalScope/atob
-tags:
- - API
- - Referencia
- - WindowBase64
- - metodo
-translation_of: Web/API/WindowOrWorkerGlobalScope/atob
-original_slug: Web/API/WindowBase64/atob
----
-<div>{{APIRef("HTML DOM")}}</div>
-
-<p>A função <strong><code>WindowBase64.atob()</code></strong> decodifica uma string de dados que foi codificada através da codificação base-64. Você pode usar o método {{domxref("WindowBase64.btoa","window.btoa()")}} para codificar e transmitir dados que, se não codificados, podem causar problemas de comunicação. Após transmití-los pode-se usar o método <code>window.atob()</code> para decodificar os dados novamente. Por exemplo, você pode codificar, transmitir,  e decodificar caracteres de controle como valores ASCII de 0 a 31.</p>
-
-<p>Para utilizar com strings Unicode ou UTF-8, veja <a href="/en-US/docs/Web/JavaScript/Base64_encoding_and_decoding#The_.22Unicode_Problem.22">esta nota em <em>Base64 encoding and decoding</em></a> e <a href="/en-US/docs/Web/API/window.btoa#Unicode_Strings">essa nota em <code>window.btoa()</code></a>.</p>
-
-<h2 id="Sintaxe">Sintaxe</h2>
-
-<pre class="syntaxbox">var dadoDecodificado = window.atob(<em>dadoCodificado</em>);</pre>
-
-<h2 id="Exemplo">Exemplo</h2>
-
-<pre class="brush:js">var <em>dadoCodificado </em>= window.btoa("Olá, mundo"); // codifica a string
-var dadoDecodificado = window.atob(<em>dadoCodificado</em>); // decodifica a string</pre>
-
-<h2 id="Especificações">Especificações</h2>
-
-<table class="standard-table">
- <thead>
- <tr>
- <th scope="col">Especificação</th>
- <th scope="col">Status</th>
- <th scope="col">Comentário</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>{{SpecName('HTML WHATWG', '#dom-windowbase64-atob', 'WindowBase64.atob()')}}</td>
- <td>{{Spec2('HTML WHATWG')}}</td>
- <td>Nenhuma mudança desde a última versão, {{SpecName("HTML5.1")}}.</td>
- </tr>
- <tr>
- <td>{{SpecName('HTML5.1', '#dom-windowbase64-atob', 'WindowBase64.atob()')}}</td>
- <td>{{Spec2('HTML5.1')}}</td>
- <td>Versão de {{SpecName("HTML WHATWG")}}. Nenhuma mudança.</td>
- </tr>
- <tr>
- <td>{{SpecName("HTML5 W3C", "#dom-windowbase64-atob", "WindowBase64.atob()")}}</td>
- <td>{{Spec2('HTML5 W3C')}}</td>
- <td>Versão de {{SpecName("HTML WHATWG")}}. Criação do <code>WindowBase64</code> (antes as propriedades ficavam no target).</td>
- </tr>
- </tbody>
-</table>
-
-<h2 id="Browser_compatibility">Compatibilidade com navegadores</h2>
-
-<div>{{Compat("api.WindowOrWorkerGlobalScope.atob")}}</div>
-
-<div id="compat-mobile"></div>
-
-<p>[1] <code>atob()</code> também está disponível para os componentes do XPCOM implementado em JavaScript, porém o objeto <code><a href="/en-US/docs/Web/API/Window">window</a></code> não é global nos componentes.</p>
-
-<p>[2] A partir do <a href="/en-US/Firefox/Releases/27/Site_Compatibility">Firefox 27</a>, <code>atob()</code> ignora todos os caracteres de espaço no argumento para seguir as últimas especificações do HTML5. ({{bug(711180)}})</p>
-
-<h2 id="Veja_também">Veja também</h2>
-
-<ul>
- <li><a href="/Web/API/WindowBase64/Base64_encoding_and_decoding">Base64 encoding and decoding</a></li>
- <li><a href="/en-US/docs/data_URIs"><code>data</code> URIs</a></li>
- <li>{{domxref("WindowBase64.btoa","window.btoa()")}}</li>
- <li><a href="/en-US/docs/Components.utils.importGlobalProperties">Components.utils.importGlobalProperties</a></li>
-</ul>
diff --git a/files/pt-br/web/api/windoworworkerglobalscope/cleartimeout/index.html b/files/pt-br/web/api/windoworworkerglobalscope/cleartimeout/index.html
deleted file mode 100644
index cbcbb80329..0000000000
--- a/files/pt-br/web/api/windoworworkerglobalscope/cleartimeout/index.html
+++ /dev/null
@@ -1,101 +0,0 @@
----
-title: WindowTimers.clearTimeout()
-slug: Web/API/WindowOrWorkerGlobalScope/clearTimeout
-tags:
- - API
- - Method
- - Window
-translation_of: Web/API/WindowOrWorkerGlobalScope/clearTimeout
-original_slug: Web/API/WindowTimers/clearTimeout
----
-<div>
-<div>
-<div>{{APIRef("HTML DOM")}}</div>
-</div>
-</div>
-
-<h2 id="Summary" name="Summary">Sumário</h2>
-
-<p>O método <strong><code>clearTimeout()</code></strong> do escopo<em> </em>{{domxref("WindowOrWorkerGlobalScope")}} cancela um <em>timeout</em> previamente estabelecido pela função {{domxref("WindowOrWorkerGlobalScope.setTimeout", "setTimeout()")}}.</p>
-
-<h2 id="Syntax" name="Syntax">Síntaxe</h2>
-
-<pre class="syntaxbox"><em>escopo</em>.clearTimeout(<em>timeoutID</em>)
-</pre>
-
-<h3 id="Parâmetros">Parâmetros</h3>
-
-<dl>
- <dt><code>timeoutID</code></dt>
- <dd>O ID do <em>timeout</em> que você deseja cancelar. Esse ID é o retorno da função <code>setTimeout()</code>.</dd>
-</dl>
-
-<p>É interessante ressaltar que os conjuntso de <em>ID</em>s usados pelos métodos {{domxref("WindowOrWorkerGlobalScope.setTimeout", "setTimeout()")}} e {{domxref("WindowOrWorkerGlobalScope.setInterval", "setInterval()")}} são compartilhados, o que significa que <code>clearTimeout()</code> e {{domxref("WindowOrWorkerGlobalScope.clearInterval", "clearInterval()")}} podem ser tecnicamente utilizados de forma intercambiável. No entanto, para obter-se maior clareza, isso deve ser evitado.</p>
-
-<h2 id="Example" name="Example">Exemplo</h2>
-
-<p>Execute o script abaixo em uma página web e clique na página uma vez. Você verá uma mensagem aparecer um segundo depois. Se você continuar clicando na página várias vezes nesse intervalo de tempo, a mensagem aparecerá uma única vez.</p>
-
-<pre class="brush: js" dir="rtl">var alarme = {
- relembrar: function(aMessage) {
- alert(aMessage);
- delete this.timeoutID;
- },
-
- setup: function() {
- if (typeof this.timeoutID === 'number') {
- this.cancelar();
- }
-
- this.timeoutID = window.setTimeout(function(msg) {
- this.relembrar(msg);
- }.bind(this), 1000, 'Wake up!');
- },
-
- cancelar: function() {
- window.clearTimeout(this.timeoutID);
- }
-};
-window.onclick = function() { alarme.setup() };</pre>
-
-<h2 id="Notes" name="Notes">Notas</h2>
-
-<p>Passar um <em>ID</em> inválido para <code>clearTimeout</code> não causa nenhum efeito (não lança nenhuma exceção).</p>
-
-<h2 id="Specification" name="Specification">Especificações</h2>
-
-<table class="standard-table" style="height: 166px; width: 1207px;">
- <tbody>
- <tr>
- <th scope="col">Especificação</th>
- <th scope="col">Status</th>
- <th scope="col">Comentário</th>
- </tr>
- <tr>
- <td>{{SpecName('HTML WHATWG', 'webappapis.html#dom-cleartimeout', 'WindowOrWorkerGlobalScope.clearTimeout()')}}</td>
- <td>{{Spec2("HTML WHATWG")}}</td>
- <td>Método movido para <code>WindowOrWorkerGlobalScope</code> .</td>
- </tr>
- <tr>
- <td>{{SpecName('HTML WHATWG', 'webappapis.html#dom-cleartimeout', 'clearTimeout()')}}</td>
- <td>{{Spec2('HTML WHATWG')}}</td>
- <td> </td>
- </tr>
- </tbody>
-</table>
-
-<h2 id="See_also" name="See_also">Compatibilidade</h2>
-
-
-
-<p>{{Compat("api.WindowOrWorkerGlobalScope.clearTimeout")}}</p>
-
-<h2 id="See_also" name="See_also">Veja também</h2>
-
-<ul>
- <li>{{domxref("WindowOrWorkerGlobalScope.setTimeout()")}}</li>
- <li>{{domxref("WindowOrWorkerGlobalScope.setInterval()")}}</li>
- <li>{{domxref("WindowOrWorkerGlobalScope.clearInterval()")}}</li>
- <li>{{domxref("Window.requestAnimationFrame()")}}</li>
- <li><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Timers/Daemons" title="JavaScript/Timers/Daemons"><em>Daemons</em> management</a></li>
-</ul>
diff --git a/files/pt-br/web/api/windoworworkerglobalscope/fetch/index.html b/files/pt-br/web/api/windoworworkerglobalscope/fetch/index.html
deleted file mode 100644
index 4567730f6c..0000000000
--- a/files/pt-br/web/api/windoworworkerglobalscope/fetch/index.html
+++ /dev/null
@@ -1,305 +0,0 @@
----
-title: WindowOrWorkerGlobalScope.fetch()
-slug: Web/API/WindowOrWorkerGlobalScope/fetch
-translation_of: Web/API/WindowOrWorkerGlobalScope/fetch
----
-<div>{{APIRef("Fetch API")}}</div>
-
-<p>O método <code><strong>fetch()</strong></code> do mixin {{domxref("WindowOrWorkerGlobalScope")}} inicia um processo de busca de um recurso da rede. Este, retorna uma promessa que resolve o objeto {{domxref("Response")}} que representa a resposta a sua requisição. </p>
-
-<p><code>WorkerOrGlobalScope</code> é implementado por {{domxref("Window")}} e {{domxref("WorkerGlobalScope")}}, o que significa que o método <code>fetch()</code> está disponível em praticamente qualquer contexto em que você possa querer obter recursos.</p>
-
-<p>Uma promessa {{domxref("WindowOrWorkerGlobalScope.fetch","fetch()")}} rejeita com um {{jsxref("TypeError")}} quando um erro de rede é encontrado, embora isso geralmente signifique um problema de permissões ou similar. Uma verificação precisa de um <code>fetch()</code> bem-sucedido incluiria a verificação de uma promessa resolvida, e depois verificando se a propriedade {{domxref("Response.ok")}} possui valor <code>true</code>. Um status HTTP 404 não constitui um erro de rede.</p>
-
-<p>O método <code>fetch()</code> é controlado pela diretiva <code>connect-src</code> da <a href="/en-US/docs/Security/CSP/CSP_policy_directives">Content Security Policy</a> em vez da diretiva dos recursos que está recuperando.</p>
-
-<div class="note">
-<p><strong>Nota</strong>: Os parâmetros do método <code>fetch()</code> são idênticos aos do construtor {{domxref("Request.Request","Request()")}}.</p>
-</div>
-
-<h2 id="Sintaxe">Sintaxe</h2>
-
-<pre class="syntaxbox">Promise&lt;Response&gt; fetch(input[, init]);</pre>
-
-<h3 id="Parâmetros">Parâmetros</h3>
-
-<dl>
- <dt><em>input</em></dt>
- <dd>Isto define o recurso que você deseja buscar. Isto pode ser:
- <ul>
- <li>Um {{domxref("USVString")}} contendo uma URL direta para o recurso que você quer obter. Alguns navegadores aceitam <code>blob:</code> e <code>data:</code> como esquemas.</li>
- <li>Um objeto {{domxref("Request")}}.</li>
- </ul>
- </dd>
- <dt><em>init</em> {{optional_inline}}</dt>
- <dd>Um objeto opcional que contém configurações personalizadas que você pode aplicar à requisição. As opções possíveis são:
- <ul>
- <li><code>method</code>: Método HTTP, por exemplo, <code>GET</code>, <code>POST</code>.</li>
- <li><code>headers</code>: Qualquer cabeçalho que você queira adicionar à sua requisição, contido dentro de um objeto {{domxref("Headers")}} ou um objeto literal com valores {{domxref("ByteString")}}.</li>
- <li><code>body</code>: Qualquer corpo que você queira adicionar à sua requisição: podendo ser um {{domxref("Blob")}}, {{domxref("BufferSource")}}, {{domxref("FormData")}}, {{domxref("URLSearchParams")}}, ou um objeto {{domxref("USVString")}}. Note que uma requisição usando os métodos <code>GET</code> ou <code>HEAD</code> não pode ter um corpo.</li>
- <li><code>mode</code>: O modo que deseja usar para a requisição, por exemplo, <code>cors</code>, <code>no-cors</code>, ou <code>same-origin.</code></li>
- <li><code>credentials</code>: A credencial que deseja usar para a requisição: <code>omit</code>, <code>same-origin</code>, ou <code>include</code>. Para enviar automaticamente cookies para o domínio atual, esta opção deve ser fornecida. Começando com o Chrome 50, essa propriedade também usa uma instância {{domxref("FederatedCredential")}} ou uma instância {{domxref("PasswordCredential")}}.</li>
- <li><code>cache</code>: O modo de cache que deseja usar na requisição: <code>default</code>, <code>no-store</code>, <code>reload</code>, <code>no-cache</code>, <code>force-cache</code>, ou <code>only-if-cached</code>.</li>
- <li><code>redirect</code>: O modo de redirecionamento pode usar: <code>follow</code> (segue automaticamente o redirecionamento), <code>error</code> (aborta com um erro se ocorrer um redirecionamento), ou <code>manual</code> (manipula redirecionamentos manualmente). No Chrome o padrão foi <code>follow</code> antes do Chrome 47 e <code>manual</code> a partir do Chrome 47.</li>
- <li><code>referrer</code>: Um {{domxref("USVString")}} especificando <code>no-referrer</code>, <code>client</code>, ou uma URL. O padrão é <code>client</code>.</li>
- <li><code>referrerPolicy</code>: Especifica o valor do cabeçalho HTTP referer. Pode ser um destes: <code>no-referrer</code>, <code>no-referrer-when-downgrade</code>, <code>origin</code>, <code>origin-when-cross-origin</code>, <code>unsafe-url</code>.</li>
- <li><code>integrity</code>: Contém o valor de <a href="/en-US/docs/Web/Security/Subresource_Integrity">integridade de subrecurso</a> da requisição (por exemplo, <code>sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=</code>).</li>
- <li><code>signal</code>: Uma instância do objeto {{domxref("FetchSignal")}}; permite que você se comunique com um pedido de busca e controle-o através de um {{domxref("FetchController")}}. {{non-standard_inline}}</li>
- <li><code>observe</code>: Um objeto {{domxref("ObserverCallback")}} — o objetivo exclusivo deste objeto é fornecer uma função de retorno de chamada que é executada quando a solicitação fetch é executada. Isto retorna um objeto {{domxref("FetchObserver")}} que pode ser usado para recuperar informações sobre o status de uma solicitação fetch. {{non-standard_inline}}</li>
- </ul>
- </dd>
-</dl>
-
-<h3 id="Valor_de_Retorno">Valor de Retorno</h3>
-
-<p>Uma {{domxref("Promise")}} que resolve um objeto {{domxref("Response")}}.</p>
-
-<h3 id="Exceptions">Exceptions</h3>
-
-<table class="standard-table">
- <thead>
- <tr>
- <th scope="col"><strong>Tipo</strong></th>
- <th scope="col"><strong>Descrição</strong></th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td><code>TypeError</code></td>
- <td>Desdo o <a href="/en-US/docs/Mozilla/Firefox/Releases/43">Firefox 43</a>, <code>fetch()</code><br>
- lançará um <code>TypeError</code> se a URL tiver credenciais, como <code>http://user:password@example.com</code>.</td>
- </tr>
- </tbody>
-</table>
-
-<h2 id="Example">Example</h2>
-
-<p>In our <a href="https://github.com/mdn/fetch-examples/tree/gh-pages/fetch-request">Fetch Request example</a> (see <a href="https://mdn.github.io/fetch-examples/fetch-request/">Fetch Request live</a>) we create a new {{domxref("Request")}} object using the relevant constructor, then fetch it using a <code>fetch()</code> call. Since we are fetching an image, we run {{domxref("Body.blob()")}} on the response to give it the proper MIME type so it will be handled properly, then create an Object URL of it and display it in an {{htmlelement("img")}} element.</p>
-
-<pre class="brush: js">var myImage = document.querySelector('img');
-
-var myRequest = new Request('flowers.jpg');
-
-fetch(myRequest).then(function(response) {
- return response.blob();
-}).then(function(response) {
- var objectURL = URL.createObjectURL(response);
- myImage.src = objectURL;
-});</pre>
-
-<p>In our <a href="https://github.com/mdn/fetch-examples/blob/master/fetch-with-init-then-request/index.html">Fetch with init then Request example</a> (see <a href="https://mdn.github.io/fetch-examples/fetch-with-init-then-request/">Fetch Request init live</a>) we do the same thing except that we pass in an init object when we invoke <code>fetch()</code>:</p>
-
-<pre class="brush: js">var myImage = document.querySelector('img');
-
-var myHeaders = new Headers();
-myHeaders.append('Content-Type', 'image/jpeg');
-
-var myInit = { method: 'GET',
- headers: myHeaders,
- mode: 'cors',
- cache: 'default' };
-
-var myRequest = new Request('flowers.jpg');
-
-fetch(myRequest,myInit).then(function(response) {
- ...
-});</pre>
-
-<p>Note that you could also pass the init object in with the <code>Request</code> constructor to get the same effect, e.g.:</p>
-
-<pre class="brush: js">var myRequest = new Request('flowers.jpg', myInit);</pre>
-
-<p>You can also use an object literal as <code>headers</code> in <code>init</code>.</p>
-
-<pre class="brush: js">var myInit = { method: 'GET',
- headers: {
- 'Content-Type': 'image/jpeg'
- },
- mode: 'cors',
- cache: 'default' };
-
-var myRequest = new Request('flowers.jpg', myInit);
-</pre>
-
-<h2 id="Specifications">Specifications</h2>
-
-<table class="standard-table">
- <tbody>
- <tr>
- <th scope="col">Specification</th>
- <th scope="col">Status</th>
- <th scope="col">Comment</th>
- </tr>
- <tr>
- <td>{{SpecName('Fetch','#fetch-method','fetch()')}}</td>
- <td>{{Spec2('Fetch')}}</td>
- <td>Defined in a <code>WindowOrWorkerGlobalScope</code> partial in the newest spec.</td>
- </tr>
- <tr>
- <td>{{SpecName('Fetch','#dom-global-fetch','fetch()')}}</td>
- <td>{{Spec2('Fetch')}}</td>
- <td>Initial definition</td>
- </tr>
- <tr>
- <td>{{SpecName('Credential Management')}}</td>
- <td>{{Spec2('Credential Management')}}</td>
- <td>Adds {{domxref("FederatedCredential")}} or {{domxref("PasswordCredential")}} instance as a possible value for <code>init.credentials</code>.</td>
- </tr>
- </tbody>
-</table>
-
-<h2 id="Browser_compatibility">Compatibilidade com navegadores</h2>
-
-<p>{{CompatibilityTable}}</p>
-
-<div id="compat-desktop">
-<table class="compat-table">
- <tbody>
- <tr>
- <th>Feature</th>
- <th>Chrome</th>
- <th>Edge</th>
- <th>Firefox (Gecko)</th>
- <th>Internet Explorer</th>
- <th>Opera</th>
- <th>Safari (WebKit)</th>
- </tr>
- <tr>
- <td>Basic support</td>
- <td>{{CompatChrome(42)}}</td>
- <td>14</td>
- <td>{{CompatGeckoDesktop(34)}}<sup>[1]</sup><br>
- {{CompatGeckoDesktop(39)}}<br>
- {{CompatGeckoDesktop(52)}}<sup>[2]</sup></td>
- <td>{{CompatNo}}</td>
- <td>29<br>
- 28<sup>[1]</sup></td>
- <td>{{CompatNo}}</td>
- </tr>
- <tr>
- <td>Streaming response body</td>
- <td>{{CompatChrome(43)}}</td>
- <td>14</td>
- <td>{{CompatUnknown}}</td>
- <td>{{CompatUnknown}}</td>
- <td>{{CompatUnknown}}</td>
- <td>{{CompatUnknown}}</td>
- </tr>
- <tr>
- <td>Support for <code>blob:</code> and <code>data:</code></td>
- <td>{{CompatChrome(48)}}</td>
- <td>{{CompatNo}}</td>
- <td>{{CompatUnknown}}</td>
- <td>{{CompatUnknown}}</td>
- <td>{{CompatUnknown}}</td>
- <td>{{CompatUnknown}}</td>
- </tr>
- <tr>
- <td><code>referrerPolicy</code></td>
- <td>{{CompatChrome(52)}}</td>
- <td>{{CompatUnknown}}</td>
- <td>{{CompatUnknown}}</td>
- <td>{{CompatUnknown}}</td>
- <td>39</td>
- <td>{{CompatUnknown}}</td>
- </tr>
- <tr>
- <td><code>signal</code> and <code>observer</code></td>
- <td>{{ CompatNo }}</td>
- <td>{{ CompatNo }}</td>
- <td>{{ CompatNo }}<sup>[3]</sup></td>
- <td>{{ CompatNo }}</td>
- <td>{{ CompatNo }}</td>
- <td>{{ CompatNo }}</td>
- </tr>
- </tbody>
-</table>
-</div>
-
-<div id="compat-mobile">
-<table class="compat-table">
- <tbody>
- <tr>
- <th>Feature</th>
- <th>Android</th>
- <th>Android Webview</th>
- <th>Edge</th>
- <th>Firefox Mobile (Gecko)</th>
- <th>IE Phone</th>
- <th>Opera Mobile</th>
- <th>Safari Mobile</th>
- <th>Chrome for Android</th>
- </tr>
- <tr>
- <td>Basic support</td>
- <td>{{CompatNo}}</td>
- <td>{{CompatChrome(42)}}</td>
- <td>14</td>
- <td>{{CompatGeckoMobile(52)}}<sup>[2]</sup></td>
- <td>{{CompatNo}}</td>
- <td>{{CompatNo}}</td>
- <td>{{CompatNo}}</td>
- <td>{{CompatChrome(42)}}</td>
- </tr>
- <tr>
- <td>Streaming response body</td>
- <td>{{CompatNo}}</td>
- <td>{{CompatChrome(43)}}</td>
- <td>14</td>
- <td>{{CompatUnknown}}</td>
- <td>{{CompatUnknown}}</td>
- <td>{{CompatUnknown}}</td>
- <td>{{CompatUnknown}}</td>
- <td>{{CompatChrome(43)}}</td>
- </tr>
- <tr>
- <td>Support for <code>blob:</code> and <code>data:</code></td>
- <td>{{CompatNo}}</td>
- <td>{{CompatChrome(43)}}</td>
- <td>{{CompatNo}}</td>
- <td>{{CompatUnknown}}</td>
- <td>{{CompatUnknown}}</td>
- <td>{{CompatUnknown}}</td>
- <td>{{CompatUnknown}}</td>
- <td>{{CompatChrome(43)}}</td>
- </tr>
- <tr>
- <td><code>referrerPolicy</code></td>
- <td>{{CompatNo}}</td>
- <td>{{CompatChrome(52)}}</td>
- <td>{{CompatUnknown}}</td>
- <td>{{CompatUnknown}}</td>
- <td>{{CompatUnknown}}</td>
- <td>39</td>
- <td>{{CompatUnknown}}</td>
- <td>{{CompatChrome(52)}}</td>
- </tr>
- <tr>
- <td><code>signal</code> and <code>observer</code></td>
- <td>{{ CompatNo }}</td>
- <td>{{ CompatNo }}</td>
- <td>{{ CompatNo }}</td>
- <td>{{ CompatNo }}<sup>[3]</sup></td>
- <td>{{ CompatNo }}</td>
- <td>{{ CompatNo }}</td>
- <td>{{ CompatNo }}</td>
- <td>{{ CompatNo }}</td>
- </tr>
- </tbody>
-</table>
-</div>
-
-<p>[1] API is implemented behind a preference.</p>
-
-<p>[2] <code>fetch()</code> now defined on {{domxref("WindowOrWorkerGlobalScope")}} mixin.</p>
-
-<p>[3] Hidden behind a preference in 55+ Nightly. In about:config, you need to create two new boolean prefs — <code>dom.fetchObserver.enabled</code> and <code>dom.fetchController.enabled</code> — and set the values of both to <code>true</code>.</p>
-
-<h2 id="See_also">See also</h2>
-
-<ul>
- <li><a href="/en-US/docs/Web/API/Fetch_API">Fetch API</a></li>
- <li><a href="/en-US/docs/Web/API/ServiceWorker_API">ServiceWorker API</a></li>
- <li><a href="/en-US/docs/Web/HTTP/Access_control_CORS">HTTP access control (CORS)</a></li>
- <li><a href="/en-US/docs/Web/HTTP">HTTP</a></li>
-</ul>
diff --git a/files/pt-br/web/api/windoworworkerglobalscope/setinterval/index.html b/files/pt-br/web/api/windoworworkerglobalscope/setinterval/index.html
deleted file mode 100644
index 65dfe562f3..0000000000
--- a/files/pt-br/web/api/windoworworkerglobalscope/setinterval/index.html
+++ /dev/null
@@ -1,629 +0,0 @@
----
-title: WindowOrWorkerGlobalScope.setInterval()
-slug: Web/API/WindowOrWorkerGlobalScope/setInterval
-translation_of: Web/API/WindowOrWorkerGlobalScope/setInterval
----
-<div>{{APIRef("HTML DOM")}}</div>
-
-<div> </div>
-
-<p>O método <strong><code>setInterval() </code></strong>oferecido das interfaces {{domxref("Window")}} e {{domxref("Worker")}}, repetem chamadas de funções or executam trechos de código, com um tempo de espera fixo entre cada chamada. Isso retorna um ID único para o intervalo, podendo remove-lo mais tarde apenas o chamando {{domxref("WindowOrWorkerGlobalScope.clearInterval", "clearInterval()")}}. Este metodo é definido pelo mixin {{domxref("WindowOrWorkerGlobalScope")}}.</p>
-
-<h2 id="Sintaxe.">Sintaxe.</h2>
-
-<pre class="syntaxbox"><em>var intervalID</em> = scope.setInterval(<em>func</em>, <em>delay</em>[, <em>param1</em>, <em>param2</em>, ...]);
-<em>var intervalID</em> = scope.setInterval(<em>code</em>, <em>delay</em>);
-</pre>
-
-<h3 id="Parâmetros">Parâmetros</h3>
-
-<dl>
- <dt><code>func</code></dt>
- <dd>Uma {{jsxref("function")}} para ser executada a cada <code>delay</code> em milisegundos.  Não é passado nenhum parâmetro para a função, e não retorna nenhum valor esperado.</dd>
- <dt><code>code</code></dt>
- <dd>Uma sintaxe opcional permite você incuir uma string ao invés de uma função, no qual é compilado e executada a cada <code>delay</code> em milisegundos. Esta sintaxe <em>não é recomendada </em>pelos mesmos motivos que envolvem riscos de segurança de {{jsxref("eval", "eval()")}}.</dd>
- <dt><code>delay</code></dt>
- <dd>O tempo, em milisegundos (milésimos de segundo), o temporizador deve atrasar entre cada execução de uma especifica função ou código. Se esse parâmetro for menos que 10, um valor de 10 é usado. Note que o atraso pode vir a ser mais longo; veja {{SectionOnPage("/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout", "Reasons for delays longer than specified")}} para exemplos.</dd>
- <dt><code>param1, ..., paramN</code> {{optional_inline}}</dt>
- <dd>Parâmetros adicionais que são passados através da função especificada pela <em>func</em> quando o temporizador expirar.</dd>
-</dl>
-
-<div class="note">
-<p><strong>Note</strong>: Passing additional parameters to <code>setInterval()</code> in the first syntax does not work in Internet Explorer 9 and earlier. If you want to enable this functionality on that browser, you must use a polyfill (see the <a href="#Callback_arguments">Callback arguments</a> section).</p>
-</div>
-
-<h3 id="Return_value">Return value</h3>
-
-<p>O <code>intervalID</code> retornado é um número, non-zero valor que identifica o temporizador criado pela chamada do <code>setInterval()</code>; este valor pode ser passado para {{domxref("WindowOrWorkerGlobalScope.clearInterval()")}} afim de cancelar o timeout.</p>
-
-<p>Isso pode ser útil, estar ciente que o <code>setInterval()</code> e {{domxref("WindowOrWorkerGlobalScope.setTimeout", "setTimeout()")}} compartilham o mesmo grupo de IDs, e que o <code>clearInterval()</code> e {{domxref("WindowOrWorkerGlobalScope.clearTimeout", "clearTimeout()")}} podem tecnicamente serem usados em conjunto. Para deixar claro, contudo, você deve sempre tentar evitar combina-los, afim de evitar confusão na manutenção do seu código.</p>
-
-<div class="note"><strong>Note</strong>: The <code>delay</code> parameter is converted to a signed 32-bit integer. This effectively limits <code>delay</code> to 2147483647 ms, since it's specified as a signed integer in the IDL.</div>
-
-<h2 id="Exemplos">Exemplos</h2>
-
-<h3 id="Exemplo_1_Sintaxe_básica">Exemplo 1: Sintaxe básica</h3>
-
-<p>O seguinte exemplo mostra a sintaxe básica do <code>setInterval()</code></p>
-
-<pre class="brush:js">var intervalID = window.setInterval(myCallback, 500);
-
-function myCallback() {
- // Your code here
-}
-</pre>
-
-<h3 id="Exemplo_2_Alternando_duas_cores">Exemplo 2: Alternando duas cores</h3>
-
-<p>O seguinte exemplo chama a função <code>flashtext()</code> uma vez por segundo até o botão de parar ser pressionado.</p>
-
-<pre class="brush:html">&lt;!DOCTYPE html&gt;
-&lt;html&gt;
-&lt;head&gt;
- &lt;meta charset="UTF-8" /&gt;
- &lt;title&gt;setInterval/clearInterval example&lt;/title&gt;
-
- &lt;script&gt;
- var nIntervId;
-
- function changeColor() {
- nIntervId = setInterval(flashText, 1000);
- }
-
- function flashText() {
- var oElem = document.getElementById('my_box');
- oElem.style.color = oElem.style.color == 'red' ? 'blue' : 'red';
- // oElem.style.color == 'red' ? 'blue' : 'red' is a ternary operator.
- }
-
- function stopTextColor() {
- clearInterval(nIntervId);
- }
- &lt;/script&gt;
-&lt;/head&gt;
-
-&lt;body onload="changeColor();"&gt;
- &lt;div id="my_box"&gt;
- &lt;p&gt;Hello World&lt;/p&gt;
- &lt;/div&gt;
-
- &lt;button onclick="stopTextColor();"&gt;Stop&lt;/button&gt;
-&lt;/body&gt;
-&lt;/html&gt;
-</pre>
-
-<h3 id="Exemplo_3_Simulação_de_máquina_de_escrever">Exemplo 3: Simulação de máquina de escrever</h3>
-
-<p>O seguinte exemplo simula uma máquina de escrever primeiro limpando e digitando lentamente o conteúdo para  <code><a href="https://developer.mozilla.org/en-US/docs/DOM/NodeList">NodeList</a></code> que corresponde a um grupo especificado de seletores.</p>
-
-<pre class="brush:html">&lt;!DOCTYPE html&gt;
-&lt;html&gt;
-&lt;head&gt;
-&lt;meta charset="UTF-8" /&gt;
-&lt;title&gt;JavaScript Typewriter - MDN Example&lt;/title&gt;
-&lt;script&gt;
- function Typewriter (sSelector, nRate) {
-
- function clean () {
- clearInterval(nIntervId);
- bTyping = false;
- bStart = true;
- oCurrent = null;
- aSheets.length = nIdx = 0;
- }
-
- function scroll (oSheet, nPos, bEraseAndStop) {
- if (!oSheet.hasOwnProperty('parts') || aMap.length &lt; nPos) { return true; }
-
- var oRel, bExit = false;
-
- if (aMap.length === nPos) { aMap.push(0); }
-
- while (aMap[nPos] &lt; oSheet.parts.length) {
- oRel = oSheet.parts[aMap[nPos]];
-
- scroll(oRel, nPos + 1, bEraseAndStop) ? aMap[nPos]++ : bExit = true;
-
- if (bEraseAndStop &amp;&amp; (oRel.ref.nodeType - 1 | 1) === 3 &amp;&amp; oRel.ref.nodeValue) {
- bExit = true;
- oCurrent = oRel.ref;
- sPart = oCurrent.nodeValue;
- oCurrent.nodeValue = '';
- }
-
- oSheet.ref.appendChild(oRel.ref);
- if (bExit) { return false; }
- }
-
- aMap.length--;
- return true;
- }
-
- function typewrite () {
- if (sPart.length === 0 &amp;&amp; scroll(aSheets[nIdx], 0, true) &amp;&amp; nIdx++ === aSheets.length - 1) { clean(); return; }
-
- oCurrent.nodeValue += sPart.charAt(0);
- sPart = sPart.slice(1);
- }
-
- function Sheet (oNode) {
- this.ref = oNode;
- if (!oNode.hasChildNodes()) { return; }
- this.parts = Array.prototype.slice.call(oNode.childNodes);
-
- for (var nChild = 0; nChild &lt; this.parts.length; nChild++) {
- oNode.removeChild(this.parts[nChild]);
- this.parts[nChild] = new Sheet(this.parts[nChild]);
- }
- }
-
- var
- nIntervId, oCurrent = null, bTyping = false, bStart = true,
- nIdx = 0, sPart = "", aSheets = [], aMap = [];
-
- this.rate = nRate || 100;
-
- this.play = function () {
- if (bTyping) { return; }
- if (bStart) {
- var aItems = document.querySelectorAll(sSelector);
-
- if (aItems.length === 0) { return; }
- for (var nItem = 0; nItem &lt; aItems.length; nItem++) {
- aSheets.push(new Sheet(aItems[nItem]));
- /* Uncomment the following line if you have previously hidden your elements via CSS: */
- // aItems[nItem].style.visibility = "visible";
- }
-
- bStart = false;
- }
-
- nIntervId = setInterval(typewrite, this.rate);
- bTyping = true;
- };
-
- this.pause = function () {
- clearInterval(nIntervId);
- bTyping = false;
- };
-
- this.terminate = function () {
- oCurrent.nodeValue += sPart;
- sPart = "";
- for (nIdx; nIdx &lt; aSheets.length; scroll(aSheets[nIdx++], 0, false));
- clean();
- };
-}
-
-/* usage: */
-var oTWExample1 = new Typewriter(/* elements: */ '#article, h1, #info, #copyleft', /* frame rate (optional): */ 15);
-
-/* default frame rate is 100: */
-var oTWExample2 = new Typewriter('#controls');
-
-/* you can also change the frame rate value modifying the "rate" property; for example: */
-// oTWExample2.rate = 150;
-
-onload = function () {
- oTWExample1.play();
- oTWExample2.play();
-};
-&lt;/script&gt;
-&lt;style type="text/css"&gt;
-span.intLink, a, a:visited {
- cursor: pointer;
- color: #000000;
- text-decoration: underline;
-}
-
-#info {
- width: 180px;
- height: 150px;
- float: right;
- background-color: #eeeeff;
- padding: 4px;
- overflow: auto;
- font-size: 12px;
- margin: 4px;
- border-radius: 5px;
- /* visibility: hidden; */
-}
-&lt;/style&gt;
-&lt;/head&gt;
-
-&lt;body&gt;
-
-&lt;p id="copyleft" style="font-style: italic; font-size: 12px; text-align: center;"&gt;CopyLeft 2012 by &lt;a href="https://developer.mozilla.org/" target="_blank"&gt;Mozilla Developer Network&lt;/a&gt;&lt;/p&gt;
-&lt;p id="controls" style="text-align: center;"&gt;[&amp;nbsp;&lt;span class="intLink" onclick="oTWExample1.play();"&gt;Play&lt;/span&gt; | &lt;span class="intLink" onclick="oTWExample1.pause();"&gt;Pause&lt;/span&gt; | &lt;span class="intLink" onclick="oTWExample1.terminate();"&gt;Terminate&lt;/span&gt;&amp;nbsp;]&lt;/p&gt;
-&lt;div id="info"&gt;
-Vivamus blandit massa ut metus mattis in fringilla lectus imperdiet. Proin ac ante a felis ornare vehicula. Fusce pellentesque lacus vitae eros convallis ut mollis magna pellentesque. Pellentesque placerat enim at lacus ultricies vitae facilisis nisi fringilla. In tincidunt tincidunt tincidunt.
-&lt;/div&gt;
-&lt;h1&gt;JavaScript Typewriter&lt;/h1&gt;
-
-&lt;div id="article"&gt;
-&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam ultrices dolor ac dolor imperdiet ullamcorper. Suspendisse quam libero, luctus auctor mollis sed, malesuada condimentum magna. Quisque in ante tellus, in placerat est. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Donec a mi magna, quis mattis dolor. Etiam sit amet ligula quis urna auctor imperdiet nec faucibus ante. Mauris vel consectetur dolor. Nunc eget elit eget velit pulvinar fringilla consectetur aliquam purus. Curabitur convallis, justo posuere porta egestas, velit erat ornare tortor, non viverra justo diam eget arcu. Phasellus adipiscing fermentum nibh ac commodo. Nam turpis nunc, suscipit a hendrerit vitae, volutpat non ipsum.&lt;/p&gt;
-&lt;form&gt;
-&lt;p&gt;Phasellus ac nisl lorem: &lt;input type="text" /&gt;&lt;br /&gt;
-&lt;textarea style="width: 400px; height: 200px;"&gt;Nullam commodo suscipit lacus non aliquet. Phasellus ac nisl lorem, sed facilisis ligula. Nam cursus lobortis placerat. Sed dui nisi, elementum eu sodales ac, placerat sit amet mauris. Pellentesque dapibus tellus ut ipsum aliquam eu auctor dui vehicula. Quisque ultrices laoreet erat, at ultrices tortor sodales non. Sed venenatis luctus magna, ultricies ultricies nunc fringilla eget. Praesent scelerisque urna vitae nibh tristique varius consequat neque luctus. Integer ornare, erat a porta tempus, velit justo fermentum elit, a fermentum metus nisi eu ipsum. Vivamus eget augue vel dui viverra adipiscing congue ut massa. Praesent vitae eros erat, pulvinar laoreet magna. Maecenas vestibulum mollis nunc in posuere. Pellentesque sit amet metus a turpis lobortis tempor eu vel tortor. Cras sodales eleifend interdum.&lt;/textarea&gt;&lt;/p&gt;
-&lt;p&gt;&lt;input type="submit" value="Send" /&gt;
-&lt;/form&gt;
-&lt;p&gt;Duis lobortis sapien quis nisl luctus porttitor. In tempor semper libero, eu tincidunt dolor eleifend sit amet. Ut nec velit in dolor tincidunt rhoncus non non diam. Morbi auctor ornare orci, non euismod felis gravida nec. Curabitur elementum nisi a eros rutrum nec blandit diam placerat. Aenean tincidunt risus ut nisi consectetur cursus. Ut vitae quam elit. Donec dignissim est in quam tempor consequat. Aliquam aliquam diam non felis convallis suscipit. Nulla facilisi. Donec lacus risus, dignissim et fringilla et, egestas vel eros. Duis malesuada accumsan dui, at fringilla mauris bibStartum quis. Cras adipiscing ultricies fermentum. Praesent bibStartum condimentum feugiat.&lt;/p&gt;
-&lt;p&gt;Nam faucibus, ligula eu fringilla pulvinar, lectus tellus iaculis nunc, vitae scelerisque metus leo non metus. Proin mattis lobortis lobortis. Quisque accumsan faucibus erat, vel varius tortor ultricies ac. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nec libero nunc. Nullam tortor nunc, elementum a consectetur et, ultrices eu orci. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque a nisl eu sem vehicula egestas.&lt;/p&gt;
-&lt;/div&gt;
-&lt;/body&gt;
-&lt;/html&gt;</pre>
-
-<p><a href="/files/3997/typewriter.html">View this demo in action</a>. See also: <a href="/en-US/docs/DOM/window.clearInterval"><code>clearInterval()</code></a>.</p>
-
-<h2 id="Argumentos_callback">Argumentos callback</h2>
-
-<p>Como já foi discutido, Internet Explorer 9 e versões anteriores não suportam passar argumentos para a função callback em ambos <code>setTimeout()</code> ou <code>setInterval()</code>. O seguinte código <strong>IE-specific</strong> demonstra um método para superar esta limitação. Para usar, apenas adicione o seguinte código no topo do seu script.</p>
-
-<pre class="brush:js">/*\
-|*|
-|*| IE-specific polyfill that enables the passage of arbitrary arguments to the
-|*| callback functions of javascript timers (HTML5 standard syntax).
-|*|
-|*| https://developer.mozilla.org/en-US/docs/Web/API/window.setInterval
-|*| https://developer.mozilla.org/User:fusionchess
-|*|
-|*| Syntax:
-|*| var timeoutID = window.setTimeout(func, delay[, param1, param2, ...]);
-|*| var timeoutID = window.setTimeout(code, delay);
-|*| var intervalID = window.setInterval(func, delay[, param1, param2, ...]);
-|*| var intervalID = window.setInterval(code, delay);
-|*|
-\*/
-
-if (document.all &amp;&amp; !window.setTimeout.isPolyfill) {
- var __nativeST__ = window.setTimeout;
- window.setTimeout = function (vCallback, nDelay /*, argumentToPass1, argumentToPass2, etc. */) {
- var aArgs = Array.prototype.slice.call(arguments, 2);
- return __nativeST__(vCallback instanceof Function ? function () {
- vCallback.apply(null, aArgs);
- } : vCallback, nDelay);
- };
- window.setTimeout.isPolyfill = true;
-}
-
-if (document.all &amp;&amp; !window.setInterval.isPolyfill) {
- var __nativeSI__ = window.setInterval;
- window.setInterval = function (vCallback, nDelay /*, argumentToPass1, argumentToPass2, etc. */) {
- var aArgs = Array.prototype.slice.call(arguments, 2);
- return __nativeSI__(vCallback instanceof Function ? function () {
- vCallback.apply(null, aArgs);
- } : vCallback, nDelay);
- };
- window.setInterval.isPolyfill = true;
-}
-</pre>
-
-<p>Outra possibilidade é uso uma função anônima para chama o callback, apesar de que esta solução seja um pouco mais pesada. Exemplo:</p>
-
-<pre class="brush:js">var intervalID = setInterval(function() { myFunc('one', 'two', 'three'); }, 1000);</pre>
-
-<p>Outra possibilidade é usar o <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind">function's bind</a>. Exemplo:</p>
-
-<pre class="brush:js">var intervalID = setInterval(function(arg1) {}.bind(undefined, 10), 1000);</pre>
-
-<p>{{h3_gecko_minversion("Inactive tabs", "5.0")}}</p>
-
-<p>Starting in Gecko 5.0 {{geckoRelease("5.0")}}, intervals are clamped to fire no more often than once per second in inactive tabs.</p>
-
-<h2 id="O_problema_do_this">O problema do "<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this"><code>this</code></a>"</h2>
-
-<p>Quando você passa um método para <code>setInterval()</code> ou qualquer outra função, ela é chamada com o valor do <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this">this</a></code> errado. Este problema é explicado em detalhes em <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this#As_an_object_method">JavaScript reference</a>.</p>
-
-<h3 id="Explicação">Explicação</h3>
-
-<p>O código executado pelo <code>setInterval()</code> roda em um contexto de execução separado da função que foi chamada. Como uma consequência, o <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this">this</a></code> da função chamada, é setado como o objeto <code>window</code> (ou <code>global</code>), esse não é o mesmo valor do <code>this</code> para a função chamada em setTimeout. veja o seguinte exemplo (que usa <code>setTimeout()</code> ao invés de <code>setInterval()</code> - o problema segue para ambos os temporizadores)</p>
-
-<pre class="brush:js">myArray = ['zero', 'one', 'two'];
-
-myArray.myMethod = function (sProperty) {
- alert(arguments.length &gt; 0 ? this[sProperty] : this);
-};
-
-myArray.myMethod(); // prints "zero,one,two"
-myArray.myMethod(1); // prints "one"
-setTimeout(myArray.myMethod, 1000); // prints "[object Window]" after 1 second
-setTimeout(myArray.myMethod, 1500, "1"); // prints "undefined" after 1,5 seconds
-// passing the 'this' object with .call won't work
-// because this will change the value of this inside setTimeout itself
-// while we want to change the value of this inside myArray.myMethod
-// in fact, it will be an error because setTimeout code expects this to be the window object:
-setTimeout.call(myArray, myArray.myMethod, 2000); // error: "NS_ERROR_XPC_BAD_OP_ON_WN_PROTO: Illegal operation on WrappedNative prototype object"
-setTimeout.call(myArray, myArray.myMethod, 2500, 2); // same error
-</pre>
-
-<p> </p>
-
-<p>Como você pode ver, não há maneiras de passar o objeto <code>this</code> para a função callback.</p>
-
-<p> </p>
-
-<h3 id="Uma_possível_solução">Uma possível solução</h3>
-
-<p>Um possível caminho para resolver o problema do <code>this</code>, é sobreescrever as duas funções globais nativas <code>setTimeout()</code> ou <code>setInterval()</code> com duas <em>non-native</em> que permitem sua invocação através do método <code><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/call">Function.prototype.call</a></code>. O seguinte exemplo mostra a possível substituição.</p>
-
-<pre class="brush:js">// Enable the passage of the 'this' object through the JavaScript timers
-
-var __nativeST__ = window.setTimeout, __nativeSI__ = window.setInterval;
-
-window.setTimeout = function (vCallback, nDelay /*, argumentToPass1, argumentToPass2, etc. */) {
- var oThis = this, aArgs = Array.prototype.slice.call(arguments, 2);
- return __nativeST__(vCallback instanceof Function ? function () {
- vCallback.apply(oThis, aArgs);
- } : vCallback, nDelay);
-};
-
-window.setInterval = function (vCallback, nDelay /*, argumentToPass1, argumentToPass2, etc. */) {
- var oThis = this, aArgs = Array.prototype.slice.call(arguments, 2);
- return __nativeSI__(vCallback instanceof Function ? function () {
- vCallback.apply(oThis, aArgs);
- } : vCallback, nDelay);
-};</pre>
-
-<div class="note">These two replacements also enable the HTML5 standard passage of arbitrary arguments to the callback functions of timers in IE. So they can be used as <em>non-standard-compliant</em> polyfills also. See the <a href="#Callback_arguments">callback arguments paragraph</a> for a <em>standard-compliant</em> polyfill.</div>
-
-<p>Teste da nova implementação:</p>
-
-<pre class="brush:js">myArray = ['zero', 'one', 'two'];
-
-myArray.myMethod = function (sProperty) {
- alert(arguments.length &gt; 0 ? this[sProperty] : this);
-};
-
-setTimeout(alert, 1500, 'Hello world!'); // the standard use of setTimeout and setInterval is preserved, but...
-setTimeout.call(myArray, myArray.myMethod, 2000); // prints "zero,one,two" after 2 seconds
-setTimeout.call(myArray, myArray.myMethod, 2500, 2); // prints "two" after 2,5 seconds
-</pre>
-
-<p>Outra, mais complexa, solução para o problema do <code>this</code> é <a href="https://developer.mozilla.org/pt-BR/docs/Web/API/WindowOrWorkerGlobalScope/setInterval$edit#A_little_framework">the following framework</a>.</p>
-
-<div class="note">JavaScript 1.8.5 introduces the <code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind">Function.prototype.bind()</a></code> method, which lets you specify the value that should be used as <code>this</code> for all calls to a given function. This lets you easily bypass problems where it's unclear what this will be, depending on the context from which your function was called. Also, ES2015 supports <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions">arrow functions</a>, with lexical this allowing us to write setInterval( () =&gt; this.myMethod) if we're inside myArray method.</div>
-
-<h2 id="MiniDaemon_-_A_framework_for_managing_timers">MiniDaemon - A framework for managing timers</h2>
-
-<p>In pages requiring many timers, it can often be difficult to keep track of all of the running timer events. One approach to solving this problem is to store information about the state of a timer in an object. Following is a minimal example of such an abstraction. The constructor architecture explicitly avoids the use of closures. It also offers an alternative way to pass the <a href="/en-US/docs/Web/JavaScript/Reference/Operators/this"><code>this</code></a> object to the callback function (see <a href="#The_.22this.22_problem">The "this" problem</a> for details). The following code is also <a href="https://github.com/madmurphy/minidaemon.js">available on GitHub</a>.</p>
-
-<div class="note">For a more complex but still modular version of it (<code><em>Daemon</em></code>) see <a href="/en-US/Add-ons/Code_snippets/Timers/Daemons">JavaScript Daemons Management</a>. This more complex version is nothing but a big and scalable collection of methods for the <code><em>Daemon</em></code> constructor. However, the <code><em>Daemon</em></code> constructor itself is nothing but a clone of <code><em>MiniDaemon</em></code> with an added support for <em>init</em> and <em>onstart</em> functions declarable during the instantiation of the <code><em>daemon</em></code>. <strong>So the <code><em>MiniDaemon</em></code> framework remains the recommended way for simple animations</strong>, because <code><em>Daemon</em></code> without its collection of methods is essentially a clone of it.</div>
-
-<h3 id="minidaemon.js">minidaemon.js</h3>
-
-<pre class="brush:js">/*\
-|*|
-|*| :: MiniDaemon ::
-|*|
-|*| Revision #2 - September 26, 2014
-|*|
-|*| https://developer.mozilla.org/en-US/docs/Web/API/window.setInterval
-|*| https://developer.mozilla.org/User:fusionchess
-|*| https://github.com/madmurphy/minidaemon.js
-|*|
-|*| This framework is released under the GNU Lesser General Public License, version 3 or later.
-|*| http://www.gnu.org/licenses/lgpl-3.0.html
-|*|
-\*/
-
-function MiniDaemon (oOwner, fTask, nRate, nLen) {
- if (!(this &amp;&amp; this instanceof MiniDaemon)) { return; }
- if (arguments.length &lt; 2) { throw new TypeError('MiniDaemon - not enough arguments'); }
- if (oOwner) { this.owner = oOwner; }
- this.task = fTask;
- if (isFinite(nRate) &amp;&amp; nRate &gt; 0) { this.rate = Math.floor(nRate); }
- if (nLen &gt; 0) { this.length = Math.floor(nLen); }
-}
-
-MiniDaemon.prototype.owner = null;
-MiniDaemon.prototype.task = null;
-MiniDaemon.prototype.rate = 100;
-MiniDaemon.prototype.length = Infinity;
-
- /* These properties should be read-only */
-
-MiniDaemon.prototype.SESSION = -1;
-MiniDaemon.prototype.INDEX = 0;
-MiniDaemon.prototype.PAUSED = true;
-MiniDaemon.prototype.BACKW = true;
-
- /* Global methods */
-
-MiniDaemon.forceCall = function (oDmn) {
- oDmn.INDEX += oDmn.BACKW ? -1 : 1;
- if (oDmn.task.call(oDmn.owner, oDmn.INDEX, oDmn.length, oDmn.BACKW) === false || oDmn.isAtEnd()) { oDmn.pause(); return false; }
- return true;
-};
-
- /* Instances methods */
-
-MiniDaemon.prototype.isAtEnd = function () {
- return this.BACKW ? isFinite(this.length) &amp;&amp; this.INDEX &lt; 1 : this.INDEX + 1 &gt; this.length;
-};
-
-MiniDaemon.prototype.synchronize = function () {
- if (this.PAUSED) { return; }
- clearInterval(this.SESSION);
- this.SESSION = setInterval(MiniDaemon.forceCall, this.rate, this);
-};
-
-MiniDaemon.prototype.pause = function () {
- clearInterval(this.SESSION);
- this.PAUSED = true;
-};
-
-MiniDaemon.prototype.start = function (bReverse) {
- var bBackw = Boolean(bReverse);
- if (this.BACKW === bBackw &amp;&amp; (this.isAtEnd() || !this.PAUSED)) { return; }
- this.BACKW = bBackw;
- this.PAUSED = false;
- this.synchronize();
-};
-</pre>
-
-<div class="note">MiniDaemon passes arguments to the callback function. If you want to work on it with browsers that natively do not support this feature, use one of the methods proposed above.</div>
-
-<h3 id="Syntax">Syntax</h3>
-
-<p><code>var myDaemon = new MiniDaemon(<em>thisObject</em>, <em>callback</em>[</code><code>, <em>rate</em></code><code>[, <em>length</em>]]);</code></p>
-
-<h3 id="Description">Description</h3>
-
-<p>Returns a JavaScript <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object"><code>Object</code></a> containing all information needed by an animation (like the <a href="/en-US/docs/Web/JavaScript/Reference/Operators/this"><code>this</code></a> object, the callback function, the length, the frame-rate).</p>
-
-<h4 id="Parameters">Parameters</h4>
-
-<dl>
- <dt><code>thisObject</code></dt>
- <dd>The <a href="/en-US/docs/Web/JavaScript/Reference/Operators/this"><code>this</code></a> object on which the <em>callback</em> function is called. It can be an <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object"><code>object</code></a> or <code>null</code>.</dd>
- <dt><code>callback</code></dt>
- <dd>The function that is repeatedly invoked . <strong>It is called with three parameters</strong>: <em>index</em> (the iterative index of each invocation), <em>length</em> (the number of total invocations assigned to the <em>daemon</em> - finite or <a href="/en-US/docs/JavaScript/Reference/Global_Objects/Infinity"><code>Infinity</code></a>) and <em>backwards</em> (a boolean expressing whether the <em>index</em> is increasing or decreasing). It is something like <em>callback</em>.call(<em>thisObject</em>, <em>index</em>, <em>length</em>, <em>backwards</em>). <strong>If the callback function returns a <code>false</code> value the <em>daemon</em> is paused</strong>.</dd>
- <dt><code>rate (optional)</code></dt>
- <dd>The time lapse (in number of milliseconds) between each invocation. The default value is 100.</dd>
- <dt><code>length (optional)</code></dt>
- <dd>The total number of invocations. It can be a positive integer or <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Infinity"><code>Infinity</code></a>. The default value is <code>Infinity</code>.</dd>
-</dl>
-
-<h4 id="MiniDaemon_instances_properties"><code>MiniDaemon</code> instances properties</h4>
-
-<dl>
- <dt><code>myDaemon.owner</code></dt>
- <dd>The <a href="/en-US/docs/Web/JavaScript/Reference/Operators/this"><code>this</code></a> object on which is executed the daemon (read/write). It can be an <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object"><code>object</code></a> or <code>null</code>.</dd>
- <dt><code>myDaemon.task</code></dt>
- <dd>The function that is repeatedly invoked (read/write). It is called with three arguments: <em>index</em> (the iterative index of each invocation), <em>length</em> (the number of total invocations assigned to the daemon - finite or <a href="/en-US/docs/JavaScript/Reference/Global_Objects/Infinity"><code>Infinity</code></a>) and backwards (a boolean expressing whether the <em>index</em> is decreasing or not) – see above. If the <code>myDaemon.task</code> function returns a <code>false</code> value the <em>daemon</em> is paused.</dd>
- <dt><code>myDaemon.rate</code></dt>
- <dd>The time lapse (in number of milliseconds) between each invocation (read/write).</dd>
- <dt><code>myDaemon.length</code></dt>
- <dd>The total number of invocations. It can be a positive integer or <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Infinity"><code>Infinity</code></a> (read/write).</dd>
-</dl>
-
-<h4 id="MiniDaemon_instances_methods"><code>MiniDaemon</code> instances methods</h4>
-
-<dl>
- <dt><code>myDaemon.isAtEnd()</code></dt>
- <dd>Returns a boolean expressing whether the <em>daemon</em> is at the start/end position or not.</dd>
- <dt><code>myDaemon.synchronize()</code></dt>
- <dd>Synchronize the timer of a started daemon with the time of its invocation.</dd>
- <dt><code>myDaemon.pause()</code></dt>
- <dd>Pauses the daemon.</dd>
- <dt><code>myDaemon.start([<em>reverse</em>])</code></dt>
- <dd>Starts the daemon forward (<em>index</em> of each invocation increasing) or backwards (<em>index</em> decreasing).</dd>
-</dl>
-
-<h4 id="MiniDaemon_global_object_methods"><code>MiniDaemon</code> global object methods</h4>
-
-<dl>
- <dt><code>MiniDaemon.forceCall(<em>minidaemon</em>)</code></dt>
- <dd>Forces a single callback to the <code><em>minidaemon</em>.task</code> function regardless of the fact that the end has been reached or not. In any case the internal <code>INDEX</code> property is increased/decreased (depending on the actual direction of the process).</dd>
-</dl>
-
-<h3 id="Example_usage">Example usage</h3>
-
-<p>Your HTML page:</p>
-
-<pre class="brush:html">&lt;!DOCTYPE html&gt;
-&lt;html&gt;
-&lt;head&gt;
- &lt;meta charset="UTF-8" /&gt;
- &lt;title&gt;MiniDaemin Example - MDN&lt;/title&gt;
- &lt;script type="text/javascript" src="minidaemon.js"&gt;&lt;/script&gt;
- &lt;style type="text/css"&gt;
- #sample_div {
- visibility: hidden;
- }
- &lt;/style&gt;
-&lt;/head&gt;
-
-&lt;body&gt;
- &lt;p&gt;
-  &lt;input type="button" onclick="fadeInOut.start(false /* optional */);" value="fade in" /&gt;
- &lt;input type="button" onclick="fadeInOut.start(true);" value="fade out"&gt;
-  &lt;input type="button" onclick="fadeInOut.pause();" value="pause" /&gt;
-  &lt;/p&gt;
-
- &lt;div id="sample_div"&gt;Some text here&lt;/div&gt;
-
- &lt;script type="text/javascript"&gt;
- function opacity (nIndex, nLength, bBackwards) {
- this.style.opacity = nIndex / nLength;
- if (bBackwards ? nIndex === 0 : nIndex === 1) {
- this.style.visibility = bBackwards ? 'hidden' : 'visible';
- }
- }
-
- var fadeInOut = new MiniDaemon(document.getElementById('sample_div'), opacity, 300, 8);
- &lt;/script&gt;
-&lt;/body&gt;
-&lt;/html&gt;</pre>
-
-<p><a href="/files/3995/minidaemon_example.html" title="MiniDaemon Example">View this example in action</a></p>
-
-<h2 id="Notes">Notes</h2>
-
-<p>The <code>setInterval()</code> function is commonly used to set a delay for functions that are executed again and again, such as animations.</p>
-
-<p>You can cancel the interval using {{domxref("WindowOrWorkerGlobalScope.clearInterval()")}}.</p>
-
-<p>If you wish to have your function called <em>once</em> after the specified delay, use {{domxref("WindowOrWorkerGlobalScope.setTimeout()")}}.</p>
-
-<h3 id="Ensure_that_execution_duration_is_shorter_than_interval_frequency">Ensure that execution duration is shorter than interval frequency</h3>
-
-<p>If there is a possibility that your logic could take longer to execute than the interval time, it is recommended that you recursively call a named function using {{domxref("WindowOrWorkerGlobalScope.setTimeout")}}. For example, if using <code>setInterval</code> to poll a remote server every 5 seconds, network latency, an unresponsive server, and a host of other issues could prevent the request from completing in its allotted time. As such, you may find yourself with queued up XHR requests that won't necessarily return in order.</p>
-
-<p>In these cases, a recursive <code>setTimeout()</code> pattern is preferred:</p>
-
-<pre class="brush:js">(function loop(){
- setTimeout(function() {
- // Your logic here
-
- loop();
- }, delay);
-})();
-</pre>
-
-<p>In the above snippet, a named function <code>loop()</code> is declared and is immediately executed. <code>loop()</code> is recursively called inside <code>setTimeout()</code> after the logic has completed executing. While this pattern does not guarantee execution on a fixed interval, it does guarantee that the previous interval has completed before recursing.</p>
-
-<h3 id="Throttling_of_intervals">Throttling of intervals</h3>
-
-<p><code>setInterval()</code> is subject to the same throttling restrictions in Firefox as {{domxref("WindowOrWorkerGlobalScope.setTimeout","setTimeout()")}}; see <a href="/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout#Reasons_for_delays_longer_than_specified">Reasons for delays longer than specified</a>.</p>
-
-<h2 id="Specifications">Specifications</h2>
-
-<table class="standard-table">
- <tbody>
- <tr>
- <th>Specification</th>
- <th>Status</th>
- <th>Comment</th>
- </tr>
- <tr>
- <td>{{SpecName('HTML WHATWG', 'webappapis.html#dom-setinterval', 'WindowOrWorkerGlobalScope.setInterval()')}}</td>
- <td>{{Spec2("HTML WHATWG")}}</td>
- <td>Method moved to the <code>WindowOrWorkerGlobalScope</code> mixin in the latest spec.</td>
- </tr>
- <tr>
- <td>{{SpecName("HTML WHATWG", "webappapis.html#dom-setinterval", "WindowTimers.setInterval()")}}</td>
- <td>{{Spec2("HTML WHATWG")}}</td>
- <td>Initial definition (DOM Level 0)</td>
- </tr>
- </tbody>
-</table>
-
-<h2 id="Browser_compatibility">Compatibilidade com navegadores</h2>
-
-<div>
-
-
-<p>{{Compat("api.WindowOrWorkerGlobalScope.setInterval")}}</p>
-</div>
-
-<h2 id="See_also">See also</h2>
-
-<ul>
- <li><a href="/en-US/Add-ons/Code_snippets/Timers">JavaScript timers</a></li>
- <li>{{domxref("WindowOrWorkerGlobalScope.setTimeout")}}</li>
- <li>{{domxref("WindowOrWorkerGlobalScope.clearTimeout")}}</li>
- <li>{{domxref("WindowOrWorkerGlobalScope.clearInterval")}}</li>
- <li>{{domxref("window.requestAnimationFrame")}}</li>
- <li><a href="/en-US/Add-ons/Code_snippets/Timers/Daemons"><em>Daemons</em> management</a></li>
-</ul>