From 074785cea106179cb3305637055ab0a009ca74f2 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:52 -0500 Subject: initial commit --- files/pt-br/web/api/navigator/battery/index.html | 40 +++++ .../web/api/navigator/cookieenabled/index.html | 49 ++++++ .../web/api/navigator/devicememory/index.html | 39 +++++ .../pt-br/web/api/navigator/geolocation/index.html | 46 ++++++ .../web/api/navigator/getusermedia/index.html | 184 +++++++++++++++++++++ files/pt-br/web/api/navigator/index.html | 119 +++++++++++++ files/pt-br/web/api/navigator/share/index.html | 87 ++++++++++ 7 files changed, 564 insertions(+) create mode 100644 files/pt-br/web/api/navigator/battery/index.html create mode 100644 files/pt-br/web/api/navigator/cookieenabled/index.html create mode 100644 files/pt-br/web/api/navigator/devicememory/index.html create mode 100644 files/pt-br/web/api/navigator/geolocation/index.html create mode 100644 files/pt-br/web/api/navigator/getusermedia/index.html create mode 100644 files/pt-br/web/api/navigator/index.html create mode 100644 files/pt-br/web/api/navigator/share/index.html (limited to 'files/pt-br/web/api/navigator') diff --git a/files/pt-br/web/api/navigator/battery/index.html b/files/pt-br/web/api/navigator/battery/index.html new file mode 100644 index 0000000000..5ae9f207f4 --- /dev/null +++ b/files/pt-br/web/api/navigator/battery/index.html @@ -0,0 +1,40 @@ +--- +title: Navigator.battery +slug: Web/API/Navigator/battery +tags: + - API + - Battery API + - Propriedade +translation_of: Web/API/Navigator/battery +--- +

{{ ApiRef("Battery API") }}

+ +

Resumo

+ +

O objeto battery fornece informações sobre o nível de carga da bateria do sistema; você pode também escutar eventos enviados por ele que fornecem atualizações sobre o status atual da carga. Isso implementa a Battery Status API; consulte essa documentação para mais detalhes, um guia de utilização da API e códigos de exemplo.

+ +

Sintaxe

+ +
var battery = window.navigator.battery;
+ +

Valor

+ +

navigator.battery é um objeto do tipo {{domxref("BatteryManager")}}.

+ +

Especificações

+ +

{{page("/pt-BR/docs/Web/API/BatteryManager","Specifications")}}

+ +

Compatibilidade entre navegadores

+ +

{{page("/pt-BR/docs/Web/API/BatteryManager","Browser_compatibility")}}

+ +

Veja também

+ + diff --git a/files/pt-br/web/api/navigator/cookieenabled/index.html b/files/pt-br/web/api/navigator/cookieenabled/index.html new file mode 100644 index 0000000000..430471cb24 --- /dev/null +++ b/files/pt-br/web/api/navigator/cookieenabled/index.html @@ -0,0 +1,49 @@ +--- +title: Navigator.cookieEnabled +slug: Web/API/Navigator/cookieEnabled +translation_of: Web/API/Navigator/cookieEnabled +--- +

{{ ApiRef("HTML DOM") }}

+ +

navigator.cookieEnabled retorna um valor Booleano que indica quando cookies estão habilitados ou não. A propriedade é de apenas leitura.

+ +

Sintaxe

+ +
var cookieEnabled = navigator.cookieEnabled;
+
+ + + +

Exemplo

+ +
if (!navigator.cookieEnabled) {
+  // The browser does not support or is blocking cookies from being set.
+}
+
+ +

Especificações

+ + + + + + + + + + + + + + + + +
EspecificaçãoStatusComentário
{{SpecName("HTML WHATWG", "webappapis.html#dom-navigator-cookieenabled", "Navigator.cookieEnabled")}}{{Spec2("HTML WHATWG")}}Initial definition
+ +

Compatibilidade entre navegadores

+ + + +

{{Compat("api.Navigator.cookieEnabled")}}

