Solved

javascript missing a bracket can't find please assist

Posted on 2014-03-12
8
299 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 51

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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 58

Expert Comment

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

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 51

Expert Comment

by:Julian Hansen
ID: 39924734
Thanks powerztom,
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

744 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

15 Experts available now in Live!

Get 1:1 Help Now