Solved

xml data not pulling

Posted on 2014-04-23
4
311 Views
Last Modified: 2014-04-24
I need to get team names and team color as well as position tean logo on center ice
As displayed http://sportsnetwork.com/gamecast/nhl/rink5.html
I need that team name and team colors to occur on this page
http://sportsnetwork.com/gamecast/nhl/rinkdots.html

I'm not sure why this is not coming up cause I mput same code in from rink5 into rinkdots.html
Don't worry about what occurs below hockey rink.

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<meta name="author" content="Tom Powers">
	<title>Current NHL Play</title>
	<link rel="stylesheet" href="css/jquery-ui-1.8.9.customver1.css">
	<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

	<script type="text/javascript">
 var xmlPath = '/xml/nhl/scores/real';
 var xmlGameID ='19059';
 var gameData, playArray, playSeqPos = -1;
var away_id, home_id, myVar;
 $(document).ready(function() {
  $.ajax({
   type: "GET",
   url:  xmlPath + "/" + xmlGameID + ".xml",
   dataType: "xml",
   success: function(data) {
    gameData = $(data);
    playArray = gameData.find('Play');
    playSeqPos = playArray.length;
	away_id = Play.find('Team[vh="A"]').attr('ID');
			home_id = Play.find('Team[vh="H"]').attr('ID');

            Play.find('Team').each(function(i,Team){
                var team = $(Team);
                //var id = team.attr("ID").toLowerCase();
                var vh = team.attr('vh'); // A or H...
                var sHomeOrAway = vh == 'H' ? 'home' : 'away';
				Colorcheck(sHomeOrAway, team.attr('ID'));
                $('#txt' + sHomeOrAway).find('div').html(team.attr('name'));
            });
   showData();
   }
  });
 });
 function showData() {
  playSeqPos--;
  play = $(playArray[playSeqPos]);
  quarter = play.attr("Quarter");
  $('#p').html("Period " + quarter);
  $('Team', gameData).each(function(i, Team) {
   team = $(Team);
   id = team.attr("ID").toLowerCase();
   vh = team.attr('vh');
   sHomeOrAway = (vh == 'A') ? 'away':'home';
   $('#img' + sHomeOrAway).attr('src', 'http://sportsnetwork.com/gamecast/nhl/nhl/' + id + '.png');
   $('#' + sHomeOrAway + 'teamscore').html(team.find('Linescore').attr('Score'));
  });

  playInfo = getPlayInfo(play);

  $('#teamID').attr('src', playInfo.teamImg);
  $('#playerID').attr('src', playInfo.playerImg);
  $('#playtype').html(playInfo.playType);
  $('#timeleft').html(playInfo.playTime);
  $('#txtgameplay').html(playInfo.playNarr);
  if (playSeqPos > 0) {
   //setInterval(showData, 1000);
  }
 }

	function getPlayInfo(play) {
		teamID, playerID;
		playTypes = {
			"GOAL": {subnode: 'Goal', teamidnode: 'ScoreTeamID', playeridnode: 'ScoreID'},
			"MISSED": {subnode: 'Missed', teamidnode: 'ShootTeamID', playeridnode: 'ShootID'},
			"BLOCKED": {subnode: 'Blocked', teamidnode: 'ShootTeamID', playeridnode: 'ShootID'},
			"ONGOAL": {subnode: 'OnGoal', teamidnode: 'ShootTeamID', playeridnode: 'ShootID'},
			"HIT": {subnode: 'Hit', teamidnode: 'HitTeamID', playeridnode: 'HitID'},
			"PENL": {subnode: 'Penalty', teamidnode: 'PONTeamID', playeridnode: 'PONID'}
		};

		if ( playInfo = $(playTypes).attr( play.attr('PlayType') ) ) {
			teamID = play.find( playInfo.subnode ).attr( playInfo.teamidnode );
			playerID = play.find( playInfo.subnode ).attr( playInfo.playeridnode );
		}

		return {
			'teamImg'	: (teamID) ? 'http://sportsnetwork.com/gamecast/nhl/nhl/' + teamID + '.png': 'http://powerzsoftware.com/tsn/IMAGES/NHLLOGOX.png',
			'playerImg'	: (playerID) ? 'http://images.sportsnetwork.com/nhl/attherink/players/' + playerID + '.jpg' : 'http://powerzsoftware.com/tsn/IMAGES/sKATE.png',
			'playType'	: play.attr('PlayType'),
			'playTime'  : play.attr('TimeLeft'),
			'playNarr'	: play.find('narrative').attr('text')
		};
	}
	function Colorcheck(sHomeOrAway, teamid) {

var lineColour = -1, fillColour = -1;

if (teamid == "145") { //Anaheim Ducks
		lineColour = 0xFFCC99;
		fillColour = 0x91764C;
	} else if (teamid == "147") { //Atlanta Thrashers
		lineColour = 0x0000FF;
		fillColour = 0x900028;
	} else if (teamid == "121") { //Boston Bruins
		lineColour = 0x000000;
		fillColour = 0xF9B426;
	} else if (teamid == "122") { //Buffalo Sabres
		lineColour = 0x000099;
		fillColour = 0x0E1F44;
	} else if (teamid == "123") { //Calgary Flames
		lineColour = 0x000000;
		if ((away_id == "129") || (home_id == "129")) {
			fillColour = 0xFF9933;
		} else {
			fillColour = 0xE13A3E;
		}
	} else if (teamid == "127") { //Carolina Hurricanes
		lineColour = 0x000000;
		fillColour = 0xD72A32;
	} else if (teamid == "124") { //Chicago Blackhawks
		lineColour = 0x000000;
		fillColour = 0xCC0000;
	} else if (teamid == "136") { //Colorado Avalanche
		lineColour = 0xFF0000;
		fillColour = 0x802939;
	} else if (teamid == "148") { //Columbus Blue Jackets
		lineColour = 0x003366; 
		if ( (away_id == "139") || (home_id == "139") || (away_id == "142") || (home_id == "142") ) {
			fillColour = 0xFF0033;
		} else {
			fillColour = 0x253E67;
		}
	} else if (teamid == "130") { //Dallas Stars
		lineColour = 0x009900;
		fillColour = 0x0A4A3D;
	} else if (teamid == "125") { //Detroit Red Wings
		lineColour = 0xFF0000;
		fillColour = 0xD5252D;
	} else if (teamid == "126") { //Edmonton Oilers
		lineColour = 0x000099;
		fillColour = 0xc5892d;
	} else if (teamid == "146") { //Florida Panthers
		lineColour = 0x000099;
		fillColour = 0xB67b11;
	} else if (teamid == "128") { //Los Angeles Kings
		lineColour = 0x0000FF;
		fillColour = 0x233289;
	} else if (teamid == "149") { //Minnesota Wild
		lineColour = 0x009900;
		fillColour = 0x004033;
	} else if (teamid == "129") { //Motreal Canadiens
		lineColour = 0xFF0000;
		fillColour = 0xB62630;
	} else if (teamid == "150") { //Nashville Predators
		lineColour = 0x000099;
		fillColour = 0x143048;
	} else if (teamid == "131") { //New Jersey Devils
		lineColour = 0xFF0000;
		fillColour = 0xD82D35;
	} else if (teamid == "133") { //New York Rangers
		lineColour = 0x0000FF;
		fillColour = 0x055B8D;
	} else if (teamid == "132") { //New York Islanders
		lineColour = 0x0000FF;
		if ((away_id == "128") || (home_id == "128")) {
			fillColour = 0xFF9933;
		} else {
			fillColour = 0x002843;
		}
	} else if (teamid == "143") { //Ottawa Senators
		lineColour = 0xFF0000;
		if ( (away_id == "146") || (home_id == "146")) {
			fillColour = 0xFF0033;
		} else {
			fillColour = 0xD89D00;
		}

	} else if (teamid == "134") { //Philadelphia Flyers
		lineColour = 0xFF6600;
		if ((away_id == "131") || (home_id == "131")) {
			fillColour = 0x000000;
		} else {
			fillColour = 0xF9773B;
		}
	} else if (teamid == "141") { //Phoenix Coyotes
		lineColour = 0xFF0000;
		if ((away_id == "125") || (home_id == "125")) {
			fillColour = 0XF4E3C7;
		} else {
		fillColour = 0xA51818;
		}
	} else if (teamid == "135") { //Pittsburgh Penguins
		lineColour = 0xFFCC00;
		fillColour = 0x000000;
	} else if (teamid == "142") { //San Jose Sharks
		lineColour = 0x000099;
		fillColour = 0x07515F;
	} else if (teamid == "137") { //St. Louis Blues
		lineColour = 0x3366FF;
		fillColour = 0x004C7D;
	} else if (teamid == "144") { //Tampa Bay Lightning
		lineColour = 0x000099;
		fillColour = 0x003D7D;
	} else if (teamid == "138") { //Toronto Maple Leafs
		lineColour = 0x3366FF;
		fillColour = 0x003559;
	} else if (teamid == "139") { //Vancouver Canucks
		lineColour = 0x000099;
		fillColour = 0x002B3E;
	} else if (teamid == "140") { //Washington Capitals
		lineColour = 0x0000FF;
		if ((away_id == "138") || (home_id == "138")) {
			fillColour = 0xFF0000;
		} else {
			fillColour = 0xD93600;
		}
	} else {
		//do nothing
	}

	if (lineColour == -1 || fillColour == -1) {
		alert('color error!');
	} else {
		$('#' + sHomeOrAway + 'color').css({'background-color': hex2str(fillColour), 'border': 'solid 3px ' + hex2str(lineColour)});
	}
	function hex2str(h) {
	return '#' + ('000000' + h.toString(16)).substr(-6);
}
}
	</script>

	<style type="text/css" media="screen">
		.midcenter { font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif; font-size: 45px; font-weight: bold; text-align: center; vertical-align: middle; }
		.small { font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif; font-size: 22px; font-weight: bold; text-align: center; vertical-align: middle; }
	</style>
