色婷婷狠狠18禁久久YY,CHINESE性内射高清国产,国产女人18毛片水真多1,国产AV在线观看

jquery lottery

jQuery Lottery(抽獎(jiǎng)插件)是一款基于jQuery框架的抽獎(jiǎng)工具,其具有操作簡單、適用范圍廣泛等優(yōu)點(diǎn),已經(jīng)獲得了許多用戶的歡迎和認(rèn)可。

<script>
$(function() {
var lottery = {
index: -1, //當(dāng)前轉(zhuǎn)動(dòng)到哪個(gè)位置,起點(diǎn)位置
count: 0, //總共有多少個(gè)位置
timer: 0, //setTimeout的ID,用clearTimeout清除
speed: 20, //初始轉(zhuǎn)動(dòng)速度
times: 0, //轉(zhuǎn)動(dòng)次數(shù)
cycle: 50, //轉(zhuǎn)動(dòng)基本次數(shù):即至少需要轉(zhuǎn)動(dòng)多少次再進(jìn)入抽獎(jiǎng)環(huán)節(jié)
prize: -1, //中獎(jiǎng)位置
init: function(id) {
if ($("#" + id).find(".lottery-unit").length >0) {
$lottery = $("#" + id);
$units = $lottery.find(".lottery-unit");
this.obj = $lottery;
this.count = $units.length;
$lottery.find(".lottery-unit.lottery-unit-" + this.index).addClass("active");
}
},
roll: function() {
var index = this.index;
var count = this.count;
var lottery = this.obj;
$(lottery).find(".lottery-unit.lottery-unit-" + index).removeClass("active");
index += 1;
if (index >count - 1) {
index = 0;
}
$(lottery).find(".lottery-unit.lottery-unit-" + index).addClass("active");
this.index = index;
return false;
},
stop: function(index) {
this.prize = index;
return false;
}
};
function roll() {
lottery.times += 1;
lottery.roll();
if (lottery.times >lottery.cycle + 10 && lottery.index == lottery.prize) {
clearTimeout(lottery.timer);
lottery.prize = -1;
lottery.times = 0;
click = false;
} else {
if (lottery.times< lottery.cycle) {
lottery.speed -= 10;
} else if (lottery.times == lottery.cycle) {
var index = Math.random() * (lottery.count) | 0;
lottery.prize = index;
} else {
if (lottery.times >lottery.cycle + 10 && (lottery.prize == 0 && lottery.index == 7) || lottery.prize == lottery.index + 1) {
lottery.speed += 110;
} else {
lottery.speed += 20;
}
}
if (lottery.speed< 40) {
lottery.speed = 40;
}
lottery.timer = setTimeout(roll, lottery.speed);
}
return false;
}
var click = false;
lottery.init('lottery');
$(".draw-btn").click(function() {
if (click) {
return false;
} else {
lottery.speed = 100;
roll();
click = true;
return false;
}
});
});
</script>

以上為jQuery Lottery的代碼,其實(shí)現(xiàn)原理是根據(jù)每個(gè)獎(jiǎng)品格子的編號(hào),通過不斷地更改樣式來模擬抽獎(jiǎng)的過程,最終確定中獎(jiǎng)號(hào)碼,同時(shí)也可以通過修改代碼中的參數(shù)來控制抽獎(jiǎng)的速度、轉(zhuǎn)動(dòng)次數(shù)等參數(shù),從而實(shí)現(xiàn)不同的抽獎(jiǎng)體驗(yàn),使其變得更加有趣和刺激。