代码拉取完成,页面将自动刷新
define(function (require, exports, module) {
var request = require("request");
var common = require("common");
var _cookie = require("cookie_v");
var obj = {};
//私有变量
var _private = {
date: null, //日期
filter: {//号码筛选数据
select: {
numbers: "",//选中的号码
twoside: ""//选中两面
},
data: {//大小单双对应的号码
"": "",
"0": "06,07,08,09,10",//大
"1": "01,02,03,04,05",//小
"2": "01,03,05,07,09",//单
"3": "02,04,06,08,10",//双
"02": "07,09",//大单
"03": "06,08,10",//大双
"12": "01,03,05",//小单
"13": "02,04"//小单
}
},
subDisabled: false, //对子是否禁用,
tableTypeBtnDisabled: false,// 切换Table显示内容Btn
tableShowTypeCode: "number"
};
//页面所需元素
var _eles = {
refreshEle: $("#history tbody"),//需要动态刷新的元素
copyTableEle: $("#historyCopy tbody"),
tableTypeEle: $("#history thead .tb_titleBtnBlock"),//切换Table显示内容
clone: {
tbody: null,
spans: {//获取号码
data: null,
len: 0
},
divs: {//获取号码区域块
data: null,
len: 0
}
}
};
//WinDow
var _winDow = {
targetEle: null,
init: function (ele) {
this.targetEle = ele;
$(".historyKaiJiang_dataBlock .close").click(function () {
_winDow.hide(ele);
});
},
show: function () {
$(".window_MaskLayer").show();
$(this.targetEle).show();
},
hide: function (ele) {
//窗口关闭事件
$(".window_MaskLayer").hide();
$(this.targetEle).hide();
}
};
//元素克隆
var _clone = function () {
_eles.clone.tbody = _eles.refreshEle.clone();
_eles.clone.divs.data = _eles.clone.tbody.find("tr td div");//获取号码区域块
_eles.clone.divs.len = _eles.clone.divs.data.length;
_eles.clone.spans.data = _eles.clone.divs.data.find("span");//获取号码
_eles.clone.spans.len = _eles.clone.spans.data.length;
};
//事件
var _event = {
UI: {
selectDate: function () {//选择日期
var SelectDateView = common.selectDateEffect('#select_date', function (date) {
_private.date = date;
});
new SelectDateView();
},
plateSwith: function (ele) {//面板控制
if (ele.tagName == "SPAN") {
$(ele).toggleClass("active");
ele = ele.parentNode;
}
else {
$(ele).children("span").toggleClass("active");
};
var code = ele.getAttribute("data-code");
//if ($(ele).children(0).hasClass("active"))
//{
// $(".lotteryPublic_contentBlock div[data-code*='" + code + "']").show();
//}
//else {
// $(".lotteryPublic_contentBlock div[data-code*='" + code + "']").hide();
//}
//if (_eles.plate.divs.filter("div[data-code*='" + code + "']").is(':hidden'))
//{
// _eles.plate.divs.filter("div[data-code*='" + code + "']").show();
//}
//else
//{
// _eles.plate.divs.filter("div[data-code*='" + code + "']").hide();
//}
if ("ballStat" == code && $(ele).children(0).hasClass("active")) {
setTimeout(_event.Ajax.ballStat, 1000);
} else if ("changLongWarn" == code && $(ele).children(0).hasClass("active")) {
setTimeout(_event.Ajax.changLongWarn, 1000);
}
$(".lotteryPublic_contentBlock div[data-code*='" + code + "']").toggle();
_cookie.setCookie(_private.lotteryCode + "-" + code, ($(ele).children("span").hasClass("active") ? 1 : 0), 180);
},
restore: function () {//恢复
var ele = null;
for (var i = 0; i < _eles.clone.spans.len; i++) {
ele = _eles.clone.spans.data[i];
ele.className = "num" + ele.getAttribute("data-number");
};
_eles.refreshEle.html(_eles.clone.tbody[0].innerHTML);
},
filter: function () {//过滤
var result = _private.filter.select.numbers + _private.filter.data[_private.filter.select.twoside];
if (result == "") {
_private.tableTypeBtnDisabled = false;
_event.UI.restore();
return;
}
var ele = null, r = false, style = "text";
for (var i = 0; i < _eles.clone.spans.len; i++) {
r = false;
ele = _eles.clone.spans.data[i];
ele.className = "num" + ele.getAttribute("data-number");
r = result.indexOf(ele.getAttribute("data-number")) > -1;
if (!r) {
if (ele.className.indexOf(style) < 0) {
ele.className += " " + style;
}
}
};
_eles.refreshEle.html(_eles.clone.tbody[0].innerHTML);
},
subFilter: function () {//对子过滤
var i, len = _eles.clone.spans.len, ele = null, afterEle = null;
for (i = 0; i < len; i++) {
ele = _eles.clone.spans.data[i];
if (ele.className.indexOf("duizhi") == -1) {
ele.className += " text";
};
afterEle = null;
if (i + 10 < len) {
afterEle = _eles.clone.spans.data[i + 10];
};
if (afterEle != null && ele.getAttribute("data-number") == afterEle.getAttribute("data-number")) {
if (ele.className.indexOf("duizhi") == -1) {
ele.className += " duizhi";
ele.className = ele.className.replace(/text/g, "");
}
afterEle.className += " duizhi";
afterEle.className = afterEle.className.replace(/text/g, "");
}
};
_eles.refreshEle.html(_eles.clone.tbody[0].innerHTML);
},
numberFilter: function (ele) {//车号筛选
var code = ele.getAttribute("data-code"), defaultClass = "checkbox";
if (!code && ele.tagName == "SPAN") {
ele = ele.parentNode;
code = ele.getAttribute("data-code");
}
if (!code || code == "number_search") {
return;
};
if (code == "number") {
if (_private.filter.select.numbers != "") {
$(_eles.filter.number).removeClass("active");
_private.filter.select.numbers = "";
_event.UI.filter();
}
}
else {
ele = ele.firstChild;
if (ele.tagName == "SPAN") {
if (ele.className.indexOf("active") > -1) {
ele.className = defaultClass;
_private.filter.select.numbers = _private.filter.select.numbers.replace(code + ",", "");
} else {
ele.className += " active";
_eles.filter.twoside.filter(":last").removeClass("active");
_private.filter.select.numbers += code + ",";
}
_event.UI.filter();
}
}
},
twosideFilter: function (ele) {//两面筛选
var code = ele.getAttribute("data-code"), defaultClass = "checkbox", next = false;
if (!code && ele.tagName == "SPAN") {
ele = ele.parentNode;
code = ele.getAttribute("data-code");
}
if (!code || code == "side_search") {
return;
};
if (code == "side") {
if (_private.filter.select.twoside != "") {
_eles.filter.twoside.removeClass("active");
_private.filter.select.twoside = "";
_event.UI.filter();
}
}
else if (code == "sub") {
if (!_private.subDisabled) {
ele = ele.firstChild;
if (ele.tagName == "SPAN") {
if (ele.className.indexOf("active") > -1) {
ele.className = defaultClass;
_private.tableTypeBtnDisabled = false;
_event.UI.restore();
}
else {
ele.className += " active";
_eles.filter.number.removeClass("active");
_eles.filter.twoside.not(":last").removeClass("active");
_private.filter.select.numbers = _private.filter.select.twoside = "";
_private.tableTypeBtnDisabled = true;
_event.UI.subFilter();
}
}
}
}
else if (code == "copy") {
_event.UI.copyTable();
}
else {
ele = ele.firstChild;
if (ele.tagName == "SPAN") {
_eles.filter.twoside.last().removeClass("active");
if (ele.className.indexOf("active") > -1) {
ele.className = defaultClass;
_private.filter.select.twoside = _private.filter.select.twoside.replace(code, "");
}
else {
ele.className += " active";
code = Number(code);
if (code < 2) {
_private.filter.select.twoside = code + _private.filter.select.twoside;
code = 1 - code;
}
else {
_private.filter.select.twoside = _private.filter.select.twoside + code;
code = (3 - code) + 2;
};
ele = _eles.filter.twoside[code];
ele.className = defaultClass;
_private.filter.select.twoside = _private.filter.select.twoside.replace(code, "");
}
_event.UI.filter();
}
}
},
copyTable: function () {//复制开奖
var tempHtml = "";
var Trs = _eles.refreshEle.find("tr:lt(20)"), len = Trs.length, i = 0, j = 0;
for (var i = 0; i < len; i++) {
tempHtml += "<tr>";
tempHtml += "<td>" + Trs[i].children[0].children[0].innerText + "</td>";
tempHtml += "<td>" + Trs[i].children[0].children[1].innerText + "</td>";
$(Trs[i].children[1]).find("span").each(function (k, item) {
tempHtml += "<td>" + item.getAttribute("data-number") + "</td>";
});
for (j = 2; j < 10; j++) {
tempHtml += "<td>" + Trs[i].children[j].innerText + "</td>";
};
};
_eles.copyTableEle.html(tempHtml);
_winDow.show();
},
tableShowType: function (code) {
var disClassName = "number_pk10";
if (code != "number") {
disClassName += " number_" + code;
}
var i = 0;
while (i < _eles.clone.divs.len) {
_eles.clone.divs.data[i].className = disClassName;
i++;
};
_eles.refreshEle.html(_eles.clone.tbody.html());
}
},
Ajax: {
query: function () {
if (_private.date) {
request.Async({ url: "/" + _private.lotteryCode + "/kaijiang", data: { date: _private.date }, dataType: "html" }).then(function (result) {
setTimeout(function () {
_eles.refreshEle.html(result);
_clone();
_eles.filter.number.removeClass("active");
_eles.filter.twoside.removeClass("active");
var btns = _eles.tableTypeEle.find(".colorWorld_button");
btns.removeClass("active");
_eles.firstTableBtn = btns[0];
$(btns[0]).addClass("active");
_private.filter.select.numbers = _private.filter.select.twoside = "";
_private.subDisabled = _private.tableTypeBtnDisabled = false;
alert('js')
}, 0)
}, function (err) { })
}
},
ballStat: function () {
request.Async({ url: "/stat/ballstat", data: { lottery: _private.lotteryCode, dirName: encodeURIComponent("racing/shared") }, dataType: "json" }).then(function (result) {
var tempHtml = "";
for (var i = 0, len = result.Data.length; i < len; i++) {
tempHtml += "<td>" + result.Data[i].big + "</td><td>" + result.Data[i].small + "</td><td>" + result.Data[i].odd + "</td><td>" + result.Data[i].even + "</td>";
};
$("#ballStatTr").html(tempHtml);
}, function (err) {
})
},
changLongWarn: function () {
request.Async({ url: "/stat/changlongwarn", data: { lottery: _private.lotteryCode }, dataType: "html" }).then(function (result) {
$("#changLongWarn_refresh").html(result);
}, function (err) { })
}
}
};
//刷新
obj.getNewHistory = null;
obj.refresh = function (result) {
if (_private.lotteryCode == "pk10") {
if (_cookie.getCookie("pk10-ballStat") != "0") {
$(".lotteryPublic_contentBlock div[data-code='ballStat']").show();
setTimeout(_event.Ajax.ballStat, 10000);
} else {
$(".lotteryPublic_contentBlock div[data-code='ballStat']").hide();
}
if (_cookie.getCookie("pk10-changLongWarn") != "0") {
$("#changLongWarn_refresh").show();
setTimeout(_event.Ajax.changLongWarn, 15000);
} else {
$("#changLongWarn_refresh").hide();
}
if (_cookie.getCookie("pk10-search") == "0")
{
$(".lotteryPublic_contentBlock div[data-code='number_search']").hide();
$(".lotteryPublic_contentBlock div[data-code='side_search']").hide();
}
};
if (!_private.date || _private.date == result.current.awardTime.substring(0, 10)) {
var tempEle = $(obj.getNewHistory(result)); //更新历史开奖
if (_private.tableShowTypeCode !== "number") {
tempEle.find(".number_pk10").addClass("number_" + _private.tableShowTypeCode);
};
if (_private.lotteryCode == "pk10") {
if ($($("#history td")[0]).text().indexOf(result.current.period) >= 0) {
return false;
}
} else {
var _datePeriod = (result.current.awardTime.substring(0, 10).replace(/-/g, '')) + "-" + (result.current.period < 10 ? "00" + result.current.period : (result.current.period < 100 ? "0" + result.current.period : result.current.period));
console.log(_datePeriod);
if ($($("#history td")[0]).text().indexOf(_datePeriod) >= 0) {
return false;
}
}
//变色
tempEle[0].className = _eles.clone.tbody.children().eq(0).hasClass("bg_gray") ? "" : "bg_gray";
_eles.refreshEle.prepend(tempEle[0]);//添加最新的记录
_eles.refreshEle.children(":last").remove();
_eles.clone.tbody.prepend((tempEle.clone())[0]);
_eles.clone.tbody.children(":last").remove();
_eles.clone.divs.data = _eles.clone.tbody.find("tr td div");//获取号码区域块
_eles.clone.spans.data = _eles.clone.divs.data.find("span");//获取号码
if (_private.tableTypeBtnDisabled) {//对子状态
_event.UI.subFilter();
}
else {
if (_private.filter.select.numbers || _private.filter.select.twoside) {
_event.UI.filter();
};
};
}
};
//初始化
obj.init = function (lotteryCode) {
_private.lotteryCode = lotteryCode;
$("#history .tb_DartBlock")[0].innerHTML='<span class="colorWorld_button"><span class="font">运行插件</span></span>'
//选择日期
_event.UI.selectDate();
$("#dayBtn").click(function () {
_event.Ajax.query();
});
//面板控制事件
_eles.plate = {
checkboxs: $(".lotteryPublic_titleBlock .lp_tb_checkboxBlock"),
divs: $(".lotteryPublic_contentBlock div[data-code]")
};
_eles.plate.checkboxs.click(function (event) {
_event.UI.plateSwith(event.target);
});
//面板Cookie设置
_eles.plate.checkboxs.children().each(function () {
var code = $(this).attr("data-code");
var value = _cookie.getCookie(_private.lotteryCode + "-" + code);
if (value == 0) {
$(this).children("span").removeClass("active");
_eles.plate.divs.filter("div[data-code*='" + code + "']").hide();
} else {
$(this).children("span").addClass("active");
}
});
_clone();//元素克隆
_eles.filter = { //历史号码筛选
number: _eles.plate.divs.filter("div[data-code='number_search']").find("span"),
twoside: _eles.plate.divs.filter("div[data-code='side_search']").find("div[data-code]").find("span")
};
//查看车号分布
_eles.plate.divs.filter("div[data-code='number_search']").click(function (event) {
_event.UI.numberFilter(event.target);
});
//大小单双分布
_eles.plate.divs.filter("div[data-code='side_search']").click(function (event) {
_event.UI.twosideFilter(event.target);
});
//遮罩
_winDow.init("#historyCopy");
//切换Table显示内容
_eles.firstTableBtn = _eles.tableTypeEle.find(".colorWorld_button:eq(0)")[0];
_eles.tableTypeEle.click(function (event) {
if (_private.tableTypeBtnDisabled) {
return;
};
var ele = event.target, code = ele.getAttribute("data-code");
if (ele.tagName == "SPAN") {
if (code == null) {
ele = ele.parentNode;
code = ele.getAttribute("data-code");
};
if (ele.className.indexOf("active") == -1) {
_private.subDisabled = code != "number";
_eles.firstTableBtn.className = "colorWorld_button";
ele.className += " active";
_eles.firstTableBtn = ele;
_private.tableShowTypeCode = code;//记录选择的显示类型
_event.UI.tableShowType(code);
}
}
});
};
module.exports = obj;
});
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。