Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 305
  • Last Modified:

Developing a NFL SCORCEBOARD NEED SOMEONE TO SPOT CHECK

i'M Developing a NFL Scoreboard in pieces I sincerely tried to write from what a learned on my previous project  I used logic from EE Guys. I have a error just asking where is it cause I have score and then Downs to deal with but i learned to do it in pieces to reduce errors.


<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>The Sports Network</title>
<style type="text/css">
.formatcell {
	text-align: center;
	vertical-align: top;
}
.formatcelldown {
	text-align: center;
	vertical-align: bottom;
}
.formatcellcenter {
	text-align: center;
	vertical-align: middle;
}
.tablecolor {
	background-image: url(Greywall.png);
}
.tablecolor tr .formatcell #imgHomeHelmet {
	color: #FFF;
}
.rr {
	background-color: #FFF;
}
</style>
</head>
<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/nfl/scores/real';
  var xmlGameID = 'AB-3171'; // game id only, _counter.xml will be added in the ajax call
  var Ballon = "", Down = "", Ydstogo = "", Q = "", Time = ""; // unused?
  var counterXml = 0;
  $(document).ready(function(){
  $.ajax({
    type: "GET",
    url: xmlPath+"/"+xmlGameID+".xml",
	
    dataType: "xml",
    success: function(data){
   var d = $(data);
   var Teams = $(data).find("Team");
	  
      $.each(Teams,function(i,Team) {
        team=$(Team);
        var id = team.attr("ID").toLowerCase();
		var teamname = team.attr("name");
  
        //var Team = $(d.find('Team')); // replaced with loop
       
		var homeOrAway = team.attr("vh");{
  if (id == "079" && (homeOrAway=="A")){
							$('#Visitor').html(teamname); 
							$('#VTeamname').html("GIANTS"); 
					} else if (id == "079" && (homeOrAway=="H")
					){
						
        					$('#HTeamName').html(teamname); 
							$('#Hometeam').html("GIANTS");	
							
					}
					if (id == "068" && (homeOrAway=="A")) {
						$('#Visitor').html(teamname); 
							$('#VTeamname').html("LIONS");
						
							
							
						} else if (id == "068" && (homeOrAway=="H")){					$('#HTeamName').html(teamname); 
							$('#Hometeam').html("LIONS");	
							
					}
					if (id == "084" && (homeOrAway=="A")) {
							$('#Visitor').html(teamname); 
							$('#VTeamname').html("49ERS");
							
						} else if (id == "084" && (homeOrAway=="H")){
							$('#HTeamName').html(teamname); 
							$('#Hometeam').html("49ERS");
							
					}
					if (id == "063" && (homeOrAway=="A")) {
						$('#Visitor').html(teamname); 
							$('#VTeamname').html("BEARS");
						
							
						} else if (id == "063" && (homeOrAway=="H")){
							$('#HTeamName').html(teamname); 
							$('#Hometeam').html("BEARS");
					}
					if (id == "083" && (homeOrAway=="A")) {
							$('#Visitor').html(teamname); 
							$('#VTeamname').html("CHARGERS");
							
						} else if (id == "083" && (homeOrAway=="H")){
							$('#HTeamName').html(teamname); 
							$('#Hometeam').html("CHARGERS");
							
					}
					if (id == "085" && (homeOrAway=="A")) {
							$('#Visitor').html(teamname); 
							$('#VTeamname').html("CHARGERS");
							
						} else if (id == "085" && (homeOrAway=="H")){
							$('#HTeamName').html(teamname); 
							$('#Hometeam').html("SEAHAWKS");
							
					}
					if (id == "088" && (homeOrAway=="A")) {
							$('#Visitor').html(teamname); 
							$('#VTeamname').html("REDSKINS");
							
						} else if (id == "088" && (homeOrAway=="H")){
							$('#HTeamName').html(teamname); 
							$('#Hometeam').html("REDSKINS");
							
					}
					if (id == "061" && (homeOrAway=="A")) {
						$('#Visitor').html(teamname); 
							$('#VTeamname').html("FALCONS");
							
						} else if (id == "061" && (homeOrAway=="H")){
							$('#HTeamName').html(teamname); 
							$('#Hometeam').html("FALCONS");
							
					}
					if (id == "062" && (homeOrAway=="A")) {
						$('#Visitor').html(teamname); 
							$('#VTeamname').html("BILLS");
							
						} else if (id == "062" && (homeOrAway=="H")){							$('#HTeamName').html(teamname); 
							$('#Hometeam').html("BILLS");
							
					}
					if (id == "064" && (homeOrAway=="A")) {
							$('#Visitor').html(teamname); 
							$('#VTeamname').html("BENGALS");
							
						} else if (id == "064" && (homeOrAway=="H")){$('#HTeamName').html(teamname); 
							$('#Hometeam').html("BENGALS");
							
					}
					if (id == "065" && (homeOrAway=="A")) {
							$('#Visitor').html(teamname); 
							$('#VTeamname').html("RAVENS");
							
						} else if (id == "065" && (homeOrAway=="H")){
							$('#HTeamName').html(teamname); 
							$('#Hometeam').html("RAVENS");
							
					}
					if (id == "066" && (homeOrAway=="A")) {
							$('#Visitor').html(teamname); 
							$('#VTeamname').html("COWBOYS");
							
							
						} else if (id == "066" && (homeOrAway=="H")){
							$('#HTeamName').html(teamname); 
							$('#Hometeam').html("COWBOYS");
							
					}
					if (id == "067" && (homeOrAway=="A")) {
							$('#Visitor').html(teamname); 
							$('#VTeamname').html("BRONCOS");
							
							
						} else if (id == "067" && (homeOrAway=="H")){
							$('#HTeamName').html(teamname); 
							$('#Hometeam').html("BRONCOS");
							
							
					}
					if (id == "069" && (homeOrAway=="A")) {
							$('#Visitor').html(teamname); 
							$('#VTeamname').html("PACKERS");
							
						} else if (id == "069" && (homeOrAway=="H")){							$('#HTeamName').html(teamname); 
							$('#Hometeam').html("PACKERS");
							
							
					}
					if (id == "070" && (homeOrAway=="A")) {
							$('#Visitor').html(teamname); 
							$('#VTeamname').html("TITANS");
						} else if (id == "070" && (homeOrAway=="H")){
							$('#HTeamName').html(teamname); 
							$('#Hometeam').html("TITANS");
					}
					if (id == "071" && (homeOrAway=="A")) {
							$('#Visitor').html(teamname); 
							$('#VTeamname').html("COLTS");
							
							
						} else if (id == "071" && (homeOrAway=="H")){
							$('#HTeamName').html(teamname); 
							$('#Hometeam').html("COLTS");
							
							
					}
					if (id == "072" && (homeOrAway=="A")) {
							$('#Visitor').html(teamname); 
							$('#VTeamname').html("CHIEFS");
						} else if (id == "072" && (homeOrAway=="H")){
							
							$('#HTeamName').html(teamname); 
							$('#Hometeam').html("CHIEFS");
							
					}
					if (id == "073" && (homeOrAway=="A")) {
							
							$('#Visitor').html(teamname); 
							$('#VTeamname').html("RAIDERS");
							
						} else if (id == "073" && (homeOrAway=="H")){
							$('#HTeamName').html(teamname); 
							$('#Hometeam').html("RAIDERS");
							
							
					}
					if (id == "074" && (homeOrAway=="A")) {
							$('#Visitor').html(teamname); 
							$('#VTeamname').html("RAMS");
							
							
						} else if (id == "074" && (homeOrAway=="H")){
							$('#HTeamName').html(teamname); 
							$('#Hometeam').html("RAMS");
							
					}
					if (id == "075" && (homeOrAway=="A")) {
						$('#Visitor').html(teamname); 
							$('#VTeamname').html("DOLPHINS");
							
							
						} else if (id == "075" && (homeOrAway=="H")){
							$('#HTeamName').html(teamname); 
							$('#Hometeam').html("DOLPHINS");
							
							
					}
					if (id == "076" && (homeOrAway=="A")) {
							$('#Visitor').html(teamname); 
							$('#VTeamname').html("VIKINGS");
							
							
						} else if (id == "076" && (homeOrAway=="H")){
							$('#HTeamName').html(teamname); 
							$('#Hometeam').html("VIKINGS");
							
							
					}
					if (id == "077" && (homeOrAway=="A")) {
						$('#Visitor').html(teamname); 
							$('#VTeamname').html("PATRIOTS");
						
							
						} else if (id == "077" && (homeOrAway=="H")){
							$('#HTeamName').html(teamname); 
							$('#Hometeam').html("PATRIOTS");
							
							
					}
					if (id == "078" && (homeOrAway=="A")) {
							$('#Visitor').html(teamname); 
							$('#VTeamname').html("SAINTS");
							
						} else if (id == "078" && (homeOrAway=="H")){
							$('#HTeamName').html(teamname); 
							$('#Hometeam').html("SAINTS");
							
					}
					if (id == "080" && (homeOrAway=="A")) {
							$('#Visitor').html(teamname); 
							$('#VTeamname').html("JETS");
							
							
						} else if (id == "080" && (homeOrAway=="H")){
							$('#HTeamName').html(teamname); 
							$('#Hometeam').html("JETS");
							
					}
					if (id == "081" && (homeOrAway=="A")) {
							$('#Visitor').html(teamname); 
							$('#VTeamname').html("EAGLES");
							
							
					} else if (id == "081" && (homeOrAway=="H")){
							$('#HTeamName').html(teamname); 
							$('#Hometeam').html("EAGLES");
					}
					if (id == "082" && (homeOrAway=="A")) {
							$('#Visitor').html(teamname); 
							$('#VTeamname').html("STEELERS");
							
						} else if (id == "082" && (homeOrAway=="H")){
							$('#HTeamName').html(teamname); 
							$('#Hometeam').html("STEELERS");
							
					}
					if (id == "086" && (homeOrAway=="A")) {
							$('#Visitor').html(teamname); 
							$('#VTeamname').html("CARDINALS");
						} else if (id == "086"  && (homeOrAway=="H")){
							$('#HTeamName').html(teamname); 
							$('#Hometeam').html("CARDINALS");
					}
					if (id == "087" && (homeOrAway=="A")) {
						$('#Visitor').html(teamname); 
							$('#VTeamname').html("BUCS");
							
						} else if (id == "087" && (homeOrAway=="H")){
							$('#HTeamName').html(teamname); 
							$('#Hometeam').html("BUCS");
					}
					if (id == "089" && (homeOrAway=="A")) {
							$('#Visitor').html(teamname); 
							$('#VTeamname').html("PANTHERS");
						} else if (id == "089" && (homeOrAway=="H")){
							$('#HTeamName').html(teamname); 
							$('#Hometeam').html("PANTHERS");
					}
					if (id == "090" && (homeOrAway=="A")) {
							$('#Visitor').html(teamname); 
							$('#VTeamname').html("JAGUARS");
						} else if (id == "090" && (homeOrAway=="H")){
							$('#HTeamName').html(teamname); 
							$('#Hometeam').html("JAGUARS");
					}
					if (id == "120" && (homeOrAway=="A")) {
							$('#Visitor').html(teamname); 
							$('#VTeamname').html("BROWNS");
							
						} else if (id == "120" && (homeOrAway=="H")){
							$('#HTeamName').html(teamname); 
							$('#Hometeam').html("BROWNS");
					}
					if (id == "151" && (homeOrAway=="A")) {
							$('#Visitor').html(teamname); 
							$('#VTeamname').html("TEXANS");
							
						} else if (id == "151" && (homeOrAway=="H")){
							$('#HTeamName').html(teamname); 
							$('#Hometeam').html("TEXANS");
							
							
					}
					if (id == "685" && (homeOrAway=="A")) {
						$('#Visitor').html(teamname); 
							$('#VTeamname').html("A-F-C");
							
						} else if (id == "685" && (homeOrAway=="H")){
							
							$('#HTeamName').html(teamname); 
							$('#Hometeam').html("A-F-C");
							
					}
					if (id == "686"&& (homeOrAway=="A")) {
							
        					$('#Visitor').html(teamname); 
							$('#VTeamname').html("N-F-C"); 
							
							
						} else if (ID == "686" && (homeOrAway=="H")){
						
        					$('#HTeamName').html(teamname); 
							$('#Hometeam').html("N-F-C");	
					}
}
  function loadData() {
    $.ajax({
      type: "GET",
      url:  xmlGameID+'_'+counterXml+".xml",  //xmlPath+"/"+xmlGameID+'_'+counterXml+".xml",
      dataType: "xml",
      success: function(data){
        var d = $(data);
        //var Team = $(d.find('Team')); // replaced with loop
        d.find('Team').each(function(i,Team){
          if ($(Team).attr('vh') == "A") { // use DOUBLE equals sign for comparison expression!
            $('#imgVisitHelmet').attr('src', 'http://images.sportsnetwork.com/nfl/atthegridiron/end_zone/'+$(Team).attr('ID')+"_helmet_away.png");
          }
          if ($(Team).attr('vh') == "H") {
            $('#imgHomeHelmet').attr('src', 'http://images.sportsnetwork.com/nfl/atthegridiron/end_zone/'+$(Team).attr('ID')+"_helmet_home.png");
          }
        });
        var Play = $(d.find('Play'));
        // changed all below to just use the variables that contain the text directly, as the arrays do not exist and don't seem necessary in this situation
        var inn = Play.attr('TimeLeft') ;
        $('#Time').html(inn ); // timeleft[inn]
        var bo = Play.attr('BallYrd') ;
        $('#Ballon').html(bo ); // ballyrd[bo]
        var dn = Play.attr('ResultingDown') ;
        $('#Down').html(dn ); // resultingdown[dn]
        var ydtogo = Play.attr('ResultingToGo') ;
        $('#Ydstogo').html(ydtogo ); // resultingtogo[ydtogo]
        var qtr = Play.attr('Quarter') ;
        $('#Q').html(qtr ); // quarter[qtr]
        ++counterXml;
      }
    });
  }
</script>
<body>
<table width="786" border="1" class="tablecolor">
  <tr>
    <td height="21" colspan="3" class="formatcell" id="Visitor">Visitor</td>
    <td colspan="4" class="formatcell" id="Time">TimeRemaining</td>
    <td colspan="3" class="formatcell" id="Hometeam">Hometeam</td>
  </tr>
  <tr>
    <td width="78" height="64" bgcolor="#FFFFFF"><p align="center" class="rr"><img src="VistorHelmet.png" name="imgVisitHelmet" width="63" height="62" class="formatcellcenter" id="imgVisitHelmet"></p></td>
    <td width="87" class="formatcellcenter" id="VTeamname">Teamname</td>
    <td width="74" class="formatcellcenter" id="VistorScore"><strong>VistorScore</strong></td>
    <td width="71" class="formatcellcenter">Ball on</td>
    <td width="65" class="formatcellcenter">Down</td>
    <td width="62" class="formatcellcenter">Yds to go</td>
    <td width="59" class="formatcellcenter">Quarter</td>
    <td width="74" class="formatcellcenter" id="HomeScore"><strong>HomeScore</strong></td>
    <td width="82" class="formatcellcenter" id="HTeamName">TeamName</td>
    <td width="70" class="rr"><img src="HomeHelmet.png" name="imgHomeHelmet" width="66" height="61" class="formatcellcenter" id="imgHomeHelmet"></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td class="formatcell" id="VDownYard">DownYard</td>
    <td>&nbsp;</td>
    <td class="formatcell" id="Ballon">Ballon</td>
    <td class="formatcell" id="Down">Down</td>
    <td class="formatcell" id="Ydstogo">Ydstogo</td>
    <td class="formatcell" id="Q">Q</td>
    <td class="formatcell">&nbsp;</td>
    <td class="formatcell" id="HDownYard">DownYard</td>
    <td class="formatcell">&nbsp;</td>
  </tr>
</table>
<p id="demo">
<script>
var myVar=setInterval(function(){myTimer()},5000);

function myTimer()
{

var d=new Date();
var t=d.toLocaleTimeString();
document.getElementById("demo").innerHTML=t;
loadData();
//checkStatus();
}
        </script>
</body>
</html>

Open in new window



Let me know what's up
Top.html
AB-3171-0.xml
AB-3171-1.xml
AB-3171-2.xml
HomeHelmet.png
HomeHelmet.png
Greywall.png
0
powerztom
Asked:
powerztom
  • 7
  • 4
1 Solution
 
Robert SchuttSoftware EngineerCommented:
Hi Tom, as you know I'm not a native english speaker but "spot check" seems like somewhat of an understatement here, I brought out a bucket and mob ;-)

As often is the case, I couldn't hold back and changed that awful list of if/else statements. But don't worry I will explain what I did and most of it you have seen before so hopefully it will be crystal clear but if not, don't hesitate to ask more about what I changed.

So first the new code:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>The Sports Network</title>
<style type="text/css">
.formatcell {
	text-align: center;
	vertical-align: top;
}
.formatcelldown {
	text-align: center;
	vertical-align: bottom;
}
.formatcellcenter {
	text-align: center;
	vertical-align: middle;
}
.tablecolor {
	background-image: url(Greywall.png);
}
.tablecolor tr .formatcell #imgHomeHelmet {
	color: #FFF;
}
.rr {
	background-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/nfl/scores/real';
  var xmlGameID = 'AB-3171'; // game id only, _counter.xml will be added in the ajax call
  var counterXml = 0;

  var teamNames = {
    "079": "GIANTS",
    "068": "LIONS",
    "084": "49ERS",
    "063": "BEARS",
    "083": "CHARGERS",
    "085": "SEAHAWKS",
    "088": "REDSKINS",
    "061": "FALCONS",
    "062": "BILLS",
    "064": "BENGALS",
    "065": "RAVENS",
    "066": "COWBOYS",
    "067": "BRONCOS",
    "069": "PACKERS",
    "070": "TITANS",
    "071": "COLTS",
    "072": "CHIEFS",
    "073": "RAIDERS",
    "074": "RAMS",
    "075": "DOLPHINS",
    "076": "VIKINGS",
    "077": "PATRIOTS",
    "078": "SAINTS",
    "080": "JETS",
    "081": "EAGLES",
    "082": "STEELERS",
    "086": "CARDINALS",
    "087": "BUCS",
    "089": "PANTHERS",
    "090": "JAGUARS",
    "120": "BROWNS",
    "151": "TEXANS",
    "685": "A-F-C",
    "686": "N-F-C"
  };

  $(document).ready(function(){
    $.ajax({
      type: "GET",
      url: xmlPath+"/"+xmlGameID+"_0.xml",
      dataType: "xml",
      success: function(data){
        var d = $(data);
        d.find('Team').each(function(i,Team){
          var team=$(Team);
          var id = team.attr("ID").toLowerCase();
          var teamname = team.attr("name");
          var homeOrAway = team.attr("vh");
          var selector1 = (homeOrAway=="A") ? '#Visitor' : '#Hometeam' ;
          var selector2 = (homeOrAway=="A") ? '#VTeamname' : '#HTeamName' ;
          $(selector1).html(teamname);
          $(selector2).html(teamNames[id]);
        });
      }
    });
  });

  function loadData() {
    $.ajax({
      type: "GET",
      url:  xmlPath+"/"+xmlGameID+'_'+counterXml+".xml",
      dataType: "xml",
      success: function(data){
        var d = $(data);
        d.find('Team').each(function(i,Team){
          if ($(Team).attr('vh') == "A") {
            $('#imgVisitHelmet').attr('src', 'http://images.sportsnetwork.com/nfl/atthegridiron/end_zone/'+$(Team).attr('ID')+"_helmet_away.png");
          }
          if ($(Team).attr('vh') == "H") {
            $('#imgHomeHelmet').attr('src', 'http://images.sportsnetwork.com/nfl/atthegridiron/end_zone/'+$(Team).attr('ID')+"_helmet_home.png");
          }
        });
        var Play = $(d.find('Play'));
        // changed all below to just use the variables that contain the text directly, as the arrays do not exist and don't seem necessary in this situation
        var inn = Play.attr('TimeLeft') ;
        $('#Time').html(inn ); // timeleft[inn]
        var bo = Play.attr('BallYrd') ;
        $('#Ballon').html(bo ); // ballyrd[bo]
        var dn = Play.attr('ResultingDown') ;
        $('#Down').html(dn ); // resultingdown[dn]
        var ydtogo = Play.attr('ResultingToGo') ;
        $('#Ydstogo').html(ydtogo ); // resultingtogo[ydtogo]
        var qtr = Play.attr('Quarter') ;
        $('#Q').html(qtr ); // quarter[qtr]
        ++counterXml;
      }
    });
  }
</script>
</head>
<body>
<table width="786" border="1" class="tablecolor">
  <tr>
    <td height="21" colspan="3" class="formatcell" id="Visitor">Visitor</td>
    <td colspan="4" class="formatcell" id="Time">TimeRemaining</td>
    <td colspan="3" class="formatcell" id="Hometeam">Hometeam</td>
  </tr>
  <tr>
    <td width="78" height="64" bgcolor="#FFFFFF"><p align="center" class="rr"><img src="VistorHelmet.png" name="imgVisitHelmet" width="63" height="62" class="formatcellcenter" id="imgVisitHelmet"></p></td>
    <td width="87" class="formatcellcenter" id="VTeamname">Teamname</td>
    <td width="74" class="formatcellcenter" id="VistorScore"><strong>VistorScore</strong></td>
    <td width="71" class="formatcellcenter">Ball on</td>
    <td width="65" class="formatcellcenter">Down</td>
    <td width="62" class="formatcellcenter">Yds to go</td>
    <td width="59" class="formatcellcenter">Quarter</td>
    <td width="74" class="formatcellcenter" id="HomeScore"><strong>HomeScore</strong></td>
    <td width="82" class="formatcellcenter" id="HTeamName">TeamName</td>
    <td width="70" class="rr"><img src="HomeHelmet.png" name="imgHomeHelmet" width="66" height="61" class="formatcellcenter" id="imgHomeHelmet"></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td class="formatcell" id="VDownYard">DownYard</td>
    <td>&nbsp;</td>
    <td class="formatcell" id="Ballon">Ballon</td>
    <td class="formatcell" id="Down">Down</td>
    <td class="formatcell" id="Ydstogo">Ydstogo</td>
    <td class="formatcell" id="Q">Q</td>
    <td class="formatcell">&nbsp;</td>
    <td class="formatcell" id="HDownYard">DownYard</td>
    <td class="formatcell">&nbsp;</td>
  </tr>
</table>
<p id="demo"></p>
<script>
var myVar=setInterval(function(){myTimer()},5000);

function myTimer()
{
var d=new Date();
var t=d.toLocaleTimeString();
document.getElementById("demo").innerHTML=t;
loadData();
//checkStatus();
}
</script>
</body>
</html>

Open in new window

I'll post the explanation in a second comment.
0
 
Robert SchuttSoftware EngineerCommented:
Here it is, line numbers refer to your posted code;

***

* line 29: </head> moved to after <script> tags, just before <body> (I don't think there is a browser that will reject this but there just shouldn't be anything in no man's land)

* line 34: deleted, unused variables

* line 39: that file was not part of your post so I used the first file for that one (ending in _0.xml)

* lines 44-47: not sure why that wasn't working but the code on 378 worked so copied that here

* lines 54-368: deleted, replaced with array of id's and team (nick) names, and a couple of lines that do the same. explanation:

      if (id == "079" && (homeOrAway=="A")){
            $('#Visitor').html(teamname);
            $('#VTeamname').html("GIANTS");
      } else if (id == "079" && (homeOrAway=="H")
      ){
            $('#HTeamName').html(teamname);
            $('#Hometeam').html("GIANTS");      
      }

so for each block the same happens: id check, home/away check, put names in corresponding html elements. I replaced it with code to determine the selectors first, based on A/H in vh attribute (also changed around #HTeamName and #Hometeam because that seemed inconsistent), then put the team name and nick name in the corresponding elements which should do exactly the same for any team that can now be found in the array.

[ by the way, line 103: copy error, big danger when copy/pasting 300 lines of code ]

* one of the most important things, between lines 369 and 370: it all just ended there and the loadData() function started, but a number of things that were opened before those 300 lines of if/else statements, weren't closed. If you have a programmer's editor (I use EditPlus, the Visual Studio IDE uses the same key) you should be able to "show matching bracket", for me it's Control and "]". This gives a quick insight in completeness of code. So in the end it needed to be: (comments only added here)

        });  // end each team
      }      // end success function
    });      // end ajax call
  });        // end document ready function

* line 435: interesting one, happened before. Missing </p> tag meant that putting the time in the "demo" element, erased the javascript code that follows.

***

By the way, I haven't put this through a validator but an open issue might be a number of attributes that are not allowed on elements where they are used now.
0
 
powerztomAuthor Commented:
Rob a issue exists don't the code need a selector for H = Home too cause H is defined in the xml file so is that what is wrong

This is what I get in Firebug

if (window.addEventListener) {
var callback_func = function(evt) {
if ('undefined' != typeof evt.target && "A" == evt.target.nodeName) {
var url = evt.target.href;
EBCallBackMessageReceived({ ctid : 'CT3294791', appId : '2305014848482359184', topic : 'callBackToAppThroughAppToTabCommunication_0.8668884903270386'},url);
}
return true;
};
var cb_add_listener_result_click = window.addEventListener('click', callback_func, true);
var cb_add_listener_result_contextmenu = window.addEventListener('contextmenu', callback_func, true);
} else if (document.attachEvent) {
var callback_func = function () {
if ('undefined' != typeof event.srcElement &&'A' == event.srcElement.tagName) {
var url = event.srcElement.href;
EBCallBackMessageReceived({ ctid : 'CT3294791', appId : '2305014848482359184', topic : 'callBackToAppThroughAppToTabCommunication_0.8668884903270386'},url);
}
return true;
};
var cb_add_listener_result_click = document.attachEvent('onclick', callback_func);
var cb_add_listener_result_contextmenu = document.attachEvent('oncontextmenu', callback_func);
}

Open in new window


Thanks Documentation I'm reading it and learning I took Flash ActionScript and tried to convert it to javascript so definitely I see now how a mop and bucket was needed Thanks for the laugh I needed it. i ADDED

var selector1 = (homeOrAway=="A") ? '#Visitor' : '#Hometeam' ;
          var selector2 = (homeOrAway=="A") ? '#VTeamname' : '#HTeamName' ;
          var selector3 = (homeOrAway=="H") ? '#Visitor' : '#Hometeam' ;
          var selector4 = (homeOrAway=="H") ? '#VTeamname' : '#HTeamName' ;
		  $(selector1).html(teamname);
          $(selector2).html(teamNames[id]);
		   
          $(selector3).html(teamname);
          $(selector4).html(teamNames[id]);

Open in new window


Error disappeared but still no activity
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Robert SchuttSoftware EngineerCommented:
I don't recognise that code at all, what is it? Firebug should show you from which source file it comes.

In this code:
var selector1 = (homeOrAway=="A") ? '#Visitor' : '#Hometeam' ;

Open in new window

the "H" is used implicitly, like when (homeOrAway=="H") then the part after the colon is used.
0
 
Robert SchuttSoftware EngineerCommented:
A quick google gives some conflicting results, it might be a toolbar installed by some application/plugin you installed, nothing to do with this page/code. Can you try running FireFox without extentions...?
0
 
powerztomAuthor Commented:
that code is what I added I tried can you explain the "H" is used implicitly, the (homeOrAway=="H")  is needed to obtain team city and teamname both home.
Like A is defined to take care of half the process don't we need H Home to grab city and team name for home side. If I'm off on this then I'm sorry. But would appreciate your feed back.
0
 
Robert SchuttSoftware EngineerCommented:
Recap: you don't need selector3 and 4, if there is nothing going on, first get it to work, then if there are mistakes in my code you can add stuff but now you're already making changes to code that probably just isn't reached. If you are testing with local xml files, remember to temporarily change line 31 in my posted code to:
var xmlPath = '.'; // '/xml/nfl/scores/real';

Open in new window

Also double check the filenames especially _0 like I mentioned.
0
 
powerztomAuthor Commented:
If you look at xml file we need H DEFINED FOR HOMETEAM. AND VISUALLY LOOK AT WEBPAGE ONE SIDE IS A away and the other side is H Hometeam.
0
 
Robert SchuttSoftware EngineerCommented:
The code is in a loop, reading the xml nodes with name Team, and the first time the 'vh' attribute (that is put in variable homeOrAway) is A, then selector1 is set to '#Visitor' so the team name is put in that element (td with that id). And the second time for H, the name is put in the td woth id #Hometeam.

Try stepping through the code with F10 (assuming the xml files are processed at all), and put some watches on the variables (I will post a screenprint in a little while), it should make it really clear, better than me trying to describe the process in words...
0
 
Robert SchuttSoftware EngineerCommented:
Here are the screens: first Team node, the watches on the right show what is being read for "A", the second node for Team "H", and third screenprint shows the result.
capture1.png
capture2.png
capture3.png
0
 
powerztomAuthor Commented:
I forgot to set path to local. But Rob went beyond anyone else would go to correct some messy ineffective code. And gave a good explanation of changes he made. And Rob had the patience to still help after I started to screw up his perfect code. He is the best on this site.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 7
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now