play68bar.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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. show_share_page()
  60. }
  61. function box_show_share() {
  62. show_share_page();
  63. toggle("play68box")
  64. }
  65. function show_share_page() {
  66. wxqrP3.innerHTML = """ + shareTitle + """;
  67. wxqrImg.src = imgUrl;
  68. if (isWeixin() == true) {
  69. document.getElementById("share-wx").style.display = "block"
  70. } else {
  71. document.getElementById("wx-qr").style.display = "block"
  72. }
  73. }
  74. function closeshare() {
  75. document.getElementById("share-wx").style.display = "none"
  76. }
  77. function closewx() {
  78. document.getElementById("wx-qr").style.display = "none"
  79. }
  80. function addShareWX() {
  81. var e = document.createElement("div");
  82. e.id = "share-wx";
  83. e.onclick = closeshare;
  84. document.body.appendChild(e);
  85. var t = document.createElement("p");
  86. t.style.cssText = "text-align:right;padding-left:10px;";
  87. e.appendChild(t);
  88. var n = document.createElement("img");
  89. n.src = "http://game.ikongzhong.cn/games/jgfx/static/share.jpg";
  90. n.id = "share-wx-img";
  91. n.style.cssText = "max-width:280px;padding-right:25px;";
  92. t.appendChild(n);
  93. addShareButtons(e)
  94. }
  95. function addWXQR() {
  96. var e = document.createElement("div");
  97. e.style.cssText = "background:rgba(0,0,0,0.8); position:fixed;top:0px; left:0px; width:100%; height:" + document.height + "px; z-index:10000; display:none;";
  98. e.id = "wx-qr";
  99. e.onclick = closewx;
  100. document.body.appendChild(e);
  101. wxqrP1 = document.createElement("p");
  102. wxqrP1.style.cssText = "text-align:center;width:220px;color:#fff;margin:50px auto 0 auto;font: bold 16px Arial, Helvetica, Microsoft Yahei, 微软雅黑, STXihei, 华文细黑, sans-serif";
  103. wxqrP1.innerHTML = "点击右上角分享给朋友一起玩!";
  104. e.appendChild(wxqrP1);
  105. addShareButtons(e)
  106. }
  107. function addShareButtons(e) {
  108. var t = document.createElement("p");
  109. t.style.cssText = "text-align:center";
  110. e.appendChild(t);
  111. wxqrImg = document.createElement("img");
  112. wxqrImg.src = imgUrl;
  113. wxqrImg.id = "wx-qr-img";
  114. wxqrImg.style.cssText = "max-width:75px";
  115. if (!HORIZONTAL || !isMobile()) {
  116. t.appendChild(wxqrImg)
  117. }
  118. wxqrP3 = document.createElement("p");
  119. var n = "210px";
  120. if (HORIZONTAL == true) {
  121. n = "400px"
  122. }
  123. wxqrP3.style.cssText = "text-align:center;width:" + n + ";color:#fff;padding-top:5px;margin:0 auto;font: bold 20px Arial, Helvetica, Microsoft Yahei, 微软雅黑, STXihei, 华文细黑, sans-serif";
  124. wxqrP3.innerHTML = """ + shareTitle + """;
  125. e.appendChild(wxqrP3);
  126. wxqrP4 = document.createElement("p");
  127. e.appendChild(wxqrP4);
  128. // if (!isMobile()) {
  129. // var i = document.createElement("a");
  130. // i.className = "jiathis_button_weixin";
  131. // i.innerHTML = "&nbsp";
  132. // r.appendChild(i)
  133. // }
  134. // var s = document.createElement("a");
  135. // s.className = "jiathis_button_tsina";
  136. // s.innerHTML = "&nbsp";
  137. // r.appendChild(s);
  138. // var o = document.createElement("a");
  139. // o.className = "jiathis_button_qzone";
  140. // o.innerHTML = "&nbsp";
  141. // r.appendChild(o);
  142. // var u = document.createElement("a");
  143. // u.className = "jiathis_button_tqq";
  144. // u.innerHTML = "&nbsp";
  145. // r.appendChild(u);
  146. // var a = document.createElement("a");
  147. // a.className = "jiathis_button_renren";
  148. // a.innerHTML = "&nbsp";
  149. // r.appendChild(a);
  150. }
  151. function isMobile() {
  152. return navigator.userAgent.match(/android|iphone|ipod|blackberry|meego|symbianos|windowsphone|ucbrowser/i)
  153. }
  154. function isIOS() {
  155. return navigator.userAgent.match(/iphone|ipod|ios/i)
  156. }
  157. var HOME_PATH = HOME_PATH || "http://game.ikongzhong.cn/games/",
  158. RESOURCE_IMG_PATH = RESOURCE_IMG_PATH || "../resources/images/",
  159. HORIZONTAL = HORIZONTAL || false,
  160. COVER_SHOW_TIME = COVER_SHOW_TIME || 2e3;
  161. var imgUrl = "http://game.ikongzhong.cn/games/jgfx/static/icon.png";
  162. var lineLink = "http://game.ikongzhong.cn/games/jgfx/";
  163. var descContent = "快来跟我一起玩!";
  164. var shareTitle = "最好玩的小游戏就在菜鸟游戏!";
  165. var appid = "";
  166. document.addEventListener("WeixinJSBridgeReady",
  167. function() {
  168. WeixinJSBridge.on("menu:share:appmessage",
  169. function(e) {
  170. shareFriend()
  171. });
  172. WeixinJSBridge.on("menu:share:timeline",
  173. function(e) {
  174. shareTimeline()
  175. });
  176. WeixinJSBridge.on("menu:share:weibo",
  177. function(e) {
  178. shareWeibo()
  179. });
  180. if (HORIZONTAL == true) {
  181. WeixinJSBridge.call("hideToolbar")
  182. }
  183. },
  184. false); (function() {
  185. function n() {
  186. window.scroll(0, 0);
  187. var e;
  188. if (window.orientation == 0 || window.orientation == 180) {
  189. e = false
  190. } else if (window.orientation == -90 || window.orientation == 90) {
  191. e = true
  192. }
  193. if (e == HORIZONTAL) {
  194. t.style.display = "none"
  195. } else {
  196. setTimeout(function() {
  197. r();
  198. t.style.width = window.innerWidth + "px";
  199. t.style.display = "block"
  200. },
  201. isIOS() ? 0 : 600)
  202. }
  203. if (HORIZONTAL == true && isWeixin() && !isIOS()) {
  204. WeixinJSBridge.call("hideToolbar")
  205. }
  206. }
  207. function r() {
  208. e.style.height = window.innerHeight + "px";
  209. e.style.width = window.innerWidth + "px";
  210. t.style.height = window.innerHeight + "px"
  211. }
  212. if (typeof play68_init == "function") {
  213. play68_init()
  214. }
  215. if (!isMobile()) return;
  216. var e = document.createElement("div");
  217. e.style.cssText = "position:absolute;z-index:1000000;left:0;top:0;background:#e9573f url(" + RESOURCE_IMG_PATH + "cover.png) no-repeat center center;background-size: 50%;width:" + window.innerWidth + "px;height:" + Math.max(window.innerHeight, window.document.documentElement.offsetHeight) + "px";
  218. e.className = "common_cover";
  219. document.body.appendChild(e);
  220. setTimeout(function() {
  221. e.parentNode.removeChild(e)
  222. },
  223. COVER_SHOW_TIME);
  224. document.addEventListener("touchmove",
  225. function(e) {
  226. e.preventDefault()
  227. },
  228. false);
  229. var t = document.createElement("div");
  230. t.className = "common_notice";
  231. t.style.cssText = "position:absolute;z-index:999999;left:0;top:0;background:#e9573f url(" + RESOURCE_IMG_PATH + "rotate_tip.png) no-repeat center center;background-size: 50%;";
  232. document.body.appendChild(t);
  233. window.addEventListener("orientationchange", n);
  234. window.addEventListener("load", n);
  235. window.addEventListener("scroll", r)
  236. })();
  237. document.oncontextmenu = function() {
  238. return false
  239. };
  240. if (isWeixin()) {
  241. addShareWX()
  242. } else {
  243. addWXQR()
  244. }
  245. window.onbeforeunload = function() {
  246. return "离开此页面将会退出游戏哦"
  247. }