common.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  1. var btGame;
  2. ~function(bt) {
  3. bt.URL = {
  4. root: "#",
  5. getMoreGame: function() {
  6. bt.dc("more");
  7. return ""
  8. },
  9. getConcern: function() {
  10. return ""
  11. },
  12. appId: "wxf91bab01569cc168"
  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="style/img_d/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. var onlyH = function(b, c) {
  355. this.myCallback = c;
  356. this.tipsCount = 0x0;
  357. bt.checkHScreen(bt.proxy(this.callback, this), false);
  358. if (b) {
  359. this.once = b
  360. }
  361. };
  362. onlyH.prototype = {
  363. hscreen: function() {
  364. this.buildScreen();
  365. if (this.once && this.tipsCount <= 0x0) {
  366. this.screen && this.screen.show()
  367. } else if (!this.once) {
  368. this.screen && this.screen.show()
  369. };
  370. this.tipsCount++
  371. },
  372. vscreen: function() {
  373. this.screen && this.screen.hide();
  374. this.myCallback && this.myCallback(this.tipsCount)
  375. },
  376. getScreenOption: function() {
  377. return {
  378. id: "bt-h-scrren",
  379. html: "<table><tr><td><img class='bt-h-screen-img' src='style/img_d/100405_7462.jpg' /></td></tr></table>",
  380. time: 0x0,
  381. lockId: "bt-hide-lock"
  382. }
  383. },
  384. buildScreen: function() { ! this.screen && (this.screen = btGame.advertisement(this.getScreenOption()))
  385. },
  386. callback: function(b) {
  387. b ? this.vscreen() : this.hscreen()
  388. }
  389. };
  390. var onlyV = function(b, c) {
  391. onlyH.call(this, b, c)
  392. };
  393. onlyV.__super__ = onlyH;
  394. onlyV.prototype = $.extend({},
  395. onlyH.prototype, {
  396. hscreen: function() {
  397. onlyH.prototype.vscreen.call(this)
  398. },
  399. vscreen: function() {
  400. onlyH.prototype.hscreen.call(this)
  401. },
  402. getScreenOption: function() {
  403. return {
  404. id: "bt-v-scrren",
  405. html: "<table><tr><td><img class='bt-v-screen-img' src='style/img_d/100433_5472.jpg' /></td></tr></table>",
  406. time: 0x0,
  407. lockId: "bt-hide-lock"
  408. }
  409. }
  410. });
  411. bt.onlyHScreen = function(b, c) {
  412. return new onlyH(b, c)
  413. };
  414. bt.onlyVScreen = function(b, c) {
  415. return new onlyV(b, c)
  416. }
  417. } (btGame || (btGame = {}));
  418. var btGame;
  419. ~function(bt) {
  420. var b = "bt-play-logo-adv";
  421. function ad(c) {};
  422. bt.playLogoAdv = ad
  423. } (btGame || (bgGame = {}));
  424. var btGame;
  425. ~function(bt) {
  426. var b = "bt-play-share-tip";
  427. function tip() {
  428. var c = bt.advertisement({
  429. id: b,
  430. html: "<img class='bt-play-share-tip-img' src='style/img_d/100500_5390.jpg' />",
  431. time: 0x0
  432. });
  433. c.show();
  434. setTimeout(function() {
  435. c.elem.on("click touchstart",
  436. function() {
  437. c.remove();
  438. c = null;
  439. return false
  440. })
  441. },
  442. 0x1f4);
  443. bt.dc("share")
  444. };
  445. bt.playShareTip = tip
  446. } (btGame || (btGame = {}));
  447. var btGame;
  448. ~function(bt) {
  449. function msg(b) {
  450. if (confirm(b)) {
  451. bt.playShareTip()
  452. }
  453. };
  454. bt.playScoreMsg = msg
  455. } (btGame || (btGame = {}));
  456. var btGame;
  457. ~function(bt) {
  458. var b = 0x0;
  459. var c = {
  460. width: "66",
  461. src: "",
  462. url: location.href,
  463. title: document.title,
  464. desc: document.title,
  465. callback: function() {
  466. if (b <= 0x0) {
  467. bt.attentOurGame()
  468. };
  469. b++;
  470. bt.dc("realshare");
  471. }
  472. };
  473. bt.setShare = function(d) {
  474. $.extend(c, d || {});
  475. document.title = c.desc = c.title;
  476. }
  477. } (btGame || (btGame = {}));