From 4f4d511f3a78d7e3dc357e44481cf0a7eba99b9f Mon Sep 17 00:00:00 2001 From: MDN Date: Thu, 17 Mar 2022 00:12:44 +0000 Subject: [CRON] sync translated content --- files/ru/_redirects.txt | 1 + files/ru/_wikihistory.json | 12 ++--- .../web/api/serviceworker/onstatechange/index.html | 60 --------------------- .../api/serviceworker/statechange_event/index.html | 61 ++++++++++++++++++++++ 4 files changed, 68 insertions(+), 66 deletions(-) delete mode 100644 files/ru/web/api/serviceworker/onstatechange/index.html create mode 100644 files/ru/web/api/serviceworker/statechange_event/index.html (limited to 'files/ru') diff --git a/files/ru/_redirects.txt b/files/ru/_redirects.txt index c9aa710795..1c06359a39 100644 --- a/files/ru/_redirects.txt +++ b/files/ru/_redirects.txt @@ -373,6 +373,7 @@ /ru/docs/Web/API/PositionError /ru/docs/Web/API/GeolocationPositionError /ru/docs/Web/API/PositionOptions /ru/docs/conflicting/Web/API/Geolocation/getCurrentPosition /ru/docs/Web/API/RandomSource/getRandomValues /ru/docs/Web/API/Crypto/getRandomValues +/ru/docs/Web/API/ServiceWorker/onstatechange /ru/docs/Web/API/ServiceWorker/statechange_event /ru/docs/Web/API/Touch_events/Supporting_both_TouchEvent_and_MouseEvent /ru/docs/conflicting/Web/API/Pointer_events /ru/docs/Web/API/USB/onconnect /ru/docs/Web/API/USB/connect_event /ru/docs/Web/API/USB/ondisconnect /ru/docs/Web/API/USB/disconnect_event diff --git a/files/ru/_wikihistory.json b/files/ru/_wikihistory.json index 17f599b98d..1bae2b40bf 100644 --- a/files/ru/_wikihistory.json +++ b/files/ru/_wikihistory.json @@ -10111,12 +10111,6 @@ "sh7dm" ] }, - "Web/API/ServiceWorker/onstatechange": { - "modified": "2020-10-15T22:25:53.618Z", - "contributors": [ - "sh7dm" - ] - }, "Web/API/ServiceWorker/scriptURL": { "modified": "2020-10-15T22:25:53.547Z", "contributors": [ @@ -10129,6 +10123,12 @@ "sh7dm" ] }, + "Web/API/ServiceWorker/statechange_event": { + "modified": "2020-10-15T22:25:53.618Z", + "contributors": [ + "sh7dm" + ] + }, "Web/API/ServiceWorkerContainer": { "modified": "2020-04-09T10:43:47.005Z", "contributors": [ diff --git a/files/ru/web/api/serviceworker/onstatechange/index.html b/files/ru/web/api/serviceworker/onstatechange/index.html deleted file mode 100644 index d7b171e887..0000000000 --- a/files/ru/web/api/serviceworker/onstatechange/index.html +++ /dev/null @@ -1,60 +0,0 @@ ---- -title: ServiceWorker.onstatechange -slug: Web/API/ServiceWorker/onstatechange -translation_of: Web/API/ServiceWorker/onstatechange ---- -
{{APIRef("Service Workers API")}}
- -

Обработчик события, вызываемый при срабатывании события statechange; по сути, срабатывает при изменении {{domxref("ServiceWorker.state")}}.

- -

Синтаксис

- -
ServiceWorker.onstatechange = function(statechangeevent) { ... }
-ServiceWorker.addEventListener('statechange', function(statechangeevent) { ... } )
- -

Примеры

- -

Данный фрагмент кода из примера событий service worker (демо) возвращает состояние при каждом его изменении.

- -
var serviceWorker;
-if (registration.installing) {
-  serviceWorker = registration.installing;
-  document.querySelector('#kind').textContent = 'installing';
-} else if (registration.waiting) {
-  serviceWorker = registration.waiting;
-  document.querySelector('#kind').textContent = 'waiting';
-} else if (registration.active) {
-  serviceWorker = registration.active;
-  document.querySelector('#kind').textContent = 'active';
-}
-
-if (serviceWorker) {
-  logState(serviceWorker.state);
-  serviceWorker.addEventListener('statechange', function(e) {
-  logState(e.target.state);
-  });
-}
- -

Обратите внимание, что при срабатывании statechange, ссылки на service worker могли измениться. Например:

- -
navigator.serviceWorker.register(..).then(function(swr) {
-  swr.installing.state == "installing"
-  swr.installing.onstatechange = function() {
-    swr.installing == null;
-    // At this point, swr.waiting OR swr.active might be true. This is because the statechange
-    // event gets queued, meanwhile the underlying worker may have gone into the waiting
-    // state and will be immediately activated if possible.
-  }
-})
- -

Спецификации

- -{{Specifications}} - -

Совместимость

- -
- - -

{{Compat}}

-
diff --git a/files/ru/web/api/serviceworker/statechange_event/index.html b/files/ru/web/api/serviceworker/statechange_event/index.html new file mode 100644 index 0000000000..b03607e229 --- /dev/null +++ b/files/ru/web/api/serviceworker/statechange_event/index.html @@ -0,0 +1,61 @@ +--- +title: ServiceWorker.onstatechange +slug: Web/API/ServiceWorker/statechange_event +translation_of: Web/API/ServiceWorker/onstatechange +original_slug: Web/API/ServiceWorker/onstatechange +--- +
{{APIRef("Service Workers API")}}
+ +

Обработчик события, вызываемый при срабатывании события statechange; по сути, срабатывает при изменении {{domxref("ServiceWorker.state")}}.

+ +

Синтаксис

+ +
ServiceWorker.onstatechange = function(statechangeevent) { ... }
+ServiceWorker.addEventListener('statechange', function(statechangeevent) { ... } )
+ +

Примеры

+ +

Данный фрагмент кода из примера событий service worker (демо) возвращает состояние при каждом его изменении.

+ +
var serviceWorker;
+if (registration.installing) {
+  serviceWorker = registration.installing;
+  document.querySelector('#kind').textContent = 'installing';
+} else if (registration.waiting) {
+  serviceWorker = registration.waiting;
+  document.querySelector('#kind').textContent = 'waiting';
+} else if (registration.active) {
+  serviceWorker = registration.active;
+  document.querySelector('#kind').textContent = 'active';
+}
+
+if (serviceWorker) {
+  logState(serviceWorker.state);
+  serviceWorker.addEventListener('statechange', function(e) {
+  logState(e.target.state);
+  });
+}
+ +

Обратите внимание, что при срабатывании statechange, ссылки на service worker могли измениться. Например:

+ +
navigator.serviceWorker.register(..).then(function(swr) {
+  swr.installing.state == "installing"
+  swr.installing.onstatechange = function() {
+    swr.installing == null;
+    // At this point, swr.waiting OR swr.active might be true. This is because the statechange
+    // event gets queued, meanwhile the underlying worker may have gone into the waiting
+    // state and will be immediately activated if possible.
+  }
+})
+ +

Спецификации

+ +{{Specifications}} + +

Совместимость

+ +
+ + +

{{Compat}}

+
-- cgit v1.2.3-54-g00ecf