-
Notifications
You must be signed in to change notification settings - Fork 0
/
BatteryManager.cljs
276 lines (183 loc) · 10.4 KB
/
BatteryManager.cljs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
(ns web.device.BatteryManager
"The BatteryManager interface provides ways to get information
the system's battery charge level."
(:refer-clojure :exclude []))
(defn add-event-listener
"Method.
The `web.EventTarget` method addEventListener() sets up a function
will be called whenever the specified event is delivered to the
`target.addEventListener(type, listener[, options]);
target.addEventListener(type, listener[, useCapture]);
target.addEventListener(type, listener[, useCapture, wantsUntrusted ]); // Gecko/Mozilla only`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener`"
[this & args]
(-> this .-addEventListener (.apply this (clj->js args))))
(defn remove-event-listener
"Method.
The EventTarget.removeEventListener() method removes from the
an event listener previously registered with `EventTarget.addEventListener()`.
event listener to be removed is identified using a combination
the event type, the event listener function itself, and various
options that may affect the matching process; see Matching event
for removal
`target.removeEventListener(type, listener[, options]);
target.removeEventListener(type, listener[, useCapture]);`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/removeEventListener`"
[this & args]
(-> this .-removeEventListener (.apply this (clj->js args))))
(defn dispatch-event
"Method.
Dispatches an `web.event.Event` at the specified `web.EventTarget`,
invoking the affected `web.EventListener`s in the appropriate
The normal event processing rules (including the capturing and
bubbling phase) also apply to events dispatched manually with
`cancelled = !target.dispatchEvent(event)`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/dispatchEvent`"
[this event]
(-> this (.dispatchEvent event)))
(defn charging
"Property.
A Boolean value indicating whether or not the device's battery
currently being charged.
`var charging = battery.charging
On return, charging indicates whether or not the battery, which is a `web.device.BatteryManager` object, is currently being charged; if the battery is charging, this value is true. Otherwise, the value is false.`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/BatteryManager/charging`"
[this]
(-> this (.-charging)))
(defn set-charging!
"Property.
A Boolean value indicating whether or not the device's battery
currently being charged.
`var charging = battery.charging
On return, charging indicates whether or not the battery, which is a `web.device.BatteryManager` object, is currently being charged; if the battery is charging, this value is true. Otherwise, the value is false.`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/BatteryManager/charging`"
[this val]
(aset this "charging" val))
(defn charging-time
"Property.
Indicates the amount of time, in seconds, that remain until the
is fully charged.
`var time = battery.chargingTime
On return, time is the remaining time in seconds until the battery, which is a `web.device.BatteryManager` object, is fully charged, or 0 if the battery is already fully charged. If the battery is currently discharging, this value is Infinity.`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/BatteryManager/chargingTime`"
[this]
(-> this (.-chargingTime)))
(defn set-charging-time!
"Property.
Indicates the amount of time, in seconds, that remain until the
is fully charged.
`var time = battery.chargingTime
On return, time is the remaining time in seconds until the battery, which is a `web.device.BatteryManager` object, is fully charged, or 0 if the battery is already fully charged. If the battery is currently discharging, this value is Infinity.`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/BatteryManager/chargingTime`"
[this val]
(aset this "chargingTime" val))
(defn discharging-time
"Property.
Indicates the amount of time, in seconds, that remains until
battery is fully discharged.
`var time = battery.dischargingTime
On return, time is the remaining time in seconds until the battery, which is a `web.device.BatteryManager` object, is fully discharged and the system will suspend. This value is Infinity if the battery is currently charging rather than discharging, or if the system is unable to report the remaining discharging time.`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/BatteryManager/dischargingTime`"
[this]
(-> this (.-dischargingTime)))
(defn set-discharging-time!
"Property.
Indicates the amount of time, in seconds, that remains until
battery is fully discharged.
`var time = battery.dischargingTime
On return, time is the remaining time in seconds until the battery, which is a `web.device.BatteryManager` object, is fully discharged and the system will suspend. This value is Infinity if the battery is currently charging rather than discharging, or if the system is unable to report the remaining discharging time.`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/BatteryManager/dischargingTime`"
[this val]
(aset this "dischargingTime" val))
(defn level
"Property.
Indicates the current battery charge level as a value between
and 1.0.
`var level = battery.level
On return, level is a number representing the system's battery charge level scaled to a value between 0.0 and 1.0. A value of 0 means the battery, which is a `web.device.BatteryManager` object, is empty and the system is about to be suspended. A value of 1.0 means the battery is full. A value of 1.0 is also returned if the implementation isn't able to determine the battery charge level or if the system is not battery-powered.`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/BatteryManager/level`"
[this]
(-> this (.-level)))
(defn set-level!
"Property.
Indicates the current battery charge level as a value between
and 1.0.
`var level = battery.level
On return, level is a number representing the system's battery charge level scaled to a value between 0.0 and 1.0. A value of 0 means the battery, which is a `web.device.BatteryManager` object, is empty and the system is about to be suspended. A value of 1.0 means the battery is full. A value of 1.0 is also returned if the implementation isn't able to determine the battery charge level or if the system is not battery-powered.`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/BatteryManager/level`"
[this val]
(aset this "level" val))
(defn onchargingchange
"Property.
Specifies an event listener to receive chargingchange events.
events occur when the battery `charging` state is updated.
`battery.onchargingchange = funcRef
Where battery is a `web.device.BatteryManager` object, and funcRef is a function to be called when the chargingchange event occurs.`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/BatteryManager/onchargingchange`"
[this]
(-> this (.-onchargingchange)))
(defn set-onchargingchange!
"Property.
Specifies an event listener to receive chargingchange events.
events occur when the battery `charging` state is updated.
`battery.onchargingchange = funcRef
Where battery is a `web.device.BatteryManager` object, and funcRef is a function to be called when the chargingchange event occurs.`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/BatteryManager/onchargingchange`"
[this val]
(aset this "onchargingchange" val))
(defn onchargingtimechange
"Property.
Specifies an event listener to receive chargingtimechange events.
events occur when the battery `chargingTime` is updated.
`battery.onchargingtimechange = funcRef
Where battery is a `web.device.BatteryManager` object, and funcRef is a function to be called when the chargingtimechange event occurs.`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/BatteryManager/onchargingtimechange`"
[this]
(-> this (.-onchargingtimechange)))
(defn set-onchargingtimechange!
"Property.
Specifies an event listener to receive chargingtimechange events.
events occur when the battery `chargingTime` is updated.
`battery.onchargingtimechange = funcRef
Where battery is a `web.device.BatteryManager` object, and funcRef is a function to be called when the chargingtimechange event occurs.`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/BatteryManager/onchargingtimechange`"
[this val]
(aset this "onchargingtimechange" val))
(defn ondischargingtimechange
"Property.
Specifies an event listener to receive dischargingtimechange
These events occur when the battery `dischargingTime` is updated.
`battery.ondischargingtimechange = funcRef
Where battery is a `web.device.BatteryManager` object, and funcRef is a function to be called when the dischargingtimechange event occurs.`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/BatteryManager/ondischargingtimechange`"
[this]
(-> this (.-ondischargingtimechange)))
(defn set-ondischargingtimechange!
"Property.
Specifies an event listener to receive dischargingtimechange
These events occur when the battery `dischargingTime` is updated.
`battery.ondischargingtimechange = funcRef
Where battery is a `web.device.BatteryManager` object, and funcRef is a function to be called when the dischargingtimechange event occurs.`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/BatteryManager/ondischargingtimechange`"
[this val]
(aset this "ondischargingtimechange" val))
(defn onlevelchange
"Property.
The BatteryManager.onlevelchange property specifies an event
to receive levelchange events. These events occur when the battery
is updated.
`navigator.battery.onlevelchange = funcRef
Where battery is a `web.device.BatteryManager` object, and funcRef is a function to be called when the levelchange event occurs.`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/BatteryManager/onlevelchange`"
[this]
(-> this (.-onlevelchange)))
(defn set-onlevelchange!
"Property.
The BatteryManager.onlevelchange property specifies an event
to receive levelchange events. These events occur when the battery
is updated.
`navigator.battery.onlevelchange = funcRef
Where battery is a `web.device.BatteryManager` object, and funcRef is a function to be called when the levelchange event occurs.`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/BatteryManager/onlevelchange`"
[this val]
(aset this "onlevelchange" val))