diff --git a/files/pt-br/web/api/navigator/devicememory/index.html b/files/pt-br/web/api/navigator/devicememory/index.html new file mode 100644 index 0000000000..9b4a48aae5 --- /dev/null +++ b/files/pt-br/web/api/navigator/devicememory/index.html @@ -0,0 +1,39 @@ +--- +title: Navigator.deviceMemory +slug: Web/API/Navigator/deviceMemory +translation_of: Web/API/Navigator/deviceMemory +--- +

{{SeeCompatTable}}{{APIRef("Device Memory")}}

+ +

A propriedade de somente-leitura deviceMemory da interface {{domxref("navigator")}} retorna a quantidade de memória do dispositivo em gigabytes. Este valor é uma aproximação por arredondamento da potência mais próxima de 2 e dividindo este número por 1024.

+ +

Sintaxe

+ +
var memory = navigator.deviceMemory
+ +

Valor

+ +

Um número de ponto flutuante.

+ +

Especificações

+ + + + + + + + + + + + + + +
EspecificaçãoStatusComentário
{{SpecName('Device Memory','#sec-device-memory-js-api','deviceMemory')}}{{Spec2('Device Memory')}}Definição inicial.
+ +

Compatibilidade de navegadores

+ + + +

{{Compat("api.Navigator.deviceMemory")}}

diff --git a/files/pt-br/web/api/navigator/geolocation/index.html b/files/pt-br/web/api/navigator/geolocation/index.html new file mode 100644 index 0000000000..12cc9cbfbc --- /dev/null +++ b/files/pt-br/web/api/navigator/geolocation/index.html @@ -0,0 +1,46 @@ +--- +title: Navigator.geolocation +slug: Web/API/Navigator/geolocation +translation_of: Web/API/Navigator/geolocation +--- +
{{APIRef("Geolocation API")}}
+ +

A propriedade de apenas leitura Navigator.geolocation retorna um objeto {{domxref("Geolocation")}} que disponibiliza acesso de conteúdo Web à localização do dispositivo. Isso permite que um Web site ou aplicativo ofereçam resultados customizados baseado na localização do usuário.

+ +
+

Nota: Por questão de segurança, quando uma página web tenta acessar as informações de localização, o usuário é notificado e lhe é perguntado se este garante permissão. Esteja alerta que cada navegador possui suas próprias políticas e métodos para requisitar permissão.

+
+ +

Sintaxe

+ +
geo = navigator.geolocation
+
+ +

Especificações

+ + + + + + + + + + + + + + + + +
EspecificaçãoSituaçãoComentário
{{SpecName('Geolocation', '#navi-geo', 'Navigator.geolocation')}}{{Spec2('Geolocation')}}Definição inicial
+ +

Compatibilidade de navegador

+ +

{{Compat("api.Navigator.geolocation")}}

+ +

Veja também

+ + diff --git a/files/pt-br/web/api/navigator/getusermedia/index.html b/files/pt-br/web/api/navigator/getusermedia/index.html new file mode 100644 index 0000000000..4df2f528d4 --- /dev/null +++ b/files/pt-br/web/api/navigator/getusermedia/index.html @@ -0,0 +1,184 @@ +--- +title: navigator.getUserMedia +slug: Web/API/Navigator/getUserMedia +translation_of: Web/API/Navigator/getUserMedia +--- +

{{APIRef("Media Capture and Streams")}}{{deprecated_header}}

+ +

O método Navigator.getUserMedia() atualmente esta deprecated (obseleto), ele é responsavel por pedir a permissão do usuário para usar até 1 dispositivo de entrada de vídeo (como câmera, ou tela compartilhada) e até 1 dispositivo de entrada de áudio (como o microfone) como fonte para o stream de mídia (pode ser representado por uma instância MediaStream).

+ +

Se o usuário der permissão, a MediaStream (o track do video e/ou audio) , é entregue ao callback de sucesso, se a permissão é negada, pode ser que não haja dispositivo compatível ou alguma condição de erro aconteceu, retornando o callback de erro com uma instancia do objeto   {{domxref("MediaStreamError")}} , com a descrição do erro que aconteceu, se o usuário não fizer nenhuma escolha, nenhum callback é retornado.

