MCPcopy Create free account
hub / github.com/GoogleChrome/samples / requestWakeLock

Function requestWakeLock

wakelock/script.js:19–37  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17 let wakeLock = null;
18
19 const requestWakeLock = () => {
20 const controller = new AbortController();
21 const signal = controller.signal;
22 window.WakeLock.request('screen', {signal})
23 .catch((e) => {
24 if (e.name === 'AbortError') {
25 wakeLockCheckbox.checked = false;
26 statusDiv.textContent = 'Wake Lock was aborted';
27 console.log('Wake Lock was aborted');
28 } else {
29 statusDiv.textContent = `${e.name}, ${e.message}`;
30 console.error(`${e.name}, ${e.message}`);
31 }
32 });
33 wakeLockCheckbox.checked = true;
34 statusDiv.textContent = 'Wake Lock is active';
35 console.log('Wake Lock is active');
36 return controller;
37 };
38
39 wakeLockCheckbox.addEventListener('change', () => {
40 if (wakeLockCheckbox.checked) {

Callers 2

script.jsFile · 0.85
handleVisibilityChangeFunction · 0.85

Calls 3

requestMethod · 0.80
logMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected