Solved

javascript missing a bracket can't find please assist

Posted on 2014-03-12
8
303 Views
Last Modified: 2014-03-12
I 'm missing a bracket somewhere and I can't seem to find it I was hoping someone on EE can see it.

  var QueryString = function () {
	var query_string = {};
	var query = window.location.search.substring(1);
	var vars = query.split("&");
	for (var i=0;i<vars.length;i++) {
		var pair = vars[i].split("=");
		// If first entry with this name
		if (typeof query_string[pair[0]] === "undefined") {
			query_string[pair[0]] = pair[1];
		// If second entry with this name
		} else if (typeof query_string[pair[0]] === "string") {
			var arr = [ query_string[pair[0]], pair[1] ];
			query_string[pair[0]] = arr;
		// If third or later entry with this name
		} else {
			query_string[pair[0]].push(pair[1]);
		}
	} 
	return query_string;
} ();  
var xmlPath = '/xml/mlb/scores/real';
  var xmlGameID = QueryString.gameID;
  var srcFieldTeamLogo;
  var playerImage;
  var intPosID = {
	'P': {
		pos: 'Pitcher',
		id: 0,
		name: 'unknown'
	},
	'C': {
		pos: 'Catcher',
		id: 0,
		name: 'unknown'
	},
	'FB': {
		pos: 'First Base',
		id: 0,
		name: 'unknown'
	},
	'SB': {
		pos: 'Second Base',
		id: 0,
		name: 'unknown'
	},
	'SS': {
		pos: 'ShortStop',
		id: 0,
		name: 'unknown'
	},
	'TB': {
		pos: 'Third Base',
		id: 0,
		name: 'unknown'
	},
	'LF': {
		pos: 'Left Field',
		id: 0,
		name: 'unknown'
	},
	'CF': {
		pos: 'Center Field',
		id: 0,
		name: 'unknown'
	},
	'RF': {
		pos: 'Right Field',
		id: 0,
		name: 'unknown'
	},
	'HPUmpire': {
		pos: 'Home Plate Umpire',
		id: 0,
		name: 'unknown'
	},
	'TBUmpire': {
		pos: 'Third Base Umpire',
		id: 0,
		name: 'unknown'
	},
	'SBUmpire': {
		pos: 'Second Base Umpire',
		id: 0,
		name: 'unknown'
	},
	'FBUmpire': {
		pos: 'First Base Umpire',
		id: 0,
		name: 'unknown'
	}
  };



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",
	
	 "target field":"targetfield.jpg"
} // no comma on the last

var homeTurf = {
	"minnesota":"target field",
  "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"
}

function startup(){
	$.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 homeOrAway = team.attr("vh");
					var name = team.attr("name").toLowerCase();
				
					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";
					$("#imgStad").attr("src",url)
					//  $('#imgStad').attr('src', imgStad);
					var loc = Play.attr('Location') ;
					var locate = "Location" + $('#txtBallparkname').html(loc).toUpperCase; 
					 var d = $(data);
                d.find('Team').each(function(i,Team){
                    if ($(Team).attr('vh') == "H") {

                        $('#imghometeam').attr('src', 'http://images.sportsnetwork.com/MLB/attheballpark/pbp_logos/' +$(Team).attr('ID') + ".png");

                    }
                })
                d.find('Team').each(function(i,Team){
                    if ($(Team).attr('vh') == "A") {

                        $('#imgawayteam').attr('src', 'http://images.sportsnetwork.com/MLB/attheballpark/pbp_logos/' +$(Team).attr('ID') + ".png");

                    }
                });
            
				}  		
			});
		}
	});

	$('#P,#C,#FB,#SB,#SS,#TB,#LF,#CF,#RF').hover(function(){
		$('#playerImage').attr('src', 'http://images.sportsnetwork.com/MLB/attheballpark/players/'+intPosID[this.id].id+'.jpg');
		$('#PlayerName').html(intPosID[this.id].name);
		$('#PositionName').html(intPosID[this.id].pos);
	},function() {
		$('#playerImage').attr('src', 'http://sportsnetwork.com/gamecast/mlb/Images/blank.png');
		$('#PlayerName').html('&nbsp;');
		$('#PositionName').html('&nbsp;');
	});

	$('#HPUmpire,#TBUmpire,#SBUmpire,#FBUmpire').hover(function(){
		$('#playerImage').attr('src', 'http://images.sportsnetwork.com/MLB/attheballpark/umpires/'+intPosID[this.id].id+'.jpg');
		$('#PlayerName').html(intPosID[this.id].name);
		$('#PositionName').html(intPosID[this.id].pos);
	},function() {
		$('#playerImage').attr('src', 'http://sportsnetwork.com/gamecast/mlb/Images/blank.png');
		$('#PlayerName').html('&nbsp;');
		$('#PositionName').html('&nbsp;');
	});

//});


