UNPKG

tethysfaceid

Version:

1 lines 4.64 kB
{"ast":null,"code":"import { FaceTecSDK } from \"core-sdk/FaceTecSDK.js/FaceTecSDK\";\nimport { message } from 'antd';\nexport var FaceMapAppUtillities = function () {\n var currentTheme = \"Sample Bank\";\n\n function displayStatus(status, method) {\n if (method) {\n method(status, 3);\n } else {\n message.info(status, 3);\n }\n }\n\n function showMainUI() {\n document.querySelector(\".wrapping-box-container\").style.opacity = 1;\n FaceMapAppUtillities.enableAllButtons();\n } // Disable buttons to prevent hammering, fade out main interface elements, and shuffle the guidance images.\n\n\n function fadeOutMainUIAndPrepareForSession() {\n disableAllButtons();\n document.querySelector(\".wrapping-box-container\").style.opacity = 0;\n }\n\n function disableAllButtons() {\n document.querySelectorAll(\"button\").forEach(function (button) {\n button.disabled = true;\n });\n }\n\n function enableAllButtons() {\n document.querySelectorAll(\"button\").forEach(function (button) {\n button.disabled = false;\n });\n }\n\n function handleErrorGettingServerSessionToken() {\n fadeInMainUI();\n enableAllButtons();\n displayStatus(\"Session could not be started due to an unexpected issue during the network request.\");\n }\n\n function generateUUId() {\n //@ts-ignore\n return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, function (c) {\n return (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16);\n });\n }\n\n function formatUIForDevice() {\n if (isLikelyMobileDevice()) {\n // Adjust button sizing\n document.querySelectorAll(\".controls > button\").forEach(function (element) {// if (element.className === \"big-button\") {\n // (element).style.height = \"40px\";\n // (element).style.fontSize = \"18px\";\n // }\n // else if (element.className === \"medium-button\") {\n // (element).style.height = \"30px\";\n // (element).style.fontSize = \"14px\";\n // }\n // (element).style.width = \"220px\";\n }); // Hide border around control panel\n // (document.getElementById(\"controls\")).style.borderColor = \"transparent\";\n // Hide status label text background and decrease label font size\n // (document.getElementById(\"status\")).style.backgroundColor = \"transparent\";\n // (document.getElementById(\"status\")).style.fontSize = \"12px\";\n // Center control interface on screen\n // (document.getElementsByClassName(\"wrapping-box-container\")[0]).style.top = \"50%\";\n // (document.getElementsByClassName(\"wrapping-box-container\")[0]).style.left = \"50%\";\n // (document.getElementsByClassName(\"wrapping-box-container\")[0]).style.transform = \"translate(-50%, -50%)\";\n }\n }\n\n function isLikelyMobileDevice() {\n var isMobileDeviceUA = !!/Android|iPhone|iPad|iPod|IEMobile|Mobile|mobile/i.test(navigator.userAgent || \"\"); // ChromeOS/Chromebook detection.\n\n if (isMobileDeviceUA && (navigator.userAgent.indexOf(\"CrOS\") != -1 || navigator.userAgent.indexOf(\"Chromebook\") != -1)) {\n isMobileDeviceUA = false;\n } // Mobile device determination based on portrait / landscape and user agent.\n\n\n if (screen.width < screen.height || isMobileDeviceUA) {\n // Assume mobile device when in portrait mode or when determined by the user agent.\n return true;\n } else {\n return false;\n }\n }\n\n function configureGuidanceScreenTextForDevice() {\n if (isLikelyMobileDevice()) {\n // using strings with breaks for Ready Screen text on mobile devices\n Config.currentCustomization.guidanceCustomization.readyScreenHeaderAttributedString = \"Get Ready For<br/>Your Video Selfie\";\n Config.currentCustomization.guidanceCustomization.readyScreenSubtextAttributedString = \"Please Frame Your Face In<br/>The Small Oval, Then The Big Oval\";\n }\n\n FaceTecSDK.setCustomization(Config.currentCustomization);\n }\n\n return {\n displayStatus: displayStatus,\n showMainUI: showMainUI,\n fadeOutMainUIAndPrepareForSession: fadeOutMainUIAndPrepareForSession,\n disableAllButtons: disableAllButtons,\n enableAllButtons: enableAllButtons,\n generateUUId: generateUUId,\n formatUIForDevice: formatUIForDevice,\n handleErrorGettingServerSessionToken: handleErrorGettingServerSessionToken,\n configureGuidanceScreenTextForDevice: configureGuidanceScreenTextForDevice,\n isLikelyMobileDevice: isLikelyMobileDevice\n };\n}();","map":null,"metadata":{},"sourceType":"module"}