+ +

Sintaxe

+ +
navigator.getUserMedia ( permissoes, callbackSucesso, callbackErro );
+ +

Exemplo

+ +

Este é um exemplo de uso da função getUserMedia() com prefixos específicos dos navegadores.

+ +
navigator.getMedia = ( navigator.getUserMedia ||
+                       navigator.webkitGetUserMedia ||
+                       navigator.mozGetUserMedia ||
+                       navigator.msGetUserMedia);
+
+navigator.getMedia (
+
+   // permissoes
+   {
+      video: true,
+      audio: true
+   },
+
+   // callbackSucesso
+   function(localMediaStream) {
+      var video = document.querySelector('video');
+      video.src = window.URL.createObjectURL(localMediaStream);
+      video.onloadedmetadata = function(e) {
+         // Faz algo com o vídeo aqui.
+      };
+   },
+
+   // callbackErro
+   function(err) {
+    console.log("O seguinte erro ocorreu: " + err);
+   }
+
+);
+ +

Parâmetros

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
parâmetroObrigatório/ 
+ Opcional 
Descrição
permissoesObrigatórioOs tipos de mídia habilitados no objeto LocalMediaStream enviado para a callbackSucesso.
callbackSucessoObrigatórioA função da aplicação a ser invocada para receber o objeto LocalMediaStream.
callbackErroOpcionalA função a ser invocada na aplicação se a chamada a getUserMedia falhar.
+ +

permissoes

+ +

O parâmetro permissoes é um objeto MediaStreamConstraints com dois membros do tipo Boolean: video e audio. Estes membros descrevem os tipos de mídia habilitados no objeto LocalMediaStream. Pelo menos um destes membros deve ser especificado para que o argumento seja validado. Se um membro especificado não for suportado pelo navegador, a função getUserMedia invocará a callbackErro com o erro NOT_SUPPORTED_ERROR. Se o navegador não puder encontrar nenhuma fonte de mídia com o tipo especificado, a função getUserMedia invocará a callbackErro com o erro MANDATORY_UNSATISFIED_ERR.

+ +

Se o valor de um membro não estiver especificado no objeto, o valor padrão deste membro será falso. Veja como configurar o objeto permissoes para obter tanto áudio como vídeo:

+ +
{ video: true, audio: true }
+ +

callbackSucesso

+ +

A função getUserMedia invocará a função especificada em callbackSucesso com o objeto LocalMediaStream que contém a fonte de mídia. Você pode associar este objeto com o elemento apropriado e trabalhar com ele, como mostrado no exemplo a seguir:

+ +
function(localMediaStream) {
+   var video = document.querySelector('video');
+   video.src = window.URL.createObjectURL(localMediaStream);
+   video.onloadedmetadata = function(e) {
+      // Faz algo com o vídeo aqui.
+   };
+},
+ +

callbackErro

+ +

A função getUserMedia invocará a função especificada em callbackErro com um argumento code. Os códigos de erro são descritos abaixo:

+ + + + + + + + + + + + + + + + + + + + + + +
ErroDescrição
PERMISSION_DENIED O usuário não permitiu acesso a um dispositivo de mídia necessário para essa operação. 
NOT_SUPPORTED_ERROR Uma mídia especificada não é suportada pelo navegador.
MANDATORY_UNSATISFIED_ERROR Nenhuma fonte de mídia do tipo especificado foi encontrada.
+ +

Compatibilidade de navegadores

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + +
FuncionalidadeChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Stream API 21{{property_prefix("webkit")}} 20{{property_prefix("moz")}} {{CompatNo}} 12{{CompatUnknown}} 
+
+ +
+ + + + + + + + + + + + + + + + + + + +
FuncionalidadeAndroidFirefox Mobile (Gecko)IE PhoneOpera MobileSafari Mobile
Stream API {{CompatNo}} {{CompatNo}}{{CompatUnknown}} 12{{CompatNo}} 
+
+ +

