This is a non-standard feature but it is available on some platforms,
essentially it will allow a web-app that uses NoSleep.js,
to also switch off the PC screensaver (currently, screensaver and power-saving are not turned off).
Also, it does not require user-interaction.
I've combine it with the normal in a little try/catch...
var screen_lock; //should be available globally for the app.
//....
function toggle_fullscreen(){
if(false === is_fullscreen_on()){
console.log("is not in fullscreen, turning on.");
nosleep.enable();
if("undefined" !== typeof window.navigator.requestWakeLock){ try{ screen_lock = window.navigator.requestWakeLock("screen");}catch(err){} } //trying to keep screen-ON using: https://developer.mozilla.org/en-US/docs/Archive/B2G_OS/API/Wake_Lock_API
fullscreen_on(undefined);
}
else{
console.log("is in fullscreen, turning off.");
nosleep.disable();
if("undefined" !== typeof window.navigator.requestWakeLock){ try{ screen_lock.unlock(); }catch(err){} }
fullscreen_off();
}
}
//.........
self.document.documentElement.ondblclick = function(ev){ //double-click on the document.
toggle_fullscreen();
};
https://developer.mozilla.org/en-US/docs/Archive/B2G_OS/API/Wake_Lock_API
This is a non-standard feature but it is available on some platforms, essentially it will allow a web-app that uses
NoSleep.js
, to also switch off the PC screensaver (currently, screensaver and power-saving are not turned off).Also, it does not require user-interaction.
I've combine it with the normal in a little try/catch...