UNPKG

cordova-app-loader

Version:

Cordova App Loader - remote update your cordova app

1 lines 1.57 kB
!function(){function t(t,e,o){function n(){r.forEach(function(e){e&&("/"===e[0]&&(e=e.substr(1)),e=t.root+e,".js"===e.substr(-3)?(a=document.createElement("script"),a.charset="UTF-8",a.type="text/javascript",a.src=e+"?"+i,a.async=!1):(a=document.createElement("link"),a.rel="stylesheet",a.href=e+"?"+i,a.type="text/css"),s.appendChild(a))})}if(e&&setTimeout(function(){window.BOOTSTRAP_OK||(console.warn("BOOTSTRAP_OK !== true; Resetting to original manifest.json..."),localStorage.removeItem("manifest"),location.reload())},o),!t.load)return void console.error("Manifest has nothing to load (manifest.load is empty).",t);var a,s=document.getElementsByTagName("head")[0],r=t.load.concat(),i=Date.now();t.root=t.root||"./",t.root.length>0&&"/"!==t.root[t.root.length-1]&&(t.root+="/"),e||localStorage.setItem("manifest",JSON.stringify(t)),"undefined"!=typeof window.cordova?document.addEventListener("deviceready",n,!1):n(),window.Manifest=t}window.pegasus=function(t,e){return e=new XMLHttpRequest,e.open("GET",t),t=[],e.onreadystatechange=e.then=function(o,n,a,s){if(o.call&&(t=[o,n]),4==e.readyState){try{200===e.status||0===e.status?(s=JSON.parse(e.responseText),a=t[0]):(s=new Error("Status: "+e.status),a=t[1])}catch(e){s=e,a=t[1]}a&&a(s)}},e.send(),e},window.Manifest={};var e=JSON.parse(localStorage.getItem("manifest")),o=document.querySelector("script[manifest]");if(e)t(e,!0,o.getAttribute("timeout")||1e4);else{var n=(o?o.getAttribute("manifest"):null)||"manifest.json";pegasus(n).then(t,function(t){console.error("Could not download "+n+": "+t.status)})}}();