From da78a9e329e272dedb2400b79a3bdeebff387d47 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:17 -0500 Subject: initial commit --- files/ko/webapi/idle/index.html | 66 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 files/ko/webapi/idle/index.html (limited to 'files/ko/webapi/idle/index.html') diff --git a/files/ko/webapi/idle/index.html b/files/ko/webapi/idle/index.html new file mode 100644 index 0000000000..eeb10abccf --- /dev/null +++ b/files/ko/webapi/idle/index.html @@ -0,0 +1,66 @@ +--- +title: Idle API +slug: WebAPI/Idle +translation_of: Archive/B2G_OS/API/Idle_API +--- +
+ {{non-standard_header}} {{B2GOnlyHeader2('certified')}}
+

Summary

+

Idle API 는 사용자가 유휴상태(idle) 상태가 되었음을 앱에 알려주는데 사용됩니다.

+

이것은 사용자가 자신의 디바이스에 아무것도 하지 않을 때에 앱이 동작을 취할 수 있게 해줍니다. 가장 많이 사용하는 경우는 배터리를 아끼기 위한 것으로 이 경우 보통 Power Management API 와 함께 사용됩니다.

+

유휴 상태의 사용자 관찰하기

+

시스템이 유휴상태일 때 어플리케이션으로 부터 알림을 받기 위해서는 idle observer에 꼭 등록을 하여야 한다. idle observer는 세가지 특성을 가지고 있는 오브젝트이다:

+ +

예제: 사용자가 반응이 없을때 화면을 어둡게 하기

+

이 예제에서, 10초 동안 사용자의 반응이 없을 때 유휴 관찰자(=idle observer)는 화면을 50% 밝기로 어둡게 한다 그리고 다시 사용자의 반응이 나타나면 100% 밝기로 돌려 놓는다. 두번째 유휴 관찰자 는 15초 동안 사용자 반응이 없을때 화면을 꺼 버린다.

+
// 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;
+  }
+}
+
+// Register the idle observers
+
+navigator.addIdleObserver(fadeLight);
+navigator.addIdleObserver(screenOff);
+
+

이 코드에는 fadeLightscreenOff 라는 두 유휴 관찰자를 정의한뒤시스템에 등록하기 위하여 각각 {{domxref("window.navigator.addIdleObserver","navigator.addIdleObserver()")}} 를 한번씩 호출한다. 어플리케이션은 필요한 만큼에 유휴 관찰자를 등록할 수 있다.

+

만약 어플리케이션에서 사용자의 반응이 없어지는지 더이상 관찰이 필요 없는 경우, 아래 예제 코드의 예처럼 유휴 관찰자를{{domxref("window.navigator.removeIdleObserver","navigator.removeIdleObserver()")}} 메서드를 통해 제거할 수 있다.

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

Specification

+

Not part of any specification yet; however, this API will be discussed at W3C as part of the System Applications Working Group.

+

See also

+ -- cgit v1.2.3-54-g00ecf