function loadAll() {

	$.ajax({
		type: "GET",
		url: xmlPath+"/"+xmlGameID+".xml",
	
		dataType: "xml",
		success: function(data){
			var d = $(data);
if (d.find('Play').attr("Status").toUpperCase() === "FINAL") {
        clearInterval(myVar);
      } 
      if (d.find('Play').attr("NoPlay").toUpperCase() === '1') {
        $('#txtBallparkname').html("Rain Delay");
       
        clearInterval(myVar);
      } 
       if (d.find('Play').attr("NoPlay").toUpperCase() === '0') {
        
       
        setInterval(myVar);
      } 
			for (var posItem in intPosID) {
				posItem.updated = false;
			}
$(d.find('Pitcher[TeamID="' + intPitcherTeamID + '"]')).find('Player').each(function(i, nodePlayer){ // always 1?
    nodePlayer = $(nodePlayer);
    var posItem = intPosID['P'];
    if (posItem) { // && !posItem.updated
        posItem.id = nodePlayer.attr('ID');
        posItem.name = nodePlayer.attr('FirstName') + ' ' + nodePlayer.attr('Lastname');
        posItem.updated = true;
        //tempCount++;
    }
});
			$(d.find('Fielders')).find('Player').each(function(indexPlayer, nodePlayer){
				nodePlayer = $(nodePlayer);
				var posItem = intPosID[nodePlayer.attr('Pos').trim().replace('1B', 'FB').replace('2B', 'SB').replace('3B', 'TB')];
				if (posItem) {
					posItem.id = nodePlayer.attr('ID');
					posItem.name = nodePlayer.attr('FirstName') + ' ' + nodePlayer.attr('Lastname');
					posItem.updated = true;
				} else {
					//console.log('invalid player positem: ' + nodePlayer.attr('Pos'));
				}
			});
			$(d.find('Umpires')).find('*').each(function(indexUmpire, nodeUmpire){
				nodeUmpire = $(nodeUmpire);
				var posItem = intPosID[nodeUmpire.prop('nodeName')];
				if (posItem) {
					posItem.id = nodeUmpire.attr('ID');
					posItem.name = nodeUmpire.text();
					posItem.updated = true;
				} else {
					//console.log('invalid umpire positem: ' + nodeUmpire.prop('nodeName'));
				}
			});

			/*
			var tempCount = 0;
			for (var posItem in intPosID) {
				if (!posItem.updated) {
					tempCount++;
				}
			}
			$('#txtBallparkname').html('temp debug: ' + tempCount + ' items NOT updated');
			*/

			var tempCount = 0;

			var intPitcherTeamID = d.find('Pitcher').attr('TeamID');
			var intBatterTeamID = d.find('Batter').attr('TeamID');
			$('#imgawayteam').attr('src', 'http://images.sportsnetwork.com/MLB/attheballpark/pbp_logos/' +intBatterTeamID + ".png");
			$('#imghometeam').attr('src', 'http://images.sportsnetwork.com/MLB/attheballpark/pbp_logos/' + intPitcherTeamID + ".png");
			// BattersSameTeamAsPitcher
			$(d.find('Batters[TeamID="' + intPitcherTeamID + '"]')).find('Player').each(function(i, nodePlayer){
				nodePlayer = $(nodePlayer);
				var posPlayer = nodePlayer.attr('Pos').replace('1B', 'FB').replace('2B', 'SB').replace('3B', 'TB');
				var posItem = intPosID[posPlayer];
				if (posItem) { // && !posItem.updated
					posItem.id = nodePlayer.attr('ID');
					posItem.name = nodePlayer.attr('FirstName') + ' ' + nodePlayer.attr('Lastname');
					posItem.updated = true;
					tempCount++;
				}
			});
			//$('#txtBallparkname').html('temp debug: ' + tempCount + ' items extra updated!');


			var Fielder = $(d.find('Fielders').find('Player:first'));
			var Team = $(d.find("Team[ID='" + Fielder.attr('TeamID') + "']"));
			var unfrm = Team.attr('Uniform'); // +'.gif';
			$('#P,#C,#FB,#SB,#SS,#TB,#LF,#CF,#RF').attr('src', 'http://images.sportsnetwork.com/MLB/attheballpark/pbp_logos/'+unfrm);
			//srcFieldTeamLogo = 'http://images.sportsnetwork.com/MLB/attheballpark/pbp_logos/'+Team.attr('ID')+'.png';
			//var d = $(data);
			//var Pitchers = $(d.find('Batters').find('Player:first'));
			///var Team = $(d.find("Team[ID='" + Batter.attr('TeamID') + "']"));
			//var unfrm = Team.attr('Uniform'); 
			//var bat = Batter.attr("Bats");
			
			//if (srcFieldTeamLogo != "") $('#srcFieldTeamLogo').attr('src', srcFieldTeamLogo);

		}
	})
}

Open in new window

Please Help
0
Comment
Question by:powerztom
  • 3
  • 2
  • 2
8 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 300 total points
ID: 39924024
function startup() is not being closed.
0
 
LVL 54

Assisted Solution

by:Julian Hansen
Julian Hansen earned 200 total points
ID: 39924116
Add '}' to line 237
0
 

Author Comment

by:powerztom
ID: 39924136
Thanks julianH. Provided correct input to fix my syntax problem.Awesome
0
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.

 
LVL 58

Expert Comment

by:Gary
ID: 39924148
Isn't that what I said half an hour ago.
0
 
LVL 54

Expert Comment

by:Julian Hansen
ID: 39924294
Gary is right - I saw his post and just filled in the missing bit - the line number.
0
 

Author Closing Comment

by:powerztom
ID: 39924431
Both guys provided same solution didn't see gary though.sorry
0
 
LVL 54

Expert Comment

by:Julian Hansen
ID: 39924734
Thanks powerztom,
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

773 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