Solved

load Ballpark Jquery

Posted on 2013-06-14
9
305 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
  • 5
  • 4
9 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
Comment Utility
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
Comment Utility
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
Comment Utility
Sorry that did nt make any sense...
0
 

Author Comment

by:powerztom
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 75

Expert Comment

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

Author Comment

by:powerztom
Comment Utility
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
Comment Utility
Hmm. Ok I also looked in the debugger.

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

Accepted Solution

by:
Michel Plungjan earned 500 total points
Comment Utility
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
Comment Utility
mplungjan: Thank You for your assistance Your Help is much appreciated
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will learn how to dynamically set the form action using jQuery.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

772 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

13 Experts available now in Live!

Get 1:1 Help Now