Atualmente, usar o WebRTC para acessar a câmera de vídeo é suportado nos navegadores Chrome, Opera e Firefox 20.

+ +

Veja também

+ + diff --git a/files/pt-br/web/api/navigator/index.html b/files/pt-br/web/api/navigator/index.html new file mode 100644 index 0000000000..6ef2055b7a --- /dev/null +++ b/files/pt-br/web/api/navigator/index.html @@ -0,0 +1,119 @@ +--- +title: Navigator +slug: Web/API/Navigator +translation_of: Web/API/Navigator +--- +

{{ apiref() }}

+ +

The Navigator interface represents the state and the identity of the user agent. It allows scripts to query it and to register themselves to carry on some activities.

+ +

A Navigator object can be retrieved using the read-only {{domxref("Window.navigator")}} property.

+ +

Properties

+ +

Doesn't inherit any property, but implements those defined in {{domxref("NavigatorID")}}, {{domxref("NavigatorLanguage")}}, {{domxref("NavigatorOnLine")}}, {{domxref("NavigatorGeolocation")}}, {{domxref("NavigatorPlugins")}}, {{domxref("NavigatorUserMedia")}}, and {{domxref("NetworkInformation")}}.

+ +

Standard

+ +
+
{{domxref("NavigatorID.appCodeName")}} {{readonlyInline}}{{experimental_inline}}
+
Returns the internal "code" name of the current browser. Do not rely on this property to return the correct value.
+
{{domxref("NavigatorID.appName")}} {{readonlyInline}}{{experimental_inline}}
+
Returns a {{domxref("DOMString")}} with the official name of the browser. Do not rely on this property to return the correct value.
+
{{domxref("NavigatorID.appVersion")}} {{readonlyInline}}{{experimental_inline}}
+
Returns the version of the browser as a {{domxref("DOMString")}}. Do not rely on this property to return the correct value.
+
{{domxref("Navigator.battery")}} {{readonlyInline}}
+
Returns a {{domxref("BatteryManager")}} object you can use to get information about the battery charging status.
+
{{domxref("NetworkInformation.connection")}} {{readonlyInline}}{{experimental_inline}}
+
Provides a {{domxref("Connection")}} with information about the network connection of a device.
+
{{domxref("NavigatorGeolocation.geolocation")}} {{readonlyInline}}
+
Returns a {{domxref("Geolocation")}} object allowing accessing the location of the device.
+
{{domxref("NavigatorPlugins.javaEnabled")}} {{readonlyInline}}{{experimental_inline}}
+
Returns a {{domxref("Boolean")}} flag indicating whether the host browser is Java-enabled or not.
+
{{domxref("NavigatorLanguage.language")}} {{readonlyInline}}
+
Returns a {{domxref("DOMString")}} representing the preferred language of the user, usually the language of the browser UI. The null value is returned when this is unknown.
+
{{domxref("NavigatorLanguage.languages")}} {{readonlyInline}}
+
Returns an array of {{domxref("DOMString")}} representing the languages known to the user, by order of preference.
+
{{domxref("NavigatorPlugins.mimeTypes")}} {{readonlyInline}}{{experimental_inline}}
+
Returns an {{domxref("MimeTypeArray")}} listing the MIME types supported by the browser.
+
{{domxref("NavigatorOnLine.onLine")}} {{readonlyInline}}
+
Returns a {{domxref("Boolean")}} indicating whether the browser is working online.
+
{{domxref("Navigator.oscpu")}}
+
Returns a string that represents the current operating system.
+
{{domxref("NavigatorID.platform")}} {{readonlyInline}}{{experimental_inline}}
+
Returns a string representing the platform of the browser. Do not rely on this function to return a significant value.
+
{{domxref("NavigatorPlugins.plugins")}} {{readonlyInline}}{{experimental_inline}}
+
Returns a {{domxref("PluginArray")}} listing the plugins installed in the browser.
+
{{domxref("NavigatorID.product")}} {{readonlyInline}} {{experimental_inline}}
+
Always returns 'Gecko', on any browser. This property is kept only for compatibility purpose.
+
{{domxref("NavigatorID.userAgent")}} {{readonlyInline}}
+
Returns the user agent string for the current browser.
+
{{domxref("Navigator.serviceWorker")}} {{readonlyInline}}
+
Returns a {{domxref("ServiceWorkerContainer")}} object, which provides access to registration, removal, upgrade, and communication with the {{domxref("ServiceWorker")}} objects for the associated document.
+
+ +

