Solved

load Ballpark Jquery

Posted on 2013-06-14
9
308 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
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
 

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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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 500 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

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…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

919 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

12 Experts available now in Live!

Get 1:1 Help Now