web2app-spa
Version:
This template is primarily designed to easily convert HTML pages and URLs into a Capacitor/Cordova based iOS/Android app that can be used as Single-page application (SPA).
1 lines • 1.6 kB
JavaScript
const app={isCordovaExist:0,isCapacitorExist:0,frameworkName:"none"};app.lastPerformanceCheckTime=Date.now(),app.onDeviceReady=function(e){window.addEventListener("load",(function(){"undefined"!=typeof Capacitor?(app.isCapacitorExist=1,app.frameworkName="capacitor",document.addEventListener("deviceready",e.bind(this),!1)):"undefined"!=typeof cordova?(app.isCordovaExist=1,app.frameworkName="cordova",document.addEventListener("deviceready",e.bind(this),!1)):(app.frameworkName="none",e())}))},app.getPlatformId=function(){let e="web";return app.isCapacitorExist?e=Capacitor.getPlatform():app.isCordovaExist&&(e=cordova.platformId),e},app.calculateResolution=function(){return page.width>800?700:page.width<400?550:600},app.checkPerformance=function(e){Date.now(),app.lastPerformanceCheckTime;app.lastPerformanceCheckTime=Date.now()},app.getSafeAreaOuterSpaces=function(e){let t=0,a=setInterval((function(){t++;let o=getComputedStyle(document.documentElement).getPropertyValue("--sat"),n=getComputedStyle(document.documentElement).getPropertyValue("--sab"),p=getComputedStyle(document.documentElement).getPropertyValue("--sal"),r=getComputedStyle(document.documentElement).getPropertyValue("--sar"),i=function(){let e={};return e.top=parseInt(o),e.bottom=parseInt(n),e.left=parseInt(p),e.right=parseInt(r),app.safeAreaInsetTop=withPageZoom(e.top),app.safeAreaInsetBottom=withPageZoom(e.bottom),app.safeAreaInsetLeft=withPageZoom(e.left),app.safeAreaInsetRight=withPageZoom(e.right),e};0!=parseInt(o)&&(e(i()),clearInterval(a)),(t>60||"web"==app.getPlatformId())&&(e(i()),clearInterval(a))}),5)};