?
Solved

load Ballpark Jquery

Posted on 2013-06-14
9
Medium Priority
?
320 Views
Last Modified: 2013-06-14
I need to load a image of a BallPark into a current image The reason is I'm going to have little Players loaded on top of Baseball field. I have code to load the image when nothing is on webpage but I need to know How to load Ballpark image into a present image.
here is the code It should load washington Nationals Ballpark and not default.
stadiums = {
	"wrigley field":"wrigley.gif",
	"comerica park":"comerica.gif" ,
	"yankee stadium":"yankee.jpg" ,
	"shea stadium":"shea.jpg" ,
	"angel stadium of anaheim":"angel.jpg" ,
	"rangers ballpark in arlington":"angel.jpg" ,
	"at&t park":"attpark.jpg" ,
	"citizens bank park":"citizenballpark.jpg" ,
	"coors field":"coors.jpg" ,
	"busch stadium":"busch.jpg" ,
	"oriole park at camden yards":"camden_baltimore.jpg",
	"dodger stadium":"dodgers.jpg" ,
	"chase field":"chasefield.jpg" ,
	"tropicana field":"tropicana.jpg" ,
	"great american ball park":"greatamerican.jpg" ,
	"kauffman stadium":"kauffmanstadium.jpg" ,
	"mcafee coliseum":"mcafeecoliseum.jpg" ,
	"hubert h. humphrey metrodome":"metrodome.jpg" ,
	"metrodome":"metrodome.jpg" ,
	"miller park":"millerpark.jpg" ,
	"minute maid park":"minutemaid.jpg" ,
	"nationals park":"nationalspark.jpg" ,
	"petco park":"petcopark.jpg" ,
	"pnc park":"pncpark.jpg" ,
	"progressive field":"progressive.jpg" ,
	"rogers centre":"rogerscentre.jpg" ,
	"safeco field":"safecofield.jpg" ,
	"turner field":"turnerfield.jpg" ,
	"dolphin stadium":"dolphinstadium.jpg" ,
	"fenway park":"fenwaypark.jpg" ,
	"u.s. cellular field":"uscellularfield.jpg" ,
	"oakland-alameda county coliseum":"mcafeecoliseum.jpg",
	"marlins park":"marlins.jpg",
	"citi field":"citifield.jpg",
	"citi field":"citifield.jpg",
	 "minnesota":"target field"
} // no comma on the last

var homeTurf = {
  "philadelphia":"citizens bank park",
  "milwaukee":"miller park",
  "san francisco":"u.s. cellular field",
  "la angels":"angel stadium of anaheim",
  "tampa bay":"tropicana field",
  "chicago wsox":"u.s. cellular field",
  "oakland":"oakland-alameda county coliseum",
  "kansas city":"kauffman stadium",
  "los angeles":"dodger stadium",
  "san diego":"petco park",
  "boston":"fenway park",
  "seattle":"safeco field",
  "detroit":"comerica park",
  "atlanta":"turner field",
  "baltimore":"oriole park at camden yards",
  "miami":"marlins park",
  "pittsburgh":"pnc park",
  "ny mets":"citi field",
  "st. louis":"busch stadium",
  "houston":"minute maid park",
  "cleveland":"progressive field",
  "cincinnati":"great american ball park",
  "texas":"rangers ballpark in arlington",
  "toronto":"rogers centre",
  "chicago cubs":"wrigley field",
  "arizona":"chase field",
  "colorado":"coors field",
  "ny yankees":"yankee stadium",
  "washington":"nationals park"
}

$(document).ready(function(){
  $.ajax({
    type: "GET",
    url: xmlPath+"/"+xmlGameID+".xml",
	
    dataType: "xml",
    success: function(data){
		 var d = $(data);
      var Play = d.find('Play');
      var Teams = $(data).find("Team");
	  
      $.each(Teams,function(i,Team) {
        team=$(Team);
        var id = team.attr("ID").toLowerCase();
        var teamLogo = $("<img/>").attr("src","http://images.sportsnetwork.com/MLB/attheballpark/pbp_logos/" + id + ".png");
        var homeOrAway = team.attr("vh");
	var name = team.attr("name").toLowerCase();
        $("#team"+homeOrAway).append(teamLogo);
        if (homeOrAway=="H") {
          var stadium_location = stadiums[homeTurf[name]]; // or have
          var url = "http://images.sportsnetwork.com/mlb/attheballpark/stadiums/";
          url = (stadium_location) ?url + stadium_location:"default.gif";
          
		 var loc = Play.attr('Location') ;
      var locate = "Location" + $('#txtBallparkname').html(loc).toUpperCase; 
        }  


      });
     }
  });
});

Open in new window

Field.html
37260.xml
0
Comment
Question by:powerztom
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 39248536
1)  var loc = Play.attr('Location') ; does not return a location
2) var locate = "Location" + $('#txtBallparkname').html(loc).toUpperCase;
does not do anything.

I get this for the home team

http://images.sportsnetwork.com/mlb/attheballpark/stadiums/nationalspark.jpg

and this:

National
0
 

Author Comment

by:powerztom
ID: 39248594
I need washington field to load butnot like that I location to match location in xml file then staduim graphic file name to be appended to i "http://images.sportsnetwork.com/mlb/attheballpark/stadiums/";
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 39248598
Sorry that did nt make any sense...
0
Quick Cloud Training

Looking for some quick training on the cloud in 2 hours or less? Check out these how-to guides in AWS, Linux, OpenStack, Azure, and more!

 

Author Comment

by:powerztom
ID: 39248707
In the xml file there is a attrib called Location the value of Location is nationalspark.jpg I am simply trying to call the value of location which is  nationalspark.jpg and put that value at the end of http://images.sportsnetwork.com/mlb/attheballpark/stadiums/ 

That is it my syntax is off though.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 39248762
But as I said, I do get national park on my computer with the files you posted
0
 

Author Comment

by:powerztom
ID: 39248790
This is the washington Nationals field the one I need
http://images.sportsnetwork.com/mlb/attheballpark/stadiums/nationalspark.jpg


The one your getting is Default.gif I guess if your not into Baseball they all look the same.

Your link
http://images.sportsnetwork.com/mlb/attheballpark/stadiums/default.gif
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 39248866
Hmm. Ok I also looked in the debugger.

I'll look again tomorrow. Bedtime here
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 2000 total points
ID: 39248931
But you never load it

Change
          url = (stadium_location) ?url + stadium_location:"default.gif";

to

          url = (stadium_location) ?url + stadium_location:"default.gif";
          $("#imgStad").attr("src",url)
0
 

Author Closing Comment

by:powerztom
ID: 39248957
mplungjan: Thank You for your assistance Your Help is much appreciated
0

Featured Post

TCP/IP Network Protocol Cheat Sheet

TCP/IP is a set of network protocols which is best known for connecting the machines that make up the Internet. The truth is that TCP/IP is one of the oldest network protocols and its survival is mainly based on its simplicity and universality.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
This article discusses how to implement server side field validation and display customized error messages to the client.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Suggested Courses

752 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