From a065e04d529da1d847b5062a12c46d916408bf32 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 21:46:22 -0500 Subject: update based on https://github.com/mdn/yari/issues/2028 --- files/zh-tw/webapi/idle/index.html | 61 -------------------------------------- 1 file changed, 61 deletions(-) delete mode 100644 files/zh-tw/webapi/idle/index.html (limited to 'files/zh-tw/webapi/idle') diff --git a/files/zh-tw/webapi/idle/index.html b/files/zh-tw/webapi/idle/index.html deleted file mode 100644 index e4eaaaaac2..0000000000 --- a/files/zh-tw/webapi/idle/index.html +++ /dev/null @@ -1,61 +0,0 @@ ---- -title: Idle -slug: WebAPI/Idle -translation_of: Archive/B2G_OS/API/Idle_API ---- -

{{ non-standard_header() }}

-

{{ B2GOnlyHeader2('certified') }}

-

摘要

-

當使用者讓裝置進入閒置/待機狀態,可通知 App 以採取相對應的行動。最常見的情形就是待機省電。而待機省電狀態又可另外搭配 Power Management API

-

Idle Observer

-

若要讓任一 App 收到「系統閒置」的通知,就必須先註冊 Idle Observer。而 Idle Observer 物件具備了 3 項屬性:

- -
// NOTE: mozPower is part of the Power Management API
-
-var fadeLight = {
-  time: 10, // Ten seconds
-
-  onidle: function () {
-    // The user does not seem active, let's dim the screen down
-    navigator.mozPower.screenBrightness = 0.5;
-  },
-
-  onactive: function () {
-    // Ok, the user is back, let's brighten the screen up
-    navigator.mozPower.screenBrightness = 1;
-  }
-}
-
-var screenOff = {
-  time: 15, // fifteen seconds
-
-  onidle: function () {
-    // Ok, the user had his chance but he's really idle, let's turn the screen off
-    navigator.mozPower.screenEnabled = false;
-  },
-
-  onactive: function () {
-    // Ok, the user is back, let's turn the screen on
-    navigator.mozPower.screenEnabled = true;
-  }
-}
-
-

任一 App 均可依需要而定義為多個 Idle Observer。但不論定義成幾個 Idle Observer,都必須以 navigator.addIdleObserver() 函式完成註冊,才能由系統所處理。

-
navigator.addIdleObserver(fadeLight);
-navigator.addIdleObserver(screenOff);
-
-

又如果 App 不再需要知道使用者是否閒置了系統,則可透過 navigator.removeIdleObserver() 函式移除 Idle Observer。

-
navigator.removeIdleObserver(fadeLight);
-navigator.removeIdleObserver(screenOff);
-
-

規格

-

目前仍未有任何規格,但 W3C 將此 API 納入為 System Applications Working Group 討論的一部分。

-

另可參閱

- -- cgit v1.2.3-54-g00ecf