no-sleep-app
Version:
NoSleepApp is a lightweight JavaScript library that prevents devices from going to sleep during critical activities. It uses the Screen Wake Lock API or a fallback video playback method to keep the screen active, ensuring uninterrupted user experiences ac
73 lines (51 loc) • 2.83 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: detect.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: detect.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>/**
* Determines if the current device is running an older version of iOS (pre-iOS 10).
* This is useful for applying platform-specific workarounds for older iOS devices.
*
* @returns {boolean} True if the device is running an iOS version older than 10, false otherwise.
*/
export const isOldIOS = () => {
if (typeof navigator === "undefined") return false;
// Regex to match the iOS version in the user agent string.
const match = /CPU.*OS ([0-9_]{3,4})[0-9_]{0,1}|(CPU like).*AppleWebKit.*Mobile/i.exec(navigator.userAgent);
if (!match) return false;
// Extract and normalize the iOS version number.
const version = match[1]
.replace("undefined", "3_2") // Default to iOS 3.2 if version is undefined.
.replace("_", ".") // Replace underscores with periods for standard decimal format.
.replace("_", ""); // Remove any additional underscores.
return parseFloat(version) < 10;
};
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="module.exports.html">exports</a></li></ul><h3>Global</h3><ul><li><a href="global.html#disable">disable</a></li><li><a href="global.html#enable">enable</a></li><li><a href="global.html#handleFullscreenChange">handleFullscreenChange</a></li><li><a href="global.html#handleVisibilityChange">handleVisibilityChange</a></li><li><a href="global.html#isEnabled">isEnabled</a></li><li><a href="global.html#isNativeWakeLockSupported">isNativeWakeLockSupported</a></li><li><a href="global.html#isOldIOS">isOldIOS</a></li><li><a href="global.html#pause">pause</a></li><li><a href="global.html#play">play</a></li><li><a href="global.html#removeListeners">removeListeners</a></li><li><a href="global.html#setMetadataListener">setMetadataListener</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.4</a> on Fri Nov 22 2024 23:19:12 GMT+0000 (Greenwich Mean Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>