Solved

unable to display xml data and images defined in xml doc

Posted on 2013-12-31
8
236 Views
Last Modified: 2014-01-06
I have a html table that displays sports stats however it's not working I created DUPLICATE ID FOR EVERYTHING like lpYDS and lpYDS2 I wanted to simply this and make it a selector statement.
I need to display home and away stats for QB ,RB, AND WR. So I was going to do it this way like this i GOT A BRACKET PROBLEM I Can't solve.

 if ($(Team).attr('vh') == "H") {

getStats();
}

 if ($(Team).attr('vh') == "A") {

getStats();

}

getStats needs to be looked at  

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Sports Network</title>
<link rel="stylesheet" href="http://powerzsoftware.com/css/jquery-ui-1.8.9.customver1.css">
<style type="text/css">
.IMAGEALIGN {
	text-align: center;
	vertical-align: middle;
}
.imagealign2 {
	text-align: center;
	vertical-align: top;
}

.tophigh {
	text-align: center;
	vertical-align: top;
}
.textcolor {
	color: #FFF;
}
.tbcolor {
	color: #FFF;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
 var xmlPath = '.' //'/xml/cfoot/scores/real';
  var xmlGameID = '40350'; // game id only, _counter.xml will be added in the ajax call
 

  
  var arrIDs = {
    "Rushing_Stats": {
      id: "Rusher",
      start: "Rush",
      attrs: {
      "ATT": "Attempts",
      "YDS": "Yards",
      "AVG": "Average",
      "TD": "Touchdowns"
      }
    },
    "Passing_Stats": {
      id: "Passer",
      start: "Pass",
      attrs: {
        "ATT": "Attempts",
        "COMP": "Completions",
        "YDS": "Yards",
        "TD": "Touchdowns",
        "INT": "Interceptions"
      }
    },
    "Pass_Receiving_Stats": {
      id: "Receiver",
      start: "Receiving",
      attrs: {
        "REC": "Receptions",
        "YDS": "Yards",
        "AVG": "Average",
        "TD": "Touchdowns"
      }
    }
  };

 

function getStats()
{
  $.ajax(
  {
    type: "GET",
    url: xmlPath + "/" + xmlGameID +  ".xml",
    dataType: "xml",
    success: function (data)
    {
      var d = $(data);
      var Play = d.find('Play');
		

    
     d.find('Team').each(function(i, Team){
 var team = $(Team);
          var id = team.attr("ID").toLowerCase();
      if ($(Team).attr('vh') == "H") {
         
// DOESN'T EXIST FOR COLLEGE
       // var Passing = $(CurrentLeaders).find('Passing[TeamID="' + TeamID + '"]');
        //var Rushing = $(CurrentLeaders).find('Rushing[TeamID="' + TeamID + '"]');
        //var Receiving = $(CurrentLeaders).find('Receiving[TeamID="' + TeamID + '"]');

        var PlayerID_Pass = Passing.attr('PlayerID');
        var PlayerID_Rush = Rushing.attr('PlayerID');
        var PlayerID_Recv = Receiving.attr('PlayerID');
 
      
        var teamlogoPlus = ($(Team).attr('ID') == TeamOffID) ? 0 : 3;
        for (var teamlogoCounter = 1; teamlogoCounter <= 3; teamlogoCounter++) {
          $('#teamlogo'+(teamlogoCounter+teamlogoPlus)).attr('src', 'http://sportsnetwork.com/gamecast/Cfootlogos/' + $(Team).attr('ID') + ".png");
        }

        var idFirstOrSecond = ($(Team).attr('ID') == TeamOffID) ? '' : '2'; // postfix for stats id selectors to target fields in first or second table

       

        var Individual_Statistics = d.find('Individual_Statistics[IS_TeamID="' + TeamID + '"]');
        $(Individual_Statistics).children().each(function(i, AllStats){
          if (arrIDs[AllStats.nodeName])
          {
            var idselector = arrIDs[AllStats.nodeName].id;
            var nodeStart = arrIDs[AllStats.nodeName].start; // AllStats.nodeName.substr(0, AllStats.nodeName.length - 5); // need the part before Stats
            var PlayerIDforThisListing = (nodeStart == "Rush" ? PlayerID_Rush : (nodeStart == "Receiving" ? PlayerID_Recv : PlayerID_Pass));
            $(AllStats).find(nodeStart + '_Listing').each(function(i2, Pass_Listing){
              if ($(Pass_Listing).find(nodeStart + '_PlayerID').text() == PlayerIDforThisListing)
              {
                var Firstname = $(Pass_Listing).find(nodeStart + '_Firstname').text();
                var Lastname = $(Pass_Listing).find(nodeStart + '_Lastname').text();
                $('#'+idselector+idFirstOrSecond).html(Firstname + ' ' + Lastname);
                switch (nodeStart)
                {
                  case "Rush":
                    $("#lratt" +idFirstOrSecond).html( $(Pass_Listing).find(nodeStart + '_' + arrIDs[AllStats.nodeName].attrs["ATT"] ).text() );
                    $("#lryds" +idFirstOrSecond).html( $(Pass_Listing).find(nodeStart + '_' + arrIDs[AllStats.nodeName].attrs["YDS"] ).text() );
                    $("#lravg" +idFirstOrSecond).html( $(Pass_Listing).find(nodeStart + '_' + arrIDs[AllStats.nodeName].attrs["AVG"] ).text() );
                    $("#gTDS"  +idFirstOrSecond).html( $(Pass_Listing).find(nodeStart + '_' + arrIDs[AllStats.nodeName].attrs["TD"]  ).text() );
                    break;
   
                  case "Pass":
                    $("#lpatt" +idFirstOrSecond).html( $(Pass_Listing).find(nodeStart + '_' + arrIDs[AllStats.nodeName].attrs["ATT"] ).text() );
                    $("#lpComp"+idFirstOrSecond).html( $(Pass_Listing).find(nodeStart + '_' + arrIDs[AllStats.nodeName].attrs["COMP"]).text() );
                    $("#lpYDS" +idFirstOrSecond).html( $(Pass_Listing).find(nodeStart + '_' + arrIDs[AllStats.nodeName].attrs["YDS"] ).text() );
                    $("#lpTD"  +idFirstOrSecond).html( $(Pass_Listing).find(nodeStart + '_' + arrIDs[AllStats.nodeName].attrs["TD"]  ).text() );
                    $("#LPINT" +idFirstOrSecond).html( $(Pass_Listing).find(nodeStart + '_' + arrIDs[AllStats.nodeName].attrs["INT"] ).text() );
                    break;
   
                  case "Receiving":
                    $("#lrrec" +idFirstOrSecond).html( $(Pass_Listing).find(nodeStart + '_' + arrIDs[AllStats.nodeName].attrs["REC"] ).text() );
                    $("#lrryds"+idFirstOrSecond).html( $(Pass_Listing).find(nodeStart + '_' + arrIDs[AllStats.nodeName].attrs["YDS"] ).text() );
                    $("#lrrAVG"+idFirstOrSecond).html( $(Pass_Listing).find(nodeStart + '_' + arrIDs[AllStats.nodeName].attrs["AVG"] ).text() );
                    $("#lrrtd" +idFirstOrSecond).html( $(Pass_Listing).find(nodeStart + '_' + arrIDs[AllStats.nodeName].attrs["TD"]  ).text() );
                    break;
               }
              }
            }); // each xxx_Listing
          }
        }); // each xxx_Stats
	  }
      }); // each Team
	
     if (d.find('Play').attr("Status").toUpperCase() === "FINAL") {
        clearInterval(myVar);
      }
	 }
    }
});
// }); //ajax
}
</script>

</head>

<body>
<table width="800" height="127" border="1" class="tbcolor">
  <tr>
    <td width="75" rowspan="4" class="tophigh"><p><strong><span class="imagealign2"><img src="http://www.sportsnetwork.com/gamecast/Cfootlogos/491.png" name="teamlogo1" width="50" height="50" id="teamlogo1"></span></strong></p></td>
    <td colspan="4"><div align="center" class="GCPBP"><strong>Leading Rusher</strong></div></td>
    <td width="77" rowspan="4" class="imagealign2"><strong><span class="tophigh"><img src="http://sportsnetwork.com/gamecast/Cfootlogos/491.png" alt="" name="teamlogo2" width="100" height="100" id="teamlogo2"></span></strong></td>
    <td colspan="5"><div align="center" class="GCPBP"><strong>Leading Passer</strong></div></td>
    <td width="83" rowspan="4" class="imagealign2"><strong><span class="tophigh"><img src="http://sportsnetwork.com/gamecast/Cfootlogos/491.png" alt="" name="teamlogo3" width="100" height="100" id="teamlogo3"></span></strong></td>
    <td colspan="4"><div align="center" class="GCPBP"><strong>Leading Receiver</strong></div></td>
  </tr>
  <tr>
    <td height="23" colspan="4" id="Rusher"><div align="center" id="Rusher"><strong id="Rusher">Rusher</strong></div></td>
    <td colspan="5" id="Passer"><div align="center" id="Passer"><strong id="Passer">Passer</strong></div></td>
    <td colspan="4" id="Receiver"><div align="center" id="Receiver"><strong id="Receiver">Receiver</strong></div></td>
  </tr>
  <tr>
    <td width="42" height="26"><div align="center" class="GCPBP"><strong>ATT</strong></div></td>
    <td width="38"><div align="center" class="GCPBP"><strong>YDS</strong></div></td>
    <td width="37"><div align="center" class="GCPBP"><strong>AVG </strong></div></td>
    <td width="32"><div align="center" class="GCPBP"><strong>TD</strong></div></td>
    <td width="39"><div align="center" class="GCPBP"><strong>ATT</strong></div></td>
    <td width="46"><div align="center" class="GCPBP"><strong>COMP</strong></div></td>
    <td width="35"><div align="center" class="GCPBP"><strong>YDS</strong></div></td>
    <td width="38"><div align="center" class="GCPBP"><strong>TD</strong></div></td>
    <td width="42"><div align="center" class="GCPBP"><strong>INT</strong></div></td>
    <td width="37"><div align="center" class="GCPBP"><strong>REC</strong></div></td>
    <td width="40"><div align="center" class="GCPBP"><strong>YDS</strong></div></td>
    <td width="36"><div align="center" class="GCPBP"><strong>AVG</strong></div></td>
    <td width="37"><div align="center" class="GCPBP"><strong>TD</strong></div></td>
  </tr>
  <tr>
    <td height="36"><div align="center" class="imagealign2" id="lratt"><strong id="lratt">lratt</strong></div></td>
    <td><div align="center" class="imagealign2" id="lryds"><strong id="lryds">lryds</strong></div></td>
    <td><div align="center" class="imagealign2" id="lravg"><strong id="lravg">lravg</strong></div></td>
    <td><div align="center" class="imagealign2" id="gTDS"><strong id="gTDS">lgTDS</strong></div></td>
    <td><div align="center" class="imagealign2" id="lpatt"><strong id="lpatt">lpatt</strong></div></td>
    <td><div align="center" class="imagealign2" id="lpComp"><strong id="lpComp">lpComp</strong></div></td>
    <td><div align="center" class="imagealign2" id="lpYDS"><strong id="lpYDS">lpYDS</strong></div></td>
    <td><div align="center" class="imagealign2" id="lpTD"><strong id="lpTD">lpTD</strong></div></td>
    <td><div align="center" class="imagealign2" id="LPINT"><strong id="LPINT">LPINT</strong></div></td>
    <td><div align="center" id="lrrec"><strong id="lrrec">lrrec</strong></div></td>
    <td><div align="center" id="lrryds"><strong id="lryds">lryds</strong></div></td>
    <td><div align="center" id="lrrAVG"><strong id="lrAVG">lrAVG</strong></div></td>
    <td><div align="center" id="lrrtd"><strong id="lrtd">lrtd</strong></div></td>
  </tr>
