main.min.js 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. var _lang = {
  2. zh1: {
  3. title: "大家都来找袜字",
  4. help_txt: "找出所有色块里文字不同的一个",
  5. score: "得分:",
  6. btn_pause: "暂停",
  7. btn_start: "开始游戏",
  8. btn_reTry: "再来一次",
  9. btn_more_game: "更多游戏",
  10. game_pause: "游戏暂停",
  11. btn_resume: "继续游戏",
  12. loading: "加载中...",
  13. lv_txt: ["文盲", "臭袜子", "脏袜子", "新袜子", "袜子搜寻者", "色魔", "超级色魔", "变态色魔", "寻袜高手"],
  14. share_txt1: "我闯过",
  15. share_txt2: "关,击败",
  16. share_txt3: "%的人,我是【",
  17. share_txt4: "】,不服来战!",
  18. desc: "找出所有色块中文字不同的一块。分享朋友圈,找到妹子中的袜子"
  19. },
  20. zh: {
  21. title: "一起寻找蔡依林",
  22. help_txt: "在众多<span style='font-size:240%'>凤姐</span>中找到唯一的<span style='font-size:240%'>蔡依林</span>",
  23. score: "过关:",
  24. btn_pause: "暂停",
  25. btn_start: "开始游戏",
  26. btn_reTry: "再来一次",
  27. btn_more_game: "更多游戏",
  28. game_pause: "游戏暂停",
  29. btn_resume: "继续游戏",
  30. loading: "加载中...",
  31. lv_txt: ["凤姐的脑残粉", "凤姐的忠实粉", "凤姐的路人粉", "慧眼识Jolin", "火眼金睛", "洞察一切", "两眼冒光", "24k氪金眼", "已被亮瞎!", ],
  32. share_txt1: "【寻找蔡依林】我在",
  33. share_txt2: "个凤姐中找到",
  34. share_txt3: "次蔡依林,我是【",
  35. share_txt4: "】,不服来战!",
  36. desc: "找出众多'凤姐'中的'蔡依林'。分享朋友圈,找到凤姐中的蔡依林"
  37. },
  38. en: {
  39. title: "How strong is your eyesight",
  40. help_txt: "Find the box with the different colour",
  41. score: "Score:",
  42. btn_pause: "Pause",
  43. btn_start: "Start",
  44. btn_reTry: "Again",
  45. btn_more_game: "More games",
  46. game_pause: "Pause",
  47. btn_resume: "Continues",
  48. loading: "loading...",
  49. lv_txt: ["Blind", "Very weak", "Weak", "Just so so", "Not bad", "Nice one", "Great", "Amazing", "Insane"],
  50. share_txt1: "I passed ",
  51. share_txt2: "stages and defeated ",
  52. share_txt3: "% people. I am ",
  53. share_txt4: ", come to challenge me if you dare!",
  54. desc: "Find the box with the different colour, share it to your friends!"
  55. }
  56. },
  57. _config = {
  58. lang: "zh",
  59. color: {
  60. allTime: 60,
  61. addTime: 0,
  62. lvMap: [2, 3, 4, 5, 5, 6, 6, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9]
  63. },
  64. pic: {
  65. isOpen: !1,
  66. allTime: 5,
  67. addTime: 0,
  68. lvMap: [2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8]
  69. }
  70. },
  71. shareData1 = {
  72. }; !
  73. function() {
  74. var a = _lang[_config.lang],
  75. b = $("#tpl").html(),
  76. c = _.template(b, a);
  77. $("#container").html(c)
  78. } (),
  79. function() {
  80. var a = $("#box"),
  81. b = {
  82. lv: $("#room .lv em"),
  83. time: $("#room .time"),
  84. start: $("#dialog .btn-restart"),
  85. back: $("#dialog .btn-back"),
  86. share: $("#dialog .btn-share"),
  87. pause: $("#room .btn-pause"),
  88. resume: $("#dialog .btn-resume"),
  89. dialog: $("#dialog"),
  90. d_content: $("#dialog .content"),
  91. d_pause: $("#dialog .pause"),
  92. d_gameover: $("#dialog .gameover")
  93. },
  94. c = {
  95. init: function(a, b, c) {
  96. this.type = a,
  97. this.api = API[a],
  98. this.config = _config[a],
  99. this.reset(),
  100. this.parent = c,
  101. this.el = b,
  102. this.renderUI(),
  103. this.inited || this.initEvent(),
  104. this.inited = !0,
  105. this.start()
  106. },
  107. renderUI: function() {
  108. var b = 90 == window.orientation || -90 == window.orientation,
  109. c = b ? window.innerHeight: window.innerWidth;
  110. c -= 20,
  111. c = Math.min(c, 500),
  112. a.width(c).height(c),
  113. this.el.show()
  114. },
  115. initEvent: function() {
  116. var d = "ontouchstart" in document.documentElement ? "touchend": "click",
  117. e = this;
  118. $(window).resize(function() {
  119. c.renderUI()
  120. }),
  121. a.on(d, "span",
  122. function() {
  123. var a = $(this).data("type");
  124. "a" == a && e.nextLv.call(e)
  125. }),
  126. b.pause.on(d, _.bind(this.pause, this)),
  127. b.resume.on(d, _.bind(this.resume, this)),
  128. b.start.on(d, _.bind(this.start, this)),
  129. b.back.on(d, _.bind(this.back, this)),
  130. b.share.on(d, _.bind(this.share, this))
  131. },
  132. start: function() {
  133. this.time > 5 && b.time.removeClass("danger"),
  134. b.dialog.hide(),
  135. this._pause = !1,
  136. this.lv = "undefined" != typeof this.lv ? this.lv + 1 : 0,
  137. this.lvMap = this.config.lvMap[this.lv] || _.last(this.config.lvMap),
  138. this.renderMap(),
  139. this.renderInfo(),
  140. this.timer || (this.timer = setInterval(_.bind(this.tick, this), 1e3));
  141. },
  142. share: function() {},
  143. resume: function() {
  144. b.dialog.hide(),
  145. this._pause = !1
  146. },
  147. pause: function() {
  148. this._pause = !0,
  149. b.d_content.hide(),
  150. b.d_pause.show(),
  151. b.dialog.show()
  152. },
  153. tick: function() {
  154. return this._pause ? void 0 : (this.time--, this.time < 6 && b.time.addClass("danger"), this.time < 0 ? void this.gameOver() : void b.time.text(parseInt(this.time)))
  155. },
  156. renderMap: function() {
  157. if (!this._pause) {
  158. var b = this.lvMap * this.lvMap,
  159. c = "",
  160. d = "lv" + this.lvMap;
  161. _(b).times(function() {
  162. c += "<span></span>"
  163. }),
  164. a.attr("class", d).html(c),
  165. this.api.render(this.lvMap, this.lv)
  166. }
  167. },
  168. renderInfo: function() {
  169. b.lv.text(this.lv + 1)
  170. },
  171. gameOver: function() {
  172. var Rankstr = "";
  173. var d = this.api.getGameOverText(this.lv);
  174. dp_submitScore(this.lv,d.lv);
  175. this.lastLv = this.lv,
  176. this.lastGameTxt = d.txt,
  177. this.lastGamePercent = d.percent,
  178. b.d_content.hide(),
  179. b.d_gameover.show().find("h3").text(this.lastGameTxt),
  180. a.find("span").fadeOut(1500,
  181. function() {
  182. b.dialog.show()
  183. }),
  184. this._pause = !0,
  185. _hmt.push(["_trackEvent", "score", "score_" + (this.lv + 1)]),
  186. this.reset()
  187. },
  188. reset: function() {
  189. this.time = this.config.allTime,
  190. this.lv = -1
  191. },
  192. nextLv: function() {
  193. this.time += this.config.addTime,
  194. b.time.text(parseInt(this.time)),
  195. this._pause || this.start()
  196. },
  197. back: function() {
  198. this._pause = !0,
  199. this.el.hide(),
  200. b.dialog.hide(),
  201. this.parent.render()
  202. }
  203. };
  204. window.Game = c
  205. } (),
  206. function(a) {
  207. var b = {
  208. index: $("#index"),
  209. room: $("#room"),
  210. loading: $("#loading"),
  211. dialog: $("#dialog"),
  212. play: $(".play-btn"),
  213. btn_boyaa: $(".btn-boyaa"),
  214. banner: $(".banner"),
  215. boyaa_logo: $(".boyaa-logo")
  216. },
  217. c = window.navigator.userAgent.toLowerCase(),
  218. d = /android/i.test(c),
  219. e = /iphone|ipad|ipod/i.test(c),
  220. f = {
  221. init: function() {
  222. this.initEvent(),
  223. this.loading(),
  224. /android/i.test(c) ? (b.banner.attr("href", "").data("type", "android").find("img").attr("src", "assets/img/banner.android.jpg"), b.banner.show()) : /iphone|ipad|ipod/i.test(c) && (b.banner.attr("href", "http://wxtest.zjkso.com/").data("type", "ios").find("img").attr("src", "assets/img/banner.ios.jpg"), b.banner.show())
  225. },
  226. loading: function() {
  227. function a() {
  228. d++,
  229. d == c && f.render()
  230. }
  231. if (_config.pic.isOpen) for (var b = ["assets/img/1.png", "assets/img/2.png", "assets/img/3.png", "assets/img/4.png", "assets/img/5.png", "assets/img/6.png", "assets/img/7.png", "assets/img/8.png", "assets/img/9.png", "assets/img/10.png", "assets/img/11.png", "assets/img/12.png", "assets/img/13.png", "assets/img/14.png", "assets/img/15.png", "assets/img/16.png", "assets/img/17.png", "assets/img/18.png"], c = b.length, d = 0, e = 0; c > e; e++) {
  232. var g = new Image;
  233. g.onload = a,
  234. g.src = b[e]
  235. } else f.render();
  236. var h = _lang[_config.lang];
  237. },
  238. render: function() {
  239. setTimeout(function() {
  240. b.loading.hide(),
  241. b.index.show()
  242. },
  243. 1e3)
  244. },
  245. initEvent: function() {
  246. var a = "ontouchstart" in document.documentElement ? "touchstart": "click",
  247. c = this;
  248. b.play.on(a,
  249. function() {
  250. var a = $(this).data("type") || "color";
  251. b.index.hide(),
  252. Game.init(a, b.room, c)
  253. }),
  254. b.btn_boyaa.on(a,
  255. function() {
  256. _hmt.push(["_trackEvent", "button", "more_game"])
  257. }),
  258. b.boyaa_logo.on(a,
  259. function() {
  260. _hmt.push(["_trackEvent", "button", "boyaa_logo"])
  261. }),
  262. b.banner.on(a,
  263. function() {
  264. var a = $(this).data("t") || "",
  265. b = d ? "android": e ? "ios": "other_os";
  266. _hmt.push(["_trackEvent", "banner", b + "_" + a])
  267. })
  268. }
  269. };
  270. f.init(),
  271. a.API = {}
  272. } (window),
  273. function() {
  274. var a = $("#box"),
  275. b = "span",
  276. c = $("#help p"),
  277. d = $("#help_color"),
  278. e = {
  279. lvT: _lang[_config.lang].lv_txt,
  280. render: function(e, f) {
  281. this.lv = f,
  282. c.hide(),
  283. d.show();
  284. var g = _config.color.lvMap[f] || _.last(_config.color.lvMap);
  285. this.d = 15 * Math.max(9 - g, 1),
  286. this.d = f > 20 ? 10 : this.d,
  287. this.d = f > 40 ? 8 : this.d,
  288. this.d = f > 50 ? 5 : this.d;
  289. var h = Math.floor(Math.random() * e * e),
  290. i = this.getColor(255 - this.d),
  291. j = this.getLvColor(i[0]);
  292. var size = a.find(b).height() * 0.96;
  293. a.find(b).css("background-color", i[1]).data("type", "b").css({"background": "url(img/1.png) "+j[1], "background-size": "cover"}),
  294. a.find(b).eq(h).css("background-color", i[1]).data("type", "a").css({"background": "url(img/2.png) "+j[1], "background-size": "cover"})
  295. },
  296. getColor: function(a) {
  297. var b = [Math.round(Math.random() * a), Math.round(Math.random() * a), Math.round(Math.random() * a)],
  298. c = "rgb(" + b.join(",") + ")";
  299. return [b, c]
  300. },
  301. getLvColor: function(a) {
  302. var b = this.d,
  303. c = _.map(a,
  304. function(a) {
  305. return a + b + 10
  306. }),
  307. d = "rgb(" + c.join(",") + ")";
  308. return [c, d]
  309. },
  310. getGameOverText: function(a) {
  311. var b = 20 > a ? 0 : Math.ceil((a - 20) / 10),
  312. c = this.lvT[b] || _.last(this.lvT),
  313. d = "找到"+(a + 1)+"次蔡依林",
  314. e = a;
  315. return e = 20 > e ? 2 * a: 30 > a ? 3 * (a - 20) + 40 : 40 > a ? 1.5 * (a - 30) + 70 : 50 > a ? 1.35 * (a - 40) + 85 : 60 > a ? .05 * (a - 50) + 98.5 : 70 > a ? .02 * (a - 60) + 99 : 80 > a ? .02 * (a - 70) + 99.2 : 90 > a ? .02 * (a - 80) + 99.4 : 100 > a ? .02 * (a - 90) + 99.6 : 110 > a ? .02 * (a - 100) + 99.8 : 100,
  316. e = ("" + e).length > 5 ? e.toFixed(2) : e,
  317. {
  318. txt: d,
  319. percent: e,
  320. lv:c
  321. }
  322. }
  323. };
  324. API.color = e
  325. } ();