var GoalCn = ["0", "0/0.5", "0.5", "0.5/1", "1", "1/1.5", "1.5", "1.5/2", "2", "2/2.5", "2.5", "2.5/3", "3", "3/3.5", "3.5", "3.5/4", "4", "4/4.5", "4.5", "4.5/5", "5", "5/5.5", "5.5", "5.5/6", "6", "6/6.5", "6.5", "6.5/7", "7", "7/7.5", "7.5", "7.5/8", "8", "8/8.5", "8.5", "8.5/9", "9", "9/9.5", "9.5", "9.5/10", "10", "10/10.5", "10.5", "10.5/11", "11", "11/11.5", "11.5", "11.5/12", "12", "12/12.5", "12.5", "12.5/13", "13", "13/13.5", "13.5", "13.5/14", "14"]; var GoalCn2 = ["0", "0/-0.5", "-0.5", "-0.5/-1", "-1", "-1/-1.5", "-1.5", "-1.5/-2", "-2", "-2/-2.5", "-2.5", "-2.5/-3", "-3", "-3/-3.5", "-3.5", "-3.5/-4", "-4", "-4/-4.5", "-4.5", "-4.5/-5", "-5", "-5/-5.5", "-5.5", "-5.5/-6", "-6", "-6/-6.5", "-6.5", "-6.5/-7", "-7", "-7/-7.5", "-7.5", "-7.5/-8", "-8", "-8/-8.5", "-8.5", "-8.5/-9", "-9", "-9/-9.5", "-9.5", "-9.5/-10", "-10"]; function Goal2GoalCn(goal) { //handicap conversion if (goal == null || isNaN(goal)) return ""; else { if (goal >= 0) return GoalCn[parseInt(goal * 4)]; else return GoalCn2[Math.abs(parseInt(goal * 4))]; } } 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 Hp_Comps = "1,3,31,8,14,24"; var Op_Comps = "1,3,31,8,14,24"; var Ou_Comps = "1,3,31,8,14,24"; var Default_Comps = "1,3,4,8"; var SclassStoreKey = "HiddenSid"; var Simplify_Key = "Simplified"; var SimplifyNum = 0; var HiddenLeagues = new Array(); var language = findCookie("language"); var Config = { //1:A,2:E,3,O OddsType: 1, //赛事等级 Level: 0, Language: (language == "" ? 0 : parseInt(language)), Date: new Date(), ScheduleMode: 0, init: function () { var val = findCookie("OddsType"); if (val != "") this.OddsType = 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; } } }, setOddsType: function (type) { this.OddsType = type; writeCookie("OddsType", type); }, setLevel: function (level) { this.Level = level; writeCookie("Level", level); }, getFileName: function () { switch (this.OddsType) { case 2: return "ouOdds_" + this.Language + "_0.js"; case 3: return "euroOdds_" + this.Language + "_0.js"; default: return "asianOdds_" + this.Language + "_0.js"; } }, getChangeFileName: function () { switch (this.OddsType) { case 2: return "ouChange.js"; case 3: return "euroChange.js"; default: return "asianChange.js"; } }, getSettingCompIds: function (opt) { var compArr = Hp_Comps; if (!opt) opt = this.OddsType; if (opt == 3) compArr = Op_Comps; else if (opt == 2) compArr = Ou_Comps; return compArr; }, getSelectedCompIds: function (opt) { if (!opt) opt = this.OddsType; var comps = findCookie(this.getSelCompKey(opt)); if (comps == "") return Default_Comps; return unescape(comps); }, getSelCompKey: function (opt) { return "SoccerCompanys"; }, getHiddenLeagueIds: function (opt, level) { if (!opt) opt = this.OddsType; if (level == undefined) level = this.Level; var key = ""; if (level == 1) key = Simplify_Key + this.getSelCompKey(opt) + SclassStoreKey; else key = this.getSelCompKey(opt) + SclassStoreKey; var hiddenIds = localStorage.getItem(key); if (hiddenIds == "undefined" || hiddenIds == null) return ""; else return hiddenIds; }, setHiddenLeagueIds: function (ids, opt) { if (!opt) opt = this.OddsType; var key = ""; if (this.Level == 1) key = Simplify_Key + this.getSelCompKey(opt) + SclassStoreKey; else key = this.getSelCompKey(opt) + SclassStoreKey; localStorage.setItem(key, ids); } } Config.init(); var companyName = new Array(42); companyName[0] = " "; companyName[1] = "澳彩"; companyName[3] = "Crown"; companyName[4] = "立博"; companyName[7] = "SNAI"; companyName[8] = "Bet365"; companyName[9] = "威廉希尔"; companyName[12] = "易胜"; companyName[14] = "韦德"; companyName[17] = "眀陞"; companyName[18] = "EuroBet"; companyName[19] = "Inter wetten"; companyName[22] = "10BET"; companyName[23] = "金宝博"; companyName[24] = "12bet/大发"; companyName[31] = "利记"; companyName[33] = "永利高"; companyName[35] = "盈禾"; 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; } } //League Class _glodds.League = function (infoStr) { var infoArr = infoStr.split(_glodds.SplitColumn); this.lId = infoArr[0]; this.name = infoArr[1]; this.type = parseInt(infoArr[2]); this.matchNum = 0; this.show = true; this.getName = function () { return this.name; } } _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.hOrder = infoArr[8]; this.gOrder = infoArr[9]; this.getScoreTag = function () { if (this.State == -1) return "" + this.hScore + ":" + this.gScore + ""; else if (this.State > 0) return "进行中"; else return "VS"; } } //OddsAsian _glodds.Odds = function (infoStr) { var infoArr = infoStr.split(_glodds.SplitColumn); this.mId = infoArr[0]; this.cId = infoArr[1]; this.oId = infoArr[2]; this.rOddsF = infoArr[5]; this.rOdds = infoArr[8]; if (Config.OddsType == 3) { this.mOddsF = infoArr[4]; this.lOddsF = infoArr[3]; this.mOdds = infoArr[7]; this.lOdds = infoArr[6]; this.Goal = function () { return this.mOdds; } this.GoalF = function () { return this.mOddsF; } } else { this.mOddsF = infoArr[3]; this.lOddsF = infoArr[4]; this.mOdds = infoArr[6]; this.lOdds = infoArr[7]; this.Goal = function () { return Goal2GoalCn(this.mOdds); } this.GoalF = function () { return Goal2GoalCn(this.mOddsF); } } } //ChangedOdds _glodds.cOdds = function (infoStr) { var infoArr = infoStr.split(_glodds.SplitColumn); this.mId = infoArr[0]; this.cId = infoArr[1]; this.rOdds = infoArr[4]; if (Config.OddsType == 3) { this.mOdds = infoArr[3]; this.lOdds = infoArr[2]; this.Goal = function () { return this.mOdds; } } else { this.mOdds = infoArr[2]; this.lOdds = infoArr[3]; this.Goal = function () { return Goal2GoalCn(this.mOdds); } } } 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 = "data/" + Config.getFileName() + "?"; if (Config.ScheduleMode == 1) { var dateParam = Config.Date.getFullYear() + "-" + (Config.Date.getMonth() + 1) + "-" + Config.Date.getDate(); dataUrl = "/OddsData.aspx?date=" + dateParam + "&t=" + Config.OddsType + "&cid=" + Config.getSettingCompIds() + "&"; } $.ajax({ url: dataUrl + Date.parse(new Date()), dataType: "text", success: RefreshScore, error: ShowError }); } function getChange() { $.ajax({ url: "data/" + Config.getChangeFileName() + "?" + 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.SplitRecord); for (var i = 0; i < oddsDomain.length; i++) { if (oddsDomain[i] == "") continue; var cItem = new _glodds.cOdds(oddsDomain[i]); var idTail = cItem.mId + "_" + cItem.cId; var oItem = _matchData.OddsList.Get(idTail); if (oItem != null) { var changed = false; var tElem = document.getElementById("table_" + cItem.mId); if (tElem != null) { var oElem = null; if (oItem.lOdds != cItem.lOdds) { oElem = document.getElementById("lo_" + idTail); if (oElem != null) { oElem.innerHTML = cItem.lOdds; oElem.style.backgroundColor = getOddsbg(oItem.lOdds, cItem.lOdds); oItem.lOdds = cItem.lOdds; $(oElem).attr("class", getColor(oItem.lOddsF, oItem.lOdds, true)); changed = true; } } if (oItem.mOdds != cItem.mOdds) { oElem = document.getElementById("mo_" + idTail); if (oElem != null) { oElem.innerHTML = cItem.Goal(); oElem.style.backgroundColor = getOddsbg(oItem.mOdds, cItem.mOdds); oItem.mOdds = cItem.mOdds; $(oElem).attr("class", getColor(oItem.mOddsF, oItem.mOdds, true)); changed = true; } } if (oItem.rOdds != cItem.rOdds) { oElem = document.getElementById("ro_" + idTail); if (oElem != null) { 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)); changed = true; } } if(changed) window.setTimeout("colors_water(" + oItem.mId + "," + oItem.cId + ")", 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) { var plexs = ["lo_", "mo_", "ro_"]; for (var i = 0; i < plexs.length; i++) { var oElem = document.getElementById(plexs[i] + mId + "_" + cId); oElem.style.backgroundColor = ""; } } function getOddsbg(numF, numR) { var n1 = parseFloat(numF); var n2 = parseFloat(numR); var cName = ""; if (n1 > n2) cName = "#a4ffbb"; else if (n1 < n2) cName = "#ffa4d1"; return cName; } var _matchData = new Object(); function RefreshScore(data) { var leagueItem, oddsItem, matchItem; _matchData.LeagueList = new _glodds.List(); _matchData.MatchList = new _glodds.List(); _matchData.OddsList = new _glodds.List(); var domains = data.split(_glodds.SplitDomain); 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; AllSimplifyNum = 0; 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) AllSimplifyNum++; lItem.matchNum++; } } var oddsDomain = domains[2].split(_glodds.SplitRecord); for (var i = 0; i < oddsDomain.length; i++) { oddsItem = new _glodds.Odds(oddsDomain[i]); _matchData.OddsList.Add(oddsItem.mId + "_" + oddsItem.cId, oddsItem); } MakeTable(); } function MakeTable() { var html = new Array(); var topHtml = new Array(); // 未开场赛程 var bottomeHtml = new Array(); // 未开场赛程 var comIds = Config.getSelectedCompIds().split(","); var hiddenIds = Config.getHiddenLeagueIds().split(","); SimplifyNum = AllSimplifyNum; _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 (hiddenIds.contains(mItem.lId)) continue; if (Config.Level == 1 && lItem.type != 1) { continue; } var oddsArr = new Array(); for (var j = 0; j < comIds.length; j++) { var oItem = _matchData.OddsList.Get(mItem.mId + "_" + comIds[j]); oddsArr.push(oItem); } if (parseInt(mItem.State) >= 0) topHtml.push(GetMatchHtml(mItem, lItem, oddsArr)); else if(mItem.State =="-1") html.push(GetMatchHtml(mItem, lItem, oddsArr)); else { bottomeHtml.push(GetMatchHtml(mItem, lItem, oddsArr)); } } $("#spnLoading").css("display", "none"); document.getElementById("oddsLive").innerHTML = topHtml.join("") + html.join("") + bottomeHtml.join(""); } function GetMatchHtml(match, league, oddsArr) { var html = new Array(); var valTitle = ["主队", "让球", "客队"]; if (Config.OddsType == 3) { valTitle = ["主胜", "和", "客胜"]; } else if (Config.OddsType == 2) { valTitle = ["大球", "大小", "小球"]; } var tpl = [ "", "", "", "", "", "", "", ].join(""); html.push(tpl); var rowContent = getOddsRow(oddsArr); if (rowContent.rowCount == 0) { _matchData.MatchCount--; if (league.type == 1) { SimplifyNum--; } return ""; } html.push(rowContent.content); html.push("
", "" + league.getName() + "" + match.MatchTime + "", "" + match.hName + "" + match.getScoreTag() + "" + match.gName + "", "
公司" + valTitle[0] + "" + valTitle[1] + "" + valTitle[2] + "
"); return html.join(""); } function toAnaly(mId, st) { location.href = "Analysis/" + (st == "-1" ? "shiJian.html" : "") + "?id=" + mId ; return; } function toDetail(mId, cId, oId) { //if (Config.OddsType == 1) // window.open("/HandicapDetail.aspx?f=1&scheId=" + mId + "&companyid=" + cId); //else if (Config.OddsType == 2) // window.open("/OuDetail.aspx?f=1&scheId=" + mId + "&companyid=" + cId); //else if (Config.OddsType == 3) // window.open("/1x2Detail.aspx?f=1&scheId=" + mId + "&o=" + oId + "&cId=" + cId); return; } function getOddsRow(oddsArr) { var html = new Array(); var rowCount = 0; for (var i = 0; i < oddsArr.length; i++) { var oItem = oddsArr[i]; if (!oItem) { continue; } rowCount++; var oddTpl = [ "" + companyName[oItem.cId] + "", "初
即", "" + oItem.lOddsF + "
" + oItem.lOdds + "
", "" + oItem.GoalF() + "
" + oItem.Goal() + "
", "" + oItem.rOddsF + "
" + oItem.rOdds + "" ].join(""); html.push(oddTpl); } return { rowCount: rowCount, content: html.join("") }; } 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 = "
加载比赛失败!
"; } var _curOption = 0; function showSetting(opt) { if (opt == 1) selectOddsType(Config.OddsType); if (opt == 2) { FilterLeague(Config.Level); } if (opt == 3) { collectDateList(); } toggleSettingMode(true, opt); } function collectDateList() { var html = new Array(); var dayMsc = 24 * 60 * 60 * 1000; for (var i = -5; i < 5; 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 selectDate(elem) { $("[data-date]").each(function () { if ($(this).hasClass("on")) $(this).removeClass("on"); }); if (!$(elem).hasClass("on")) $(elem).addClass("on"); } 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 collectLeagueForSelect(simplify) { if (typeof (_matchData.LeagueList) == "undefined") return; var html = new Array(); var hiddenIds = Config.getHiddenLeagueIds(Config.oddsType, (simplify ? 1 : 0)).split(","); var hiddenCount = 0; for (var i = 0; i < _matchData.LeagueList.items.length; i++) { var lItem = _matchData.LeagueList.items[i]; if (simplify && lItem.type != 1) { continue; } var isOn = !hiddenIds.contains(lItem.lId); html.push("" + lItem.getName() + ""); if (!isOn) { hiddenCount += lItem.matchNum; } } document.getElementById("hiddenCount").innerHTML = hiddenCount; document.getElementById("sclassDiv").innerHTML = html.join(""); } 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 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 selectOddsType(opt) { if (opt > 3 || opt < 1) return; for (var i = 1; i < 4; i++) { if (i == opt) $("#sT" + i).addClass("on"); else $("#sT" + i).removeClass("on"); } collectCompsForSelect(opt); } function collectCompsForSelect(opt) { var compArr = Config.getSettingCompIds(opt); var selComps = Config.getSelectedCompIds(opt); var html = new Array(); var compIds = compArr.split(","); var selIds = selComps.split(","); for (var i = 0; i < compIds.length; i++) { var isOn = selIds.contains(compIds[i]); html.push("" + companyName[parseInt(compIds[i])] + ""); } document.getElementById("compDiv").innerHTML = html.join(""); } 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 cancel() { toggleSettingMode(false, 0); } 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" : ""); } function confirm() { var isValid = true; if (_curOption == 1) { isValid = confirmComp(); } else if (_curOption == 2) { isValid = confirmLeague(); } else if (_curOption == 3) { changeDate(); } } function confirmComp() { var compArr = new Array(); $("#compDiv [data-cId]").each(function () { if ($(this).hasClass("on")) compArr.push(($(this).attr("data-cId"))); }); if (compArr.length < 1) { alert("请至少选择一家公司。") return false; } if (compArr.length > 4) { alert("至多选择四家公司。") return false; } var compIds = compArr.join(","); var oddsType = Config.OddsType; for (var i = 1; i < 4; i++) { var typ = document.getElementById("sT" + i); if ($(typ).hasClass("on")) oddsType = parseInt($(typ).attr("data-type")); } if (oddsType != Config.OddsType) { Config.setOddsType(oddsType); writeCookie(Config.getSelCompKey(oddsType), compIds); toggleSettingMode(false, 0); $("#spnLoading").css("display", ""); LoadLiveFile(); } else { writeCookie(Config.getSelCompKey(oddsType), compIds); toggleSettingMode(false, 0); $("#spnLoading").css("display", ""); MakeTable(); } 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); } } }); } $(document).ready(function () { LoadLiveFile(); if (Config.ScheduleMode == 0) window.setTimeout("getChange()", 3000); });