</table>
<table width="855" height="126" border="1" class="tbcolor">
  <tr>
    <td width="62" rowspan="4" class="tophigh"><strong><span class="textcolor"><img src="http://sportsnetwork.com/gamecast/Cfootlogos/498.png" alt="" name="teamlogo4" width="50" height="50" id="teamlogo4"></span></strong></td>
    <td colspan="4"><div align="center" class="GCPBP"><strong><span class="GCPBP">Leading Rusher</span></strong></div></td>
    <td width="63" rowspan="4" class="imagealign2"><strong><span class="textcolor"><span class="tophigh"><img src="http://sportsnetwork.com/gamecast/Cfootlogos/498.png" alt="" name="teamlogo5" width="50" height="50" id="teamlogo5"></span></span></strong></td>
    <td colspan="5"><div align="center" class="GCPBP"><strong>Leading Passer</strong></div></td>
    <td width="70" rowspan="4" class="imagealign2"><strong><span class="textcolor"><span class="tophigh"><img src="http://sportsnetwork.com/gamecast/Cfootlogos/498.png" alt="" name="teamlogo6" width="57" height="64" id="teamlogo6"></span></span></strong></td>
    <td colspan="4"><div align="center" class="GCPBP"><strong><span class="GCPBP">Leading Receiver</span></strong></div></td>
  </tr>
  <tr>
    <td height="23" colspan="4" id="Rusher2"><div align="center" id="Rusher2"><strong><span class="textcolor" id="Rusher2">Rusher</span></strong></div></td>
    <td colspan="5" id="Passer2"><div align="center" id="Passer2"><strong><span class="textcolor" id="Passer2">Passer</span></strong></div></td>
    <td colspan="4" id="Receiver2"><div align="center" id="Receiver2"><strong><span class="textcolor" id="Receiver2">Receiver</span></strong></div></td>
  </tr>
  <tr>
    <td width="37" height="26"><div align="center" class="GCPBP"><strong>ATT</strong></div></td>
    <td width="39"><div align="center" class="GCPBP"><strong>YDS</strong></div></td>
    <td width="44"><div align="center" class="GCPBP"><strong>AVG </strong></div></td>
    <td width="46"><div align="center" class="GCPBP"><strong>TD</strong></div></td>
    <td width="36"><div align="center" class="GCPBP"><strong>ATT</strong></div></td>
    <td width="54"><div align="center" class="GCPBP"><strong>COMP</strong></div></td>
    <td width="46"><div align="center" class="GCPBP"><strong>YDS</strong></div></td>
    <td width="37"><div align="center" class="GCPBP"><strong>TD</strong></div></td>
    <td width="50"><div align="center" class="GCPBP"><strong>INT</strong></div></td>
    <td width="39"><div align="center" class="GCPBP"><strong>REC</strong></div></td>
    <td width="39"><div align="center" class="GCPBP"><strong>YDS</strong></div></td>
    <td width="47"><div align="center" class="GCPBP"><strong>AVG</strong></div></td>
    <td width="46"><div align="center" class="GCPBP"><strong>TD</strong></div></td>
  </tr>
  <tr>
    <td height="23"><div align="center" class="imagealign2" id="lratt2"><strong><span class="textcolor" id="lratt2">lratt</span></strong></div></td>
    <td><div align="center" class="imagealign2" id="lryds2"><strong><span class="textcolor" id="lryds2">lryds</span></strong></div></td>
    <td><div align="center" class="imagealign2" id="lravg2"><strong><span class="textcolor" id="lravg2">lravg</span></strong></div></td>
    <td><div align="center" class="imagealign2" id="gTDS2"><strong><span class="textcolor" id="gTDS2">lgTDS</span></strong></div></td>
    <td><div align="center" class="imagealign2" id="lpatt2"><strong><span class="textcolor" id="lpatt2">lpatt</span></strong></div></td>
    <td><div align="center" class="imagealign2" id="lpComp2"><strong><span class="textcolor" id="lpComp2">lpComp</span></strong></div></td>
    <td><div align="center" class="imagealign2" id="lpYDS2"><strong><span class="textcolor" id="lpYDS2">lpYDS</span></strong></div></td>
    <td><div align="center" class="imagealign2" id="lpTD2"><strong><span class="textcolor" id="lpTD2">lpTD</span></strong></div></td>
    <td><div align="center" class="imagealign2" id="LPINT2"><strong><span class="textcolor" id="LPINT2">LPINT</span></strong></div></td>
    <td><div align="center" id="lrrec2"><strong><span class="textcolor" id="lrrec2">lrrec</span></strong></div></td>
    <td><div align="center" id="lrryds2"><strong><span class="textcolor" id="lrryds2">lryds</span></strong></div></td>
    <td><div align="center" id="lrrAVG2"><strong><span class="textcolor" id="lrrAVG2">lrAVG</span></strong></div></td>
    <td><div align="center" id="lrrtd2"><strong><span class="textcolor" id="lrrtd2">lrtd</span></strong></div></td>
  </tr>
