var isShowRank = true;
var isShowYellowCard = true;
var isShowRedCard = true;
var isTanScore = true;
var isTanRed = true;
var isSound = true;
var isRedSound = true;
var scoreType = "0";//0全部,1一级,2足彩,3竞猜,4单场
var language = "";
var sclassList = "";
var arrSche = new Array();
var arrSclass = new Array();
var arrOdds = new Array();
var arrVideo = [];
var arrColor = ["#006666", "#518ed2", "#e8811a", "#949720", "#8f6dd6", "#53ac98", "#ff9966", "#a2e76f", "#8d8abd", "#996733", "#8c8a64", "#999012", "#ff6633", "#ca00ca", "#1ba570", "#990099"];
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", "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 timeDiff = 0;
var refreshTime = 3000;
var focusObj = (function () {
var n = "focusArr";
var strFocusStr = $.cookie(n);
return {
cookieName: n,
idArray: typeof (strFocusStr) == "undefined" ? [] : strFocusStr.split(",")
}
})();
$(document).ready(function () {
var audio = document.getElementById("sound");
function readySound() {
audio.load();
}
var u = navigator.userAgent;
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
if (isAndroid)
$(document).one('click', readySound);
if (isiOS)
$(document).one('touchstart', readySound);
});
function letsgo() {
//加载cookie
isShowRank = (findCookie("isRankShow") == "1");
isShowYellowCard = (findCookie("isYellowShow") == "1");
isRedSound = (findCookie("isRedSound") == "1");
isTanScore = (findCookie("isScoreTan") == "1");
isTanRed = (findCookie("isRedTan") == "1");
isSound = (findCookie("isScoreSoundLq") == "1");
language = findCookie("language");
scoreType = findCookie("scoreTypeLq");
var ifLevel1 = false;
if (scoreType == "" || scoreType == "1")
scoreType = "0";
if (language == ""||language=="2")
language = "0";
var scoreTxt = "Schedule_" + language + "_0.js";
bomHelper.ajaxGet("/live/lq/data/GetVideoJson.js?ifScoccer=false", function (videoData) {
arrVideo = videoData;
//加载比分赛程
bomHelper.ajaxGet("/live/lq/data/" + scoreTxt, function (data) {
if (data == "$$")
showData();
var arrData = data.split("$$");
dealWithData(arrData[0], arrData[1]);
setInterval("dealwithScoreChange()", refreshTime);
});
});
}
//处理数据
function dealWithData(sclassData, data) {
var arrSclassDD = sclassData.split("!");
sclassList = findCookie("sclassListLq");
var arrSclassList;
if (!sclassList || sclassList == "")
arrSclassList = new Array();
else
arrSclassList = sclassList.split(",");
for (var i = 0; i < arrSclassDD.length; i++) {
var qt = new QtSclass(arrSclassDD[i]);
//if (scoreType == 2 && qt.sclassID != 1)
// continue;
if (qt.isShow)
for (var m = 0; m < arrSclassList.length; m++) {
if (qt.sclassID == arrSclassList[m]) {
qt.isShow = qt.isTmpShow = false;
}
}
arrSclass.push(qt);
}
var isTopCookieStr = findCookie("isTopLq");
var arrNewCookie = new Array();
var arrNotTop = new Array();
var arr = data.split("!");
for (var i = 0; i < arr.length; i++) {
var qt = new Qtscore(arr[i]);
var sclass = null;
for (var j = 0; j < arrSclass.length; j++) {
var tempSclass = arrSclass[j];
if (qt.sclassid == tempSclass.sclassID) {
sclass = tempSclass;
break;
}
}
if (sclass == null)
continue;
qt.sclassColor = sclass.sclassColor;
qt.sclassName = sclass.sclassName;
qt.isShow = sclass.ifSelected();
for (var j = 0; j < arrOdds.length; j++) {
var od = arrOdds[j];
if (qt.scheduleid == od.scheid) {
qt.Odds = od;
break;
}
}
if (typeof(isTopCookieStr) != "undefined" && isTopCookieStr.indexOf(qt.scheduleid) != -1) {
qt.isTop = true;
//qt.isShow = !sclass.ifHided();
arrNewCookie.push(qt.scheduleid + ",");
arrSche.push(qt);
} else
arrNotTop.push(qt);
}
//更新现有cookie
document.cookie = "isTopLq=" + arrNewCookie.join("");
for (var i = 0; i < arrNotTop.length; i++)
arrSche.push(arrNotTop[i]);
showData();
}
var advHelper = new AdvertHelper(5);
advHelper.init(function () {
if (typeof (Advert.supple) === "function") Advert.supple();
});
function Advert() {
var AdvertObj = this;
this.topIndex = 0;
var arrAd = advHelper.getItem("arrAd", null);
var length = arrAd == null ? 3 : arrAd.length;
if (arrAd == null) {
Advert.supple = function () {
advHelper.setArrEach("arrAd", function (obj) {
return showCotent(obj);
});
}
} else Advert.supple = undefined;
function showCotent(adObj) {
var url = advHelper.link + adObj.id;
if (adObj.imgPath == "")
return "" + adObj.title + "";
else return "
";
}
function showAdvert(html, arrAd, index) {
var reVal = "";
if (arrAd !== null)
reVal = showCotent(arrAd[index]);
html.push("
" + reVal + "
");
}
this.Show = function (html, index) {
if (index < 1 || (index - 2) % 2 != 0)
return;
if (this.topIndex < length) {
showAdvert(html, arrAd, this.topIndex);
this.topIndex++;
}
}
this.ShowRemain = function (html) {
for (var i = this.topIndex; i < length; i++) {
showAdvert(html, arrAd, i);
}
}
}
function filterData() {
}
//显示数据
function showData() {
var arrHtml = new Array();
var matchCount = 0;
var advertTool = new Advert();
for (var i = 0; i < arrSche.length; i++) {
var qt = arrSche[i];
advertTool.Show(arrHtml, i);
matchCount++;
var scoreColor = "blue";
if (qt.matchState < 0)
scoreColor = "red";
var stateColor = "red";
if (qt.matchState == 0)
stateColor = "weiKai";
else if (qt.matchState == 50)
stateColor = "zBlue";
arrHtml.push(" "
+ "
"
+ " " + qt.sclassName + " " + qt.matchTimeStr + " " + showMatchState(qt.matchState) + " " + qt.remainTime + " | " + (qt.letgoal === "" ? "" : "让:" + qt.letgoal) + "" + (qt.totalgoal === "" ? "" : "总:" + qt.totalgoal) + " |
"
+ " | " + qt.homeTeam + " | " + qt.homeScore1 + " | " + qt.homeScore2 + " | " + qt.homeScore3 + " | " + qt.homeScore4 + " | " + qt.homeScore + " |
"
+ " | " + qt.awayTeam + " | " + qt.awayScore1 + " | " + qt.awayScore2 + " | " + qt.awayScore3 + " | " + qt.awayScore4 + " | " + qt.awayScore + " |
");
arrHtml.push("
" + qt.textLive + "
");
arrHtml.push("
");
}
advertTool.ShowRemain(arrHtml);
if (matchCount != 0) {
document.getElementById("content").innerHTML = arrHtml.join("");
}
else
{
document.getElementById("content").innerHTML = "暂无相关比赛
" + arrHtml.join("");
}
}
//初始化比分对象
function Qtscore(data) {
var arrTr = data.split("^");
this.scheduleid = arrTr[0];
this.sclassid = arrTr[1];
this.matchState = parseInt(arrTr[4]);
this.matchTime = arrTr[3];
this.matchTimeStr = arrTr[3].substr(8, 2) + ":" + arrTr[3].substr(10, 2);
this.remainTime = arrTr[5];
this.homeTeam = arrTr[6];
this.awayTeam = arrTr[7];
this.homeScore = arrTr[8];
this.awayScore = arrTr[9];
this.letgoal = arrTr[10];
this.totalgoal = arrTr[28];
this.textLive="";
if (this.sclassid<3) {
if (this.matchState==0) {
this.textLive="未开场";
}else if (this.matchState==50) {
var tl = " 中场休息 分差:" + (parseInt(this.homeScore) - parseInt(this.awayScore)) + ",总分:" + (parseInt(this.homeScore) + parseInt(this.awayScore));
this.textLive=tl;
}else if(this.matchState==-1) {
var tl = " 全场结束 分差:" + (parseInt(this.homeScore) - parseInt(this.awayScore)) + ",总分:" + (parseInt(this.homeScore) + parseInt(this.awayScore));
this.textLive=tl;
}else{
this.textLive = arrTr[13];
}
}
this.homeScore1 = arrTr[15];
this.awayScore1 = arrTr[16];
this.homeScore2 = arrTr[17];
this.awayScore2 = arrTr[18];
this.homeScore3 = arrTr[19];
this.awayScore3 = arrTr[20];
this.homeScore4 = arrTr[21];
this.awayScore4 = arrTr[22];
this.homeScore5 = arrTr[23];
this.awayScore5 = arrTr[24];
this.sclassName = "";
this.sclassColor = "";
this.isShow = true;
this.isTop = false;
this.isFocus = $.inArray(this.scheduleid, focusObj.idArray) > -1;
}
//初始化联赛对象
function QtSclass(data) {
var arrTr = data.split("^");
this.sclassID = arrTr[1];
this.sclassName = arrTr[0];
this.isLevel1 = (arrTr[2] == "1");
this.sclassColor = arrColor[parseInt(this.sclassID) % 16];
this.isShow = true;
this.isTmpShow = true;
this.ifHided = function () {
return scoreType == 2 && this.sclassID != 1;
}
this.ifSelected = function () {
return this.isShow && !this.ifHided();
}
}
//显示状态
function showMatchState(mState) {
var ms = "";
switch (mState) {
case -1: ms = "完"; break;
case 0: ms = "未开"; break;
case 1:
case 2:
case 3:
case 4: ms = "第" + mState + "节"; break;
case 50: ms = "中场"; break;
case 5:
case 6:
case 7: ms = (mState - 4) + "'OT"; break;
case -2: ms = "待定"; break;
case -3: ms = "中断"; break;
case -4: ms = "取消"; break;
case -5: ms = "推迟"; break;
// default:ms=[NSString stringWithFormat:@"%@:%@",self.homeScore,self.awayScore];
// break;
}
if (language && language == "1") {
switch (mState) {
case 0: ms = "未開"; break;
case 50: ms = "中場"; break;
case -5: ms = "推遲"; break;
}
}
return ms;
}
//处理数据变化文件
function dealwithScoreChange() {
function setClass(dom, className) {
if (typeof dom.setAttribute !== "undefined")
dom.setAttribute("class", className);
else
dom.className = className;
}
bomHelper.ajaxGet("/live/lq/data/livechange.js", function (data) {
var arrData = data.split("!");
var isTan = true;
for (var i = 0; i < arrData.length; i++) {
if (arrData[i] === "")
continue;
var live = new QtliveChange(arrData[i]);
var isStateChange = false;
var j = 0;
for (; j < arrSche.length; j++) {
var qt = arrSche[j];
if (live.scheduleid == qt.scheduleid) {
if (live.matchState != qt.matchState || live.remainTime != qt.remainTime) {
qt.matchState = live.matchState;
qt.remainTime = live.remainTime;
var stateObj = document.getElementById("state_" + qt.scheduleid);
if (qt.matchState >= 0)
stateObj.innerHTML = showMatchState(qt.matchState) + " " + qt.remainTime;
else
{
stateObj.innerHTML = showMatchState(qt.matchState) + " ";
var hObj = document.getElementById("h_" + qt.scheduleid);
setClass(hObj, "red b");
var aObj = document.getElementById("a_" + qt.scheduleid);
setClass(aObj, "red b");
}
setClass(stateObj, "state " + (qt.matchState == 0 ? "weiKai" : (qt.matchState == 50 ? "zBlue" : "red")));
isStateChange = (qt.matchState <= -1);
}
//主队
if (live.homeScore1 != qt.homeScore1)
{
qt.homeScore1 = live.homeScore1;
var hObj = document.getElementById("h1_" + qt.scheduleid);
hObj.innerHTML = qt.homeScore1;
hObj.style.color = "red";
setTimeout("resetColor('h1_" + qt.scheduleid + "')", 10000);
}
if (live.homeScore2 != qt.homeScore2) {
qt.homeScore2 = live.homeScore2;
var hObj = document.getElementById("h2_" + qt.scheduleid);
hObj.innerHTML = qt.homeScore2;
hObj.style.color = "red";
setTimeout("resetColor('h2_" + qt.scheduleid + "')", 10000);
}
if (live.homeScore3 != qt.homeScore3) {
qt.homeScore3 = live.homeScore3;
var hObj = document.getElementById("h3_" + qt.scheduleid);
hObj.innerHTML = qt.homeScore3;
hObj.style.color = "red";
setTimeout("resetColor('h3_" + qt.scheduleid + "')", 10000);
}
if (live.homeScore4 != qt.homeScore4) {
qt.homeScore4 = live.homeScore4;
var hObj = document.getElementById("h4_" + qt.scheduleid);
hObj.innerHTML = qt.homeScore4;
hObj.style.color = "red";
setTimeout("resetColor('h4_" + qt.scheduleid + "')", 10000);
}
//if (live.homeScore5 != qt.homeScore5) {
// qt.homeScore5 = live.homeScore5;
// var hObj = document.getElementById("h5_" + qt.scheduleid);
// hObj.innerHTML = qt.homeScore5;
// hObj.style.color = "red";
// setTimeout("resetColor('h5_" + qt.scheduleid + "')", 10000);
//}
if (live.homeScore != qt.homeScore) {
playSound();
qt.homeScore = live.homeScore;
var hObj = document.getElementById("h_" + qt.scheduleid);
hObj.innerHTML = qt.homeScore;
hObj.style.backgroundColor = "yellow";
setTimeout("resetOddsColor('h_" + qt.scheduleid + "')", 10000);
}
if (live.awayScore1 != qt.awayScore1) {
qt.awayScore1 = live.awayScore1;
var hObj = document.getElementById("a1_" + qt.scheduleid);
hObj.innerHTML = qt.awayScore1;
hObj.style.color = "red";
setTimeout("resetColor('a1_" + qt.scheduleid + "')", 10000);
}
if (live.awayScore2 != qt.awayScore2) {
qt.awayScore2 = live.awayScore2;
var hObj = document.getElementById("a2_" + qt.scheduleid);
hObj.innerHTML = qt.awayScore2;
hObj.style.color = "red";
setTimeout("resetColor('a2_" + qt.scheduleid + "')", 10000);
}
if (live.awayScore3 != qt.awayScore3) {
qt.awayScore3 = live.awayScore3;
var hObj = document.getElementById("a3_" + qt.scheduleid);
hObj.innerHTML = qt.awayScore3;
hObj.style.color = "red";
setTimeout("resetColor('a3_" + qt.scheduleid + "')", 10000);
}
if (live.awayScore4 != qt.awayScore4) {
qt.awayScore4 = live.awayScore4;
var hObj = document.getElementById("a4_" + qt.scheduleid);
hObj.innerHTML = qt.awayScore4;
hObj.style.color = "red";
setTimeout("resetColor('a4_" + qt.scheduleid + "')", 10000);
}
if (live.awayScore4 != qt.awayScore4) {
qt.awayScore4 = live.awayScore4;
var hObj = document.getElementById("a4_" + qt.scheduleid);
hObj.innerHTML = qt.awayScore4;
hObj.style.color = "red";
setTimeout("resetColor('a4_" + qt.scheduleid + "')", 10000);
}
//if (live.awayScore5 != qt.awayScore5) {
// qt.awayScore5 = live.awayScore5;
// var hObj = document.getElementById("a5_" + qt.scheduleid);
// hObj.innerHTML = qt.awayScore5;
// hObj.style.color = "red";
// setTimeout("resetColor('a5_" + qt.scheduleid + "')", 10000);
//}
if (live.awayScore != qt.awayScore) {
playSound();
qt.awayScore = live.awayScore;
var hObj = document.getElementById("a_" + qt.scheduleid);
hObj.innerHTML = qt.awayScore;
hObj.style.backgroundColor = "yellow";
setTimeout("resetOddsColor('a_" + qt.scheduleid + "')", 10000);
}
if (live.textLive!="")
{
qt.textLive = live.textLive;
document.getElementById("tl_" + qt.scheduleid).innerHTML = qt.textLive;
}
break;
}
}
if (isStateChange) {
//完场赛事置底
setTimeout("toBottom(" + j + ")", 8000);
}
}
});
}
function QtliveChange(data) {
var arrTr = data.split("^");
this.scheduleid = arrTr[0];
this.matchState = parseInt(arrTr[1]);
this.remainTime = arrTr[2];
this.homeScore = parseInt(arrTr[3]);
this.awayScore = parseInt(arrTr[4]);
if (this.matchState == 0) {
this.textLive = "未开场";
} else if (this.matchState == 50) {
var tl = " 中场休息 分差:" + (this.homeScore - this.awayScore) + ",总分:" + (this.homeScore + this.awayScore);
this.textLive = tl;
} else if (this.matchState == -1) {
var tl = " 全场结束 分差:" + (this.homeScore - this.awayScore) + ",总分:" + (this.homeScore + this.awayScore);
this.textLive = tl;
} else {
this.textLive = arrTr[5];
}
this.homeScore1 = arrTr[6];
this.awayScore1 = arrTr[7];
this.homeScore2 = arrTr[8];
this.awayScore2 = arrTr[9];
this.homeScore3 = arrTr[10];
this.awayScore3 = arrTr[11];
this.homeScore4 = arrTr[12];
this.awayScore4 = arrTr[13];
this.homeScore5 = arrTr[14];
this.awayScore5 = arrTr[15];
}
//重置颜色
function resetColor(sid) {
document.getElementById(sid).style.color = "black";
}
function resetOddsColor(sid) {
var oj = document.getElementById(sid);
oj.style.backgroundColor = "";
}
//隐藏弹窗
function hideTan(sid) {
document.getElementById(sid).style.display = "none";
}
function Goal2GoalCn(goal) { //数字盘口转汉汉字
if (goal == null || goal + "" == "")
return "";
else {
if (goal > 10 || goal < -10) return goal + "";
if (goal >= 0) return GoalCn2[parseInt(goal * 4)];
else return "-" + GoalCn2[Math.abs(parseInt(goal * 4))];
}
}
//置顶
function zhiDing(scheid, aObj, evt) {
var e = (evt) ? evt : window.event; //判断浏览器的类型,在基于ie内核的浏览器中的使用cancelBubble
if (window.event) {
e.cancelBubble = true;
} else {
//e.preventDefault(); //在基于firefox内核的浏览器中支持做法stopPropagation
e.stopPropagation();
}
var obj = undefined;
var i = 0;
var isFind = false;
for (; i < arrSche.length; i++) {
var qt = arrSche[i];
if (qt.scheduleid == scheid) {
qt.isTop = !qt.isTop;
obj = qt;
isFind = true;
var aClass = aObj.querySelector(".topOn,.topOff").classList;
aClass.toggle("topOn");
aClass.toggle("topOff");
//处理cookie
var isTopCookie = findCookie("isTopLq");
if (isTopCookie == "" || typeof (isTopCookie) == "undefined") {
if (qt.isTop)
document.cookie = "isTopLq=" + qt.scheduleid + ",";
} else {
if (qt.isTop && isTopCookie.indexOf(qt.scheduleid) == -1)
document.cookie = "isTopLq=" + isTopCookie + qt.scheduleid + ",";
else if (!qt.isTop && isTopCookie.indexOf(qt.scheduleid) != -1) {
var rp = isTopCookie.replace("" + qt.scheduleid + ",", "");
document.cookie = "isTopLq=" + rp;
}
}
break;
}
}
if (isFind) {
arrSche.splice(i, 1);
var contentObj = document.getElementById("content");
var childNode = document.getElementById("match_" + scheid);
contentObj.removeChild(childNode);
positionObj(obj, childNode);
}
}
function positionObj(qs, childNode) {
var i = 0;
var o;
for (; i < arrSche.length; i++) {
o = arrSche[i];
//假若为置顶
if (qs.isTop) {
if (o.isTop)//判断置顶
{
//判断状态
if (o.matchState > 0 && qs.matchState > 0) {
if (o.matchTime.localeCompare(qs.matchTime) > 0)//时间大的排在后面
break;
else
continue;//否则下一个
} else if (o.matchState > 0 && qs.matchState <= 0) {
continue;
} else if (o.matchState == 0 && qs.matchState > 0)
break;
else if (o.matchState == 0 && qs.matchState == 0) {
if (o.matchTime.localeCompare(qs.matchTime) > 0)//时间大的排在后面
break;
else
continue;//否则下一个
}
else if (o.matchState == 0 && qs.matchState < 0)
continue;
else if (o.matchState < 0 && qs.matchState >= 0)
break;
else//大家都小于0
{
if (o.matchTime.localeCompare(qs.matchTime) > 0)//时间大的排在后面
break;
else
continue;//否则下一个
}
} else
break;//置顶优先
} else {
if (o.isTop)
continue;
else {
//判断状态
if (o.matchState > 0 && qs.matchState > 0) {
if (o.matchTime.localeCompare(qs.matchTime) > 0)//时间大的排在后面
break;
else
continue;//否则下一个
} else if (o.matchState > 0 && qs.matchState <= 0) {
continue;
} else if (o.matchState == 0 && qs.matchState > 0)
break;
else if (o.matchState == 0 && qs.matchState == 0) {
if (o.matchTime.localeCompare(qs.matchTime) > 0)//时间大的排在后面
break;
else
continue;//否则下一个
}
else if (o.matchState == 0 && qs.matchState < 0)
continue;
else if (o.matchState < 0 && qs.matchState >= 0)
break;
else//大家都小于0
{
if (o.matchTime.localeCompare(qs.matchTime) > 0)//时间大的排在后面
break;
else
continue;//否则下一个
}
}
}
}
arrSche.splice(i, 0, qs);
if (!o)
return;
var tempNode = document.getElementById("match_" + o.scheduleid);
document.getElementById("content").insertBefore(childNode, tempNode);
}
//把完场节点移到底部
function toBottom(pos) {
var qt = arrSche[pos];
arrSche.splice(pos, 1);
var contentObj = document.getElementById("content");
var childNode = document.getElementById("match_" + qt.scheduleid);
contentObj.removeChild(childNode);
positionObj(qt, childNode);
}
function toFenXi(scheid) {
for (var i = 0; i < arrSche.length; i++) {
var qt = arrSche[i];
if (qt.scheduleid == scheid) {
if (qt.matchState == 0) {
window.location.href = "/live/lq/Analysis/?id=" + scheid;
} else {
window.location.href = "/live/lq/Analysis/shiJian.html?id=" + scheid;
}
break;
}
}
}
//声音相应,暂时只支持android
function playSound() {
if (isSound) {
document.getElementById("sound").play();
}
}
function playRedSound() {
if (isRedSound) {
document.getElementById("sound").play();
}
}