[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

load Ballpark Jquery

Posted on 2013-06-14
9
Medium Priority
?
321 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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)
Suggested Courses

656 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