</table>
<p>&nbsp; </p>
<p>&nbsp; </p>
<script>
var myVar=setInterval(function(){myTimer()},1000);

function myTimer()
{

getStats();

}
  </script>
</body>
</html>

Open in new window

40350.XML
LeadersCollegeTest.html
0
Comment
Question by:powerztom
  • 5
  • 3
8 Comments
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 500 total points
ID: 39748545
There seem to be a number of discrepancies between the file and the posted code. There were indeed 1 or 2 closing braces too many...

Also I saw white text on white background? then nothing seems to show up of course.

When you delete those 3 lines, some other lines become unnecessary and will error out.

I added a .first() which makes the each() a bit senseless but it's a quick fix ;-)

try this:
function getStats()
{
  $.ajax(
  {
    type: "GET",
    url: xmlPath + "/" + xmlGameID +  ".xml",
    dataType: "xml",
    success: function (data)
    {
      var d = $(data);
      var Play = d.find('Play');

      var TeamOffID = $(Play).attr('OffID');
      var TeamDefID = $(Play).attr('DefID');

      d.find('Team').each(function(i, Team){
        var team = $(Team);
        var id = team.attr("ID").toLowerCase();
        //if ($(Team).attr('vh') == "H") {
           
          // DOESN'T EXIST FOR COLLEGE
          //var Passing = $(CurrentLeaders).find('Passing[TeamID="' + TeamID + '"]');
          //var Rushing = $(CurrentLeaders).find('Rushing[TeamID="' + TeamID + '"]');
          //var Receiving = $(CurrentLeaders).find('Receiving[TeamID="' + TeamID + '"]');

          //var PlayerID_Pass = Passing.attr('PlayerID');
          //var PlayerID_Rush = Rushing.attr('PlayerID');
          //var PlayerID_Recv = Receiving.attr('PlayerID');

          var teamlogoPlus = ($(Team).attr('ID') == TeamOffID) ? 0 : 3;
          for (var teamlogoCounter = 1; teamlogoCounter <= 3; teamlogoCounter++) {
            $('#teamlogo'+(teamlogoCounter+teamlogoPlus)).attr('src', 'http://sportsnetwork.com/gamecast/Cfootlogos/' + $(Team).attr('ID') + ".png");
          }

          var idFirstOrSecond = ($(Team).attr('ID') == TeamOffID) ? '' : '2'; // postfix for stats id selectors to target fields in first or second table

          var Individual_Statistics = d.find('Individual_Statistics[IS_TeamID="' + id + '"]'); // TeamID
          $(Individual_Statistics).children().each(function(i, AllStats){
            if (arrIDs[AllStats.nodeName])
            {
              var idselector = arrIDs[AllStats.nodeName].id;
              var nodeStart = arrIDs[AllStats.nodeName].start; // AllStats.nodeName.substr(0, AllStats.nodeName.length - 5); // need the part before Stats
              //var PlayerIDforThisListing = (nodeStart == "Rush" ? PlayerID_Rush : (nodeStart == "Receiving" ? PlayerID_Recv : PlayerID_Pass));
              $(AllStats).find(nodeStart + '_Listing').each(function(i2, Pass_Listing){
                //if ($(Pass_Listing).find(nodeStart + '_PlayerID').text() == PlayerIDforThisListing)
                //{
                  var Firstname = $(Pass_Listing).find(nodeStart + '_Firstname').text();
                  var Lastname = $(Pass_Listing).find(nodeStart + '_Lastname').text();
                  $('#'+idselector+idFirstOrSecond).html(Firstname + ' ' + Lastname);
                  switch (nodeStart)
                  {
                    case "Rush":
                      $("#lratt" +idFirstOrSecond).html( $(Pass_Listing).find(nodeStart + '_' + arrIDs[AllStats.nodeName].attrs["ATT"] ).text() );
                      $("#lryds" +idFirstOrSecond).html( $(Pass_Listing).find(nodeStart + '_' + arrIDs[AllStats.nodeName].attrs["YDS"] ).text() );
                      $("#lravg" +idFirstOrSecond).html( $(Pass_Listing).find(nodeStart + '_' + arrIDs[AllStats.nodeName].attrs["AVG"] ).text() );
                      $("#gTDS"  +idFirstOrSecond).html( $(Pass_Listing).find(nodeStart + '_' + arrIDs[AllStats.nodeName].attrs["TD"]  ).text() );
                      break;
     
                    case "Pass":
                      $("#lpatt" +idFirstOrSecond).html( $(Pass_Listing).find(nodeStart + '_' + arrIDs[AllStats.nodeName].attrs["ATT"] ).text() );
                      $("#lpComp"+idFirstOrSecond).html( $(Pass_Listing).find(nodeStart + '_' + arrIDs[AllStats.nodeName].attrs["COMP"]).text() );
                      $("#lpYDS" +idFirstOrSecond).html( $(Pass_Listing).find(nodeStart + '_' + arrIDs[AllStats.nodeName].attrs["YDS"] ).text() );
                      $("#lpTD"  +idFirstOrSecond).html( $(Pass_Listing).find(nodeStart + '_' + arrIDs[AllStats.nodeName].attrs["TD"]  ).text() );
                      $("#LPINT" +idFirstOrSecond).html( $(Pass_Listing).find(nodeStart + '_' + arrIDs[AllStats.nodeName].attrs["INT"] ).text() );
                      break;
     
                    case "Receiving":
                      $("#lrrec" +idFirstOrSecond).html( $(Pass_Listing).find(nodeStart + '_' + arrIDs[AllStats.nodeName].attrs["REC"] ).text() );
                      $("#lrryds"+idFirstOrSecond).html( $(Pass_Listing).find(nodeStart + '_' + arrIDs[AllStats.nodeName].attrs["YDS"] ).text() );
                      $("#lrrAVG"+idFirstOrSecond).html( $(Pass_Listing).find(nodeStart + '_' + arrIDs[AllStats.nodeName].attrs["AVG"] ).text() );
                      $("#lrrtd" +idFirstOrSecond).html( $(Pass_Listing).find(nodeStart + '_' + arrIDs[AllStats.nodeName].attrs["TD"]  ).text() );
                      break;
                  }
                //}
              }); // each xxx_Listing
            }
          }); // each xxx_Stats
        //}
      }); // each Team

     if (d.find('Play').attr("Status").toUpperCase() === "FINAL") {
        clearInterval(myVar);
      }
    }
  });
}

