|
发表于 2012-11-18 15:43:19
|
显示全部楼层
- $().ready(function () {
- var homecompobj = $(".homecomp");
- var awaycompobj = $(".awaycomp");
- var vscompobj = $(".vscomp");
- var hometrobj = homecompobj.find("tr");
- var awaytrobj = awaycompobj.find("tr");
- var vstrobj = vscompobj.find("tr");
- var teamname = 0;
- var homeindex = 2;
- var awayindex = 4;
- var recordindex = 3;
- if (GetCookie('historyShowThisMatch') == 1) {
- $('#jsSetVisible').attr('checked', true);
- $('.jsThisMatch').show();
- } else {
- $('#jsSetVisible').attr('checked', false);
- $('.jsThisMatch').hide();
- }
- $('#jsSetVisible').click(function () {
- if (this.checked) {
- SetCookie('historyShowThisMatch', 1, 100 * 24 * 60 * 60, '/');
- $('.jsThisMatch').show();
- google_p([action, '选择包含本场']);
- } else {
- SetCookie('historyShowThisMatch', 0, 100 * 24 * 60 * 60, '/');
- $('.jsThisMatch').hide();
- google_p([action, '取消包含本场']);
- }
- })
- function gethomerecord(team, returnid, trobj) {
- var victory = 0;
- var failure = 0;
- var draw = 0;
- var homevictory = 0;
- var homefailure = 0;
- var homedraw = 0;
- for (var i = 3, ilen = trobj.length; i < ilen; i++) {
- if ($(trobj[i]).css("display") == "none") continue;
- var datasarr = $(trobj[i]).attr("attr").split(",");
- var recordval = datasarr[1];
- if (recordval == "-") continue;
- var recordarr = recordval.split("-");
- var homescore = Number(recordarr[0]);
- var awayscore = Number(recordarr[1]);
- var homeid = $(trobj[i]).find("td").eq(homeindex).attr("attr");
- var awayid = $(trobj[i]).find("td").eq(awayindex).attr("attr");
- if (returnid == homeid) {
- var checkscore = homescore - awayscore;
- if (checkscore > 0) {
- homevictory++;
- } else if (checkscore < 0) {
- homefailure++;
- } else if (checkscore == 0) {
- homedraw++
- }
- } else if (returnid == awayid) {
- var checkscore = awayscore - homescore;
- }
- if (checkscore > 0) {
- victory++;
- } else if (checkscore < 0) {
- failure++;
- } else if (checkscore == 0) {
- draw++
- }
- }
- if (team != "away") {
- var gethtml = victory + "胜" + draw + "平" + failure + "负,其中主场" + homevictory + "胜" + homedraw + "平" + homefailure + "负";
- } else {
- var gethtml = victory + "胜" + draw + "平" + failure + "负,其中客场" + (victory - homevictory) + "胜" + (draw - homedraw) + "平" + (failure - homefailure) + "负";
- }
- return gethtml;
- }
- function getscorehtml(team, returnid, trobj) {
- $("." + team + "score").html(gethomerecord(team, returnid, trobj));
- }
- getscorehtml("home", host_team_id, hometrobj);
- getscorehtml("away", guest_team_id, awaytrobj);
- getscorehtml("vs", host_team_id, vstrobj);
- $("#HomeLeagueFilter").change(function () {
- filter(hometrobj, "Home", host_team_id, $(this));
- getscorehtml("home", host_team_id, hometrobj);
- });
- $("#HomeFilter").change(function () {
- filter(hometrobj, "Home", host_team_id, $(this));
- getscorehtml("home", host_team_id, hometrobj);
- });
- $("#HomeCount").change(function () {
- filter(hometrobj, "Home", host_team_id, $(this));
- getscorehtml("home", host_team_id, hometrobj);
- });
- $("#AwayLeagueFilter").change(function () {
- filter(awaytrobj, "Away", guest_team_id, $(this));
- getscorehtml("away", guest_team_id, awaytrobj);
- });
- $("#AwayFilter").change(function () {
- filter(awaytrobj, "Away", guest_team_id, $(this));
- getscorehtml("away", guest_team_id, awaytrobj);
- });
- $("#AwayCount").change(function () {
- filter(awaytrobj, "Away", guest_team_id, $(this));
- getscorehtml("away", guest_team_id, awaytrobj);
- });
- $("#VsLeagueFilter").change(function () {
- filter(vstrobj, "Vs", host_team_id, $(this));
- getscorehtml("vs", host_team_id, vstrobj);
- });
- $("#VsFilter").change(function () {
- filter(vstrobj, "Vs", host_team_id, $(this));
- getscorehtml("vs", host_team_id, vstrobj);
- });
- $("#VsCount").change(function () {
- filter(vstrobj, "Vs", host_team_id, $(this));
- getscorehtml("vs", host_team_id, vstrobj);
- });
- function filter(trobj, team, idval, curobj) {
- var teamval = $("#" + team + "LeagueFilter").val();
- var haval = $("#" + team + "Filter").val();
- var conval = $("#" + team + "Count ").val();
- var checki = 0;
- for (var i = 3, ilen = trobj.length; i < ilen; i++) {
- var teamtext = $(trobj[i]).find("td").eq(teamname).text().trim();
- var datasarr = $(trobj[i]).attr("attr").split(",");
- var homeid = datasarr[0];
- var awayid = datasarr[2];
- var isFriendly = $(trobj[i]).attr('data-lt');
- if (teamval == 'notFriendly' && isFriendly == 'friend') {
- $(trobj[i]).hide();
- continue;
- }
- if (teamval != "all" && teamval != 'notFriendly' && teamtext != teamval) {
- $(trobj[i]).hide();
- continue;
- }
- if (haval != "all" && haval == "Away") {
- if (awayid != idval) {
- $(trobj[i]).hide();
- continue;
- }
- } else if (haval != "all" && haval == "Home") {
- if (homeid != idval) {
- $(trobj[i]).hide();
- continue;
- }
- }
- checki++;
- if (checki > Number(conval)) {
- $(trobj[i]).hide();
- continue;
- }
- $(trobj[i]).show();
- }
- google_p([action, team + $('option:selected', curobj).text()]);
- }
- });
- function showTable(ID, TotalCount) {
- for (var I = 1; I <= TotalCount; I++) {
- if (I == ID) {
- document.getElementById("Table" + I).style.display = "";
- } else {
- document.getElementById("Table" + I).style.display = "none";
- }
- }
- }
复制代码 关键代码,这个是利用jQuery动态生成的,十分难搞啊……
http://img1.okoooimg.com/min/?b=JS&f=dataanalysis%2ffootcompetitionhistory.js&v=201211151048 |
|