Non-standard

+ +
+
{{domxref("window.navigator.buildID", "navigator.buildID")}} {{non-standard_inline}}
+
Returns the build identifier of the browser (e.g., "2006090803").
+
{{domxref("Navigator.cookieEnabled")}} {{non-standard_inline}}
+
Returns a boolean indicating whether cookies are enabled in the browser or not.
+
{{domxref("navigator.doNotTrack")}} {{non-standard_inline}}
+
Reports the value of the user's do-not-track preference. When this value is "yes", your web site or application should not track the user.
+
{{domxref("navigator.id")}} {{non-standard_inline}}
+
Returns the {{domxref("window.navigator.id", "id")}} object which you can use to add support for BrowserID to your web site.
+
{{domxref("window.navigator.mozApps", "navigator.mozApps")}} {{non-standard_inline}}
+
Returns an {{domxref("window.navigator.mozApps", "Apps")}} object you can use to install, manage, and control Open Web apps.
+
{{domxref("Navigator.mozAudioChannelManager", "navigator.mozAudioChannelManager")}} {{non-standard_inline}}
+
The navigator.mozAudioChannelManager object provides access to the {{domxref("mozAudioChannelManager")}} interface, which is used to manage your Firefox OS device's audio channels, including setting what channel's volume to affect when the volume buttons are pressed inside a particular app.
+
{{domxref("window.navigator.mozNotification","navigator.mozNotification")}} {{deprecated_inline("22")}} {{non-standard_inline}}
+ {{domxref("window.navigator.webkitNotification","navigator.webkitNotification")}}
+
Returns a {{domxref("navigator.mozNotification", "notification")}} object you can use to deliver notifications to the user from your web application.
+
{{domxref("navigator.mozSocial")}} {{non-standard_inline}}
+
The Object, returned by the navigator.mozSocial property, is available within the social media provider's panel to provide functionality it may need.
+
{{domxref("window.navigator.productSub", "navigator.productSub")}} {{non-standard_inline}}
+
Returns the build number of the current browser (e.g., "20060909").
+
{{domxref("window.navigator.securitypolicy", "navigator.securitypolicy")}} {{non-standard_inline}}
+
Returns an empty string. In Netscape 4.7x, returns "US & CA domestic policy" or "Export policy".
+
{{domxref("window.navigator.standalone", "navigator.standalone")}} {{non-standard_inline}}
+
Returns a boolean indicating whether the browser is running in standalone mode. Available on Apple's iOS Safari only.
+
{{domxref("window.navigator.vendor", "navigator.vendor")}} {{non-standard_inline}}
+
Returns the vendor name of the current browser (e.g., "Netscape6").
+
{{domxref("window.navigator.vendorSub", "navigator.vendorSub")}} {{non-standard_inline}}
+
Returns the vendor version number (e.g. "6.1").
+
navigator.webkitPointer {{non-standard_inline}}
+
Returns a PointerLock object for the Mouse Lock API.
+
+ +

Methods

+ +

Doesn't inherit any method, but implements those defined in {{domxref("NavigatorID")}}, {{domxref("NavigatorContentUtils")}}, {{domxref("NavigatorUserMedia")}}, and {{domxref("NavigatorStorageUtils")}}.

+ +

Standard