</head>
<body>

	<table width="100%" border="0">
	  <tr>
	    <td width="24%"><div id="awaycolor"></div></td>
	    <td width="25%"><div id="txtaway">
          <div align="left">awayteam</div>
        </div></td>
	    <td width="25%"><div id="txthome">
          <div align="right">hometeam</div></td>
	    <td width="26%"><div id="homecolor"></div></td>
      </tr>
	  <tr>
	    <td colspan="4"><img src="Images/Rink.png" width="354" height="163" alt=""/></td>
      </tr>
	  <tr>
	    <td>&nbsp;</td>
	    <td>&nbsp;</td>
	    <td>&nbsp;</td>
	    <td>&nbsp;</td>
      </tr>
</table>
	<table width="100%" border="0">
		<tr>
			<td width="24%" class="midcentre" style="text-align: center"><img src="http://sportsnetwork.com/gamecast/nhl/nhl/130.png" id="teamID" width="100%"></td>
			<td width="25%" class="midcenter"><img src="images.sportsnetwork.com/nhl/attherink/players/2867.jpg" id="playerID" width="100%"></td>
			<td width="25%" class="small " id="playtype">&nbsp;</td>
			<td width="26%" class="small" id="timeleft">&nbsp;</td>
		</tr>
	</table>

	<table width="100%" border="0">
		<tr>
			<td><p class="small " id="txtgameplay">&nbsp;</p></td>
		</tr>
	</table>

	<table width="100%" border="0">
		<tr>
			<td width="24%"><p class="midcenter"><img src="http://sportsnetwork.com/gamecast/nhl/nhl/400.png" width="100%" id="imgaway"></p></td>
			<td width="25%" class="midcenter" id="awayteamscore">0</td>
			<td width="25%" class="midcenter" id="hometeamscore">0</td>
			<td width="26%" class="midcenter"><img src="http://sportsnetwork.com/gamecast/nhl/136.png" id="imghome" width="100%"></td>
		</tr>
	</table>

	<table width="100%" border="0">
		<tr>
			<td class="GCPBP" id="period"><div align="center" id="p" style="text-align: center" class="GCPBP">PERIOD #</div></td>
		</tr>
	</table>