Open in new window

0
 
LVL 35

Expert Comment

by:Robert Schutt
ID: 39748565
capture
0
 
LVL 35

Expert Comment

by:Robert Schutt
ID: 39748575
Note that I commented out the if ($(Team).attr('vh') == "H") because, as before, the each() is executed for both home and visitor and fills the appropriate fields. No 'global' if() necessary in that situation.
0
 

Author Closing Comment

by:powerztom
ID: 39748578
Perfect exactly what I wanted. And now I can test at 2:00 which I'm positive it will come up running successful Unlike Obama's Heathcare.gov. Did I say that ? anyway Excellent help from a Professional.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:powerztom
ID: 39749235
Rob What I noticed that the leaders are the last players of the node that are being displayed in this case . I know there is some attribute to grab the first player in the start of the node that is available in his position. The way the xml is outputted is best to lowest in terms of yards and that is what I want to show is the first is it firstseq? The attribute  ?
0
 
LVL 35

Expert Comment

by:Robert Schutt
ID: 39749240
It would be possible to loop through all listing nodes, determine the min or max of a certain subnode and the corresponding player id, then go back and use that listing. Or grab all info needed each time you see a lower/higher number in that field.

Ai ai ai, I just noticed that I posted about adding first() but it wasn't in the version of the code I posted, so it's overwriting the elements for each listing found, that's why it's showing the last!