+ +
+
{{domxref("NavigatorUserMedia.getUserMedia()")}}
+
After having prompted the user for permission, returns the audio or video stream associated to a camera or microphone on the local computer.
+
{{domxref("window.navigator.registerContentHandler", "navigator.registerContentHandler")}}
+
Allows web sites to register themselves as a possible handler for a given MIME type.
+
{{domxref("navigator.registerProtocolHandler", "navigator.registerProtocolHandler")}}
+
Allows web sites to register themselves as a possible handler for a given protocol.
+
{{domxref("NavigatorID.taintEnabled()")}} {{deprecated_inline("1.7.8")}} {{obsolete_inline("9.0")}} {{experimental_inline}}
+
Returns false. JavaScript taint/untaint functions removed in JavaScript 1.2.
+
{{domxref("Navigator.vibrate()")}} {{gecko_minversion_inline("11.0")}}
+
Causes vibration on devices with support for it. Does nothing if vibration support isn't available.
+
+ +

Non standard

+ +
+
{{domxref("window.navigator.mozIsLocallyAvailable", "navigator.mozIsLocallyAvailable")}} {{non-standard_inline}}
+
Lets code check to see if the document at a given URI is available without using the network.
+
{{domxref("window.navigator.mozPay", "navigator.mozPay")}} {{non-standard_inline}}
+
Allows in-app payment.
+
{{domxref("window.navigator.preference", "navigator.preference")}} {{obsolete_inline("2.0")}} {{non-standard_inline}}
+
Sets a user preference. This method is only available to privileged code and is obsolete; you should use the XPCOM Preferences API instead.
+
{{domxref("window.navigator.requestWakeLock", "navigator.requestWakeLock")}} {{non-standard_inline}}
+
Request a wake lock for a resource. A wake lock prevents a specific part of a device from being turned off automatically.
+
diff --git a/files/pt-br/web/api/navigator/share/index.html b/files/pt-br/web/api/navigator/share/index.html new file mode 100644 index 0000000000..ce6640ada2 --- /dev/null +++ b/files/pt-br/web/api/navigator/share/index.html @@ -0,0 +1,87 @@ +--- +title: Navigator.share() +slug: Web/API/Navigator/share +translation_of: Web/API/Navigator/share +--- +
{{APIRef("HTML DOM")}}{{securecontext_header}}
+ +

O método navigator.share() da API de compartilhamento da Web chama o mecanismo de compartilhamento nativo do dispositivo.

+ +

Sintaxe

+ +
var sharePromise = navigator.share(data);
+
+ +

Parâmetros

+ +
+
data
+
Um objeto que contém dados para compartilhar. Pelo menos um dos seguintes campos deve ser especificado. As opções disponíveis são:
+
+ + + +
+
+ +

Valor de retorno

+ +

Um {{domxref ("Promise")}} que será cumprido assim que um usuário concluir uma ação de compartilhamento (geralmente o usuário escolheu um aplicativo para compartilhar). Ele rejeitará imediatamente se o parâmetro de dados não estiver especificado corretamente e também rejeitará se o usuário cancelar o compartilhamento.

+ +

Exemplos

+ +

Em nosso teste de compartilhamento na Web (consulte o código-fonte), há um botão que, quando clicado, invoca a API de compartilhamento na Web para compartilhar o URL da MDN. O JavaScript fica assim:

+ +
const shareData = {
+  title: 'MDN',
+  text: 'Aprenda desenvolvimento web no MDN!',
+  url: 'https://developer.mozilla.org',
+}
+
+const btn = document.querySelector('button');
+const resultPara = document.querySelector('.result');
+
+// Deve ser acionado algum tipo de "ativação do usuário"
+btn.addEventListener('click', async () => {
+  try {
+    await navigator.share(shareData)
+  } catch(err) {
+    resultPara.textContent = 'Error: ' + e
+  }
+  resultPara.textContent = 'MDN compartilhado com sucesso!'
+});
+ +

Especificações

+ + + + + + + + + + + + + + + + +
EspecificaçãoStatusComment
{{SpecName('Web Share API','#share-method','share()')}}{{Spec2('Web Share API')}}
+ +

Compatibilidade do navegador

+ + + +

{{Compat("api.Navigator.share")}}

+ +

Veja também

+ + -- cgit v1.2.3-54-g00ecf