index1005.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>LuckyPotGame</title>
  6. <!--http://www.html5rocks.com/en/mobile/mobifying/-->
  7. <meta name="viewport"
  8. content="width=device-width,user-scalable=no,initial-scale=1, minimum-scale=1,maximum-scale=1"/>
  9. <!--https://developer.apple.com/library/safari/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html-->
  10. <meta name="apple-mobile-web-app-capable" content="yes">
  11. <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
  12. <meta name="format-detection" content="telephone=no">
  13. <!-- force webkit on 360 -->
  14. <meta name="renderer" content="webkit"/>
  15. <meta name="force-rendering" content="webkit"/>
  16. <!-- force edge on IE -->
  17. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
  18. <meta name="msapplication-tap-highlight" content="no">
  19. <!-- force full screen on some browser -->
  20. <meta name="full-screen" content="yes"/>
  21. <meta name="x5-fullscreen" content="true"/>
  22. <meta name="360-fullscreen" content="true"/>
  23. <!-- force screen orientation on some browser -->
  24. <meta name="screen-orientation" content="landscape"/>
  25. <meta name="x5-orientation" content="landscape">
  26. <!--fix fireball/issues/3568 -->
  27. <!--<meta name="browsermode" content="application">-->
  28. <meta name="x5-page-mode" content="app">
  29. <!--<link rel="apple-touch-icon" href=".png" />-->
  30. <!--<link rel="apple-touch-icon-precomposed" href=".png" />-->
  31. <link rel="stylesheet" type="text/css" href="style-mobile.6e9cd.css"/>
  32. <link rel="icon" href="favicon.8de18.ico"/>
  33. <link rel=manifest href=../manifest1004.json>
  34. <meta name=mobile-web-app-capable content=yes>
  35. <link rel=icon sizes=192x192 href=../images/icon192.png>
  36. <meta name=apple-mobile-web-app-capable content=yes>
  37. <meta name=apple-mobile-web-app-status-bar-style content=black>
  38. <link rel=apple-touch-icon-precomposed href=../images/icon192.png>
  39. <meta name=apple-mobile-web-app-title content=Luckypot>
  40. <meta name=application-name content=Luckypot>
  41. <meta name=format-detection content="telephone=yes">
  42. <script>!function (f, b, e, v, n, t, s) {
  43. if (f.fbq) return; n = f.fbq = function () {
  44. n.callMethod ?
  45. n.callMethod.apply(n, arguments) : n.queue.push(arguments)
  46. };
  47. if (!f._fbq) f._fbq = n; n.push = n; n.loaded = !0; n.version = '2.0';
  48. n.queue = []; t = b.createElement(e); t.async = !0;
  49. t.src = v; s = b.getElementsByTagName(e)[0];
  50. s.parentNode.insertBefore(t, s)
  51. }(window, document, 'script',
  52. 'https://connect.facebook.net/en_US/fbevents.js');
  53. </script>
  54. </head>
  55. <body>
  56. <canvas id="GameCanvas" oncontextmenu="event.preventDefault()" tabindex="0"></canvas>
  57. <div id="splash">
  58. <div class="progress-bar stripes">
  59. <span style="width: 0%"></span>
  60. </div>
  61. </div>
  62. <div id="cover" style="position: fixed;left: 0;top: 0;width: 100%;height: 100%;display: none;">
  63. </div>
  64. <div id="full_screen" style="position: fixed;left: 0;top: 0;width: 100%;height: 100%;"></div>
  65. <script>if ("serviceWorker" in navigator && 'PushManager' in window) {
  66. window.addEventListener('load', async () => { // 这个load 可以删除 如果你的浏览器没加载出来 可以添加一下这个
  67. navigator.serviceWorker.register("../sw.js").then(function (registration) {
  68. });
  69. })
  70. }</script>
  71. <script src="src/settings.51c8a.js" charset="utf-8"></script>
  72. <script src="main.4506e.js" charset="utf-8"></script>
  73. <script type="text/javascript">
  74. function isMobileDevice() {
  75. return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
  76. }
  77. function isChromeBrowser() {
  78. return (/Chrome/i.test(navigator.userAgent));
  79. }
  80. function isIphone() {
  81. return (/iPhone|iPad/i.test(navigator.userAgent));
  82. }
  83. function PWA_MODE(){
  84. if(getUrlParm("pwa") >= 1)
  85. return true;
  86. return false;
  87. // const screen = document.querySelector('body');
  88. // if (window.screen.width == screen.clientWidth && window.screen.height == screen.clientHeight) {
  89. // // 应用处于全屏模式
  90. // console.log('PWA app is in full screen mode');
  91. // return true;
  92. // } else {
  93. // // 应用不处于全屏模式
  94. // console.log('PWA app is not in full screen mode');
  95. // return false;
  96. // }
  97. }
  98. function PWA_MODE_test(){
  99. const screen = document.querySelector('body');
  100. var flag = false;
  101. if (window.screen.width == screen.clientWidth && window.screen.height == screen.clientHeight) {
  102. // 应用处于全屏模式
  103. console.log('PWA app is in full screen mode');
  104. flag = true;
  105. return "PWA_MODE = true --"+"window w = "+window.screen.width+" h = "+window.screen.height+"; body w = "+ screen.clientWidth +" h = "+ screen.clientHeight;
  106. } else {
  107. // 应用不处于全屏模式
  108. console.log('PWA app is not in full screen mode');
  109. flag = false;
  110. }
  111. return "window w = "+window.screen.width+" h = "+window.screen.height+"; body w = "+ screen.clientWidth +" h = "+ screen.clientHeight;
  112. }
  113. function PWA_MODE_test2(){
  114. if(/Safari/.test(navigator.userAgent)){
  115. if (window.navigator.standalone) {
  116. // 用户从PWA应用进入
  117. console.log('User is Safari accessing from PWA app');
  118. return 'User is Safari accessing from PWA app';
  119. } else {
  120. // 用户从浏览器进入
  121. console.log('User is Safari accessing from browser');
  122. return 'User is Safari accessing from browser';
  123. }
  124. }else if(/Chrome/i.test(navigator.userAgent)){
  125. if (window.matchMedia('(display-mode: standalone)').matches) {
  126. // 用户从PWA应用进入
  127. console.log('User is Chrome accessing from PWA app');
  128. return 'User is Chrome accessing from PWA app';
  129. } else {
  130. // 用户从浏览器进入
  131. console.log('User is Chrome accessing from browser');
  132. return 'User is Chrome accessing from browser';
  133. }
  134. }
  135. return "";
  136. }
  137. function getFbpid(){
  138. if(window.localStorage){
  139. var fbqid = window.localStorage.getItem("fbpid");
  140. if(fbqid)
  141. return fbqid;
  142. }
  143. return "";
  144. }
  145. function sendFbPageView(){
  146. fbq('track', 'PageView');
  147. }
  148. function sendFbReg(){
  149. fbq('track', 'CompleteRegistration');
  150. }
  151. function sendFbPurchase(_value){
  152. // fbq('track', 'Purchase',{currency: "BRL", value: _value});
  153. }
  154. function sendFbAddToCart(){
  155. fbq('track', 'AddToCart');
  156. }
  157. function handleOrientationChange() {
  158. const screen = document.querySelector('body');
  159. const width = screen.clientWidth;
  160. const height = screen.clientHeight;
  161. var debug = window._CCSettings.debug;
  162. var splash = document.getElementById('splash');
  163. if(splash.style.display == 'none')
  164. return;
  165. splash.style.display = 'block';
  166. if (window.orientation == 0 || window.orientation == 180) {
  167. splash.style.transform = "rotate(90deg)";
  168. splash.style.transformOrigin = "0px 0px 0px";
  169. splash.style.width = height + "px";
  170. splash.style.height = width + "px";
  171. splash.style.margin = "0px 0px 0px " + width + "px";
  172. splash.style.padding = "0px";
  173. }else{
  174. splash.style.transform = "rotate(0deg)";
  175. splash.style.transformOrigin = "0px 0px 0px";
  176. splash.style.width = width + "px";
  177. splash.style.height = height + "px";
  178. splash.style.margin = "0px 0px 0px 0px";
  179. splash.style.padding = "0px";
  180. }
  181. }
  182. var deferredPrompt = null;
  183. var have_install = false;
  184. var have_click = false;
  185. var have_accepted = false;
  186. window.addEventListener('beforeinstallprompt', (e) => {
  187. e.preventDefault();
  188. deferredPrompt = e;
  189. console.log('!!! ---- beforeinstallprompt suc');
  190. document.getElementById("cover").style.display = "block";
  191. feedData("loadSucc","")
  192. });
  193. document.getElementById("cover").addEventListener('click', function() {
  194. document.getElementById("cover").style.width = 0;
  195. installPWA();
  196. feedData("showPrompt","")
  197. });
  198. window.addEventListener('appinstalled', (evt) => {
  199. have_install = true;
  200. });
  201. function isClickInstall() {
  202. return have_click;
  203. }
  204. var denyTimes = 0;
  205. function installPWA() {
  206. console.log('!!! ---- installPWA called');
  207. if (isMobileDevice()&& !PWA_MODE()){
  208. console.log('!!! ---- installPWA isMobileDevice && !PWA_MODE ');
  209. if(have_click || have_install || have_accepted) return;
  210. have_click = true;
  211. console.log('!!! ---- installPWA not have_click ');
  212. if(deferredPrompt != null) {
  213. console.log('!!! ---- installPWA deferredPrompt != null ');
  214. deferredPrompt.prompt();
  215. console.log('!!! ---- installPWA deferredPrompt prompt ');
  216. deferredPrompt.userChoice.then((choiceResult) => {
  217. if (choiceResult.outcome === 'accepted') {
  218. feedData("clickInstall1","")
  219. console.log('User accepted the A2HS prompt'); //生效
  220. have_accepted = true;
  221. have_click = false;
  222. } else {
  223. console.log('User dismissed the A2HS prompt'); //取消
  224. if( denyTimes < 3 ){
  225. let _t = 1000*60*2;
  226. if(denyTimes==1)
  227. _t = 1000*60*5;
  228. else if(denyTimes==2)
  229. _t = 1000*60*10;
  230. setTimeout(function() {
  231. document.getElementById("cover").style.width = "100%";
  232. },_t);
  233. denyTimes += 1;
  234. have_click = false;
  235. }
  236. }
  237. });
  238. }else {
  239. console.log('!!! ---- installPWA deferredPrompt == null ');
  240. }
  241. }
  242. }
  243. function callInstallCover(){
  244. if ( deferredPrompt == null || have_click || PWA_MODE()) return;
  245. document.getElementById("cover").style.width = "100%";
  246. if( denyTimes < 3 ){
  247. denyTimes -= 1;
  248. }
  249. }
  250. function getCookie(name) {
  251. var cookies = document.cookie.split(';');
  252. for (var i = 0; i < cookies.length; i++) {
  253. var cookie = cookies[i].trim();
  254. if (cookie.startsWith(name + '=')) {
  255. return cookie.substring(name.length + 1);
  256. }
  257. }
  258. return null;
  259. }
  260. function getUrlParm(name) {
  261. var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
  262. var r = window.location.search.substr(1).match(reg);
  263. if (r != null) {
  264. return unescape(r[2]);
  265. }
  266. return null;
  267. }
  268. var uuid = Math.random().toString(36).substring(7);
  269. //feedData("init","");
  270. //feedData("showPrompt","")
  271. //feedData("accepted","")
  272. //feedData("loadSucc","")
  273. //feedData("clickInstall1","")
  274. //feedData("clickInstall2","")
  275. //feedData("finishInstall","")
  276. function feedData(type, optionStr) {
  277. var fbp = getCookie('_fbp');
  278. if (fbp != null && fbp != '' && fbp != undefined) {
  279. uuid = fbp;
  280. }
  281. const url = "https://gg.907545.com/Gapi/facebookParms";
  282. const params = new URLSearchParams();
  283. params.append("uuid", uuid);
  284. params.append("fbinfo", optionStr);
  285. params.append("type", type);
  286. const xhr = new XMLHttpRequest();
  287. xhr.open("POST", url, true);
  288. xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  289. xhr.onreadystatechange = function () {
  290. if (xhr.readyState === XMLHttpRequest.DONE) {
  291. if (xhr.status === 200) {
  292. const result = JSON.parse(xhr.responseText);
  293. console.log(result);
  294. } else {
  295. console.error(xhr.status);
  296. }
  297. }
  298. };
  299. xhr.send(params);
  300. }
  301. var is_full = 0;
  302. function fullScreen() {
  303. if(is_full > 0) return;
  304. is_full = 1;
  305. var elem = document.documentElement;
  306. if (elem.requestFullscreen) {
  307. elem.requestFullscreen();
  308. } else if (elem.mozRequestFullScreen) {
  309. elem.mozRequestFullScreen();
  310. } else if (elem.webkitRequestFullscreen) {
  311. elem.webkitRequestFullscreen();
  312. } else if (elem.msRequestFullscreen) {
  313. elem.msRequestFullscreen();
  314. }
  315. document.getElementById("full_screen").style.width = 0;
  316. setTimeout(function() {
  317. forceLandscape();
  318. },100);
  319. }
  320. function forceLandscape() {
  321. if(!isMobileDevice()) { return; }
  322. try{
  323. if (screen.orientation && screen.orientation.lock) {
  324. screen.orientation.lock('landscape');
  325. } else if (screen.lockOrientation) {
  326. screen.lockOrientation('landscape');
  327. } else if (screen.mozLockOrientation) {
  328. screen.mozLockOrientation('landscape');
  329. } else if (screen.msLockOrientation) {
  330. screen.msLockOrientation('landscape');
  331. }
  332. }catch(e){
  333. }
  334. }
  335. document.getElementById("full_screen").addEventListener('click', function() {
  336. document.getElementById("full_screen").style.display = "none";
  337. fullScreen();
  338. });
  339. (function () {
  340. if(isIphone()){
  341. document.getElementById("full_screen").style.width = 0;
  342. }
  343. setTimeout(function() {
  344. feedData("init",navigator.userAgent);
  345. },200);
  346. if (isMobileDevice()&& !PWA_MODE()){
  347. handleOrientationChange();
  348. window.addEventListener('orientationchange', handleOrientationChange);
  349. }else if(PWA_MODE()){
  350. setTimeout(function() {
  351. handleOrientationChange();
  352. },1000);
  353. }
  354. let pixId = localStorage.getItem('pixId');
  355. if(!pixId){
  356. pixId = '1001043758216463';
  357. localStorage.setItem('pixId',pixId);
  358. }
  359. fbq('init', pixId);
  360. setTimeout(function() {
  361. localStorage.setItem('_fbc',getCookie('_fbc'));
  362. localStorage.setItem('_fbp',getCookie('_fbp'));
  363. },1000);
  364. // open web debugger console
  365. if (typeof VConsole !== 'undefined') {
  366. window.vConsole = new VConsole();
  367. }
  368. var debug = window._CCSettings.debug;
  369. var splash = document.getElementById('splash');
  370. splash.style.display = 'block';
  371. function loadScript (moduleName, cb) {
  372. function scriptLoaded () {
  373. document.body.removeChild(domScript);
  374. domScript.removeEventListener('load', scriptLoaded, false);
  375. cb && cb();
  376. };
  377. var domScript = document.createElement('script');
  378. domScript.async = true;
  379. domScript.src = moduleName;
  380. domScript.addEventListener('load', scriptLoaded, false);
  381. document.body.appendChild(domScript);
  382. }
  383. loadScript(debug ? 'cocos2d-js.js' : 'cocos2d-js-min.22367.js', function () {
  384. if (CC_PHYSICS_BUILTIN || CC_PHYSICS_CANNON) {
  385. loadScript(debug ? 'physics.js' : 'physics-min.js', window.boot);
  386. }
  387. else {
  388. window.boot();
  389. }
  390. });
  391. })();
  392. </script>
  393. </body>
  394. </html>