Skip to content

Instantly share code, notes, and snippets.

@pyrocat101
Created December 23, 2011 14:34
Show Gist options
  • Save pyrocat101/1514362 to your computer and use it in GitHub Desktop.
Save pyrocat101/1514362 to your computer and use it in GitHub Desktop.
豆瓣电影2011彩蛋脚本
Do.ready("tmpl", "share", function () {
var f = $("body"),
b = f.attr("data-cover").split(","),
h = 0,
a = $("#summary-2011"),
d = $("#summary-hd"),
g = $("#summary-bd"),
c = $("#summary-ft");
$.fn.resortMovie = function () {
$(this).one("click", function (m) {
var k = $("li:not(.hide)").index($(this)),
l = $(m.target),
j = b[k];
l.removeClass("cursor").animate({
opacity: "0"
}, 300, function () {
l.css({
background: 'url("' + j + '") repeat 0 0'
}).animate({
opacity: "1"
}, 300, function () {
h += 1;
if (h === 33) {
setTimeout(function () {}, 500)
}
})
})
})
};
function i() {
var q = $("li:not(.hide)"),
m = q.length,
o = [],
k = [],
j = [],
n;
for (n = 0; n < m; n++) {
o.push(n);
k.push(n);
j.push(n)
}
o.sort(function () {
return 0.5 - Math.random()
});
k.sort(function () {
return 0.5 - Math.random()
});
j.sort(function () {
return 0.5 - Math.random()
});
function p() {
if (o.length) {
var u = o.pop(),
t = j.pop(),
r = b[u];
$(q.get(t)).css({
background: 'url("' + r + '") repeat 0 0'
}).fadeIn("slow").delay(200).fadeOut("slow")
} else {
clearInterval(l);
var s = setInterval(function () {
if (k.length) {
u = k.pop();
$(q.get(u)).fadeIn("slow")
} else {
clearInterval(s);
var v = [function () {
$("#decimal").animate({
marginLeft: "-=68"
}, 200, w)
}, function () {
$("#unit").animate({
marginLeft: "-=68"
}, 200, w)
}, function () {
$("#hundred").animate({
marginLeft: "+=68"
}, 200, w)
}, function () {
$("#summary-2011").animate({
width: "-=68"
}, 200, w)
}, function () {
setTimeout(function () {
if (b.length < 15) {
c.empty().append('<p style="font-size:24px;">你今年看的电影也太少了吧</p>')
}
c.animate({
opacity: 1
}, 400, function () {
c.find(".text").animate({
opacity: 1
}, 200, function () {
setTimeout(function () {
c.find("strong").animate({
opacity: 1
}, 2000, function () {
setTimeout(function () {
if (c.find(".tags").length) {
c.find(".tags").animate({
opacity: "1"
}, 2000, function () {
setTimeout(function () {
$("#you-are-the-apple-of-my-eye").fadeIn("1000");
$("#the-da-vinci-code").focus()
}, 1000)
})
} else {
setTimeout(function () {
$("#you-are-the-apple-of-my-eye").fadeIn("1000");
$("#the-da-vinci-code").focus()
}, 1000)
}
}, 1000)
})
}, 1000)
})
})
}, 600)
}],
w = function () {
setTimeout(function () {
d.dequeue("anims")
}, 200)
};
d.queue("anims", v);
w()
}
}, 200)
}
}
var l = setInterval(p, 200)
}
function e() {
var k = $("#number-tmpl-zero").tmpl({
id: "hundred"
}),
o = $("#number-tmpl-one").tmpl({
id: "decimal"
}),
j = $("#number-tmpl-one").tmpl({
id: "unit"
}),
m = $("#number-tmpl-two").tmpl({
id: "thousand"
}),
l = 0;
var p = [function () {
d.append(m).append(k).append(o).append(j).fadeIn(function () {
setTimeout(i, 500)
})
}],
n = function () {
setTimeout(function () {
d.empty();
a.dequeue("animations")
}, 600)
};
a.queue("animations", p);
n()
}
$("#the-da-vinci-code").bind("click", function () {
var j = $("#star-trek");
if (!j.hasClass("expand")) {
j.addClass("expand").animate({
height: "460",
marginTop: "-460",
opacity: ".9"
}, 500, function () {
$("#paul").html("");
$("#the-da-vinci-code").focus()
})
}
return false
}).bind("keyup", function (q) {
var r = $("li:not(.hide)"),
o = $("#star-trek"),
n = $("#paul"),
s = $("#you-are-the-apple-of-my-eye");
if (q.keyCode === 13) {
var m = $.trim($(this).val().replace(/ /g, "")).toLowerCase(),
j = ["christophernolan", "woodyallen", "davidlynch", "peterjackson", "ericrohmer", "alejandrogonzáleziñárritu", "darrenaronofsky", "timburton", "pedroalmodóvar", "侯孝贤", "李安", "黑泽明", "徐克", "堤幸彦", "岩井俊二", "宫崎骏"];
if ($.inArray(m, j) > 0) {
m = "inception"
}
switch (m) {
case "sort":
o.animate({
height: "20",
marginTop: "0"
}, 200, function () {
$(this).removeClass("expand");
r.addClass("cursor").resortMovie()
});
break;
case "2012":
n.html('<p>如果你有10亿欧元,可以去 <a href="http://movie.douban.com/subject/1292000/">搏击俱乐部</a> 处兑换参赛门票一张。如果你能打赢一场的话,说不定可以拿到船票。</p>');
break;
case "exit":
n.empty();
o.removeClass("expand").animate({
marginTop: "0"
}, 200);
break;
case "iseedeadpeople":
o.animate({
marginTop: "0"
}, 200, function () {
var t = [],
u;
$(this).removeClass("expand");
r.addClass("cursor").resortMovie();
for (u = 0; u < 33; u++) {
t.push(u)
}
t.sort(function () {
return 0.5 - Math.random()
});
var v = setInterval(function () {
if (t.length) {
u = t.pop();
$(r.get(u)).click()
} else {
clearInterval(v)
}
}, 200)
});
break;
case "inception":
function p() {
var u = [function () {
a.show("600", t);
c.find("p").hide();
$(document).unbind()
}, function () {
var v = $('<div id="see-u-2012"><h3>2012</h3><p>你还能看几部电影?</p></div>');
g.append(v).show("600", t)
}, function () {
g.animate({
opacity: "1",
height: "450"
}, 3000, t)
}, function () {
setTimeout(function () {
$("#source-code").fadeIn("slow")
}, 1000)
}],
t = function () {
g.dequeue("animations")
};
g.queue("animations", u);
setTimeout(t, 1000)
}
function l(A, t, B) {
var u = A.length,
x = t + B > u ? u : t + B,
v = $('<div id="comments"></div>'),
y;
if (t >= x || x - t < B / 2) {
p();
return
}
for (y = t; y < x; y++) {
var z = A[y];
v.append(z)
}
$("body").append(v).css({
opacity: "1"
});
var w = [function () {
v.animate({
opacity: "1"
}, 3000, C)
}, function () {
setTimeout(function () {
v.animate({
opacity: "0"
}, 3000, C)
}, 600)
}, function () {
setTimeout(function () {
$("#comments").remove();
l(A, x, 10)
}, 600)
}],
C = function () {
f.dequeue("animation")
};
f.queue("animation", w);
C()
}
var k = [];
$.get("/j/final2011_comment", function (t) {
$.each(t, function (w, u) {
var y = {
comment: u[2],
star: u[0],
date: u[1].split(" ")[0],
movie: w
},
x = $("#comment-tmpl").tmpl(y);
k.push(x)
});
if (k.length < 10) {
n.html("显然,你的对白不够多。");
return
}
$("#the-da-vinci-code").blur();
s.remove();
o.removeClass("expand").animate({
marginTop: "0"
}, 200, function () {
o.remove();
c.find(".text, strong, .tags").animate({
opacity: "0"
}, 500);
d.animate({
opacity: "0"
}, 500, function () {
var u = k.length;
d.empty();
a.hide();
l(k, 0, 10)
})
})
});
break;
default:
n.html("Who is the good movie's daddy?")
}
$(this).val("")
}
});
$(document).bind("click", function (j) {
if (!$(j.target).parent("#star-trek").length) {
$("#paul").empty();
$("#the-da-vinci-code").val("");
$("#star-trek").stop().removeClass("expand").animate({
height: "20",
marginTop: "0"
}, 500)
}
});
setTimeout(e, 500);
$("#the-da-vinci-code").val("")
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment