Just a moment...
Just a moment...
Just a moment...
Just a moment...
Just a moment...
/** * @desc function star_mlb_standings() * The function star_mlb_standings() builds a small table of current standings * and outputs it as a table inside the given html object. * * @param string division * @param string team */ function star_mlb_standings() { // Deal with any passed arguments. if (arguments[0] != null && arguments[0] != 'undefined' && in_array(arguments[0], ["alc","ale","alw","nlc","nle","nlw"])) { star_mlb_options['division'] = arguments[0]; } if (arguments[1] != null && arguments[1] != 'undefined' && in_array(arguments[1], ["oak","ana","hou","tor","atl","mil","stl","chc","tb","ari","la","sf","cle","sea","fla","nym","was","bal","sd","phi","pit","tex","cin","bos","col","kc","det","min","cws","nyy"])) { star_mlb_options['team'] = arguments[1]; } var showDivs = true; var showSubHead = true; // Build team mascots array. var mascots = new Object; mascots['oak'] = 'A\'s'; mascots['ana'] = 'Angels'; mascots['hou'] = 'Astros'; mascots['tor'] = 'Blue Jays'; mascots['atl'] = 'Braves'; mascots['mil'] = 'Brewers'; mascots['stl'] = 'Cardinals'; mascots['chc'] = 'Cubs'; mascots['tb'] = 'Devil Rays'; mascots['ari'] = 'Diamondbacks'; mascots['la'] = 'Dodgers'; mascots['sf'] = 'Giants'; mascots['cle'] = 'Indians'; mascots['sea'] = 'Mariners'; mascots['fla'] = 'Marlins'; mascots['nym'] = 'Mets'; mascots['was'] = 'Nationals'; mascots['bal'] = 'Orioles'; mascots['sd'] = 'Padres'; mascots['phi'] = 'Phillies'; mascots['pit'] = 'Pirates'; mascots['tex'] = 'Rangers'; mascots['cin'] = 'Reds'; mascots['bos'] = 'Red Sox'; mascots['col'] = 'Rockies'; mascots['kc'] = 'Royals'; mascots['det'] = 'Tigers'; mascots['min'] = 'Twins'; mascots['cws'] = 'White Sox'; mascots['nyy'] = 'Yankees'; // Get the object to contain the standings content. var standingsBody = document.getElementById('star_mlb_standings_body'); // Get the object to contain the standings head. var standingsHead = document.getElementById('star_mlb_standings_head'); // Get the variable that contains the current standings and the head. var standings_rs = ''; var standings_head = ''; // Deal with the division. var division = star_mlb_options['division']; if (division == null || division == 'undefined') { division = 'nlc'; } // Deal with the team. var team = star_mlb_options['team']; switch (division) { // American League East. case 'ale': standings_rs = eval('standings_rs_' + division); standings_head = 'AL East'; break; // American League Central. case 'alc': standings_rs = eval('standings_rs_' + division); standings_head = 'AL Central'; break; // American League West. case 'alw': standings_rs = eval('standings_rs_' + division); standings_head = 'AL West'; break; // National League East. case 'nle': standings_rs = eval('standings_rs_' + division); standings_head = 'NL East'; break; // National League West. case 'nlw': standings_rs = eval('standings_rs_' + division); standings_head = 'NL West'; break; // National League Central. case 'nlc': default: standings_rs = eval('standings_rs_' + division); standings_head = 'NL Central'; break; } if (!showSubHead) { standings_head = ''; } // Build the links. var standings = ''; if (showDivs) { standings += '
'; if (division == 'alw') { standings += 'ALW\n'; } else { standings += 'ALW\n'; } if (division == 'alc') { standings += 'ALC\n'; } else { standings += 'ALC\n'; } if (division == 'ale') { standings += 'ALE\n'; } else { standings += 'ALE\n'; } if (division == 'nlw') { standings += 'NLW\n'; } else { standings += 'NLW\n'; } if (division == 'nlc') { standings += 'NLC\n'; } else { standings += 'NLC\n'; } if (division == 'nle') { standings += 'NLE\n'; } else { standings += 'NLE
\n'; } standings += '
'; } // Start the standings table. standings += ''; // Iterate through each of the teams, displaying their data. for (i = 0; i < standings_rs.length; i++) { // Bold the selected team. if (standings_rs[i].code == team) { standings_rs[i].league_sensitive_team_name = standings_rs[i].league_sensitive_team_name; } // Check URL for last game wrap. if (standings_rs[i].wrap != null) { var url = '' + standings_rs[i].league_sensitive_team_name + ''; } else { var url = '' + standings_rs[i].league_sensitive_team_name + ''; } standings += ''; standings += ''; standings += ''; standings += ''; standings += ''; standings += ''; standings += ''; } // Close the table. standings += '
TeamWLPct.GB
' + url + '' + standings_rs[i].w + '' + standings_rs[i].l + '' + standings_rs[i].pct + '' + standings_rs[i].gb + '
'; // Include a link to full standings. standings += 'Expanded Standings'; // Set the standings object to the standings table. standingsBody.innerHTML = standings; standingsHead.innerHTML = standings_head; if (typeof(tableruler) == 'function') { tableruler(); } } function in_array(needle, haystack, strict) { // http://kevin.vanzonneveld.net // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // * example 1: in_array('van', ['Kevin', 'van', 'Zonneveld']); // * returns 1: true var found = false, key, strict = !!strict; for (key in haystack) { if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) { found = true; break; } } return found; } function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); } func(); } } } var star_mlb_options = new Object; star_mlb_options['division'] = ''; star_mlb_options['team'] = ''; addLoadEvent(star_mlb_standings);