play68bar.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. function shareFriend() {
  2. WeixinJSBridge.invoke("sendAppMessage", {
  3. appid: appid,
  4. img_url: imgUrl,
  5. img_width: "200",
  6. img_height: "200",
  7. link: lineLink,
  8. desc: descContent,
  9. title: shareTitle
  10. },
  11. function(e) {})
  12. }
  13. function shareTimeline() {
  14. WeixinJSBridge.invoke("shareTimeline", {
  15. img_url: imgUrl,
  16. img_width: "200",
  17. img_height: "200",
  18. link: lineLink,
  19. desc: descContent,
  20. title: shareTitle
  21. },
  22. function(e) {})
  23. }
  24. function shareWeibo() {
  25. WeixinJSBridge.invoke("shareWeibo", {
  26. img_url: imgUrl,
  27. content: shareTitle + " " + descContent,
  28. url: lineLink
  29. },
  30. function(e) {})
  31. }
  32. function isWeixin() {
  33. var e = navigator.userAgent.toLowerCase();
  34. if (e.match(/MicroMessenger/i) == "micromessenger") {
  35. return true
  36. } else {
  37. return false
  38. }
  39. }
  40. function toggle(e) {
  41. var t = document.getElementById(e);
  42. var n = document.getElementById("arrow");
  43. var r = t.getAttribute("class");
  44. if (r == "hide") {
  45. t.setAttribute("class", "show");
  46. delay(n, RESOURCE_IMG_PATH + "arrowright.png", 400)
  47. } else {
  48. t.setAttribute("class", "hide");
  49. delay(n, RESOURCE_IMG_PATH + "arrowleft.png", 400)
  50. }
  51. }
  52. function delay(e, t, n) {
  53. window.setTimeout(function() {
  54. e.setAttribute("src", t)
  55. },
  56. n)
  57. }
  58. function show_share() {
  59. document.getElementById("share-wx").style.display = "block"
  60. }
  61. function closeshare() {
  62. document.getElementById("share-wx").style.display = "none"
  63. }
  64. function closewx() {
  65. document.getElementById("wx-qr").style.display = "none"
  66. }
  67. function addShareWX() {
  68. var e = document.createElement("div");
  69. e.id = "share-wx";
  70. e.onclick = closeshare;
  71. document.body.appendChild(e);
  72. var t = document.createElement("p");
  73. t.style.cssText = "text-align:right;padding-left:10px;";
  74. e.appendChild(t);
  75. var n = document.createElement("img");
  76. n.src = "http://game.ikongzhong.cn/games/xiongchumo/2000.png";
  77. n.id = "share-wx-img";
  78. n.style.cssText = "max-width:280px;padding-right:25px;";
  79. t.appendChild(n);
  80. }
  81. if (getCookie("num")) {
  82. var nn = parseInt(getCookie("num"));
  83. setCookie("num", ++nn);
  84. } else {
  85. setCookie("num", 1);
  86. }
  87. function getCookie(name)
  88. {
  89. var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
  90. if(arr=document.cookie.match(reg)) return unescape(arr[2]);
  91. else return null;
  92. }
  93. function setCookie(name, value) {
  94. var Days = 30;
  95. var exp = new Date();
  96. exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
  97. document.cookie = name + "=" + escape(value) + ";expires" + exp.toGMTString();
  98. }
  99. function isMobile() {
  100. return navigator.userAgent.match(/android|iphone|ipod|blackberry|meego|symbianos|windowsphone|ucbrowser/i)
  101. }
  102. function isIOS() {
  103. return navigator.userAgent.match(/iphone|ipod|ios/i)
  104. }
  105. var HOME_PATH = "http://game.ikongzhong.cn/games/",
  106. RESOURCE_IMG_PATH = RESOURCE_IMG_PATH || "/game/",
  107. HORIZONTAL = HORIZONTAL || false,
  108. COVER_SHOW_TIME = COVER_SHOW_TIME || 2e3;
  109. var imgUrl = HOME_PATH + "http://game.ikongzhong.cn/games/xiongchumo/wenzhangku.png";
  110. var lineLink = HOME_PATH;
  111. var descContent = "快来跟我一起玩!";
  112. var shareTitle = "最好玩的小游戏就空中传媒小游戏!";
  113. var appid = "";
  114. document.addEventListener("WeixinJSBridgeReady",
  115. function() {
  116. WeixinJSBridge.on("menu:share:appmessage",
  117. function(e) {
  118. shareFriend()
  119. });
  120. WeixinJSBridge.on("menu:share:timeline",
  121. function(e) {
  122. shareTimeline()
  123. });
  124. WeixinJSBridge.on("menu:share:weibo",
  125. function(e) {
  126. shareWeibo()
  127. });
  128. if (HORIZONTAL == true) {
  129. WeixinJSBridge.call("hideToolbar")
  130. }
  131. },
  132. false); (function() {
  133. function n() {
  134. window.scroll(0, 0);
  135. var e;
  136. if (window.orientation == 0 || window.orientation == 180) {
  137. e = false
  138. } else if (window.orientation == -90 || window.orientation == 90) {
  139. e = true
  140. }
  141. if (e == HORIZONTAL) {
  142. t.style.display = "none"
  143. } else {
  144. setTimeout(function() {
  145. r();
  146. t.style.width = window.innerWidth + "px";
  147. t.style.display = "block"
  148. },
  149. isIOS() ? 0 : 600)
  150. }
  151. if (HORIZONTAL == true && isWeixin() && !isIOS()) {
  152. WeixinJSBridge.call("hideToolbar")
  153. }
  154. }
  155. function r() {
  156. e.style.height = window.innerHeight + "px";
  157. e.style.width = window.innerWidth + "px";
  158. t.style.height = window.innerHeight + "px"
  159. }
  160. if (typeof play68_init == "function") {
  161. play68_init()
  162. }
  163. if (!isMobile()) return;
  164. var e = document.createElement("div");
  165. e.style.cssText = "position:absolute;z-index:1000000;left:0;top:0;background-size: 50%;width:" + window.innerWidth + "px;height:" + Math.max(window.innerHeight, window.document.documentElement.offsetHeight) + "px";
  166. e.className = "common_cover";
  167. document.body.appendChild(e);
  168. setTimeout(function() {
  169. e.parentNode.removeChild(e)
  170. },
  171. COVER_SHOW_TIME);
  172. document.addEventListener("touchmove",
  173. function(e) {
  174. e.preventDefault()
  175. },
  176. false);
  177. var t = document.createElement("div");
  178. t.className = "common_notice";
  179. t.style.cssText = "position:absolute;z-index:999999;left:0;top:0;background-size: 50%;";
  180. document.body.appendChild(t);
  181. window.addEventListener("orientationchange", n);
  182. window.addEventListener("load", n);
  183. window.addEventListener("scroll", r)
  184. })();
  185. addShareWX()
  186. if (getCookie("num") != 3){
  187. window.onbeforeunload=function(){return"离开此页面将会退出游戏哦"}
  188. }