function getElementsByClassName(className, context) {
function hasClass(className, node) {
var classNames = node.className.split(/\s+/);
for (var i = 0; i < classNames.length; i++) {
if (classNames[i] == className) {
return true;
}
}
return false;
}
context = context || document;
if (context.getElementsByClassName) {
return context.getElementsByClassName(className);
}
var nodes = context.getElementsByTagName('*');
var rets = [];
for (var i = 0; i < nodes.length; i++) {
if (hasClass(className, nodes[i])) {
rets.push(nodes[i]);
}
}
return rets;
}
/****/
var adList = [2, 4, 10, 20];
var AnalysisObj = {
cookieName: "analysis_set",
idList: [{ id: "porlet_0", name: "联赛" }, { id: "porlet_1", name: "杯赛" }, { id: "porlet_3", name: "对赛" }, { id: "porlet_5", name: "战绩" }, { id: "porlet_6", name: "对比" }, { id: "porlet_7", name: "特征" }, { id: "porlet_8", name: "Crown" }, { id: "porlet_9", name: "必发" }, { id: "porlet_11", name: "盘路" }, { id: "porlet_12", name: "历史" }, { id: "porlet_13", name: "近期" }, { id: "sameRound", name: "同轮" }, { id: "porlet_14", name: "赛程" }, { id: "porlet_15", name: "阵容" }, { id: "porlet_16", name: "情报" }, { id: "porlet_17", name: "简报" }, { id: "porlet_18", name: "推介" }, { id: "porlet_19", name: "分布" }, { id: "porlet_21", name: "半全" }, { id: "porlet_22", name: "单双" }, { id: "porlet_23", name: "时间" }, { id: "cornerTime", name: "角球" }, { id: "thisSeasonAvg", name: "平均" }, { id: "porlet_24", name: "积分" }, { id: "porlet_25", name: "统计" }, { id: "porlet_26", name: "前瞻" }],
list: new Array(), //页面上显示的块,有顺序的
hideList: new Array(),//页面上隐藏的块,有顺序的
companyIDList: new Array(), //即时指数比较显示的指数公司,有顺序的
cmpList: new Array(),
isLogin: false,
idchange: 0, //当更新数据就+1
init: function () {
var str = getCookie(this.cookieName, null);
this.initWith(str);
this.porlet();
},
initWith: function (str) {
var thisObj = this;
var arr = new Array();
this.hideList = new Array();
this.companyIDList = new Array();
jQuery(this.idList).each(function (i, v) { arr.push(v.id); });
if (str === null){
this.list = arr;
}else if (str != "")
{
var strList = str.split('^');
this.list = strList[0].split('#');
var reArr,reg = new RegExp("^\\d+$");
for (var i = 0; i < this.list.length; i++)
if (reArr = this.list[i].match(reg))
this.list[i] = "porlet_" + reArr[0];
if (strList.length > 1) {
this.companyIDList = strList[1].split('#');
}
if (strList.length > 2) {
this.hideList = strList[2].split('#');
}
var otherArr = Array.minus(arr, Array.union(this.list, this.hideList));
jQuery(otherArr).each(function (i, v) { thisObj.list.push(v); });
}
},
update: function () {
var oristr = getCookie(this.cookieName);
var str = this.list.join("#") + "^" + this.companyIDList.join("#") + "^" + this.hideList.join("#");
writeCookie(this.cookieName, str);
if (oristr != str) {
this.idchange += 1;
}
},
porlet: function () {//显示
function showSpan(context,display)
{
var divNode = getElementsByClassName("porlet_right", context);
if (divNode.length == 0)
return;
var spans = divNode[0].getElementsByTagName("span");
for (var kk = 0; kk < spans.length; kk++) {
spans[kk].style.display = display;
}
}
var tmpListStr = "," + this.list.join(",") + ",";
var listTmp = this.list;
var right_floatHTML = "定制";
for (var i = 0; i < listTmp.length; i++) {
var curNode = $(listTmp[i]);
if (curNode) {
$("porletP_Group").removeChild(curNode);
$("porletP_Group").appendChild(curNode);
curNode.style.display = "";
curNode.onmousemove = function () {
showSpan(this, "block");
}
curNode.onmouseout = function () {
showSpan(this, "none");
}
}
}
listTmp = this.hideList;
for (var i = 0; i < listTmp.length; i++) {
var curNode = $(listTmp[i]);
if (curNode) {
curNode.style.display = "none";
$("porletP_Group").removeChild(curNode);
}
}
for (var i = 0; i < adList.length; i++) {
var ad = $("porlet_" + adList[i]);
var adIndex = i*2 + 1;
$("porletP_Group").removeChild(ad);
if (i == 3 ) adIndex = 12
while (jQuery("#porlet_" + adIndex).length == 0) {
if (adIndex == 10) { adIndex += 2;}
adIndex += 1;
}
jQuery("#porlet_" + adIndex).after(ad);
}
showAndHide();
setTimeout("AnalysisObj.rightSet()", 100);
},
rightSet: function () {
var obj = new Object();
jQuery(this.idList).each(function (i, v) { obj[v.id] = v.name;});
var listTmp = this.list;
var newTool = '
';
var right_floatHTML = "定制" + newTool + "";
for (var i = 0; i < listTmp.length; i++) {
var idName=listTmp[i];
var curNode = $(idName);
if (curNode) {
var pname = obj[idName];
if (pname != "") {
if (["cornerTime", "thisSeasonAvg", "sameRound"].contains(idName))
pname += newTool;
right_floatHTML += "" + pname + "";
}
}
}
$("right_float").innerHTML = right_floatHTML;
resePos();
}
};
//AnalysisObj.load();
AnalysisObj.init();
function resePos() {
setTimeout("changePostion()", 100);
}
/**指数公司定制**/
function addOddsCmp() {
if ($("bt_add_div")) {
if (!$("addOddsCmp_id")) $("bt_add_div").innerHTML = "";
var html = "";
for (var i = 0; i < AnalysisObj.cmpList.length; i += 2) {
var isShow = false;
for (var k = 0; k < AnalysisObj.companyIDList.length; k++) {
if (AnalysisObj.companyIDList[k] == AnalysisObj.cmpList[i]) {
isShow = true;
break;
}
}
html += "" + AnalysisObj.cmpList[i + 1] + "";
}
$("addOddsCmp_id").innerHTML = "" + html + "
";
}
Popup.init({ target: Popup.create('openNew-container-company', '指数公司定制', 'addOddsCmp_id', 480), drag: true, resize: false, autoOpen: true, createOverlay: true, autoLayout: false });
}
function submitOddsCmp() {
AnalysisObj.companyIDList = new Array();
var oddscmpList = document.getElementsByName("oddscmp");
for (var i = 0; i < oddscmpList.length; i++) {
if (oddscmpList[i].checked) {
AnalysisObj.companyIDList.push(oddscmpList[i].value);
}
}
reDisplayCmp();
AnalysisObj.update();
Popup.getInstanceById('openNew-container-company').close();
}
function checkOCompany(obj) {
var isChecked = obj.className == "odds_checked";
obj.getElementsByTagName("input")[0].checked = !isChecked;
obj.className = (!isChecked ? "odds_checked" : "odds_unchecked");
}
function hidOddsCmp(cmpID) {
for (var i = 0; i < AnalysisObj.companyIDList.length; i++) {
if (AnalysisObj.companyIDList[i] == cmpID) {
AnalysisObj.companyIDList.splice(i, 1);
break;
}
}
reDisplayCmp();
}
function reDisplayCmp() {
for (var i = 0; i < AnalysisObj.cmpList.length; i += 2) {
var isShow = false;
for (var k = 0; k < AnalysisObj.companyIDList.length; k++) {
if (AnalysisObj.companyIDList[k] == AnalysisObj.cmpList[i]) {
isShow = true;
break;
}
}
$("tr_o_1_" + AnalysisObj.cmpList[i]).style.display = (isShow ? "" : "none");
$("tr_o_2_" + AnalysisObj.cmpList[i]).style.display = (isShow ? "" : "none");
try {
$("tr_o_3_" + AnalysisObj.cmpList[i]).style.display = (isShow ? "" : "none");
}
catch (e) { }
}
}
//从odds读取回来的页面数据显示
function oddsComp() {
var nods = $("iframeA").childNodes;
for (var c = 0; c < 3; c++) {//nods.length
var theTag = nods[c];
if (c == 0) {
if (!theTag || theTag.getAttribute("id") != "iframeAOdds") continue;
var allCompOdds = new Array();
var ll = theTag.value.split("^");
for (var i = 0; i < ll.length; i++) {
allCompOdds.push(ll[i].split(';'));
}
var html = '即时指数比较
公司 | | 欧洲指数 | 欧转亚盘 | 实际最新亚盘 | 大小球 | 变化 | |
'
+ '主胜 | 和局 | 客胜 | 主队 | 让球 | 客队 | 总水位 | 主队 | 让球 | 客队 | 总水位 | 大球 | 让球 | 小球 |
';
//Crown 初指 1.60 3.60 4.55 0.90 半/一 0.95 1.85 0.85 半/一 1.01 1.86 0.99 2.5/3 0.85
//var allCompOdds = [["3","SB","1.60,3.60,4.55,0.90,半/一,0.95,1.85,0.85,半/一,1.01,1.86,0.99,2.5/3,0.85","1.45,4.10,5.35,0.90,一球,0.95,1.85,0.32,平手,2.00,2.32,3.33,4.5,0.10"],["...","...","...","..."]];
AnalysisObj.cmpList = new Array();
for (var i = 0; i < allCompOdds.length; i++) {
var odds = allCompOdds[i];
AnalysisObj.cmpList.push(odds[0]);
AnalysisObj.cmpList.push(odds[1]);
var addCss = "display:none;";
for (var k = 0; k < AnalysisObj.companyIDList.length; k++) {
if (AnalysisObj.companyIDList[k] == odds[0]) {
addCss = "";
break;
}
}
var o1 = odds[2].split(',');
var o2 = odds[3].split(',');
var o3;
var tdNum = 2;
if (odds.length > 4) {
o3 = odds[4].split(',');
if (typeof (o3[0]) != "undefined" && o3[0] != "")
tdNum = 3;
}
html += '' + odds[1] + ' | 初指 | ' + o1[0] + ' | ' + o1[1] + ' | ' + o1[2] + ' | ' + o1[3] + ' | ' + o1[4] + ' | ' + o1[5] + ' | ' + o1[6] + ' | ' + o1[7] + ' | ' + o1[8] + ' | ' + o1[9] + ' | ' + o1[10] + ' | ' + o1[11] + ' | ' + o1[12] + ' | ' + o1[13] + ' | | |
'
+ '' + (tdNum == 2 ? "即时" : "终指") + ' | ' + o2[0] + ' | ' + o2[1] + ' | ' + o2[2] + ' | ' + o2[3] + ' | ' + o2[4] + ' | ' + o2[5] + ' | ' + o2[6] + ' | ' + o2[7] + ' | ' + o2[8] + ' | ' + o2[9] + ' | ' + o2[10] + ' | ' + o2[11] + ' | ' + o2[12] + ' | ' + o2[13] + ' |
';
if (tdNum == 3) {
html += '滚球 | ' + (o2[1] != o3[1] ? o3[0] : "") + ' | ' + (o2[1] != o3[1] ? o3[1] : "") + ' | ' + (o2[1] != o3[1] ? o3[2] : "") + ' | | | | | ' + o3[7] + ' | ' + o3[8] + ' | ' + o3[9] + ' | ' + o3[10] + ' | ' + o3[11] + ' | ' + o3[12] + ' | ' + o3[13] + ' |
';
}
}
html += '
';
$("porlet_" + (c + 1)).innerHTML = html;
}
else //console.log(theTag.innerHTML);
$("porlet_" + (c + 1)).innerHTML = theTag.innerHTML;
}
$("iframeA").innerHTML = "";
//showAndHide();
AnalysisObj.porlet();
}
/**页面上的板块**/
function openSetting() {
Popup.init({ target: Popup.create('openNew-container-setting' + AnalysisObj.idchange, '分析数据定制', 'ASetting.html?', 550, 500), drag: true, resize: true, autoOpen: true, createOverlay: true, autoLayout: false });
}
function openLnk(sid) {
if (location.href.toLowerCase().indexOf("_big") != -1)
location.href = "/analysis/" + sid + "_big.htm";
else
location.href = "/analysis/" + sid + ".htm";
}
//页面那些板块的显隐藏
function showAndHide() {
//读取设置,控制显示
var listTmp = AnalysisObj.list;
for (var i = 0; i < listTmp.length; i++) {
var idName = listTmp[i];
var curNode = $(idName);
if (curNode) {
var tagH2 = curNode.getElementsByTagName("h3");
if (tagH2.length > 0) {
if (tagH2[0].innerHTML.indexOf("porlet_right") <= 0) {
var html = "
" + tagH2[0].innerHTML;
tagH2[0].innerHTML = html;//float:right的标签要放在前面
}
}
}
}
}
function r_up(id) {
var listTmp = AnalysisObj.list;
if (typeof (id) === "number")
id = "porlet_" + id;
for (var i = 0; i < listTmp.length; i++) {
var idName = listTmp[i];
if (idName == id)
{
if (i > 0) {
for (var j = i - 1; j >-1; j--)
{
var idName2=listTmp[j];
var curNode = $(idName2);
if (curNode && jQuery(curNode).is(":visible")) {
listTmp[j] = idName;
listTmp[i] = idName2;
AnalysisObj.update();
AnalysisObj.porlet();
break;
}
}
}
break;
}
}
}
function r_down(id) {
var listTmp = AnalysisObj.list;
if (typeof (id) === "number")
id = "porlet_" + id;
for (var i = 0; i < listTmp.length; i++) {
var idName = listTmp[i];
if (idName == id) {
if (i > 0) {
for (var j = i + 1; j < listTmp.length; j++) {
var idName2 = listTmp[j];
var curNode = $(idName2);
if (curNode && jQuery(curNode).is(":visible")) {
listTmp[j] = idName;
listTmp[i] = idName2;
AnalysisObj.update();
AnalysisObj.porlet();
break;
}
}
}
break;
}
}
}
function r_close(id) {
var listTmp = AnalysisObj.list;
if (typeof (id) === "number")
id = "porlet_" + id;
for (var i = 0; i < listTmp.length; i++) {
var idName = listTmp[i];
if (idName == id) {
listTmp.splice(i, 1);
AnalysisObj.hideList.push(id);
AnalysisObj.update();
AnalysisObj.porlet();
break;
}
}
}
/**其他方法**/
function getLeft(e) {
var offset = e.offsetLeft;
if (e.offsetParent != null)
offset += getLeft(e.offsetParent);
return offset;
}
//cookie操作
function getCookie(name, dV) {
var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
if (arr = document.cookie.match(reg))
return unescape(arr[2]);
else
return typeof dV === "undefined" ? "" : dV;
}
function writeCookie(name, value) {
var expire = "";
var hours = 365;
expire = new Date((new Date()).getTime() + hours * 3600000);
expire = ";path=/;expires=" + expire.toGMTString();
document.cookie = name + "=" + value + expire;
}
/**重写**/
function changePostion() {
if (typeof window.fixedDiv == "function") {
window.fixedDiv = function () { };
}
var analyMapNode = document.getElementById("analyMap");
var rfNode = document.getElementById("right_float");
var nodeLeft = document.getElementById("teammain").offsetWidth / 2 + 5;
analyMapNode.style.cssText = "position:absolute;left:50%;width:60px;top:0px;height:100%;margin-left:" + nodeLeft+"px;z-index:100";
rfNode.style.position = "fixed";
rfNode.style.top = Math.min(200, Math.max(0, _dom_W_H.h - rfNode.offsetHeight) / 2) + "px";
}