Please try changing this first (line 44 in my posted code), then I'll also post an example of what I described before.
$(AllStats).find(nodeStart + '_Listing').first().each(function(i2, Pass_Listing){

Open in new window

0
 
LVL 35

Expert Comment

by:Robert Schutt
ID: 39749254
So, this could be an alternative: keep a maximum in a var and only show values if the new value is higher (not terribly efficient, but if you need it like this then we can work on that...
            var MaxYards = 0;
            $(AllStats).find(nodeStart + '_Listing').each(function(i2, Pass_Listing){
              var newMaxYards = Number($(Pass_Listing).find(nodeStart + '_Yards').text());
              if (newMaxYards > MaxYards) {
                MaxYards = newMaxYards;
                var Firstname = $(Pass_Listing).find(nodeStart + '_Firstname').text();
                var Lastname = $(Pass_Listing).find(nodeStart + '_Lastname').text();
                $('#'+idselector+idFirstOrSecond).html(Firstname + ' ' + Lastname);
                switch (nodeStart)
                {
                  case "Rush":
                    $("#lratt" +idFirstOrSecond).html( $(Pass_Listing).find(nodeStart + '_' + arrIDs[AllStats.nodeName].attrs["ATT"] ).text() );
                    $("#lryds" +idFirstOrSecond).html( $(Pass_Listing).find(nodeStart + '_' + arrIDs[AllStats.nodeName].attrs["YDS"] ).text() );
                    $("#lravg" +idFirstOrSecond).html( $(Pass_Listing).find(nodeStart + '_' + arrIDs[AllStats.nodeName].attrs["AVG"] ).text() );
                    $("#gTDS"  +idFirstOrSecond).html( $(Pass_Listing).find(nodeStart + '_' + arrIDs[AllStats.nodeName].attrs["TD"]  ).text() );
                    break;
   
                  case "Pass":
                    $("#lpatt" +idFirstOrSecond).html( $(Pass_Listing).find(nodeStart + '_' + arrIDs[AllStats.nodeName].attrs["ATT"] ).text() );
                    $("#lpComp"+idFirstOrSecond).html( $(Pass_Listing).find(nodeStart + '_' + arrIDs[AllStats.nodeName].attrs["COMP"]).text() );
                    $("#lpYDS" +idFirstOrSecond).html( $(Pass_Listing).find(nodeStart + '_' + arrIDs[AllStats.nodeName].attrs["YDS"] ).text() );
                    $("#lpTD"  +idFirstOrSecond).html( $(Pass_Listing).find(nodeStart + '_' + arrIDs[AllStats.nodeName].attrs["TD"]  ).text() );
                    $("#LPINT" +idFirstOrSecond).html( $(Pass_Listing).find(nodeStart + '_' + arrIDs[AllStats.nodeName].attrs["INT"] ).text() );
                    break;
   
                  case "Receiving":
                    $("#lrrec" +idFirstOrSecond).html( $(Pass_Listing).find(nodeStart + '_' + arrIDs[AllStats.nodeName].attrs["REC"] ).text() );
                    $("#lrryds"+idFirstOrSecond).html( $(Pass_Listing).find(nodeStart + '_' + arrIDs[AllStats.nodeName].attrs["YDS"] ).text() );
                    $("#lrrAVG"+idFirstOrSecond).html( $(Pass_Listing).find(nodeStart + '_' + arrIDs[AllStats.nodeName].attrs["AVG"] ).text() );
                    $("#lrrtd" +idFirstOrSecond).html( $(Pass_Listing).find(nodeStart + '_' + arrIDs[AllStats.nodeName].attrs["TD"]  ).text() );
                    break;
                }
              } // if (newMaxYards > MaxYards)
            }); // each xxx_Listing

Open in new window

Note that the first() call is gone again now, and only a few lines have been added for checking the max value of xxx_Yards. You could easily change that to check for minimum and/or different node (xxx_Average or xxx_Longest).
0
 

Author Comment

by:powerztom
ID: 39759283
Thanks Rob,

I just got back from being off from work for like over a week. This is good stuff that I might be able to apply or use it in another situation.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now