ws4kp/gulpserver/nosleep.min.js

2 lines
10 KiB
JavaScript
Raw Normal View History

/*! NoSleep.min.js v0.11.0 - git.io/vfn01 - Rich Tibbett - MIT license */
!function(A,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.NoSleep=e():A.NoSleep=e()}(window,(function(){return function(A){var e={};function o(n){if(e[n])return e[n].exports;var t=e[n]={i:n,l:!1,exports:{}};return A[n].call(t.exports,t,t.exports,o),t.l=!0,t.exports}return o.m=A,o.c=e,o.d=function(A,e,n){o.o(A,e)||Object.defineProperty(A,e,{enumerable:!0,get:n})},o.r=function(A){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(A,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(A,"__esModule",{value:!0})},o.t=function(A,e){if(1&e&&(A=o(A)),8&e)return A;if(4&e&&"object"==typeof A&&A&&A.__esModule)return A;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:A}),2&e&&"string"!=typeof A)for(var t in A)o.d(n,t,function(e){return A[e]}.bind(null,t));return n},o.n=function(A){var e=A&&A.__esModule?function(){return A.default}:function(){return A};return o.d(e,"a",e),e},o.o=function(A,e){return Object.prototype.hasOwnProperty.call(A,e)},o.p="",o(o.s=0)}([function(A,e,o){"use strict";var n=function(){function A(A,e){for(var o=0;o<e.length;o++){var n=e[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(A,n.key,n)}}return function(e,o,n){return o&&A(e.prototype,o),n&&A(e,n),e}}();var t=o(1),B=t.webm,Q=t.mp4,c="undefined"!=typeof navigator&&parseFloat((""+(/CPU.*OS ([0-9_]{3,4})[0-9_]{0,1}|(CPU like).*AppleWebKit.*Mobile/i.exec(navigator.userAgent)||[0,""])[1]).replace("undefined","3_2").replace("_",".").replace("_",""))<10&&!window.MSStream,i="wakeLock"in navigator,a=function(){function A(){var e=this;if(function(A,e){if(!(A instanceof e))throw new TypeError("Cannot call a class as a function")}(this,A),i){this._wakeLock=null;var o=function(){null!==e._wakeLock&&"visible"===document.visibilityState&&e.enable()};document.addEventListener("visibilitychange",o),document.addEventListener("fullscreenchange",o)}else c?this.noSleepTimer=null:(this.noSleepVideo=document.createElement("video"),this.noSleepVideo.setAttribute("title","No Sleep"),this.noSleepVideo.setAttribute("playsinline",""),this._addSourceToVideo(this.noSleepVideo,"webm",B),this._addSourceToVideo(this.noSleepVideo,"mp4",Q),this.noSleepVideo.addEventListener("loadedmetadata",(function(){e.noSleepVideo.duration<=1?e.noSleepVideo.setAttribute("loop",""):e.noSleepVideo.addEventListener("timeupdate",(function(){e.noSleepVideo.currentTime>.5&&(e.noSleepVideo.currentTime=Math.random())}))})))}return n(A,[{key:"_addSourceToVideo",value:function(A,e,o){var n=document.createElement("source");n.src=o,n.type="video/"+e,A.appendChild(n)}},{key:"enable",value:function(){var A=this;i?navigator.wakeLock.request("screen").then((function(e){A._wakeLock=e,console.log("Wake Lock active."),A._wakeLock.addEventListener("release",(function(){console.log("Wake Lock released.")}))})).catch((function(A){console.error(A.name+", "+A.message)})):c?(this.disable(),console.warn("\n NoSleep enabled for older iOS devices. This can interrupt\n active or long-running network requests from completing successfully.\n See https://github.com/richtr/NoSleep.js/issues/15 for more details.\n "),this.noSleepTimer=window.setInterval((function(){document.hidden||(window.location.href=window.location.href.split("#")[0],window.setTimeout(window.stop,0))}),15e3)):this.noSleepVideo.play()}},{key:"disable",value:function(){i?(this._wakeLock.release(),this._wakeLock=null):c?this.noSleepTimer&&(console.warn("\n NoSleep now disabled for older iOS devices.\n "),window.clearInterval(this.noSleepTimer),this.noSleepTimer=null):this.noSleepVideo.pause()}}]),A}();A.exports=a},function(A,e,o){"use strict";A.exports={webm:"data:video/webm;base64,GkXfo0AgQoaBAUL3gQFC8oEEQvOBCEKCQAR3ZWJtQoeBAkKFgQIYU4BnQI0VSalmQCgq17FAAw9CQE2AQAZ3aGFtbXlXQUAGd2hhbW15RIlACECPQAAAAAAAFlSua0AxrkAu14EBY8WBAZyBACK1nEADdW5khkAFVl9WUDglhohAA1ZQOIOBAeBABrCBCLqBCB9DtnVAIueBAKNAHIEAAIAwAQCdASoI