Solved

javascript missing a bracket can't find please assist

Posted on 2014-03-12
8
306 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
[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
  • 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 56

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
Technology Partners: 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!

 
LVL 58

Expert Comment

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

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 56

Expert Comment

by:Julian Hansen
ID: 39924734
Thanks powerztom,
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Suggested Solutions

Title # Comments Views Activity
Sending ASP to server side 8 31
Link not working 6 42
MediaWiki - Move a site 4 31
Jquery HTML() with ajax... replacing content 2 28
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
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…

756 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