var SimplifyNum = 0;
function GetQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null) {
return unescape(r[2]);
}
return null;
}
function checkDate(date) {
var r = date.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/);
if (r == null) return false; var d = new Date(r[1], r[3] - 1, r[4]);
return (d.getFullYear() == r[1] && (d.getMonth() + 1) == r[3] && d.getDate() == r[4]);
}
var companyName = new Array(9);
companyName[0] = " ";
companyName[1] = "澳门";
companyName[2] = "易胜博";
companyName[3] = "Crown";
companyName[8] = "bet365";
companyName[9] = "韦德";
var language = findCookie("language");
var DomainKey = "LQ_Odds";
var SclassStoreKey = "HiddenSid";
var Simplify_Key = "Simplified";
var CompyKey = "Lq_Comp";
var Config = {
Company: 2,
Level: 0,
Language: (language == "" ? 0 : parseInt(language)),
Date: new Date(),
ScheduleMode: 0,
init: function () {
var val = findCookie(CompyKey);
if (val != "")
this.Company = parseInt(val);
val = findCookie("Level");
if (val != "")
this.Level = parseInt(val);
var date = GetQueryString("date");
if (date != null && checkDate(date)) {
var dateParam = new Date(date);
if (dateParam.toLocaleDateString() != Config.Date.toLocaleDateString()) {
Config.Date = dateParam;
this.ScheduleMode = 1;
}
}
},
setLevel: function (level) {
this.Level = level;
writeCookie("Level", level);
},
getHiddenLeagueIds: function (level) {
if (level == undefined) level = this.Level;
var key = DomainKey + SclassStoreKey;
if (level == 1) key = Simplify_Key + DomainKey + SclassStoreKey;
var hiddenIds = localStorage.getItem(key);
if (hiddenIds == "undefined" || hiddenIds == null) return "";
else return hiddenIds;
},
setHiddenLeagueIds: function (ids) {
var key = DomainKey + SclassStoreKey;
if (this.Level == 1) key = Simplify_Key + DomainKey + SclassStoreKey;
localStorage.setItem(key, ids);
}
}
Config.init();
var _glodds = new Object();
_glodds.SplitColumn = "^";
_glodds.SplitDomain = "$$";
_glodds.SplitRecord = "!";
_glodds.List = function () {
this.items = new Array();
this.keys = new Array();
this.Add = function (key, value) {
if (typeof (key) != "undefined") {
var vv = typeof (value) == "undefined" ? null : value;
var idx = this.keys[key];
if (idx == null) {
idx = this.items.length;
this.keys[key] = idx;
}
this.items[idx] = vv;
}
}
this.Get = function (key) {
var idx = this.keys[key];
if (idx != null)
return this.items[idx];
return null;
}
}
//初始化联赛
_glodds.League = function (infoStr) {
var infoArr = infoStr.split(_glodds.SplitColumn);
this.lId = infoArr[1];
this.name = infoArr[0];
this.type = parseInt(infoArr[2]);
this.matchNum = 0;
this.show = true;
this.isValid = false;
}
//初始化变化指数数据
_glodds.cOdds = function (type, infoStr) {
var infoArr = infoStr.split(_glodds.SplitColumn);
this.mId = infoArr[0];
this.cId = Config.Company;
this.type = type;
if (type != 3) {
this.lOdds = infoArr[1];
this.mOdds = infoArr[2];
this.rOdds = infoArr[3];
}
else {
this.lOdds = infoArr[1];
this.mOdds = " ";
this.rOdds = infoArr[2];
}
}
//初始化指数数据
_glodds.Odds = function (type, infoStr) {
var infoArr = infoStr.split(_glodds.SplitColumn);
this.mId = infoArr[0];
this.cId = Config.Company;
this.type = type;
if (type != 3) {
this.lOddsF = infoArr[1];
this.mOddsF = infoArr[2];
this.rOddsF = infoArr[3];
this.lOdds = infoArr[4];
this.mOdds = infoArr[5];
this.rOdds = infoArr[6];
}
else {
this.lOddsF = infoArr[1];
this.mOddsF = " ";
this.rOddsF = infoArr[2];
this.lOdds = infoArr[3];
this.mOdds = " ";
this.rOdds = infoArr[4];
}
this.getTitle = function () {
switch (this.type) {
case 1: return "让分";
case 2: return "总分";
case 3: return "欧赔";
}
}
}
//初始化赛事信息
_glodds.Match = function (infoStr) {
var infoArr = infoStr.split(_glodds.SplitColumn);
this.mId = infoArr[0];
this.lId = infoArr[1];
this.MatchTime = GetTime(infoArr[2]);
this.hName = infoArr[3];
this.gName = infoArr[4];
this.State = infoArr[5];
this.hScore = infoArr[6];
this.gScore = infoArr[7];
this.getScoreTag = function () {
if (this.State == -1)
return "" + this.hScore + ":" + this.gScore + "";
else if (this.State > 0)
return "进行中";
else return "VS";
}
if (infoArr[8] == "" && infoArr[9] == "" && infoArr[10] == "" && infoArr[11] == "" && infoArr[12] == "" && infoArr[13] == "") {
this.Hpodds = null;
} else {
this.Hpodds = new _glodds.Odds(1, infoArr[0] + "^" + infoArr[8] + "^" + infoArr[9] + "^" + infoArr[10] + "^" + infoArr[11] + "^" + infoArr[12] + "^" + infoArr[13]);
}
if (infoArr[14] == "" && infoArr[15] == "" && infoArr[16] == "" && infoArr[17] == "" && infoArr[18] == "" && infoArr[19] == "") {
this.Tpodds = null;
} else {
this.Tpodds = new _glodds.Odds(2, infoArr[0] + "^" + infoArr[14] + "^" + infoArr[15] + "^" + infoArr[16] + "^" + infoArr[17] + "^" + infoArr[18] + "^" + infoArr[19]);
}
if (infoArr[20] == "" && infoArr[21] == "" && infoArr[22] == "" && infoArr[23] == "") {
this.Opodds = null;
} else {
this.Opodds = new _glodds.Odds(3, infoArr[0] + "^" + infoArr[20] + "^" + infoArr[21] + "^" + infoArr[22] + "^" + infoArr[23]);
}
this.hasOp = function () {
return this.Opodds != null;
}
this.hasTp = function () {
return this.Tpodds != null;
}
this.hasOdds = function () {
return this.Hpodds != null;
}
}
function GetTime(strTime) {
if (!strTime || strTime.length < 8) return;
else {
return strTime.substr(4, 2) + "-" + strTime.substr(6, 2) + " " + strTime.substr(8, 2) + ":" + strTime.substr(10, 2);
}
}
function LoadLiveFile() {
//var dataUrl = "/phone/txt/" + Config.getFileName() + "?";
//if (Config.ScheduleMode == 1) {
var dateParam = Config.Date.getFullYear() + "-" + (Config.Date.getMonth() + 1) + "-" + Config.Date.getDate();
dataUrl = "/live/lq/data/oddsDataFilter.php?date=" + dateParam + "&cid=" + Config.Company + "&T=";
//}
$.ajax({
url: dataUrl + Date.parse(new Date()),
dataType: "text",
success: RefreshScore,
error: ShowError
});
}
function getChangeDate() {
var dateParam = Config.Date.getFullYear() + "-" + (Config.Date.getMonth() + 1) + "-" + Config.Date.getDate();
dataUrl = "/Lq/OddsChange.aspx?date=" + dateParam + "&cid=" + Config.Company + "&T=";
$.ajax({
url: dataUrl + Date.parse(new Date()),
dataType: "text",
success: UpdateOdds,
});
}
var _matchData = new Object();
function RefreshScore(data) {
var leagueItem, oddsItem, matchItem;
_matchData.LeagueList = new _glodds.List();
_matchData.MatchList = new _glodds.List();
var domains = data.split(_glodds.SplitDomain);
if (domains.length > 1) {
var leagueDomain = domains[0].split(_glodds.SplitRecord);
_matchData.LeagueNum = leagueDomain.length;
for (var i = 0; i < leagueDomain.length; i++) {
leagueItem = new _glodds.League(leagueDomain[i]);
_matchData.LeagueList.Add(leagueItem.lId, leagueItem);
}
var matchDomain = domains[1].split(_glodds.SplitRecord);
_matchData.MatchCount = matchDomain.length;
for (var i = 0; i < matchDomain.length; i++) {
matchItem = new _glodds.Match(matchDomain[i]);
_matchData.MatchList.Add(matchItem.mId, matchItem);
var lItem = _matchData.LeagueList.Get(matchItem.lId);
if (lItem != null) {
if (lItem.type == 1) SimplifyNum++;
lItem.matchNum++;
}
}
}
MakeTable();
}
var showMatchList = new Array();
function MakeTable() {
var html = new Array();
var hiddenIds = Config.getHiddenLeagueIds().split(",");
_matchData.MatchCount = _matchData.MatchList.items.length;
for (var i = 0; i < _matchData.MatchList.items.length; i++) {
var mItem = _matchData.MatchList.items[i];
var lItem = _matchData.LeagueList.Get(mItem.lId);
if (!mItem.hasOdds()) {
_matchData.MatchCount--;
if (lItem.type == 1)
SimplifyNum--;
continue;
}
lItem.isValid = true;
if (hiddenIds.contains(mItem.lId)) continue;
if (Config.Level == 1 && lItem.type != 1) {
continue;
}
showMatchList.push(mItem);
html.push(GetMatchHtml(mItem, lItem));
}
$("#spnLoading").css("display", "none");
document.getElementById("oddsLive").innerHTML = html.join("");
}
function GetMatchHtml(mItem, lItem) {
var html = new Array();
var tpl = [
"
",
"| ",
"" + lItem.name + "" + mItem.MatchTime + "",
"" + mItem.hName + "" + mItem.getScoreTag() + "" + mItem.gName + "",
" |
",
"| 类型 | ",
" | ",
"主(大) | ",
"让分/大小 | ",
"客(小) |
",
].join("");
html.push(tpl);
html.push(getOddsRow(mItem.Hpodds));
if (mItem.hasTp()) {
html.push(getOddsRow(mItem.Tpodds));
}
if (mItem.hasOp()) {
html.push(getOddsRow(mItem.Opodds));
}
html.push("
");
return html.join("");
}
function getOddsRow(oItem) {
var html = new Array();
var cId = Config.Company;
var oddTpl = [
"| " + oItem.getTitle() + " | ",
"初 即 | ",
"" + oItem.lOddsF + " " + oItem.lOdds + " | ",
"" + oItem.mOddsF + " " + oItem.mOdds + " | ",
"" + oItem.rOddsF + " " + oItem.rOdds + " |
"
].join("");
html.push(oddTpl);
return html.join("");
}
function toAnaly(mId, st) {
location.href = "/live/lq/Analysis/" + (st == "-1" ? "shiJian" : "index") + ".html?id=" + mId;
return;
}
function toDetail(mId, cId, type) {
//if (type == 1)
// window.open("/LQ/HandicapDetail.aspx?f=1&scheId=" + mId + "&companyid=" + cId);
//else if (type == 2)
// window.open("/LQ/OuDetail.aspx?f=1&scheId=" + mId + "&companyid=" + cId);
//else if (type == 3)
// window.open("/LQ/1x2Detail.aspx?f=1&scheId=" + mId + "&cId=" + cId);
return;
}
function getColor(numF, numR, cutC) {
var n1 = Math.abs(parseFloat(numR));
var n2 = Math.abs(parseFloat(numF));
var cName = "";
if (n1 > n2) cName = "red";
else if (n1 < n2) cName = "green";
if (cutC != undefined && cutC) {
return cName;
}
return "class='" + cName + "' ";
}
function ShowError() {
document.getElementById("oddsLive").innerHTML = "加载比赛失败!
";
}
function toggleSettingMode(isSet, opt) {
$("[data-ex]").each(function () {
if ($(this).attr("data-ex") == (isSet ? "0" : "1")) {
$(this).css("display", "none");
}
else $(this).css("display", "");
});
if (isSet) {
_curOption = opt;
}
var currentViewId = "";
switch (_curOption) {
case 1: currentViewId = "compSetContent"; break;
case 2: currentViewId = "leagueSetContent"; break;
case 3: currentViewId = "dateSetContent"; break;
}
_curOption = opt;
if (isSet && opt == 2) document.getElementById("bottomBarFloat").style.display = "";
else document.getElementById("bottomBarFloat").style.display = "none";
if (currentViewId != "") document.getElementById(currentViewId).style.display = (isSet ? "" : "none");
document.getElementById("oddsLive").style.display = (isSet ? "none" : "");
}
var _curOption = 0;
function showSetting(opt) {
if (opt == 1) {
$("#compDiv [data-cId]").each(function () {
if ($(this).attr("data-cId") == Config.Company)
$(this).addClass("on");
else $(this).removeClass("on");
});
}
if (opt == 2) {
FilterLeague(Config.Level);
}
if (opt == 3) {
collectDateList();
}
toggleSettingMode(true, opt);
}
function cancel() {
toggleSettingMode(false, 0);
}
function collectDateList() {
var html = new Array();
var dayMsc = 24 * 60 * 60 * 1000;
for (var i = 0; i > -6; i--) {
var date = new Date(new Date().valueOf() + dayMsc * i);
var dateText = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
var exC = "";
if (i == 0) exC = " today ";
if (date.getMonth() == Config.Date.getMonth() && date.getDate() == Config.Date.getDate()) {
exC += " on ";
}
html.push("" + dateText + "");
}
document.getElementById("dateDiv").innerHTML = html.join("");
}
function selectRadio(elem, type) {
var attrib = "data-date";
if (type == 1) { attrib = "data-cId" }
$("[" + attrib + "]").each(function () {
if ($(this).hasClass("on")) $(this).removeClass("on");
});
if (!$(elem).hasClass("on")) $(elem).addClass("on");
}
function selectItem(elem) {
var selected = -1;
if ($(elem).hasClass("on")) { $(elem).removeClass("on"); selected = 1; }
else { $(elem).addClass("on"); }
if (_curOption == 2) {
var lId = $(elem).attr("data-lId");
var lItem = _matchData.LeagueList.Get(lId);
var hiddenCount = parseInt(document.getElementById("hiddenCount").innerHTML);
if (lItem != null) {
document.getElementById("hiddenCount").innerHTML = hiddenCount + (selected * lItem.matchNum);
}
}
}
function selectImportantLeague() {
if (typeof (_matchData.LeagueList) == "undefined") return;
var hiddenCount = 0;
var arr = [];
for (var i = 0; i < _matchData.LeagueList.items.length; i++) {
var lItem = _matchData.LeagueList.items[i];
if (lItem.type == 1)
arr.push(lItem.lId);
else
hiddenCount += lItem.matchNum;
}
$("[data-lId]").each(function () {
var oo = $(this);
var id = parseInt(oo.attr("data-lid"));
if (arr.contains(id))
oo.addClass("on");
else oo.removeClass("on");
});
document.getElementById("hiddenCount").innerHTML = hiddenCount;
}
function FilterLeague(level) {
$("[data-simple]").each(function () {
if ($(this).attr("data-simple") != level) { $(this).removeClass("on"); }
else $(this).addClass("on");
});
if (level == "1")
collectLeagueForSelect(true);
else
collectLeagueForSelect(false);
}
function collectLeagueForSelect(simplify) {
if (typeof (_matchData.LeagueList) == "undefined") return;
var html = new Array();
var hiddenIds = Config.getHiddenLeagueIds((simplify ? 1 : 0)).split(",");
var hiddenCount = 0;
for (var i = 0; i < _matchData.LeagueList.items.length; i++) {
var lItem = _matchData.LeagueList.items[i];
if (!lItem.isValid) continue;
if (simplify && lItem.type != 1) {
continue;
}
var isOn = !hiddenIds.contains(lItem.lId);
html.push("" + lItem.name + "");
if (!isOn) {
hiddenCount += lItem.matchNum;
}
}
document.getElementById("hiddenCount").innerHTML = hiddenCount;
document.getElementById("sclassDiv").innerHTML = html.join("");
}
function SelectAllLeague() {
$("[data-lId]").each(function () {
if (!$(this).hasClass("on")) $(this).addClass("on");
});
document.getElementById("hiddenCount").innerHTML = 0;
}
function UnselectAllLeague() {
$("[data-lId]").each(function () {
if ($(this).hasClass("on")) $(this).removeClass("on");
});
var hElem = document.getElementById("hiddenCount");
var hiddenCount = parseInt(hElem.innerHTML);
if ($("#tools [data-simple='1']").hasClass("on")) {
hiddenCount = SimplifyNum;
}
else hiddenCount = _matchData.MatchCount;
hElem.innerHTML = hiddenCount;
}
function confirm() {
var isValid = true;
if (_curOption == 1) {
isValid = confirmComp();
}
else if (_curOption == 2) {
isValid = confirmLeague();
}
else if (_curOption == 3) {
changeDate();
}
}
function confirmComp() {
var compId = new Object();
$("#compDiv [data-cId]").each(function () {
if ($(this).hasClass("on")) compId = ($(this).attr("data-cId"));
});
if (compId != Config.Company) {
Config.Company = compId;
writeCookie(CompyKey, compId);
toggleSettingMode(false, 0);
$("#spnLoading").css("display", "");
LoadLiveFile();
}
else
toggleSettingMode(false, 0);
refreshTitle();
return true;
}
function confirmLeague() {
var sclassArr = new Array();
var hiddenArr = new Array();
$("#sclassDiv [data-lId]").each(function () {
if ($(this).hasClass("on")) sclassArr.push(($(this).attr("data-lId")));
else { hiddenArr.push(($(this).attr("data-lId"))); }
});
if (sclassArr.length < 1) {
alert("请至少选择一场赛事。")
return false;
}
toggleSettingMode(false, 0);
$("#spnLoading").css("display", "");
if ($("#tools [data-simple='1']").hasClass("on")) {
Config.setLevel(1);
}
else {
Config.setLevel(0);
}
Config.setHiddenLeagueIds(hiddenArr);
MakeTable();
return true;
}
function changeDate() {
$("[data-date]").each(function () {
if ($(this).hasClass("on")) {
var date = new Date($(this).attr("data-date"));
if (date.getDate() != Config.Date.getDate()) {
window.location.href = "?date=" + $(this).attr("data-date");
}
else {
toggleSettingMode(false, 0);
}
}
});
}
function getChange() {
$.ajax({
url: "/live/lq/data/oddsChangeFilter.php?cID=" + Config.Company + "&T=" + Date.parse(new Date()),
dataType: "text",
success: UpdateOdds,
});
window.setTimeout("getChange()", 3000);
}
var old_change_data = null;
function UpdateOdds(data) {
if (old_change_data == data) return;
old_change_data = data;
var oddsDomain = data.split(_glodds.SplitDomain);
var cItem = null;
var hpDomain = oddsDomain[0].split(_glodds.SplitRecord);
for (var i = 0; i < hpDomain.length; i++) {
if (hpDomain[i] != "") {
cItem = new _glodds.cOdds(1, hpDomain[i]);
ChangeOddsCells(cItem);
}
}
var cItem = null;
var ouDomain = oddsDomain[1].split(_glodds.SplitRecord);
for (var i = 0; i < ouDomain.length; i++) {
if (ouDomain[i] != "") {
cItem = new _glodds.cOdds(2, ouDomain[i]);
ChangeOddsCells(cItem);
}
}
var cItem = null;
var opDomain = oddsDomain[2].split(_glodds.SplitRecord);
for (var i = 0; i < opDomain.length; i++) {
if (opDomain[i]) {
cItem = new _glodds.cOdds(3, opDomain[i]);
ChangeOddsCells(cItem);
}
}
}
function ChangeOddsCells(cItem) {
var cId = Config.Company;
var idTail = cItem.type + "_" + cItem.mId + "_" + cId;
var mItem = _matchData.MatchList.Get(cItem.mId);
if (mItem != null) {
var oItem = null;
if (cItem.type == 1)
oItem = mItem.Hpodds;
else if (cItem.type == 2)
oItem = mItem.Tpodds;
else if (cItem.type == 3)
oItem = mItem.Opodds;
else return;
var tElem = document.getElementById("table_" + cItem.mId);
if (tElem != null) {
var oElem = null;
if (oItem.lOdds != cItem.lOdds) {
oElem = document.getElementById("lo_" + idTail);
oElem.innerHTML = cItem.lOdds;
oElem.style.backgroundColor = getOddsbg(oItem.lOddsF, cItem.lOdds);
oItem.lOdds = cItem.lOdds;
$(oElem).attr("class", getColor(oItem.lOddsF, oItem.lOdds, true));
}
if (oItem.mOdds != cItem.mOdds) {
oElem = document.getElementById("mo_" + idTail);
oElem.innerHTML = cItem.mOdds;
oElem.style.backgroundColor = getOddsbg(oItem.mOdds, cItem.mOdds);
oItem.mOdds = cItem.mOdds;
$(oElem).attr("class", getColor(oItem.mOddsF, oItem.mOdds, true));
}
if (oItem.rOdds != cItem.rOdds) {
oElem = document.getElementById("ro_" + idTail);
oElem.innerHTML = cItem.rOdds;
oElem.style.backgroundColor = getOddsbg(oItem.rOdds, cItem.rOdds);
oItem.rOdds = cItem.rOdds;
$(oElem).attr("class", getColor(oItem.rOddsF, oItem.rOdds, true));
}
window.setTimeout("colors_water(" + oItem.mId + "," + oItem.cId + "," + oItem.type + ")", 30000);
}
else {
if (oItem.lOdds != cItem.lOdds) { oItem.lOdds = cItem.lOdds; }
if (oItem.mOdds != cItem.mOdds) { oItem.mOdds = cItem.mOdds; }
if (oItem.rOdds != cItem.rOdds) { oItem.rOdds = cItem.rOdds; }
}
}
}
function colors_water(mId, cId, type) {
var plexs = ["lo_", "mo_", "ro_"];
for (var i = 0; i < plexs.length; i++) {
var oElem = document.getElementById(plexs[i] + type + "_" + mId + "_" + cId);
if (oElem != null && oElem.style != null) {
oElem.style.backgroundColor = "";
}
}
}
function getOddsbg(numF, numR) {
var n1 = parseFloat(numF);
var n2 = parseFloat(numR);
var cName = "";
if (n1 > n2) cName = "#ffa4d1";
else if (n1 < n2) cName = "#a4ffbb";
return cName;
}
$(document).ready(function () {
LoadLiveFile();
refreshTitle();
if (Config.ScheduleMode == 0)
window.setTimeout("getChange()", 3000);
});
function refreshTitle() {
document.getElementById("NameContent1").innerHTML = companyName[Config.Company];
}