<script>
var myVar=setInterval(function(){myTimer()},10000);

function myTimer()
{
showData();

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

Open in new window

I want to use canvas ultimately and draw dots to represent shots with their nteam's respected colors along with a tool tip for each Dot. This is getting ahead of myself buT THAT'S THE ULTIMATE GOAL. Thanks EE
RINKDOTS.HTML
19059.XML
0
Comment
Question by:powerztom
  • 2
  • 2
4 Comments
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 40019717
In your css

#apDiv1 {
position: absolute;
width: 370px;
/* height: 164px; */
z-index: 10;
/* CHANGE LEFT TO 17PX */
left: 17px;
top: 39px;
}

Open in new window

0
 

Author Comment

by:powerztom
ID: 40020038
What I need to happen is
http://sportsnetwork.com/gamecast/nhl/rink5.html

1.awayteam color
2.awayteam name
3.hometeam color
4.hometeam name
5. center hometeam ice logo # my code for this is not included #

I tried

#apDiv1 {
position: absolute;
width: 370px;
/* height: 164px; */
z-index: 10;
/* CHANGE LEFT TO 17PX */
left: 17px;
top: 39px;
}

I am not sure what that will accomplish but I probably didn't make myself and what I wanted clear that's my fault.
0
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
ID: 40020257
When I change the position to 17px, the logo is mostly in the center.  I also noticed some missing files.
17pxmissing files
I have no idea what you want with any of this
1.awayteam color
2.awayteam name
3.hometeam color
4.hometeam name
5. center hometeam ice logo # my code for this is not included #


To help you better, I think it would be best to organize exactly what you need.  Create a test page using only the code that is important to the question.  If there is extra code, "Don't worry about what occurs below hockey rink." then no need to include it.  It just means more work to figure out what is what.  Take a quick read of how to set up an example http://www.sscce.org/

For now, I would start with just static html and images and forget about any database, php, ajax, xml etc.  Let's start with only rendered html code and getting thing placed where they should be.  Once that is done, you can back in the dynamic xml/ajax.  For now, that is just adding an extra layer of confusion.

What is the point of using canvas instead of just background images of div's if you are not doing any drawing?

Watch out using a mix of % width's and absolute positioning. You should be able to do all of this using relative positioning.

Using tables for your layout may hurt in the long run too.  You can do all of this using div's.
rinkLooking at the image above, I would probably do something like this.
-div id = container
---div  id = header
------div id = home
------div id = away
---div  id = rink
------div id = center_logo
---div  id = footer_stats
0
 

Author Closing Comment

by:powerztom
ID: 40020517
I break it down real simple like you suggested. There is a reason why I want to use canvas
here and that is I have to paint each teams shots on goal on the ice as a dot based on that team's colors and game log contained within the xml file.It's not going to be easy. Thanks for breaking it down into basics.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

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 …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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)

706 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

16 Experts available now in Live!

Get 1:1 Help Now