index4.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. Zepto(function ($) {
  2. function m() {
  3. setTimeout(function () {
  4. var e = new Date * 1;
  5. if (e - a > u) {
  6. T();
  7. return
  8. }
  9. var t = w();
  10. c.css("left", i[t]), s = t, m()
  11. }, b())
  12. }
  13. function b() {
  14. var e = y[g++] || 1e3;
  15. return e
  16. }
  17. function w() {
  18. var e = Math.floor(Math.random() * 9 / 3);
  19. return e === s ? w() : e
  20. }
  21. function E() {
  22. g = 0, s = 1, f = 0, a = new Date * 1, o = !0, c.show().css("left", i[s]), m(), x()
  23. }
  24. function x() {
  25. v.show(), S = setInterval(function () {
  26. var e = ((1e4 - new Date * 1 + a) / 1e3).toFixed(1);
  27. if (e <= 0) {
  28. clearInterval(S), T(), v.html("0.0");
  29. return
  30. }
  31. v.html(e)
  32. }, 20)
  33. }
  34. function T() {
  35. if (!o)return;
  36. o = !1, c.hide(), v.hide(), $("#scoreScreen").show().find(".desc em").html(f), N(), setTimeout(function () {
  37. $(".baidu").show()
  38. }, 1e3)
  39. }
  40. function N() {
  41. dataForWeixin.title = "疯狂挠痒痒,我在10秒内挠了" + f + "次痒痒,你敢来挑战么?";
  42. }
  43. function k() {
  44. if (C)return;
  45. C = !0, c.addClass("animate"), c.on("webkitAnimationEnd", function () {
  46. c.removeClass("animate"), C = !1
  47. })
  48. }
  49. function A(e) {
  50. h.show().css("left", i[e]), clearTimeout(L), h.hasClass("animate") ? h.removeClass("animate") : h.addClass("animate"), L = setTimeout(function () {
  51. h.hide()
  52. }, 300)
  53. }
  54. function O(e) {
  55. e == s && (k(), M(e))
  56. }
  57. function M(e) {
  58. f++;
  59. var t = $('<div class="add1"></div>').appendTo(document.body);
  60. t.css("left", i[e] + (n - 56) / 2), t.addClass("animate"), t.on("webkitAnimationEnd", function () {
  61. t.remove()
  62. })
  63. }
  64. function _() {
  65. p.css("left", (e - 100) / 2), p.show().addClass("animate"), p.on("webkitAnimationEnd", function () {
  66. p.hide(), E()
  67. })
  68. }
  69. var e = $(window).width(), t = $(window).height(), n = Math.floor(e / 3), r = 105, i = [Math.max((n - r) / 2, -10), (e - r) / 2, n * 2 + (n - r) / 2], s = 1, o = !1, u = 1e4, a = 0, f = 0, l = "", c = $(".feet").css("top", (t - 275) / 2), h = $(".feather").css("top", (t - 180) / 2), p = $("#go").css("top", (t - 160) / 2), d = $(".intro").css("top", (t - 320) / 2), v = $("#time"), g = 0, y = [1e3, 2e3, 1500, 1500, 1e3, 1e3, 1e3], S = 0, C = !1, L = 0;
  70. $(".buttons .col").tap(function () {
  71. if (!o)return;
  72. var e = $(this).attr("data-index");
  73. O(e), A(e)
  74. }), $("#start").tap(function () {
  75. d.hide(), _()
  76. }), $(".retry").tap(function () {
  77. $("#scoreScreen, .baidu").hide(), _()
  78. })
  79. });