Created
August 31, 2014 16:21
-
-
Save potaty/56d602c0f640254fa546 to your computer and use it in GitHub Desktop.
renrenlottery.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(function() { | |
var q = !!window.ActiveXObject; | |
var p = q && !window.XMLHttpRequest; | |
var r = jQuery("#rpLotteryPop"); | |
var w = jQuery("#rpPage_popMask"); | |
var u = jQuery("#rp_lotteryDial"); | |
var y; | |
var k; | |
var v; | |
var b; | |
var n; | |
if (p) { | |
u.attr("src", "http://a.xnimg.cn/n/apps/rp/res/rp_lotteryDialNew1IE.png") | |
} | |
function z(C, B) { | |
return Math.ceil(C + Math.random() * (B - C)) | |
} | |
function f(N, F, H, M) { | |
var D; | |
if (N == 0) { | |
D = 90 | |
} else { | |
if (N == 1) { | |
D = 45 | |
} else { | |
D = (10 - N) * 45 | |
} | |
} | |
var E = z(5, 10) * 360 + z(D - 40, D - 5); | |
var C = E + 3000; | |
var I = jQuery("#lotBtnMask"); | |
var K = jQuery("#lotteryObj"); | |
var B = r.find("img"); | |
var J = r.find("#lotteryObj"); | |
var G = r.find(".useBtnNormal"); | |
var L = r.find(".changeBtn"); | |
I.show(); | |
u = jQuery("#rp_lotteryDial"); | |
u.rotate({animateTo: E,duration: C}); | |
setTimeout(function() { | |
if (N == 0 || N == 7) { | |
r.find(".first_content").find(".useBtnNormal").hide(); | |
if (N == 0) { | |
K.text("加油,再接再励!") | |
} else { | |
if (N == 7) { | |
K.html("很遗憾!<br>获得了" + F); | |
l(F, H, M); | |
t() | |
} | |
} | |
L.hide(); | |
G.hide(); | |
J.addClass("wrong"); | |
B.attr("src", "http://a.xnimg.cn/n/apps/rp/res/lotteryNoObj.jpg") | |
} else { | |
r.find(".first_content").find(".useBtnNormal").show(); | |
K.html("恭喜您!<br>获得了" + F); | |
B.attr("src", H); | |
G.show(); | |
jQuery(".lotteryPresent").removeClass("wrong"); | |
l(F, H, M) | |
} | |
a(0, null, N); | |
I.hide() | |
}, C) | |
} | |
function l(B, D, C) { | |
var E = jQuery(".rpR_hotMain"); | |
E.find(".rpR_goods").eq(4).remove(); | |
if (E.find(".rpR_goods").length == 0) { | |
E.find(".noObjTextLine").remove(); | |
E.find(".noObjImg").remove() | |
} | |
y = '<div href="javascript:void(0);" class="rpR_goods"> <img src="' + D + '"/> <div class="rpR_goodsText"> <a href="javascript:void(0)" class="rpRg_goodsName">' + B + '</a> <div class="rpRg_rpValue">' + C + '</div> </div> <input type="hidden" value="' + k + '" class="lotteryUser_id"/> <a href="javascript:void(0)" id="newLotteryItem" class="useBtnNormal" value="' + b + '">立即获取</a> </div>'; | |
jQuery(".rpR_title").after(y) | |
} | |
function a(B, F, G) { | |
r.find(".wrongTips").text(""); | |
var D = parseInt(r.find(".rpPage_popBox").css("height")); | |
var C = document.documentElement.clientHeight / 2 - D / 2; | |
var E = (document.documentElement.clientWidth - 980) / 2; | |
r.css({top: C + "px",left: E + "px"}); | |
r.show(); | |
w.css({height: document.documentElement.clientHeight + "px",width: document.documentElement.clientWidth + "px"}); | |
w.show(); | |
if (B == 1) { | |
r.find("#lotteryObj").removeClass("wrong"); | |
r.find(".first_content").hide(); | |
r.find(".second_content").show(); | |
r.find(".first_content").find(".useBtnNormal").show(); | |
r.find(".changeBtn").show(); | |
j("lotteryTelNum") | |
} else { | |
if (B == 0) { | |
if (G != 0 && G != 7) { | |
r.find("#lotteryObj").removeClass("wrong") | |
} | |
r.find(".first_content").show(); | |
r.find(".second_content").hide(); | |
r.find(".changeBtn").hide() | |
} else { | |
if (B == 2) { | |
r.find("#lotteryObj").addClass("wrong").text(F); | |
r.find("img").attr("src", "http://a.xnimg.cn/n/apps/rp/res/lotteryNoObj.jpg"); | |
r.find(".first_content").find(".useBtnNormal").hide(); | |
r.find(".first_content").show(); | |
r.find(".second_content").hide(); | |
r.find(".changeBtn").hide() | |
} | |
} | |
} | |
d() | |
} | |
function s(C) { | |
var B = typeof C == "string" ? jQuery("#" + C) : C; | |
var D = B.maxLength; | |
if (B.value.length >= D) { | |
return true | |
} else { | |
B.focus(); | |
return false | |
} | |
} | |
function d() { | |
jQuery(window).resize(function() { | |
var B = document.documentElement.clientWidth >= 980 ? document.documentElement.clientWidth : 980; | |
var D = parseInt(r.find(".rpPage_popBox").css("height")); | |
var C = document.documentElement.clientHeight / 2 - D / 2; | |
var E = (B - 980) / 2; | |
r.css({top: C + "px",left: E + "px"}); | |
w.css({height: document.documentElement.clientHeight + "px",width: B + "px"}) | |
}) | |
} | |
function j(B) { | |
} | |
var g = jQuery("#addScoreAni"); | |
function o() { | |
g.html(""); | |
g.removeClass("active") | |
} | |
function A(B) { | |
if (B >= 0) { | |
g.css({color: "#f2532f",top: "90px"}); | |
g.html("+" + B) | |
} else { | |
g.css({color: "#70c25d",top: "10px"}); | |
g.html(B) | |
} | |
g.animate({top: "45px",opacity: "1"}, 1000); | |
setTimeout(function() { | |
g.animate({top: "45px",opacity: "0"}, 500) | |
}, 2500) | |
} | |
function i(E, B, D) { | |
var C = parseInt(jQuery("#" + E).css("top")) + D; | |
jQuery("#" + E).animate({top: C,width: 350,height: 200,left: 300}, 800); | |
setTimeout(function() { | |
jQuery("#" + B).animate({opacity: "1"}, 200) | |
}, 800) | |
} | |
jQuery("#lotteryTelNum").focus(function() { | |
j("lotteryTelNum") | |
}); | |
jQuery("#rpPage_popCloseBtn").click(function() { | |
r.hide(); | |
w.hide(); | |
jQuery("#newLotteryItem").removeAttr("id"); | |
jQuery("#lotteryTelNum").val("") | |
}); | |
jQuery(".cancelBtn").click(function() { | |
r.hide(); | |
w.hide(); | |
jQuery("#newLotteryItem").removeAttr("id"); | |
jQuery("#lotteryTelNum").val("") | |
}); | |
jQuery(".submitBtn").click(function() { | |
if (s(r.find("input")[0])) { | |
var B = r.find("input")[0].value; | |
new XN.net.xmlhttp({url: "http://renpin.renren.com/mall/lottery/use",method: "post",data: "id=" + k + "&mobile=" + B,onSuccess: function(E) { | |
var C = XN.json.parse(E.responseText); | |
if (C.code != 0) { | |
XN.DO.showMessage(C.msg) | |
} else { | |
var F = jQuery(".top_content"); | |
var D = jQuery(".bottomBtn"); | |
F.hide(); | |
D.hide(); | |
jQuery("#rpLotSucAffirm").find("img").attr("src", "http://a.xnimg.cn/n/apps/rp/res/successEx.jpg"); | |
r.find("#rpSuccessObj").text('"' + n + '"'); | |
i("rpLotChanBox", "rpLotSucAffirm", 15); | |
setTimeout(function() { | |
r.hide(); | |
w.hide(); | |
F.show(); | |
D.show(); | |
r.find(".rpPage_popBox").css({width: "400px",height: "230px",left: "290px"}); | |
document.getElementById("rpLotSucAffirm").filter = "alpha(opacity=0)"; | |
jQuery("#rpLotSucAffirm").css("opacity", 0); | |
r.find(".wrongTips").html(""); | |
if (jQuery("#newLotteryItem").length > 0) { | |
v = jQuery("#newLotteryItem") | |
} | |
v.addClass("inactive"); | |
v.html("已获取"); | |
v.removeAttr("id"); | |
jQuery("#lotteryTelNum").val("") | |
}, 5000) | |
} | |
}}) | |
} else { | |
r.find(".wrongTips").text("*请输入正确的手机号码") | |
} | |
}); | |
jQuery(".lotBtn").click(function() { | |
o(); | |
new XN.net.xmlhttp({url: "http://renpin.renren.com/mall/lottery/dolottery",method: "post",onSuccess: function(D) { | |
var B = XN.json.parse(D.responseText); | |
if (B.code != 0) { | |
if (B.code == 6) { | |
a(2, "不好意思,你的人品好像差一点喔,快去多攒攒吧") | |
} else { | |
if (B.code == 11) { | |
a(2, "不好意思,今天已经抽过20次了,明天再来吧") | |
} else { | |
XN.DO.showMessage(B.msg) | |
} | |
} | |
} else { | |
f(B.result, B.name, B.pic, B.time); | |
var C = jQuery("#rpCurrValue").text(); | |
jQuery("#nowRemainTime").text(B.remainCount); | |
n = B.name; | |
jQuery("#rpCurrValue").text(B.remainRp.toString()); | |
A(-B.costRp); | |
b = B.type; | |
k = B.id | |
} | |
}}) | |
}); | |
r.find(".useBtnNormal").click(function() { | |
o(); | |
if (b == 0) { | |
new XN.net.xmlhttp({url: "http://renpin.renren.com/mall/lottery/use",method: "post",data: "id=" + k,onSuccess: function(C) { | |
var B = XN.json.parse(C.responseText); | |
if (B.code != 0) { | |
XN.DO.showMessage(B.msg) | |
} else { | |
r.hide(); | |
w.hide(); | |
jQuery("#rpCurrValue").text(B.myrp.toString()); | |
A(parseInt(B.lotteryRp)); | |
jQuery("#newLotteryItem").addClass("inactive"); | |
jQuery("#newLotteryItem").html("已获取"); | |
jQuery("#newLotteryItem").removeAttr("id") | |
} | |
}}) | |
} else { | |
if (b == 1) { | |
a(1) | |
} | |
} | |
}); | |
function t() { | |
o(); | |
new XN.net.xmlhttp({url: "http://renpin.renren.com/mall/lottery/use",method: "post",data: "id=" + k,onSuccess: function(C) { | |
var B = XN.json.parse(C.responseText); | |
if (B.code != 0) { | |
XN.DO.showMessage(B.msg) | |
} else { | |
jQuery("#rpCurrValue").text(B.myrp.toString()); | |
A(parseInt(B.lotteryRp)); | |
jQuery("#newLotteryItem").addClass("inactive"); | |
jQuery("#newLotteryItem").html("已获取"); | |
jQuery("#newLotteryItem").removeAttr("id") | |
} | |
}}) | |
} | |
jQuery(document).on("click", ".rpR_goods .useBtnNormal", function() { | |
o(); | |
if (!jQuery(this).hasClass("inactive")) { | |
b = jQuery(this).attr("value"); | |
var B = jQuery(this).siblings(".lotteryUser_id").val(); | |
v = jQuery(this); | |
n = jQuery(this).siblings(".rpR_goodsText").find(".rpRg_goodsName").text(); | |
if (b == 1) { | |
a(1) | |
} else { | |
if (b == 0) { | |
new XN.net.xmlhttp({url: "http://renpin.renren.com/mall/lottery/use",method: "post",data: "id=" + B,onSuccess: function(D) { | |
var C = XN.json.parse(D.responseText); | |
if (C.code != 0) { | |
XN.DO.showMessage(C.msg) | |
} else { | |
v.addClass("inactive"); | |
v.html("已获取"); | |
jQuery("#rpCurrValue").text(C.myrp.toString()); | |
A(parseInt(C.lotteryRp)) | |
} | |
}}) | |
} | |
} | |
} | |
}); | |
var c = new Image(); | |
var h = jQuery(".userLink").find("img"); | |
m(); | |
function m() { | |
if (c.src != h.attr("src")) { | |
c.src = h.attr("src") | |
} | |
if (e()) { | |
x(); | |
h.show() | |
} else { | |
setTimeout(function() { | |
m() | |
}, 100) | |
} | |
} | |
function x() { | |
var C = c.width; | |
var B = c.height; | |
if (C >= B) { | |
h.addClass("vertical"); | |
_left = -(100 * (C / B) - 100) / 2; | |
h.css({marginLeft: _left + "px"}) | |
} else { | |
_top = -(100 * (B / C) - 100) / 2; | |
h.css({marginTop: _top + "px"}) | |
} | |
} | |
function e() { | |
if (!!window.ActiveXObject) { | |
if (c.readyState == "complete") { | |
return true | |
} else { | |
return false | |
} | |
} else { | |
if (c.complete == true) { | |
return true | |
} else { | |
return false | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment