aboutsummaryrefslogtreecommitdiff
path: root/files/ru/web/api/usb
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:42:52 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:42:52 -0500
commit074785cea106179cb3305637055ab0a009ca74f2 (patch)
treee6ae371cccd642aa2b67f39752a2cdf1fd4eb040 /files/ru/web/api/usb
parentda78a9e329e272dedb2400b79a3bdeebff387d47 (diff)
downloadtranslated-content-074785cea106179cb3305637055ab0a009ca74f2.tar.gz
translated-content-074785cea106179cb3305637055ab0a009ca74f2.tar.bz2
translated-content-074785cea106179cb3305637055ab0a009ca74f2.zip
initial commit
Diffstat (limited to 'files/ru/web/api/usb')
-rw-r--r--files/ru/web/api/usb/getdevices/index.html63
-rw-r--r--files/ru/web/api/usb/index.html60
-rw-r--r--files/ru/web/api/usb/onconnect/index.html43
-rw-r--r--files/ru/web/api/usb/ondisconnect/index.html43
-rw-r--r--files/ru/web/api/usb/requestdevice/index.html82
5 files changed, 291 insertions, 0 deletions
diff --git a/files/ru/web/api/usb/getdevices/index.html b/files/ru/web/api/usb/getdevices/index.html
new file mode 100644
index 0000000000..8b69fce817
--- /dev/null
+++ b/files/ru/web/api/usb/getdevices/index.html
@@ -0,0 +1,63 @@
+---
+title: USB.getDevices()
+slug: Web/API/USB/getDevices
+tags:
+ - API
+ - Method
+ - Reference
+ - USB
+ - WebUSB
+ - WebUSB API
+ - getDevices()
+translation_of: Web/API/USB/getDevices
+---
+<p>{{APIRef("WebUSB API")}}{{SeeCompatTable}}{{securecontext_header}}</p>
+
+<p>Метод<strong> <code>getDevices</code> </strong>интерфейса {{DOMxRef("USB")}} возвращает {{JSxRef("Promise")}}, который разрешается с массивом {{DOMxRef("USBDevice")}} объектов сопряжённых подключённых устройств. Для информации о сопряжённых устройствах, смотрите {{DOMxRef("USB.requestDevice()")}}.</p>
+
+<h2 id="Синтаксис">Синтаксис</h2>
+
+<pre class="syntaxbox notranslate"><em>USB</em>.getDevices()</pre>
+
+<h3 id="Параметры">Параметры</h3>
+
+<p>Нет.</p>
+
+<h3 id="Возвращаемое_значение">Возвращаемое значение</h3>
+
+<p>{{JSxRef("Promise")}}, который разрешается с массивом объектов {{DOMxRef("USBDevice")}}.</p>
+
+<h2 id="Пример">Пример</h2>
+
+<p>В следующем примере имена продуктов и серийные номера сопряжённых устройств выводятся в консоль. Для информации о сопряжённых устройствах, смотрите {{DOMxRef("USB.requestDevice","USB.requestDevice()")}}.</p>
+
+<pre class="brush: js notranslate">navigator.usb.getDevices()
+.then(devices =&gt; {
+  console.log("Total devices: " + devices.length);
+  devices.forEach(device =&gt; {
+    console.log("Product name: " + device.productName + ", serial number " + device.serialNumber);
+  });
+});</pre>
+
+<h2 id="Спецификация">Спецификация</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("Web USB","#dom-usb-getdevices","getDevices")}}</td>
+ <td>{{Spec2("Web USB")}}</td>
+ <td>Изначальное определение.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Совместимость_с_браузерами">Совместимость с браузерами</h2>
+
+
+
+<p>{{Compat("api.USB.getDevices")}}</p>
diff --git a/files/ru/web/api/usb/index.html b/files/ru/web/api/usb/index.html
new file mode 100644
index 0000000000..423ffc90da
--- /dev/null
+++ b/files/ru/web/api/usb/index.html
@@ -0,0 +1,60 @@
+---
+title: USB
+slug: Web/API/USB
+tags:
+ - API
+ - Interface
+ - Reference
+ - USB
+ - WebUSB
+ - WebUSB API
+translation_of: Web/API/USB
+---
+<p>{{APIRef("WebUSB API")}}{{SeeCompatTable}}{{securecontext_header}}</p>
+
+<p>Интерфейс <strong><code>USB</code></strong> <a href="/en-US/docs/Web/API/WebUSB_API">WebUSB API</a> представляет аттрибуты и методы для поиска и подключения USB устройств из WEB страницы.</p>
+
+<h2 id="Свойтсва">Свойтсва</h2>
+
+<p>Нет.</p>
+
+<h3 id="Обработчики_событий">Обработчики событий</h3>
+
+<dl>
+ <dt>{{domxref("USB.onconnect")}}</dt>
+ <dd>Обработчик событий вызывается всегда, когда ранее сопряжённое устройство подключается.</dd>
+ <dt>{{domxref("USB.ondisconnect")}}</dt>
+ <dd>Обработчик событий вызывается всегда, когда ранее сопряжённое устройство отключается.</dd>
+</dl>
+
+<h2 id="Методы">Методы</h2>
+
+<dl>
+ <dt>{{domxref("USB.getDevices()")}}</dt>
+ <dd>Возвращает {{jsxref("Promise")}}, который разрешается массивов объектов {{domxref("USBDevice")}} сопряжённых устройств.</dd>
+ <dt>{{domxref("USB.requestDevice()")}}</dt>
+ <dd>Возвращает {{jsxref("Promise")}}, который разрешается экземпляром {{domxref("USBDevice")}}, если указаннное устройство найдено. Вызов этой функции запускает поток сопряжения агента пользователя.</dd>
+</dl>
+
+<h2 id="Спецификация">Спецификация</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('Web USB','#enumeration','USB')}}</td>
+ <td>{{Spec2('Web USB')}}</td>
+ <td>Изначальное определение.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Совместимость_с_браузерами">Совместимость с браузерами</h2>
+
+
+
+<p>{{Compat("api.USB")}}</p>
diff --git a/files/ru/web/api/usb/onconnect/index.html b/files/ru/web/api/usb/onconnect/index.html
new file mode 100644
index 0000000000..3a7d64e234
--- /dev/null
+++ b/files/ru/web/api/usb/onconnect/index.html
@@ -0,0 +1,43 @@
+---
+title: USB.onconnect
+slug: Web/API/USB/onconnect
+tags:
+ - API
+ - Method
+ - Reference
+ - USB
+ - WebUSB
+ - WebUSB API
+ - onconnect
+translation_of: Web/API/USB/onconnect
+---
+<p>{{APIRef("WebUSB API")}}{{SeeCompatTable}}{{securecontext_header}}</p>
+
+<p>Свойство <strong><code>onconnect</code></strong> интерфейса {{DOMxRef("USB")}} является обработчиком события, который вызывается всегда, когда сопряжённое устройство подключается.</p>
+
+<h2 id="Синтаксис">Синтаксис</h2>
+
+<pre class="syntaxbox notranslate"><em>USB</em>.onconnect = <em>connectFunction</em></pre>
+
+<h2 id="Спецификации">Спецификации</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("Web USB","#dom-usb-onconnect","onconnect")}}</td>
+ <td>{{Spec2("Web USB")}}</td>
+ <td>Изначальное определение.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Совместимость_с_браузерами">Совместимость с браузерами</h2>
+
+
+
+<p>{{Compat("api.USB.onconnect")}}</p>
diff --git a/files/ru/web/api/usb/ondisconnect/index.html b/files/ru/web/api/usb/ondisconnect/index.html
new file mode 100644
index 0000000000..25dff131a0
--- /dev/null
+++ b/files/ru/web/api/usb/ondisconnect/index.html
@@ -0,0 +1,43 @@
+---
+title: USB.ondisconnect
+slug: Web/API/USB/ondisconnect
+tags:
+ - API
+ - Method
+ - Reference
+ - USB
+ - WebUSB
+ - WebUSB API
+ - ondisconnect
+translation_of: Web/API/USB/ondisconnect
+---
+<p>{{APIRef("WebUSB API")}}{{SeeCompatTable}}{{securecontext_header}}</p>
+
+<p>Свойство <strong><code>ondisconnect</code></strong> интерфейса {{domxref("USB")}} является обработчиком события, который вызывается всегда, когда сопряжённое устройство отключается.</p>
+
+<h2 id="Синтаксис">Синтаксис</h2>
+
+<pre class="syntaxbox notranslate">USB.ondisconnect = <em>disconnectFunction</em></pre>
+
+<h2 id="Спецификации">Спецификации</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('Web USB','#dom-usb-ondisconnect','ondisconnect')}}</td>
+ <td>{{Spec2('Web USB')}}</td>
+ <td>Изначальное определение.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Совместимость_с_браузерами">Совместимость с браузерами</h2>
+
+
+
+<p>{{Compat("api.USB.ondisconnect")}}</p>
diff --git a/files/ru/web/api/usb/requestdevice/index.html b/files/ru/web/api/usb/requestdevice/index.html
new file mode 100644
index 0000000000..bb162ad242
--- /dev/null
+++ b/files/ru/web/api/usb/requestdevice/index.html
@@ -0,0 +1,82 @@
+---
+title: USB.requestDevice()
+slug: Web/API/USB/requestDevice
+tags:
+ - API
+ - USB
+ - WebUSB
+ - WebUSB API
+ - getDevices()
+ - Определение
+ - метод
+translation_of: Web/API/USB/requestDevice
+---
+<p>{{APIRef("WebUSB API")}}{{SeeCompatTable}}{{securecontext_header}}</p>
+
+<p>Метод <strong><code>requestDevice()</code></strong> интерфейса {{domxref("USB")}} возвращает {{jsxref("Promise")}}, возвращающий экземпляр {{domxref("USBDevice")}}, если необходимое устройство было найдено. Вызов этого метода начинает процесс соединения браузера с устройством.</p>
+
+<h2 id="Синтаксис">Синтаксис</h2>
+
+<pre class="syntaxbox notranslate"><em>USB</em>.requestDevice([<em>filters</em>])</pre>
+
+<h3 id="Параметры">Параметры</h3>
+
+<dl>
+ <dt>filters</dt>
+ <dd>Массив объектов, определяющих фильтры для устройств, к которым требуется подключиться. Каждый фильтр может содержать следующие свойства:
+ <ul>
+ <li><code>vendorId</code> - ИД производителя (USB VID)</li>
+ <li><code>productId</code> - ИД устройства USB PID</li>
+ <li><code>classCode</code> - код класса функциональности устройства</li>
+ <li><code>subclassCode</code> - код подкласса</li>
+ <li><code>protocolCode</code> - код протокола</li>
+ <li><code>serialNumber</code> - серийный номер</li>
+ </ul>
+ </dd>
+</dl>
+
+<h3 id="Возвращаемое_значение">Возвращаемое значение</h3>
+
+<p>{{JSxRef("Promise")}}, возвращающий экземпляр {{DOMxRef("USBDevice")}}.</p>
+
+<h2 id="Пример">Пример</h2>
+
+<p>Этот пример запрашивает любое из перечисленных USB-устройств. Обратите внимание, указаны два разных PID. Оба присутствуют в списке фильтров для <code>requestDevice()</code>. При этом браузер покажет окно для выбора и подтверждения доступа к устройству. Только выбранное пользователем устройство будет передано в <code>then()</code>.</p>
+
+<p>Количество фильтров не определяет количество устройств, показываемых браузером. Например, если найдено только USB-устройство с product ID <code>0xa800</code>, браузер отобразит только одно устройство. Но, если браузер определит два устройства, совпадающих с первым фильтром, и еще одно, совпадающее со вторым, будут показаны все три устройства.</p>
+
+<pre class="brush: js notranslate">const filters = [
+        {vendorId: 0x1209, productId: 0xa800},
+  {vendorId: 0x1209, productId: 0xa850}
+      ];
+navigator.usb.requestDevice({filters: filters})
+.then(usbDevice =&gt; {
+  console.log("Product name: " + usbDevice.productName);
+})
+.catch(e =&gt; {
+  console.log("There is no device. " + e);
+});
+</pre>
+
+<h2 id="Спецификации">Спецификации</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Спецификация</th>
+ <th scope="col">Статус</th>
+ <th scope="col">Комментарий</th>
+ </tr>
+ <tr>
+ <td>{{SpecName("Web USB","#dom-usb-requestdevice-options-options","requestDevice")}}</td>
+ <td>{{Spec2("Web USB")}}</td>
+ <td>Изначальное определение.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Совместимость">Совместимость</h2>
+
+
+
+<p>{{Compat("api.USB.requestDevice")}}</p>