Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 326
  • Last Modified:

javascript missing a bracket can't find please assist

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
powerztom
Asked:
powerztom
  • 3
  • 2
  • 2
2 Solutions
 
GaryCommented:
function startup() is not being closed.
0
 
Julian HansenCommented:
Add '}' to line 237
0
 
powerztomAuthor Commented:
Thanks julianH. Provided correct input to fix my syntax problem.Awesome
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
GaryCommented:
Isn't that what I said half an hour ago.
0
 
Julian HansenCommented:
Gary is right - I saw his post and just filled in the missing bit - the line number.
0
 
powerztomAuthor Commented:
Both guys provided same solution didn't see gary though.sorry
0
 
Julian HansenCommented:
Thanks powerztom,
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now