var filterHelper = new FilterHelper();
var loaded = 0, LoadTime = 0, nofityTimer, matchType = -1, runtimeTimer, getoddsxmlTimer, LoadLiveFileTimer;
var loadDetailFileTime = new Date();
var loadVideoFileTime = new Date();
var oldOddsXML;
var lastUpdateTime, oldUpdateTime = "", oldXML = "";
var lastUpdateFileTime = 0;
var oXmlHttp = zXmlHttp.createRequest();
var needSound = false;
var orderby = "time";
var oldLetBig = 0; //判断让球 大小是否有切换
var strCompanyID = ",3,23,24,31,";
var concernIds = getCookie("concernIds").split(",");
if (concernIds[0] === "")
concernIds.splice(0, 1);
var flashScheduleIDs = "";
var jcIdList = "", idList = "";
function GetXml(url, doSuccess) {
$.ajax({ url: url, type: 'get', async: false, dataType: 'XML', success: doSuccess });
}
function getXmlChildNodes_Text(childNodes, index) {
return childNodes.length > index ? childNodes[index][document.all && parseInt(ieNum) < 10 ? "text" : "textContent"] : "";
}
function ShowBf() {
$("#hiddencount").html(0);
loaded = 0;
SortData();
var ifSortByLeague = orderby == "league";
if (ifSortByLeague) {
$("#conditionBtn").hide();
MakeTableOrderByLeague();
document.getElementById("li_league").style.display = "none";
document.getElementById("li_time").style.display = "";
}
else {
$("#conditionBtn").show();
MakeTable();
document.getElementById("li_league").style.display = "";
document.getElementById("li_time").style.display = "none";
}
$.when(showRecommend()).done(function (arr) {
$.each(arr, function (i, one) { one.show() });
});
//联赛/杯赛名列表
makeMyLeague();
setTimeout(function () {
filterHelper.linkData();
//国家列表
makeMyCountry();
//让球选择/查询
makeGoalTable(oldLetBig); //让球
filterHelper.initHtml(!ifSortByLeague);
}, 500);
var dataUrl = (Config.companyID == 3 ? "/data/goalbf3.xml" : "/data/goal.php?id=" + Config.companyID + "&t=" + Date.parse(new Date()));
GetXml(dataUrl , function (data) {
idList = getXmlChildNodes_Text(data.documentElement.childNodes, 1);
showodds(false, data);
window.clearTimeout(getoddsxmlTimer);
getoddsxmlTimer = window.setTimeout("getoddsxml()", 3000);
if (Config.companyID == 3){
GetXml("/data/goal3.xml", function (data) {
jcIdList = getXmlChildNodes_Text(data.documentElement.childNodes, 2);
});
}else{
jcIdList = getXmlChildNodes_Text(data.documentElement.childNodes, 2);
}
});
window.clearTimeout(runtimeTimer);
runtimeTimer = window.setTimeout("setMatchTime()", 1000);
if (Config.rank == 1) ShowTeamRank();
if (Config.explain == 0) ShowExplain();
document.getElementById("scoreLoading").style.display = "none";
window.setTimeout("showLeagueList(1)", 500);
}
function SortData() {
if (concernIds.length == 0)
return;
var temp = [];
var tempCount = matchcount;
for (var i = 0; i < tempCount && concernIds.length > temp.length; i++) {
if (concernIds.contains(A[i][0]))
{
temp.push(A[i]);
A.splice(i, 1);
tempCount--;
i--;
}
}
if (temp.length > 0) {
A = temp.concat(A);
}
}
function MakeTable() {
var state, bg = "", hh = 0;
var H_redcard, G_redcard, H_yellow, G_yellow;
var html = new Array();
var isCreateTr = false;
html.push("
");
var advertTool = new Advert(matchcount, 14);
var cid = Config.companyID;
var ifAlias = Config.ifAlias;
var lang = Config.language;
for (var i = 0; i < matchcount; i++) {
try {
var data = A[i];
var schID = data[0];
var sclassArr = B[data[1]];
var sclassId = sclassArr[0];
var hn = getTeamName(ifAlias, data[4 + lang], T[data[2] + "_3"]);
var gn = getTeamName(ifAlias, data[7 + lang], T[data[3] + "_3"]);
sclassArr[8]++;
var ifConcern = concernIds.contains(schID);
if (!isCreateTr && !ifConcern) {
html.push("
")
document.getElementById("ScoreDiv").innerHTML = html.join("");
document.getElementById("hiddencount").innerHTML = hh;
$(".bts .p_concern").hide();
}
function makeMyLeague() {
var leaguehtml = new Array();
leaguehtml.push("
");
for (var i = 0; i < B.length; i++) {
var oneSclass = B[i];
if (oneSclass[8] > 0) {
leaguehtml.push("
');
if (orderby == "time")
leaguehtml.push('
');
leaguehtml.push('
');
}
}
leaguehtml.push("
");
$("#myleague").html(leaguehtml.join(""));
}
function makeMyCountry() {
function cutStr(str, len) {
var str_length = 0;
var str_len = 0;
var str_cut="";
var str_len = str.length;
for (var i = 0; i < str_len; i++) {
var a = str.charAt(i);
str_length++;
if (escape(a).length > 4) {
str_length++;
}
if (str_length <= len)
str_cut = str_cut.concat(a);
if (str_length >= len) {
return str_cut;
}
}
return str;
}
//国家列表
var country = new Array();
country.push("
");
filterHelper.country.forEach(function (v, k) {
var v = v.value;
country.push("");
});
country.push("
");
document.getElementById("countryList").innerHTML = country.join("");
}
function showodds(needSleep,xmlNode) //是否需显示一场之后暂停一会
{
try {
var root = xmlNode.documentElement.childNodes[0];
if (root.childNodes.length == 0) return;
needSound = false;
showodds2(root, 0, needSleep);
} catch (e) { }
}
function showodds2(root, i, needSleep) {
try {
var odds, old = new Array();
odds = getXmlChildNodes_Text(root.childNodes, i);//id,oddsid,goal,home,away,oddsid,hw,st,gw,oddsid,up,goal,down
var D = odds.split(",");
var tr = document.getElementById("tr1_" + D[0]);
if (tr != null) {
var oldOdds = tr.attributes["odds"].value;
var oldD = oldOdds.split(",");
if (oldOdds !== odds || oldD.length != D.length) {
var ifChange = false;
var arr = [[2, Goal2GoalCn], 3, 4, 6, 7, 8, [10, Goal2GoalCn2], 11, 12]
for (var j = 0; j < arr.length; j++) {
var one = arr[j];
var fuc = null, index = one;
if (one instanceof Array) {
index = one[0];
fuc = one[1];
}
if (index >= D.Length)
break;
var oldV = oldD[index], v = D[index];
if (typeof fuc === "function")
v = fuc(v);
if (oldV != D[index] && typeof oldV !== "undefined" && oldV != "") {
if (D[index] > oldV)
v = "" + v + "";
else v = "" + v + "";
ifChange = true;
}
D[index] = v;
}
if (ifChange) {
window.setTimeout("restoreOddsColor(" + D[0] + ")", 30000);
if (Config.oddsSound == 1) {
if (tr.style.display != "none") needSound = true;
}
}
var ifeng_yp = D[14] != "0", ifeng_op = D[15] != "0", ifeng_dx = D[16] != "0";
var tmp = "";
if (Config.yp == 1) tmp += "
";
var obj = document.getElementById('winScore');
obj.style.left = (document.body.clientWidth / 2 - (location.href.indexOf("old") != -1 ? 199 : 255)) + "px";
var trid = "tr1_" + schID;
obj.style.top = getElementPos(trid).y + document.getElementById(trid).offsetHeight + "px" ;
obj.innerHTML = html;
obj.style.display = "";
} catch (e) { }
}
function getPageHeight() {
var pageHeight = window.innerHeight;
if (typeof pageWindth != "number") {
if (document.compatMode == "CSS1Compat") {
pageHeight = document.documentElement.clientHeight;
}
else {
pageHeight = document.body.clientHeight;
}
}
return pageHeight;
}
function showvideo(n, event) {
try {
if (Math.floor((new Date() - loadVideoFileTime) / 600) > 60) LoadVideoFile();
var html = "
";
html += "
直播频道
";
var soft = "";
for (var i = 0; i < V[A[n][0]].length / 5; i++) {
var j = i + i * 4;
if (soft != V[A[n][0]][j + 1] || i == 0) {
if (i > 0)
html += "";
html += "
"
}
if (V[A[n][0]][j + 1].indexOf("外部链接") != -1) {
var urls = V[A[n][0]][j + 1].split('|');
if (urls.length > 1)
html += "" + urls[0] + " ";
}
else
//html+=""+V[A[n][0]][j+1]+" ";
html += "" + V[A[n][0]][j + 1] + " ";
soft = V[A[n][0]][j + 1];
}
html += "
';
}
}
else {
var i = 0;
var hasData = false;
var hashLetGoal = filterHelper.letGoal, hashTotalGoal = filterHelper.totalGoal;
var lKey = hashLetGoal.keys().sort();
var tKey = hashTotalGoal.keys().sort();
do {
var html = showGoal(lKey[i], hashLetGoal, 0) + showGoal(tKey[i], hashTotalGoal, 1);
if (hasData = (html.length > 0)) {
str += '
';
str += html;
str += '
';
}
i++;
}
while (hasData);
}
str += '
';
document.getElementById("goalTable").innerHTML = str;
oldLetBig = t;
}
function showOrHiddenSche(arrValue, ifShow) {
var schID = arrValue[0];
if ($("#tr1_" + schID).is(":visible") != ifShow) {
var doms = $("#tr1_" + schID + (arrValue[27] + arrValue[32] != "" ? ",#tr2_" + schID : "") + (flashScheduleIDs != "" && parseInt(flashScheduleIDs) == arrValue[0] && flashData.scheduleList.items.length > 0 ? ",#tr3_" + schID : ""));
(ifShow ? doms.show() : doms.hide());
return true;
} else return false;
}
function checkGoalInput(t1) {
$("#goalTable input:checkbox[name=goalType]").each(function (i) {
var node = this;
var value = filterHelper.getGoalValue(node.value);
var t = $(node).attr("data-type");
var oldChecked = node.checked;
if (t1 == 1)
node.checked = true; //全选
else if (t1 == 2)
node.checked = !oldChecked; //反选
if (oldChecked != node.checked) {
if (t == 0)
filterHelper.updateLetgoal(value, node.checked);
else
filterHelper.updateTotalgoal(value, node.checked);
}
});
}
function hiddenGoalData(node) {
var value = node.value;
var isShow = node.checked;
var t = $(node).attr("data-type");
if (t == 0)
filterHelper.updateLetgoal(value, isShow);
else
filterHelper.updateTotalgoal(value, isShow);
}
function addConcern(matchIndex) {
var schid = A[matchIndex][0];
if (concernIds.contains(schid))
return;
concernIds.push(schid);
writeCookie("concernIds", concernIds);
var tr = document.getElementById("tr1_" + A[matchIndex][0]);
tr.cells[13].innerHTML = tr.cells[13].innerHTML.replace("addConcern", "deleteConcern").replace("setTopOff", "setTopOn").replace("添加", "取消");
var TTime = new Date();
var isChange = false;
var nt2 = getMatchTime(A[matchIndex]);;
for (var i = 1; i < matchcount; i++) {
if (concernIds.contains(A[i][0])) {
if (A[i][13] > 0) {
var ot2 = getMatchTime(A[i]);
if (ot2 > nt2) {
isChange = true;
MovePlace(A[i][0], A[matchIndex][0]);
break;
}
}
}
}
if (!isChange)
MovePlace(0, A[matchIndex][0]);
}
function deleteConcern(matchIndex) {
var schid = A[matchIndex][0];
if (!concernIds.contains(schid)) return;
var i = 0;
for (; i < concernIds.length; i++)
{
if (concernIds[i] == schid)
break;
}
doDeleteOneConcern(matchIndex);
concernIds.splice(i, 1);
writeCookie("concernIds", concernIds);
}
function doDeleteOneConcern(matchIndex)
{
var tr = document.getElementById("tr1_" + A[matchIndex][0]);
var conTdObj = $(tr).find("td.Concern");
if (conTdObj.length>0)
conTdObj[0].innerHTML = conTdObj[0].innerHTML.replace("deleteConcern", "addConcern").replace("setTopOn", "setTopOff").replace("取消", "添加");
var TTime = new Date();
var isChange = false;
var nt2 = getMatchTime(A[matchIndex]);
var matchState = A[matchIndex][12];
var schid = A[matchIndex][0]
var sameStateID = -1;
for (var i = 0; i < matchcount; i++) {
var tempSchid = A[i][0];
var tempState = A[i][12];
if (tempSchid < 1 || concernIds.contains(tempSchid))
continue;
if ((matchState == 0 && tempState == 0) || matchState * tempState > 0) {
sameStateID = tempSchid;
var tempTime = getMatchTime(A[i]);
isChange = tempTime > nt2 || (tempTime - nt2 == 0 && i > matchIndex);
}
else if (sameStateID < 0 && matchState > tempState)
isChange = true;
if (isChange) {
MovePlace(tempSchid, schid);
break;
}
}
if (!isChange) {
if (sameStateID == -1)
MovePlace(-1, schid, "BeforeEnd");
else MovePlace(sameStateID, schid, "afterEnd");
}
}
$("#DivLeague").on("click", ".sclassPlaceTop", function () {
var thisObj = $(this);
var sclassID = parseInt(thisObj.parents("li").find("[type=checkbox]").val());
var hasTop = thisObj.hasClass("top");
for (var i = 0; i < matchcount; i++) {
var tempSclassID = A[i][1];
if (sclassID == tempSclassID) {
if (hasTop)
deleteConcern(i);
else addConcern(i);
}
}
if (hasTop) {
thisObj.removeClass("top");
}
else {
thisObj.addClass("top");
}
});
function removeSclassConcern() {//取消联赛置顶
var arr = concernIds;
for (var i = 0; i < arr.length; i++) {
var schID = arr[i];
var v = filterHelper.schs.get(schID);
if (typeof (v) == "undefined")
continue;
doDeleteOneConcern(v.index);
}
$(".sclassPlaceTop.top").removeClass("top");
concernIds = [];
writeCookie("concernIds", concernIds);
}
function getMatchTime(match) {
var dt = match[10].split(":");
var nt = match[11].split(",");
var reTime = new Date(nt[0], nt[1], nt[2], dt[0], dt[1], 0);
if (match[12] != 0) {
if (reTime > new Date())
reTime.setDate(reTime.getDate() - 1);
if (reTime > new Date())
reTime.setFullYear(reTime.getFullYear() - 1);
}
return reTime;
}
function MovePlace(newPos, oldPos, sWhere) {
try {
if (typeof (sWhere) === "undefined")
sWhere = "BeforeBegin";
var oEle = null;
if (newPos == 0) {
oEle = document.getElementById("tr_" + newPos);
}
else if (newPos > 0) {
oEle = document.getElementById("tr1_" + newPos);
}
else if (newPos == -1) {
oEle = document.getElementById("tr_0").parentElement;
}
if (oEle != null) {
var arr = [document.getElementById("tr1_" + oldPos), document.getElementById("tr2_" + oldPos)];
if (!!document.getElementById("tr3_" + oldPos))
arr.push(document.getElementById("tr3_" + oldPos));
if (sWhere.toLowerCase().indexOf("after") == 0)
arr.reverse();
for (var i = 0; i < arr.length; i++)
oEle.insertAdjacentElement(sWhere, arr[i]);
}
changeTxtAdLocation();
}
catch (e) {
}
}
//竞猜推荐
function showRecommend() {
var defer = $.Deferred();
$.ajax({
type: "GET", url: "/data/GetRecommend.js", dataType: "json", async: true, cache: true, success: function (data) {
var arr = new Array();
for (var i = 0; i < data.length; i++) {
var node = $("#recommend_" + data[i]);
if (node.length > 0 && node.is(':hidden')) { //如果node是隐藏的则显示node元素,否则隐藏
arr.push(node);
}
}
defer.resolve(arr);
}
});
return defer.promise();
}
$("#conditionBtn").click(function () {
filterHelper.getConfition(function () {
var titleCn = new Array("连胜场次", "连负场次", "连续让球胜", "连续让球负", "连续大球", "连续小球", "近20场让胜率", "近20场让负率", "近20场大球率", "近20场小球率");
var titleBig = new Array("連勝場次", "連負場次", "連續讓球勝", "連續讓球負", "連續大球", "連續小球", "近20場讓勝率", "近20場讓負率", "近20場大球率", "近20場小球率");
var numTtitle = new Array("3~4", "5~6", "7+");
var perTitle = new Array("60~65", "65~70", "75+");
var title = Config.language == 1 ? titleBig : titleCn;
var choiseNum = 0;
var conditionHtml = "";
for (var i = 0; i < title.length; i++) {
var subTitle = i < 6 ? numTtitle : perTitle;
conditionHtml += '
';
conditionHtml += '' + title[i] + '';
for (var j = 0; j < subTitle.length; j++) {
var className = "condition";
var id = i + "_" + j;
var arr = filterHelper.conditionHash.get(id);
if (arr.length > 0) {
var temNum = 0;
$(arr).each(function (i, v) {
if (v.ifShowNotCondition && v.sclass.ifShow && v.country.ifShow) temNum++;
});
if (temNum > 0)
{
className += " btn";
if (filterHelper.selCondition != "" && filterHelper.selCondition == id) {
className += " on";
choiseNum = temNum;
}
}
}
conditionHtml += '' + subTitle[j] + '';
}
conditionHtml += '
';
}
$("#filterList").html(conditionHtml);
$("#conditionNum").html("[" + choiseNum + "]");
showPopupBox("filterBox");
});
});
$("#filterBox").on("click", ".btn", function () {
var _this = $(this);
if (!_this.hasClass("on"))
{
$("#filterList .btn.on").removeClass("on");
_this.addClass("on");
var arr = filterHelper.conditionHash.get(_this.attr("data-condition"));
var temNum = 0;
$(arr).each(function (i, v) {
if (v.ifShowNotCondition && v.sclass.ifShow && v.country.ifShow) temNum++;
});
$("#conditionNum").html("[" + temNum + "]");
}
else {
_this.removeClass("on");
$("#conditionNum").html("[0]");
}
});
$("#filterBox .ok").click(function () {
var selObj = $("#filterList .btn.on");
var selCondition = "";
if (selObj.length > 0)
selCondition = selObj.attr("data-condition");
filterHelper.updateCondition(selCondition);
showPopupBox("filterBox", true);
});
function showPopupBox(popName,ifHide)
{
if (ifHide)
{
MM_showHideLayers(popName, '', 'hide');
} else {
var pops = ["filterBox", "DivLeague", "DivCountry", "goalDiv", "DivFunction"];
if ($.inArray(popName, pops) > -1)
{
var arr = [];
$(pops).each(function (i, v) {
arr.push(v, "", popName == v ? "show" : "hide");
});
MM_showHideLayers.apply(null, arr);
} else MM_showHideLayers(popName, '', 'show');
}
}
Config.getCookie("2in1");
if (Config.companyID != 1 && Config.companyID != 3 && Config.companyID != 4 && Config.companyID != 8 && Config.companyID != 12 && Config.companyID != 17 && Config.companyID != 23 && Config.companyID != 24 && Config.companyID != 31) Config.companyID = 3;
getEleById("company" + Config.companyID).className = "selected";
showOrHideGoalSel(Config.companyID);
orderby = getCookie("orderby");
if (orderby == null) orderby = "time";
audioHelper.init("flashsound", flash_sound[Config.sound]);
audioHelper.init("oddsFlashSound", flash_sound[4]);
LoadLiveFile();
if (Config.fontsize != 12 && Config.fontsize > 0) document.getElementById("ScoreDiv").style.fontSize = Config.fontsize + "px";
window.setTimeout("gettime()", 2000);
window.setTimeout("check()", 30000);
$("#cb_ifShowCorn").click(function () {
Config.ifShowCorn = this.checked? 1:0;
Config.writeCookie();
});
/************************************/
function changeTxtAdLocation()
{
if (filterHelper.needChangeSchNum > 0)
return;
var trs = $("#table_live tr:visible");
var lastIndex = 0;
var arr = [];
var arrAd = [];
var lastObj = null;
trs.each(function (i, v) {
var thisObj = $(v);
if (thisObj.hasClass("Leaguestitle"))
return;
if (lastObj == null) {
if (thisObj.hasClass("ki1"))
lastObj = thisObj;
return;
}
if (thisObj.hasClass("showTxtAd"))
arrAd.push(thisObj);
else {
if (typeof (thisObj.attr("index")) !== "undefined" && !lastObj.hasClass("ki1"))
arr.push(lastObj);
lastObj = thisObj;
}
});
if (lastObj != null && !lastObj.hasClass("ki1"))
arr.push(lastObj);
var advertTool = new Advert(arr.length, 0);
var adIndex = 0;
for (var i = 0; i < arr.length; i++)
{
var html = [];
advertTool.Show(html, i);
if (html.length > 0)
arrAd[adIndex++].insertAfter(arr[i]);
}
if (lastObj != null)
while (adIndex < arrAd.length) {
arrAd[adIndex++].insertAfter(lastObj);
}
}