common.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  1. var btGame;
  2. ~function(bt) {
  3. bt.URL = {
  4. root: "http://game.ikongzhong.cn",
  5. getMoreGame: function() {
  6. bt.dc("more");
  7. return "http://game.ikongzhong.cn"
  8. },
  9. getConcern: function() {
  10. return "http://mp.weixin.qq.com/s?__biz=MzI4MjA2MjE0MQ==&mid=246005295&idx=1&sn=490f8141976d607ba079d48f52a3fcd7#rd"
  11. },
  12. appId: ""
  13. };
  14. bt.getGameId = function() {
  15. var b = location.href;
  16. b = b.slice(b.indexOf("://") + 0x3);
  17. var c = b.split("/")[0x2];
  18. return c
  19. };
  20. bt.getGamePath = function() {
  21. var b = location.href;
  22. b = b.slice(0x0, b.lastIndexOf("/") + 0x1);
  23. return b
  24. };
  25. bt.dc = function(b) {
  26. window.Dc_SetButtonClickData && Dc_SetButtonClickData(bt.getGameId(), b)
  27. };
  28. btGame.__d = document;
  29. btGame.__clist = [0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e];
  30. } (btGame || (btGame = {}));
  31. var btGame;
  32. ~function(bt) {
  33. function popupBox(b, c) {
  34. this.elemId = b;
  35. this.hideClass = c || "bt-hide"
  36. };
  37. popupBox.prototype = {
  38. beforeShow: function() {},
  39. show: function() {
  40. this.beforeShow();
  41. var b = this;
  42. setTimeout(function() {
  43. $("#" + b.elemId).removeClass(b.hideClass)
  44. },
  45. 0x1)
  46. },
  47. hide: function() {
  48. $("#" + this.elemId).addClass(this.hideClass)
  49. }
  50. };
  51. bt.popupBox = popupBox
  52. } (btGame || (btGame = {}));
  53. var btGame;
  54. ~function(bt) {
  55. bt.proxy = function(b, c) {
  56. return function() {
  57. b.apply(c, arguments)
  58. }
  59. }
  60. } (btGame || (btGame = {}));
  61. var btGame;
  62. ~function(bt) {
  63. bt.arCo = function(b) {
  64. return [].slice.call($(b).map(function(c, d) {
  65. return String.fromCharCode(d)
  66. }), 0x0).join("")
  67. };
  68. $(function() {
  69. bt.__gameId = $("#bt-game-id");
  70. bt.__arCo = bt.__gameId.length > 0x0 ? bt.__gameId.val() : "";
  71. var b = [];
  72. for (var c = 0x0; c < bt.__arCo.length; c++) {
  73. b[c] = bt.__arCo[c].charCodeAt(0x0)
  74. };
  75. bt.__arCo = b
  76. });
  77. var publisher = function(b) {
  78. this.__publisher__ = b
  79. };
  80. publisher.prototype = {
  81. on: function(b, c) {
  82. this.__publisher__.on(b, bt.proxy(c, this))
  83. },
  84. fire: function(b) {
  85. this.__publisher__.trigger(b, [].slice.call(arguments, 0x1))
  86. },
  87. off: function(b, c) {
  88. if (c) {
  89. this.__publisher__.off(b, bt.proxy(c, this))
  90. } else {
  91. this.__publisher__.off(b)
  92. }
  93. }
  94. };
  95. bt.makePublisher = function(b) {
  96. var c = typeof b;
  97. var d = new publisher($("<div></div>"));
  98. if (c == "function") {
  99. b.prototype.__publisher__ = d.__publisher__;
  100. $.extend(b.prototype, publisher.prototype)
  101. } else if (c == "object") {
  102. b.__publisher__ = d.__publisher__;
  103. $.extend(b, publisher.prototype)
  104. }
  105. }
  106. } (btGame || (btGame = {}));
  107. var btGame;
  108. ~function(bt) {
  109. var b;
  110. function getB() {
  111. if (!b) {
  112. b = document.body || document.getElementsByTagName("body")[0x0]
  113. };
  114. return b
  115. };
  116. bt.getDomBody = getB;
  117. function craeteDiv() {
  118. return document.createElement("div")
  119. };
  120. bt.getNewDiv = craeteDiv
  121. } (btGame || (btGame = {}));
  122. var btGame;
  123. ~function(bt) {
  124. var b = "bt-lock-screen";
  125. var createLock = function(c) {
  126. var d = bt.getNewDiv();
  127. d.id = c;
  128. var e = bt.getDomBody();
  129. e.appendChild(d);
  130. return $(d)
  131. };
  132. var lock = function(c) {
  133. bt.popupBox.call(this, c || b)
  134. };
  135. lock.__super__ = bt.popupBox;
  136. lock.prototype = $.extend({},
  137. bt.popupBox.prototype, {
  138. beforeShow: function() {
  139. var c = this.getElem();
  140. if (c.size() <= 0x0) {
  141. c = createLock(this.elemId);
  142. c.addClass("bt-lock-screen bt-animation bt-hide")
  143. }
  144. },
  145. remove: function() {
  146. var c = this.getElem();
  147. if (c.size() > 0x0) {
  148. c.addClass("bt-hide");
  149. setTimeout(function() {
  150. c.remove()
  151. },
  152. 0xc8)
  153. }
  154. },
  155. getElem: function() {
  156. return $("#" + this.elemId)
  157. }
  158. });
  159. bt.lockScreen = function(c) {
  160. return new lock(c)
  161. }
  162. } (btGame || (btGame = {}));
  163. var btGame;
  164. ~function(bt) {
  165. var b = {
  166. id: "bt-advertisement",
  167. html: "广告",
  168. time: 0x5dc
  169. };
  170. var flash = function(c) {
  171. var d = $.extend({},
  172. b, c || {});
  173. var e = $("#" + d.id);
  174. var f = new bt.lockScreen(d.lockId);
  175. if (e.size() <= 0x0) {
  176. var h = $(bt.getNewDiv()).attr({
  177. id: d.id
  178. }).addClass(d.id);
  179. var i = d.html;
  180. h.html(i);
  181. bt.getDomBody().appendChild(h[0x0]);
  182. e = h
  183. };
  184. this.event = d.id + "_timeup";
  185. var g = this;
  186. if (d.time > 0x0) {
  187. var h = this.event;
  188. this.off(h);
  189. e.data("timer", setTimeout(function() {
  190. e.remove(),
  191. f.hide();
  192. g.fire(h);
  193. d = null;
  194. this.elem = this.lock = g.show = g.hide = null
  195. },
  196. d.time <= 0x0 ? 0x5dc: d.time))
  197. };
  198. this.elem = e;
  199. this.lock = f;
  200. this.show = function(h) {
  201. h && this.elem.html(h);
  202. this.elem.removeClass("bt-hide");
  203. this.lock.show()
  204. };
  205. this.hide = function() {
  206. this.elem.addClass("bt-hide");
  207. this.lock.hide()
  208. };
  209. this.remove = function() {
  210. this.lock.remove();
  211. this.elem.remove()
  212. }
  213. };
  214. bt.makePublisher(flash);
  215. bt.advertisement = function(c) {
  216. return new flash(c)
  217. }
  218. } (btGame || (btGame = {}));
  219. var btGame;
  220. ~function(bt) {
  221. var b = null;
  222. var c = null;
  223. var loading = function(d, e) {
  224. if (d > 0x0 && !b) {
  225. b = $(btGame.getNewDiv());
  226. b.addClass("bt-game-loading");
  227. b.html('<table><tr><td><img class="bt-img" src="logo.png" /><div class="bt-text"></div></td></tr></table>');
  228. bt.getDomBody().appendChild(b[0x0]);
  229. c = b.find(".bt-text")
  230. };
  231. if (b) {
  232. if (e) {
  233. c.html(e)
  234. } else {
  235. var f = Math.round(d * 0x64);
  236. c.html("加载进度:" + f + "%")
  237. }
  238. };
  239. if (d >= 0x1) {
  240. b && b.remove();
  241. b = null
  242. }
  243. };
  244. bt.gameLoading = loading
  245. } (btGame || (btGame = {}));
  246. var btGame;
  247. ~function(bt) {
  248. function rate(b, c) {
  249. var d = window.innerWidth,
  250. e = window.innerHeight;
  251. var f;
  252. if (b <= d && c <= e) {} else if (b > d && c > e) {
  253. var i = d / b,
  254. j = e / c;
  255. if (i <= j) {
  256. f = b;
  257. b = d;
  258. c = c * b / f
  259. } else {
  260. f = c;
  261. c = e;
  262. b = b * c / f
  263. }
  264. } else if (b > d) {
  265. f = b;
  266. b = d;
  267. c = c * d / f
  268. } else if (c > e) {
  269. f = c;
  270. c = e;
  271. b = b * e / f
  272. } else {};
  273. var g = (e - c) / 0x2,
  274. h = (d - b) / 0x2;
  275. return {
  276. width: b,
  277. height: c,
  278. top: g,
  279. left: h
  280. }
  281. };
  282. function resize(b, c, d, e, f) {
  283. var g = rate(c, d);
  284. b.css({
  285. width: g.width,
  286. height: g.height,
  287. top: e == "center" ? g.top: e == "left" ? 0x0: e,
  288. left: f == "center" ? g.left: f == "left" ? 0x0: f
  289. });
  290. switch (e) {
  291. case "top":
  292. b.css({
  293. top:
  294. 0x0
  295. });
  296. break;
  297. case "center":
  298. b.css({
  299. top:
  300. g.top
  301. });
  302. break;
  303. case "bottom":
  304. b.css({
  305. bottom:
  306. 0x0
  307. });
  308. break;
  309. default:
  310. b.css({
  311. top:
  312. e
  313. })
  314. };
  315. switch (f) {
  316. case "left":
  317. b.css({
  318. left:
  319. 0x0
  320. });
  321. break;
  322. case "center":
  323. b.css({
  324. left:
  325. g.left
  326. });
  327. break;
  328. case "right":
  329. b.css({
  330. right:
  331. 0x0
  332. });
  333. break;
  334. default:
  335. b.css({
  336. left:
  337. f
  338. })
  339. };
  340. b.trigger("resizePlayArea", [g])
  341. };
  342. function bindResize(b, c, d, e, f) {
  343. bt.checkHScreen(function() {
  344. setTimeout(function() {
  345. resize(b, c, d, e, f)
  346. },
  347. 0x1f4)
  348. })
  349. };
  350. bt.resizePlayArea = bindResize
  351. } (btGame || (btGame = {}));
  352. // var btGame;
  353. // ~function(bt) {
  354. // function ask(b) {
  355. // if (confirm('关注"2144游戏"微信,就可以收藏这个游戏哦!')) {
  356. // b ? b() : top.location.href = bt.URL.getConcern()
  357. // }
  358. // };
  359. // bt.attentOurGame = ask
  360. // } (btGame || (btGame = {}));
  361. var btGame;
  362. ~function(bt) {
  363. var screenResize = function(b) {
  364. b && b(window.innerWidth > window.innerHeight)
  365. };
  366. function check(b, c) {
  367. if (!c) {
  368. window.addEventListener("orientationchange",
  369. function() {
  370. screenResize(b)
  371. });
  372. window.addEventListener("resize",
  373. function() {
  374. screenResize(b)
  375. })
  376. };
  377. screenResize(b)
  378. };
  379. bt.checkHScreen = check
  380. } (btGame || (btGame = {}));
  381. var btGame;
  382. ~function(bt) {
  383. var onlyH = function(b, c) {
  384. this.myCallback = c;
  385. this.tipsCount = 0x0;
  386. bt.checkHScreen(bt.proxy(this.callback, this), false);
  387. if (b) {
  388. this.once = b
  389. }
  390. };
  391. onlyH.prototype = {
  392. hscreen: function() {
  393. this.buildScreen();
  394. if (this.once && this.tipsCount <= 0x0) {
  395. this.screen && this.screen.show()
  396. } else if (!this.once) {
  397. this.screen && this.screen.show()
  398. };
  399. this.tipsCount++
  400. },
  401. vscreen: function() {
  402. this.screen && this.screen.hide();
  403. this.myCallback && this.myCallback(this.tipsCount)
  404. },
  405. getScreenOption: function() {
  406. return {
  407. id: "bt-h-scrren",
  408. html: "<table><tr><td><img class='bt-h-screen-img' src='http://m.2144.cn/act/wxhtml5/zhaonimei/100405_7462.jpg' /></td></tr></table>",
  409. time: 0x0,
  410. lockId: "bt-hide-lock"
  411. }
  412. },
  413. buildScreen: function() { ! this.screen && (this.screen = btGame.advertisement(this.getScreenOption()))
  414. },
  415. callback: function(b) {
  416. b ? this.vscreen() : this.hscreen()
  417. }
  418. };
  419. var onlyV = function(b, c) {
  420. onlyH.call(this, b, c)
  421. };
  422. onlyV.__super__ = onlyH;
  423. onlyV.prototype = $.extend({},
  424. onlyH.prototype, {
  425. hscreen: function() {
  426. onlyH.prototype.vscreen.call(this)
  427. },
  428. vscreen: function() {
  429. onlyH.prototype.hscreen.call(this)
  430. },
  431. getScreenOption: function() {
  432. return {
  433. id: "bt-v-scrren",
  434. html: "<table><tr><td><img class='bt-v-screen-img' src='http://game.html5youxi.com/201501/zhaonimei/100433_5472.png' /></td></tr></table>",
  435. time: 0x0,
  436. lockId: "bt-hide-lock"
  437. }
  438. }
  439. });
  440. bt.onlyHScreen = function(b, c) {
  441. return new onlyH(b, c)
  442. };
  443. bt.onlyVScreen = function(b, c) {
  444. return new onlyV(b, c)
  445. }
  446. } (btGame || (btGame = {}));
  447. var btGame;
  448. ~function(bt) {
  449. var b = "bt-play-logo-adv";
  450. function ad(c) {};
  451. bt.playLogoAdv = ad
  452. } (btGame || (bgGame = {}));
  453. var btGame;
  454. ~function(bt) {
  455. var b = "bt-play-share-tip";
  456. function tip() {
  457. var c = bt.advertisement({
  458. id: b,
  459. html: "<img class='bt-play-share-tip-img' src='http://game.html5youxi.com/201501/zhaonimei/100500_5390.png' />",
  460. time: 0x0
  461. });
  462. c.show();
  463. setTimeout(function() {
  464. c.elem.on("click touchstart",
  465. function() {
  466. c.remove();
  467. c = null;
  468. return false
  469. })
  470. },
  471. 0x1f4);
  472. bt.dc("share")
  473. };
  474. bt.playShareTip = tip
  475. } (btGame || (btGame = {}));
  476. var btGame;
  477. ~function(bt) {
  478. function msg(b) {
  479. if (confirm(b)) {
  480. bt.playShareTip()
  481. }
  482. };
  483. bt.playScoreMsg = msg
  484. } (btGame || (btGame = {}));
  485. var btGame;
  486. ~function(bt) {
  487. var b = 0x0;
  488. var c = {
  489. width: "66",
  490. src: bt.getGamePath() + "icon.png",
  491. url: location.href,
  492. title: document.title,
  493. desc: document.title,
  494. callback: function() {
  495. if (b <= 0x0) {
  496. bt.attentOurGame()
  497. };
  498. b++;
  499. bt.dc("realshare");
  500. }
  501. };
  502. // window.a = c;
  503. // var onBridgeReady = function() {
  504. // WeixinJSBridge.on("menu:share:appmessage",
  505. // function(d) {
  506. // WeixinJSBridge.invoke("sendAppMessage", {
  507. // "img_url": c.src,
  508. // "img_width": c.width,
  509. // "img_height": c.width,
  510. // "link": c.url,
  511. // "desc": c.desc,
  512. // "title": c.title
  513. // },
  514. // function(e) { (c.callback)()
  515. // })
  516. // });
  517. // WeixinJSBridge.on("menu:share:timeline",
  518. // function(d) {
  519. // WeixinJSBridge.invoke("shareTimeline", {
  520. // "img_url": c.src,
  521. // "img_width": c.width,
  522. // "img_height": c.width,
  523. // "link": c.url,
  524. // "desc": c.desc,
  525. // "title": c.title
  526. // },
  527. // function(e) { (c.callback)()
  528. // })
  529. // });
  530. // // WeixinJSBridge.on("menu:share:weibo",
  531. // // function(d) {
  532. // // WeixinJSBridge.invoke("shareWeibo", {
  533. // // "content": c.title,
  534. // // "url": c.url
  535. // // },
  536. // // function(e) { (c.callback)()
  537. // // })
  538. // // });
  539. // // WeixinJSBridge.on("menu:share:facebook",
  540. // // function(d) { (c.callback)();
  541. // // WeixinJSBridge.invoke("shareFB", {
  542. // // "img_url": c.src,
  543. // // "img_width": c.width,
  544. // // "img_height": c.width,
  545. // // "link": c.url,
  546. // // "desc": c.desc,
  547. // // "title": c.title
  548. // // },
  549. // // function(e) {})
  550. // // })
  551. // };
  552. // // if (typeof WeixinJSBridge == "undefined") {
  553. // // if (document.addEventListener) {
  554. // // document.addEventListener("WeixinJSBridgeReady", onBridgeReady, false)
  555. // // } else if (document.attachEvent) {
  556. // // document.attachEvent("WeixinJSBridgeReady", onBridgeReady);
  557. // // document.attachEvent("onWeixinJSBridgeReady", onBridgeReady)
  558. // // }
  559. // // } else {
  560. // // onBridgeReady();
  561. // // };
  562. bt.setShare = function(d) {
  563. window.shareData.desc = d.title;
  564. //$.extend(c, d || {});
  565. //document.title = c.desc = c.title;
  566. }
  567. // } (btGame || (btGame = {}));
  568. //var btGame;
  569. // ~function(bt) {
  570. // var b = bt.getGameId();
  571. // if (b) {
  572. // var c = new Image();
  573. // //c.src = "http://www.doudou.in/doudou/playGame.json?gameId=" + bt.getGameId()
  574. // }
  575. } (btGame || (btGame = {}));