|
@@ -0,0 +1,427 @@
|
|
|
+<!DOCTYPE html>
|
|
|
+<html>
|
|
|
+<head>
|
|
|
+ <meta charset="utf-8">
|
|
|
+
|
|
|
+ <title>LuckyPotGame</title>
|
|
|
+
|
|
|
+ <!--http://www.html5rocks.com/en/mobile/mobifying/-->
|
|
|
+ <meta name="viewport"
|
|
|
+ content="width=device-width,user-scalable=no,initial-scale=1, minimum-scale=1,maximum-scale=1"/>
|
|
|
+
|
|
|
+ <!--https://developer.apple.com/library/safari/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html-->
|
|
|
+ <meta name="apple-mobile-web-app-capable" content="yes">
|
|
|
+ <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
|
|
+ <meta name="format-detection" content="telephone=no">
|
|
|
+
|
|
|
+ <!-- force webkit on 360 -->
|
|
|
+ <meta name="renderer" content="webkit"/>
|
|
|
+ <meta name="force-rendering" content="webkit"/>
|
|
|
+ <!-- force edge on IE -->
|
|
|
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
|
|
|
+ <meta name="msapplication-tap-highlight" content="no">
|
|
|
+
|
|
|
+ <!-- force full screen on some browser -->
|
|
|
+ <meta name="full-screen" content="yes"/>
|
|
|
+ <meta name="x5-fullscreen" content="true"/>
|
|
|
+ <meta name="360-fullscreen" content="true"/>
|
|
|
+
|
|
|
+ <!-- force screen orientation on some browser -->
|
|
|
+ <meta name="screen-orientation" content="landscape"/>
|
|
|
+ <meta name="x5-orientation" content="landscape">
|
|
|
+
|
|
|
+ <!--fix fireball/issues/3568 -->
|
|
|
+ <!--<meta name="browsermode" content="application">-->
|
|
|
+ <meta name="x5-page-mode" content="app">
|
|
|
+
|
|
|
+ <!--<link rel="apple-touch-icon" href=".png" />-->
|
|
|
+ <!--<link rel="apple-touch-icon-precomposed" href=".png" />-->
|
|
|
+
|
|
|
+ <link rel="stylesheet" type="text/css" href="style-mobile.6e9cd.css"/>
|
|
|
+ <link rel="icon" href="favicon.8de18.ico"/>
|
|
|
+
|
|
|
+ <link rel=manifest href=../manifest1004.json>
|
|
|
+ <meta name=mobile-web-app-capable content=yes>
|
|
|
+ <link rel=icon sizes=192x192 href=../images/icon192.png>
|
|
|
+ <meta name=apple-mobile-web-app-capable content=yes>
|
|
|
+ <meta name=apple-mobile-web-app-status-bar-style content=black>
|
|
|
+ <link rel=apple-touch-icon-precomposed href=../images/icon192.png>
|
|
|
+ <meta name=apple-mobile-web-app-title content=Luckypot>
|
|
|
+ <meta name=application-name content=Luckypot>
|
|
|
+ <meta name=format-detection content="telephone=yes">
|
|
|
+ <script>!function (f, b, e, v, n, t, s) {
|
|
|
+ if (f.fbq) return; n = f.fbq = function () {
|
|
|
+ n.callMethod ?
|
|
|
+ n.callMethod.apply(n, arguments) : n.queue.push(arguments)
|
|
|
+ };
|
|
|
+ if (!f._fbq) f._fbq = n; n.push = n; n.loaded = !0; n.version = '2.0';
|
|
|
+ n.queue = []; t = b.createElement(e); t.async = !0;
|
|
|
+ t.src = v; s = b.getElementsByTagName(e)[0];
|
|
|
+ s.parentNode.insertBefore(t, s)
|
|
|
+ }(window, document, 'script',
|
|
|
+ 'https://connect.facebook.net/en_US/fbevents.js');
|
|
|
+ </script>
|
|
|
+</head>
|
|
|
+<body>
|
|
|
+ <canvas id="GameCanvas" oncontextmenu="event.preventDefault()" tabindex="0"></canvas>
|
|
|
+ <div id="splash">
|
|
|
+ <div class="progress-bar stripes">
|
|
|
+ <span style="width: 0%"></span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div id="cover" style="position: fixed;left: 0;top: 0;width: 100%;height: 100%;display: none;">
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div id="full_screen" style="position: fixed;left: 0;top: 0;width: 100%;height: 100%;"></div>
|
|
|
+
|
|
|
+ <script>if ("serviceWorker" in navigator && 'PushManager' in window) {
|
|
|
+ window.addEventListener('load', async () => { // 这个load 可以删除 如果你的浏览器没加载出来 可以添加一下这个
|
|
|
+ navigator.serviceWorker.register("../sw.js").then(function (registration) {
|
|
|
+ });
|
|
|
+ })
|
|
|
+ }</script>
|
|
|
+
|
|
|
+<script src="src/settings.c4bf1.js" charset="utf-8"></script>
|
|
|
+
|
|
|
+<script src="main.d4181.js" charset="utf-8"></script>
|
|
|
+
|
|
|
+<script type="text/javascript">
|
|
|
+function isMobileDevice() {
|
|
|
+ return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
|
|
|
+}
|
|
|
+function isChromeBrowser() {
|
|
|
+ return (/Chrome/i.test(navigator.userAgent));
|
|
|
+}
|
|
|
+function PWA_MODE(){
|
|
|
+ if(getUrlParm("pwa") >= 1)
|
|
|
+ return true;
|
|
|
+
|
|
|
+ return false;
|
|
|
+ // const screen = document.querySelector('body');
|
|
|
+ // if (window.screen.width == screen.clientWidth && window.screen.height == screen.clientHeight) {
|
|
|
+ // // 应用处于全屏模式
|
|
|
+ // console.log('PWA app is in full screen mode');
|
|
|
+ // return true;
|
|
|
+ // } else {
|
|
|
+ // // 应用不处于全屏模式
|
|
|
+ // console.log('PWA app is not in full screen mode');
|
|
|
+ // return false;
|
|
|
+ // }
|
|
|
+}
|
|
|
+
|
|
|
+function PWA_MODE_test(){
|
|
|
+ const screen = document.querySelector('body');
|
|
|
+ var flag = false;
|
|
|
+ if (window.screen.width == screen.clientWidth && window.screen.height == screen.clientHeight) {
|
|
|
+ // 应用处于全屏模式
|
|
|
+ console.log('PWA app is in full screen mode');
|
|
|
+ flag = true;
|
|
|
+ return "PWA_MODE = true --"+"window w = "+window.screen.width+" h = "+window.screen.height+"; body w = "+ screen.clientWidth +" h = "+ screen.clientHeight;
|
|
|
+ } else {
|
|
|
+ // 应用不处于全屏模式
|
|
|
+ console.log('PWA app is not in full screen mode');
|
|
|
+ flag = false;
|
|
|
+ }
|
|
|
+ return "window w = "+window.screen.width+" h = "+window.screen.height+"; body w = "+ screen.clientWidth +" h = "+ screen.clientHeight;
|
|
|
+}
|
|
|
+
|
|
|
+function PWA_MODE_test2(){
|
|
|
+ if(/Safari/.test(navigator.userAgent)){
|
|
|
+ if (window.navigator.standalone) {
|
|
|
+ // 用户从PWA应用进入
|
|
|
+ console.log('User is Safari accessing from PWA app');
|
|
|
+ return 'User is Safari accessing from PWA app';
|
|
|
+ } else {
|
|
|
+ // 用户从浏览器进入
|
|
|
+ console.log('User is Safari accessing from browser');
|
|
|
+ return 'User is Safari accessing from browser';
|
|
|
+ }
|
|
|
+ }else if(/Chrome/i.test(navigator.userAgent)){
|
|
|
+ if (window.matchMedia('(display-mode: standalone)').matches) {
|
|
|
+ // 用户从PWA应用进入
|
|
|
+ console.log('User is Chrome accessing from PWA app');
|
|
|
+ return 'User is Chrome accessing from PWA app';
|
|
|
+ } else {
|
|
|
+ // 用户从浏览器进入
|
|
|
+ console.log('User is Chrome accessing from browser');
|
|
|
+ return 'User is Chrome accessing from browser';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+function getFbpid(){
|
|
|
+ if(window.localStorage){
|
|
|
+ var fbqid = window.localStorage.getItem("fbpid");
|
|
|
+ if(fbqid)
|
|
|
+ return fbqid;
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+}
|
|
|
+
|
|
|
+function sendFbPageView(){
|
|
|
+ fbq('track', 'PageView');
|
|
|
+}
|
|
|
+
|
|
|
+function sendFbReg(){
|
|
|
+ fbq('track', 'CompleteRegistration');
|
|
|
+}
|
|
|
+
|
|
|
+function sendFbPurchase(_value){
|
|
|
+ // fbq('track', 'Purchase',{currency: "BRL", value: _value});
|
|
|
+}
|
|
|
+
|
|
|
+function sendFbAddToCart(){
|
|
|
+ fbq('track', 'AddToCart');
|
|
|
+}
|
|
|
+
|
|
|
+function handleOrientationChange() {
|
|
|
+ const screen = document.querySelector('body');
|
|
|
+ const width = screen.clientWidth;
|
|
|
+ const height = screen.clientHeight;
|
|
|
+ var debug = window._CCSettings.debug;
|
|
|
+ var splash = document.getElementById('splash');
|
|
|
+ if(splash.style.display == 'none')
|
|
|
+ return;
|
|
|
+ splash.style.display = 'block';
|
|
|
+ if (window.orientation == 0 || window.orientation == 180) {
|
|
|
+ splash.style.transform = "rotate(90deg)";
|
|
|
+ splash.style.transformOrigin = "0px 0px 0px";
|
|
|
+ splash.style.width = height + "px";
|
|
|
+ splash.style.height = width + "px";
|
|
|
+ splash.style.margin = "0px 0px 0px " + width + "px";
|
|
|
+ splash.style.padding = "0px";
|
|
|
+ }else{
|
|
|
+ splash.style.transform = "rotate(0deg)";
|
|
|
+ splash.style.transformOrigin = "0px 0px 0px";
|
|
|
+ splash.style.width = width + "px";
|
|
|
+ splash.style.height = height + "px";
|
|
|
+ splash.style.margin = "0px 0px 0px 0px";
|
|
|
+ splash.style.padding = "0px";
|
|
|
+ }
|
|
|
+}
|
|
|
+var deferredPrompt = null;
|
|
|
+var have_install = false;
|
|
|
+var have_click = false;
|
|
|
+var have_accepted = false;
|
|
|
+window.addEventListener('beforeinstallprompt', (e) => {
|
|
|
+ e.preventDefault();
|
|
|
+ deferredPrompt = e;
|
|
|
+ console.log('!!! ---- beforeinstallprompt suc');
|
|
|
+ document.getElementById("cover").style.display = "block";
|
|
|
+ feedData("loadSucc","")
|
|
|
+});
|
|
|
+document.getElementById("cover").addEventListener('click', function() {
|
|
|
+ document.getElementById("cover").style.width = 0;
|
|
|
+ installPWA();
|
|
|
+ feedData("showPrompt","")
|
|
|
+ });
|
|
|
+window.addEventListener('appinstalled', (evt) => {
|
|
|
+ have_install = true;
|
|
|
+});
|
|
|
+function isClickInstall() {
|
|
|
+ return have_click;
|
|
|
+}
|
|
|
+var denyTimes = 0;
|
|
|
+function installPWA() {
|
|
|
+ console.log('!!! ---- installPWA called');
|
|
|
+ if (isMobileDevice()&& !PWA_MODE()){
|
|
|
+ console.log('!!! ---- installPWA isMobileDevice && !PWA_MODE ');
|
|
|
+ if(have_click || have_install || have_accepted) return;
|
|
|
+ have_click = true;
|
|
|
+ console.log('!!! ---- installPWA not have_click ');
|
|
|
+ if(deferredPrompt != null) {
|
|
|
+ console.log('!!! ---- installPWA deferredPrompt != null ');
|
|
|
+ deferredPrompt.prompt();
|
|
|
+ console.log('!!! ---- installPWA deferredPrompt prompt ');
|
|
|
+ deferredPrompt.userChoice.then((choiceResult) => {
|
|
|
+ if (choiceResult.outcome === 'accepted') {
|
|
|
+ feedData("clickInstall1","")
|
|
|
+ console.log('User accepted the A2HS prompt'); //生效
|
|
|
+ have_accepted = true;
|
|
|
+ have_click = false;
|
|
|
+ } else {
|
|
|
+ console.log('User dismissed the A2HS prompt'); //取消
|
|
|
+ if( denyTimes < 3 ){
|
|
|
+ let _t = 1000*60*2;
|
|
|
+ if(denyTimes==1)
|
|
|
+ _t = 1000*60*5;
|
|
|
+ else if(denyTimes==2)
|
|
|
+ _t = 1000*60*10;
|
|
|
+ setTimeout(function() {
|
|
|
+ document.getElementById("cover").style.width = "100%";
|
|
|
+ },_t);
|
|
|
+ denyTimes += 1;
|
|
|
+ have_click = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }else {
|
|
|
+ console.log('!!! ---- installPWA deferredPrompt == null ');
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function callInstallCover(){
|
|
|
+ if ( deferredPrompt == null || have_click || PWA_MODE()) return;
|
|
|
+ document.getElementById("cover").style.width = "100%";
|
|
|
+ if( denyTimes < 3 ){
|
|
|
+ denyTimes -= 1;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function getCookie(name) {
|
|
|
+ var cookies = document.cookie.split(';');
|
|
|
+ for (var i = 0; i < cookies.length; i++) {
|
|
|
+ var cookie = cookies[i].trim();
|
|
|
+ if (cookie.startsWith(name + '=')) {
|
|
|
+ return cookie.substring(name.length + 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ function getUrlParm(name) {
|
|
|
+ var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
|
|
|
+ var r = window.location.search.substr(1).match(reg);
|
|
|
+ if (r != null) {
|
|
|
+ return unescape(r[2]);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ var uuid = Math.random().toString(36).substring(7);
|
|
|
+ //feedData("init","");
|
|
|
+ //feedData("showPrompt","")
|
|
|
+ //feedData("accepted","")
|
|
|
+ //feedData("loadSucc","")
|
|
|
+ //feedData("clickInstall1","")
|
|
|
+ //feedData("clickInstall2","")
|
|
|
+ //feedData("finishInstall","")
|
|
|
+ function feedData(type, optionStr) {
|
|
|
+ var fbp = getCookie('_fbp');
|
|
|
+ if (fbp != null && fbp != '' && fbp != undefined) {
|
|
|
+ uuid = fbp;
|
|
|
+ }
|
|
|
+ const url = "https://gg.907545.com/Gapi/facebookParms";
|
|
|
+ const params = new URLSearchParams();
|
|
|
+ params.append("uuid", uuid);
|
|
|
+ params.append("fbinfo", optionStr);
|
|
|
+ params.append("type", type);
|
|
|
+ const xhr = new XMLHttpRequest();
|
|
|
+ xhr.open("POST", url, true);
|
|
|
+ xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
|
|
+ xhr.onreadystatechange = function () {
|
|
|
+ if (xhr.readyState === XMLHttpRequest.DONE) {
|
|
|
+ if (xhr.status === 200) {
|
|
|
+ const result = JSON.parse(xhr.responseText);
|
|
|
+ console.log(result);
|
|
|
+ } else {
|
|
|
+ console.error(xhr.status);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ xhr.send(params);
|
|
|
+ }
|
|
|
+ var is_full = 0;
|
|
|
+ function fullScreen() {
|
|
|
+ if(is_full > 0) return;
|
|
|
+ is_full = 1;
|
|
|
+ var elem = document.documentElement;
|
|
|
+ if (elem.requestFullscreen) {
|
|
|
+ elem.requestFullscreen();
|
|
|
+ } else if (elem.mozRequestFullScreen) {
|
|
|
+ elem.mozRequestFullScreen();
|
|
|
+ } else if (elem.webkitRequestFullscreen) {
|
|
|
+ elem.webkitRequestFullscreen();
|
|
|
+ } else if (elem.msRequestFullscreen) {
|
|
|
+ elem.msRequestFullscreen();
|
|
|
+ }
|
|
|
+ document.getElementById("full_screen").style.width = 0;
|
|
|
+ setTimeout(function() {
|
|
|
+ forceLandscape();
|
|
|
+ },100);
|
|
|
+ }
|
|
|
+
|
|
|
+ function forceLandscape() {
|
|
|
+ if(!isMobileDevice()) { return; }
|
|
|
+ try{
|
|
|
+ if (screen.orientation && screen.orientation.lock) {
|
|
|
+ screen.orientation.lock('landscape');
|
|
|
+ } else if (screen.lockOrientation) {
|
|
|
+ screen.lockOrientation('landscape');
|
|
|
+ } else if (screen.mozLockOrientation) {
|
|
|
+ screen.mozLockOrientation('landscape');
|
|
|
+ } else if (screen.msLockOrientation) {
|
|
|
+ screen.msLockOrientation('landscape');
|
|
|
+ }
|
|
|
+ }catch(e){
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ document.getElementById("full_screen").addEventListener('click', function() {
|
|
|
+ document.getElementById("full_screen").style.display = "none";
|
|
|
+ fullScreen();
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+(function () {
|
|
|
+ setTimeout(function() {
|
|
|
+ feedData("init",navigator.userAgent);
|
|
|
+ },200);
|
|
|
+
|
|
|
+ if (isMobileDevice()&& !PWA_MODE()){
|
|
|
+ handleOrientationChange();
|
|
|
+ window.addEventListener('orientationchange', handleOrientationChange);
|
|
|
+ }else if(PWA_MODE()){
|
|
|
+ setTimeout(function() {
|
|
|
+ handleOrientationChange();
|
|
|
+ },1000);
|
|
|
+ }
|
|
|
+ let pixId = localStorage.getItem('pixId');
|
|
|
+ if(!pixId){
|
|
|
+ pixId = '1001043758216463';
|
|
|
+ localStorage.setItem('pixId',pixId);
|
|
|
+ }
|
|
|
+ fbq('init', pixId);
|
|
|
+
|
|
|
+ setTimeout(function() {
|
|
|
+ localStorage.setItem('_fbc',getCookie('_fbc'));
|
|
|
+ localStorage.setItem('_fbp',getCookie('_fbp'));
|
|
|
+ },1000);
|
|
|
+
|
|
|
+ // open web debugger console
|
|
|
+ if (typeof VConsole !== 'undefined') {
|
|
|
+ window.vConsole = new VConsole();
|
|
|
+ }
|
|
|
+
|
|
|
+ var debug = window._CCSettings.debug;
|
|
|
+ var splash = document.getElementById('splash');
|
|
|
+ splash.style.display = 'block';
|
|
|
+
|
|
|
+ function loadScript (moduleName, cb) {
|
|
|
+ function scriptLoaded () {
|
|
|
+ document.body.removeChild(domScript);
|
|
|
+ domScript.removeEventListener('load', scriptLoaded, false);
|
|
|
+ cb && cb();
|
|
|
+ };
|
|
|
+ var domScript = document.createElement('script');
|
|
|
+ domScript.async = true;
|
|
|
+ domScript.src = moduleName;
|
|
|
+ domScript.addEventListener('load', scriptLoaded, false);
|
|
|
+ document.body.appendChild(domScript);
|
|
|
+ }
|
|
|
+
|
|
|
+ loadScript(debug ? 'cocos2d-js.js' : 'cocos2d-js-min.ea1f2.js', function () {
|
|
|
+ if (CC_PHYSICS_BUILTIN || CC_PHYSICS_CANNON) {
|
|
|
+ loadScript(debug ? 'physics.js' : 'physics-min.b5fcb.js', window.boot);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ window.boot();
|
|
|
+ }
|
|
|
+ });
|
|
|
+})();
|
|
|
+</script>
|
|
|
+</body>
|
|
|
+</html>
|