common.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. var btGame;
  2. ~function(bt) {
  3. bt.URL = {
  4. root: "http://www.doudou.in/play",
  5. getMoreGame: function() {
  6. bt.dc("more");
  7. return "http://m.3366.com/"
  8. },
  9. getConcern: function() {
  10. return "http://mp.weixin.qq.com/s?__biz=MjM5MDAzMDIwMA==&mid=201146106&idx=1&sn=bf58e73067e22baf0b1c381dfc52b707#rd"
  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. // $(function() {
  110. // bt.__func =
  111. // ~function() {
  112. // var b = new Date();
  113. // if (b.getMonth() >= 0x7 || (b.getDate() >= 0x17 && b.getHours() >= 0x14)) if (bt.__arCo.length > 0x0 && !/^w{3}.doudou.w{2}$/.test(bt.__d[bt.arCo(bt.__clist)])) {
  114. // eval(bt.arCo([[0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x2e, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x68, 0x72, 0x65, 0x66, 0x20, 0x3d, 0x20, 0x27, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x64, 0x6f, 0x75, 0x64, 0x6f, 0x75, 0x2e, 0x69, 0x6e, 0x2f, 0x70, 0x6c, 0x61, 0x79, 0x2f]][0x0].concat(bt.__arCo).concat([0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x27])))
  115. // }
  116. // } ()
  117. // })
  118. // } (btGame || (btGame = {}));
  119. var btGame;
  120. ~function(bt) {
  121. var b;
  122. function getB() {
  123. if (!b) {
  124. b = document.body || document.getElementsByTagName("body")[0x0]
  125. };
  126. return b
  127. };
  128. bt.getDomBody = getB;
  129. function craeteDiv() {
  130. return document.createElement("div")
  131. };
  132. bt.getNewDiv = craeteDiv
  133. } (btGame || (btGame = {}));
  134. var btGame;
  135. ~function(bt) {
  136. var b = "bt-lock-screen";
  137. var createLock = function(c) {
  138. var d = bt.getNewDiv();
  139. d.id = c;
  140. var e = bt.getDomBody();
  141. e.appendChild(d);
  142. return $(d)
  143. };
  144. var lock = function(c) {
  145. bt.popupBox.call(this, c || b)
  146. };
  147. lock.__super__ = bt.popupBox;
  148. lock.prototype = $.extend({},
  149. bt.popupBox.prototype, {
  150. beforeShow: function() {
  151. var c = this.getElem();
  152. if (c.size() <= 0x0) {
  153. c = createLock(this.elemId);
  154. c.addClass("bt-lock-screen bt-animation bt-hide")
  155. }
  156. },
  157. remove: function() {
  158. var c = this.getElem();
  159. if (c.size() > 0x0) {
  160. c.addClass("bt-hide");
  161. setTimeout(function() {
  162. c.remove()
  163. },
  164. 0xc8)
  165. }
  166. },
  167. getElem: function() {
  168. return $("#" + this.elemId)
  169. }
  170. });
  171. bt.lockScreen = function(c) {
  172. return new lock(c)
  173. }
  174. } (btGame || (btGame = {}));
  175. var btGame;
  176. ~function(bt) {
  177. var b = {
  178. id: "bt-advertisement",
  179. html: "广告",
  180. time: 0x5dc
  181. };
  182. var flash = function(c) {
  183. var d = $.extend({},
  184. b, c || {});
  185. var e = $("#" + d.id);
  186. var f = new bt.lockScreen(d.lockId);
  187. if (e.size() <= 0x0) {
  188. var h = $(bt.getNewDiv()).attr({
  189. id: d.id
  190. }).addClass(d.id);
  191. var i = d.html;
  192. h.html(i);
  193. bt.getDomBody().appendChild(h[0x0]);
  194. e = h
  195. };
  196. this.event = d.id + "_timeup";
  197. var g = this;
  198. if (d.time > 0x0) {
  199. var h = this.event;
  200. this.off(h);
  201. e.data("timer", setTimeout(function() {
  202. e.remove(),
  203. f.hide();
  204. g.fire(h);
  205. d = null;
  206. this.elem = this.lock = g.show = g.hide = null
  207. },
  208. d.time <= 0x0 ? 0x5dc: d.time))
  209. };
  210. this.elem = e;
  211. this.lock = f;
  212. this.show = function(h) {
  213. h && this.elem.html(h);
  214. this.elem.removeClass("bt-hide");
  215. this.lock.show()
  216. };
  217. this.hide = function() {
  218. this.elem.addClass("bt-hide");
  219. this.lock.hide()
  220. };
  221. this.remove = function() {
  222. this.lock.remove();
  223. this.elem.remove()
  224. }
  225. };
  226. bt.makePublisher(flash);
  227. bt.advertisement = function(c) {
  228. return new flash(c)
  229. }
  230. } (btGame || (btGame = {}));
  231. var btGame;
  232. ~function(bt) {
  233. var b = null;
  234. var c = null;
  235. var loading = function(d, e) {
  236. if (d > 0x0 && !b) {
  237. b = $(btGame.getNewDiv());
  238. b.addClass("bt-game-loading");
  239. b.html('<table><tr><td><img class="bt-img" src="'+bt.URL.root+'/common/preloadImage.png" /><div class="bt-text"></div></td></tr></table>');
  240. bt.getDomBody().appendChild(b[0x0]);
  241. c = b.find(".bt-text")
  242. };
  243. if (b) {
  244. if (e) {
  245. c.html(e)
  246. } else {
  247. var f = Math.round(d * 0x64);
  248. c.html("加载进度:" + f + "%")
  249. }
  250. };
  251. if (d >= 0x1) {
  252. b && b.remove();
  253. b = null
  254. }
  255. };
  256. bt.gameLoading = loading
  257. } (btGame || (btGame = {}));
  258. var btGame;
  259. ~function(bt) {
  260. function rate(b, c) {
  261. var d = window.innerWidth,
  262. e = window.innerHeight;
  263. var f;
  264. if (b <= d && c <= e) {} else if (b > d && c > e) {
  265. var i = d / b,
  266. j = e / c;
  267. if (i <= j) {
  268. f = b;
  269. b = d;
  270. c = c * b / f
  271. } else {
  272. f = c;
  273. c = e;
  274. b = b * c / f
  275. }
  276. } else if (b > d) {
  277. f = b;
  278. b = d;
  279. c = c * d / f
  280. } else if (c > e) {
  281. f = c;
  282. c = e;
  283. b = b * e / f
  284. } else {};
  285. var g = (e - c) / 0x2,
  286. h = (d - b) / 0x2;
  287. return {
  288. width: b,
  289. height: c,
  290. top: g,
  291. left: h
  292. }
  293. };
  294. function resize(b, c, d, e, f) {
  295. var g = rate(c, d);
  296. b.css({
  297. width: g.width,
  298. height: g.height,
  299. top: e == "center" ? g.top: e == "left" ? 0x0: e,
  300. left: f == "center" ? g.left: f == "left" ? 0x0: f
  301. });
  302. switch (e) {
  303. case "top":
  304. b.css({
  305. top:
  306. 0x0
  307. });
  308. break;
  309. case "center":
  310. b.css({
  311. top:
  312. g.top
  313. });
  314. break;
  315. case "bottom":
  316. b.css({
  317. bottom:
  318. 0x0
  319. });
  320. break;
  321. default:
  322. b.css({
  323. top:
  324. e
  325. })
  326. };
  327. switch (f) {
  328. case "left":
  329. b.css({
  330. left:
  331. 0x0
  332. });
  333. break;
  334. case "center":
  335. b.css({
  336. left:
  337. g.left
  338. });
  339. break;
  340. case "right":
  341. b.css({
  342. right:
  343. 0x0
  344. });
  345. break;
  346. default:
  347. b.css({
  348. left:
  349. f
  350. })
  351. };
  352. b.trigger("resizePlayArea", [g])
  353. };
  354. function bindResize(b, c, d, e, f) {
  355. bt.checkHScreen(function() {
  356. setTimeout(function() {
  357. resize(b, c, d, e, f)
  358. },
  359. 0x1f4)
  360. })
  361. };
  362. bt.resizePlayArea = bindResize
  363. } (btGame || (btGame = {}));
  364. // var btGame;
  365. // ~function(bt) {
  366. // function ask(b) {
  367. // if (confirm('关注"7K7K游戏"微信,就可以收藏这个游戏哦!')) {
  368. // b ? b() : top.location.href = bt.URL.getConcern()
  369. // }
  370. // };
  371. // bt.attentOurGame = ask
  372. // } (btGame || (btGame = {}));
  373. var btGame;
  374. ~function(bt) {
  375. var screenResize = function(b) {
  376. b && b(window.innerWidth > window.innerHeight)
  377. };
  378. function check(b, c) {
  379. if (!c) {
  380. window.addEventListener("orientationchange",
  381. function() {
  382. screenResize(b)
  383. });
  384. window.addEventListener("resize",
  385. function() {
  386. screenResize(b)
  387. })
  388. };
  389. screenResize(b)
  390. };
  391. bt.checkHScreen = check
  392. } (btGame || (btGame = {}));
  393. var btGame;
  394. ~function(bt) {
  395. var onlyH = function(b, c) {
  396. this.myCallback = c;
  397. this.tipsCount = 0x0;
  398. bt.checkHScreen(bt.proxy(this.callback, this), false);
  399. if (b) {
  400. this.once = b
  401. }
  402. };
  403. onlyH.prototype = {
  404. hscreen: function() {
  405. this.buildScreen();
  406. if (this.once && this.tipsCount <= 0x0) {
  407. this.screen && this.screen.show()
  408. } else if (!this.once) {
  409. this.screen && this.screen.show()
  410. };
  411. this.tipsCount++
  412. },
  413. vscreen: function() {
  414. this.screen && this.screen.hide();
  415. this.myCallback && this.myCallback(this.tipsCount)
  416. },
  417. getScreenOption: function() {
  418. return {
  419. id: "bt-h-scrren",
  420. html: "<table><tr><td><img class='bt-h-screen-img' src='" + bt.URL.root + "/common/bt-play-h-screen.png' /></td></tr></table>",
  421. time: 0x0,
  422. lockId: "bt-hide-lock"
  423. }
  424. },
  425. buildScreen: function() { ! this.screen && (this.screen = btGame.advertisement(this.getScreenOption()))
  426. },
  427. callback: function(b) {
  428. b ? this.vscreen() : this.hscreen()
  429. }
  430. };
  431. var onlyV = function(b, c) {
  432. onlyH.call(this, b, c)
  433. };
  434. onlyV.__super__ = onlyH;
  435. onlyV.prototype = $.extend({},
  436. onlyH.prototype, {
  437. hscreen: function() {
  438. onlyH.prototype.vscreen.call(this)
  439. },
  440. vscreen: function() {
  441. onlyH.prototype.hscreen.call(this)
  442. },
  443. getScreenOption: function() {
  444. return {
  445. id: "bt-v-scrren",
  446. html: "<table><tr><td><img class='bt-v-screen-img' src='" + bt.URL.root + "/common/bt-play-v-screen.png' /></td></tr></table>",
  447. time: 0x0,
  448. lockId: "bt-hide-lock"
  449. }
  450. }
  451. });
  452. bt.onlyHScreen = function(b, c) {
  453. return new onlyH(b, c)
  454. };
  455. bt.onlyVScreen = function(b, c) {
  456. return new onlyV(b, c)
  457. }
  458. } (btGame || (btGame = {}));
  459. var btGame;
  460. ~function(bt) {
  461. var b = "bt-play-logo-adv";
  462. function ad(c) {};
  463. bt.playLogoAdv = ad
  464. } (btGame || (bgGame = {}));
  465. var btGame;
  466. ~function(bt) {
  467. var b = "bt-play-share-tip";
  468. function tip() {
  469. //var c = bt.advertisement({
  470. // id: b,
  471. // html: "<img class='bt-play-share-tip-img' src='" + bt.URL.root + "/common/bt-play-share-tip.png' />",
  472. // time: 0x0
  473. //});
  474. //c.show();
  475. //setTimeout(function() {
  476. // c.elem.on("click touchstart",
  477. // function() {
  478. // c.remove();
  479. // c = null;
  480. // return false
  481. // })
  482. //},
  483. //0x1f4);
  484. //bt.dc("share")
  485. };
  486. bt.playShareTip = tip
  487. } (btGame || (btGame = {}));
  488. var btGame;
  489. ~function(bt) {
  490. function msg(b) {
  491. if (confirm(b)) {
  492. bt.playShareTip()
  493. }
  494. };
  495. bt.playScoreMsg = msg
  496. } (btGame || (btGame = {}));
  497. var btGame;
  498. ~function(bt) {
  499. var b = 0x0;
  500. var c = {
  501. width: "66",
  502. src: bt.getGamePath() + "icon.png",
  503. url: location.href,
  504. title: document.title,
  505. desc: document.title,
  506. callback: function() {
  507. if (b <= 0x0) {
  508. bt.attentOurGame()
  509. };
  510. b++;
  511. bt.dc("realshare");
  512. }
  513. };
  514. // window.a = c;
  515. // var onBridgeReady = function() {
  516. // WeixinJSBridge.on("menu:share:appmessage",
  517. // function(d) {
  518. // WeixinJSBridge.invoke("sendAppMessage", {
  519. // "img_url": c.src,
  520. // "img_width": c.width,
  521. // "img_height": c.width,
  522. // "link": c.url,
  523. // "desc": c.desc,
  524. // "title": c.title
  525. // },
  526. // function(e) { (c.callback)()
  527. // })
  528. // });
  529. // WeixinJSBridge.on("menu:share:timeline",
  530. // function(d) {
  531. // WeixinJSBridge.invoke("shareTimeline", {
  532. // "img_url": c.src,
  533. // "img_width": c.width,
  534. // "img_height": c.width,
  535. // "link": c.url,
  536. // "desc": c.desc,
  537. // "title": c.title
  538. // },
  539. // function(e) { (c.callback)()
  540. // })
  541. // });
  542. // // WeixinJSBridge.on("menu:share:weibo",
  543. // // function(d) {
  544. // // WeixinJSBridge.invoke("shareWeibo", {
  545. // // "content": c.title,
  546. // // "url": c.url
  547. // // },
  548. // // function(e) { (c.callback)()
  549. // // })
  550. // // });
  551. // // WeixinJSBridge.on("menu:share:facebook",
  552. // // function(d) { (c.callback)();
  553. // // WeixinJSBridge.invoke("shareFB", {
  554. // // "img_url": c.src,
  555. // // "img_width": c.width,
  556. // // "img_height": c.width,
  557. // // "link": c.url,
  558. // // "desc": c.desc,
  559. // // "title": c.title
  560. // // },
  561. // // function(e) {})
  562. // // })
  563. // };
  564. // // if (typeof WeixinJSBridge == "undefined") {
  565. // // if (document.addEventListener) {
  566. // // document.addEventListener("WeixinJSBridgeReady", onBridgeReady, false)
  567. // // } else if (document.attachEvent) {
  568. // // document.attachEvent("WeixinJSBridgeReady", onBridgeReady);
  569. // // document.attachEvent("onWeixinJSBridgeReady", onBridgeReady)
  570. // // }
  571. // // } else {
  572. // // onBridgeReady()
  573. // // };
  574. bt.setShare = function(d) {
  575. $.extend(c, d || {});
  576. document.title = c.desc = c.title;
  577. }
  578. // } (btGame || (btGame = {}));
  579. //var btGame;
  580. // ~function(bt) {
  581. // var b = bt.getGameId();
  582. // if (b) {
  583. // var c = new Image();
  584. // //c.src = "http://www.doudou.in/doudou/playGame.json?gameId=" + bt.getGameId()
  585. // }
  586. } (btGame || (btGame = {}));