// given a game object from the schedule - millisecond gmt time, and
// the timezone offsets to return a gameTime object with date objects
// for these adjusted times, along with string versions of the times
function createGameTimes(game) {
var localDate = new Date();
gameTime = { milliseconds: parseInt(game.game_time, 10), date: "", dateObj: new Date() };
gameTime.local = { milliseconds: gameTime.milliseconds, time: "", dateObj: new Date() };
gameTime.eastern = { milliseconds: gameTime.milliseconds, time: "", dateObj: new Date() };
// adjust the milliseconds time for est/venue time based on provided timezone offset
if (game.game_time_offset_local) {
gameTime.local.milliseconds = gameTime.milliseconds + (60 * 60 * game.game_time_offset_local * 1000);
}
if (game.game_time_offset_eastern) {
gameTime.eastern.milliseconds = gameTime.milliseconds + (60 * 60 * game.game_time_offset_eastern * 1000);
}
// create date objects from these millisecond time values
gameTime.dateObj.setTime(gameTime.milliseconds + (localDate.getTimezoneOffset() * 60 * 1000));
gameTime.local.dateObj.setTime(gameTime.local.milliseconds + (localDate.getTimezoneOffset() * 60 * 1000));
gameTime.eastern.dateObj.setTime(gameTime.eastern.milliseconds + (localDate.getTimezoneOffset() * 60 * 1000));
// for 2006, every game is in March
gameTime.date = gameTime.local.dateObj.getDate() + " Mar";
// write "US" versions of dates with am/pm, others all get 24hr time
if (localize) {
gameTime.local.time = gameTime.local.dateObj.getHours() + ":" + getTwoDigitValue(gameTime.local.dateObj.getMinutes());
gameTime.eastern.time = gameTime.eastern.dateObj.getHours() + ":" + getTwoDigitValue(gameTime.eastern.dateObj.getMinutes());
} else {
gameTime.local.time = ":" + getTwoDigitValue(gameTime.local.dateObj.getMinutes());
gameTime.eastern.time = ":" + getTwoDigitValue(gameTime.eastern.dateObj.getMinutes());
var hour = gameTime.local.dateObj.getHours();
if (hour > 12) {
hour = hour - 12;
gameTime.local.time = hour + gameTime.local.time + "pm";
} else if (hour == 12) {
gameTime.local.time = hour + gameTime.local.time + "pm"; // noon
} else {
gameTime.local.time = hour + gameTime.local.time + "am";
}
hour = gameTime.eastern.dateObj.getHours();
if (hour > 12) {
hour = hour - 12;
gameTime.eastern.time = hour + gameTime.eastern.time + "pm";
} else if (hour == 12) {
gameTime.eastern.time = hour + gameTime.eastern.time + "pm"; // noon
} else {
gameTime.eastern.time = hour + gameTime.eastern.time + "am";
}
}
gameTime.eastern.clock = gameTime.eastern.time;
// if the EST time falls on another date, then add the date/month to the time string
/*
if (game.division_id == 310) {
if (gameTime.local.dateObj.getDate() != gameTime.eastern.dateObj.getDate()) {
gameTime.eastern.time = "" + gameTime.eastern.dateObj.getDate() + " Mar " + gameTime.eastern.time
} else {
gameTime.eastern.time = gameTime.eastern.dateObj.getDate() + " Mar " + gameTime.eastern.time
}
}
*/
if (gameTime.local.dateObj.getDate() != gameTime.eastern.dateObj.getDate()) {
gameTime.eastern.time = gameTime.eastern.dateObj.getDate() + " Mar " + gameTime.eastern.time
}
return gameTime;
}
function buildLiveGame(params) { // for now its just the same function
return buildUpcomingGame(params);
}
// build a single table row with the information for an upcoming or unfinished game
function buildUpcomingGame(params) {
var game = setupPreviewRecap(params.game, params.previews, "previews");
var html = "";
var matchup = "";
var stadium = "";
var video = "";
var audio = "";
var preview = "";
var gameday = "";
var gameId = game.game_id;
gameId = gameId.replace(/\//g, "_").replace(/\-/g, "_");
audio = buildMedia(gameId, media, "audio");
video = buildMedia(gameId, media, "video");
try {
if (game.away.previews || game.home.previews) {
if (localize) {
var lang = "en";
lang = lang.replace(/\-/g, "_");
if (game.home.previews[lang]) {
game.home.preview = game.home.previews[lang];
} else {
if (game.home.previews.en) { game.home.preview = game.home.previews.en; }
}
if (game.away.previews[lang]) {
game.away.preview = game.away.previews[lang];
} else {
if (game.away.previews.en) { game.away.preview = game.away.previews.en; }
}
} else {
if (game.home.previews.en) { game.home.preview = game.home.previews.en; }
if (game.away.previews.en) { game.away.preview = game.away.previews.en; }
}
}
} catch (e) { }
var tbdTeams = {
// pool 1
pk39925: { away: "Pool A Runner-up", home: "Pool B Runner-up" }, // anaheim 3/12 1
pk39927: { away: "Pool B Winner", home: "Pool A Winner" }, // anaheim 3/12 2
pk39930: { away: "Pool B Runner-up", home: "Pool A Winner" }, // anaheim 3/13
pk39931: { away: "Pool A Runner-up", home: "Pool B Winner" }, // anaheim 3/14
pk39934: { away: "Pool A Winner", home: "Pool A Runner-up" }, // anaheim 3/15
pk39935: { away: "Pool B Runner-up", home: "Pool B Winner" }, // anaheim 3/16
// pool 2
pk39924: { away: "Pool C Runner-up", home: "Pool D Runner-up" }, // hiram 3/12 1
pk39926: { away: "Pool C Winner", home: "Pool D Winner" }, // hiram 3/12 2
pk39928: { away: "Pool D Winner", home: "Pool C Runner-up" }, // hiram 3/13 1
pk39929: { away: "Pool D Runner-up", home: "Pool C Winner" }, // hiram 3/13 2
pk39932: { away: "Pool D Runner-up", home: "Pool D Winner" }, // hiram 3/14
pk39933: { away: "Pool C Runner-up", home: "Pool C Winner" }, // hiram 3/15
pk39936: { away: "Pool 2 Runner-up", home: "Pool 2 Winner" }, // semi 1
pk39937: { away: "Pool 1 Runner-up", home: "Pool 1 Winner" }, // semi 2
pk39938: { away: "SF 1 Winner", home: "SF 2 Winner" } // example from final game
}
gameTime = createGameTimes(game);
try {
var teamAwayName = "";
var teamHomeName = "";
if (game.away.code_num == "32") {
if (tbdTeams["pk" + game.game_pk]) {
teamAwayName = tbdTeams["pk" + game.game_pk].away
} else {
teamAwayName = "TBD";
}
} else {
if (params.name == "display") {
teamAwayName = countryName["t" + game.away.code_num];
} else {
teamAwayName = countryAbbr["t" + game.away.code_num];
}
}
if (game.home.code_num == "32") {
if (tbdTeams["pk" + game.game_pk]) {
teamHomeName = tbdTeams["pk" + game.game_pk].home
} else {
teamHomeName = "TBD";
}
} else {
if (params.name == "display") {
teamHomeName = countryName["t" + game.home.code_num];
} else {
teamHomeName = countryAbbr["t" + game.home.code_num];
}
}
matchup = teamAwayName + " vs " + teamHomeName;
} catch (e) {
matchup = "TBD vs TBD";
}
if (game.venue_id) {
stadium = stadiumName["v" + game.venue_id];
} else if (game.game_venue) {
stadium = game.game_venue;
}
// if we're on the main schedule page, display both previews, otherwise just display this teams preview
// and only display previews in Preview, Warmup or Immediate Preview
if ((game.game_status == "P") || (game.game_status == "IP") || (game.game_status == "W")) {
if (params.name == "display") {
if (game.away.preview) { preview += "" + countryAbbr["t" + game.away.code_num] + " Preview "; }
if (game.home.preview) { preview += "" + countryAbbr["t" + game.home.code_num] + " Preview"; }
} else {
if (("t" + game.home.code_num) == 'wbc') {
if (game.home.preview) { preview = "Preview"; }
}
if (("t" + game.away.code_num) == 'wbc') {
if (game.away.preview) { preview = "Preview"; }
}
}
}
// show gameday for "inprogress" games
if ((game.game_status == "I") || (game.game_status == "D") || (game.game_status == "W") || (game.game_status == "IP")) {
gameday = "Gameday
";
gameday = "
";
} else {
stadium += "
";
}
html += "