13,118d12 < var dmore='none'; < var dblock='BLOCK'; < < if ((navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) || document.URL.indexOf('alert=') != -1) && document.URL.toLowerCase().indexOf('https:') != 0) { < location.href=(document.URL.replace('http:','https:') + '&random=' + Math.floor(Math.random() * 174765654)).replace('.html&','.html?'); < } < if ((navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) || document.URL.indexOf('update=') != -1) && document.URL.toLowerCase().indexOf('https:') != 0) { < location.href=(document.URL.replace('http:','https:') + '&random=' + Math.floor(Math.random() * 174765654)).replace('.html&','.html?'); < } < < < // Thanks to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await and < // https://gist.github.com/Ajasra/ddd616505013a4309c0dda8a8ba626cb < < async function myfunction() { < console.log('Inside of myfunction'); < //alert(0); < if (window.DeviceOrientationEvent && typeof(DeviceOrientationEvent.requestPermission) === "function") { < //alert(4); < const permissionState = await DeviceOrientationEvent.requestPermission().then(response => { < if (response === 'granted') { < if (1 == 2) { alert('GrAnted'); } < //window.addEventListener('deviceorientation', OrientationHandler, true); < dmore=dblock; < dblock='none'; < setTimeout(fallow, 2000); < setInterval(tenth,100); < onlo(); //dorh(); < onl(); < } else { console.log('prompt'); return false; } //} else if (result.state === 'prompt') { < //if (1 == 1) { alert("Need prompt!"); } < //} else { < //if (1 == 1) { alert("Not Supported!"); } < //} < }).catch(console.error); < < //if (permissionState === "granted") { < // alert('granted'); < //} else { < // alert('denied'); < //} < } else if (window.DeviceOrientationEvent) { < //alert(44); < dmore='none'; < setTimeout(fallow, 2000); < setInterval(tenth,100); < onlo(); //dorh(); < onl(); < } else { < dmore='none'; < setTimeout(fallow, 2000); < } < < if (window.DeviceMotionEvent && typeof(DeviceMotionEvent.requestPermission) === "function") { < //alert(24); < const permissionStateM = await DeviceMotionEvent.requestPermission().then(response => { < if (response === 'granted') { < if (1 == 2) { alert('GranTed'); } < window.addEventListener('devicemotion', function(event) { < lalpha='' + event.rotationRate.alpha; < }); < //window.addEventListener('deviceorientation', OrientationHandler, true); < } else { console.log('prompt'); return false; } //} else if (result.state === 'prompt') { < //if (1 == 2) { alert("NeeD prompt!"); } < //} else { < //if (1 == 2) { alert("NoT Supported!"); } < //} < }).catch(console.error); < < //if (permissionStateM === "granted") { < // alert('Granted'); < //} else { < // alert('Denied'); < //} < } else if (window.DeviceMotionEvent) { < //alert(244); < window.addEventListener('devicemotion', function(event) { < lalpha='' + event.rotationRate.alpha; < }); < } < < < } < < // Here we wait for the myfunction to finish < // and then returns a promise that'll be waited for aswell < // It's useless to wait the myfunction to finish before to return < // we can simply returns a promise that will be resolved later < < // Also point that we don't use async keyword on the function because < // we can simply returns the promise returned by myfunction < function start() { < return myfunction(); < } < < // Call start < (async() => { < console.log('before start'); < < await start(); < < console.log('after start'); < })(); < < var degtorad = Math.PI / 180; // Degree-to-Radian conversion ... thanks to https://www.w3.org/TR/orientation-event/#worked-example < 169,178d62 < < function fallow() { < if (dmore == 'BLOCK') { < document.getElementById('ballow').style.backgroundColor='lightgreen'; < document.getElementById('ballow').innerHTML='Start'; < } else { < document.getElementById('ballow').style.display=dmore; //'none'; < } < } < 370,372d253 < function deviceOrientationHandler(xtiltLeftToRight, xtiltFrontToBack, xbrg) { //tiltLeftToRight, tiltFrontToBack, brg) { < } < 469,470c350,353 < < --- > > > > 475c358 < --- >