Below is an advertisement.
Standings
* first-half division winner
$ first-half Wild Card winner
@ clinched playoff
# clinched division
& clinched wildcard
'
].join("");
$("#elimMsg").html(elimMsg);
}
else {
$("#elimMsg").empty();
}
if ((sit_code == "wc")&&(wcType=="L")){
$("#standings_wc").show();
for (dids in data.standingsInfo.division_ids) {
if (data.standingsInfo.division_ids.hasOwnProperty(dids)) {
$get("#standings_"+data.standingsInfo.division_ids[dids]).hide();
}
}
}
else {
$("#standings_wc").hide();
for (dids in data.standingsInfo.division_ids) {
if (data.standingsInfo.division_ids.hasOwnProperty(dids)) {
$get("#standings_"+data.standingsInfo.division_ids[dids]).show();
}
}
}
// console.dir(data);
},
renderError: function (error) {
$get("#loading").html("There was an error loading standings data.").removeClass("ldImg");
},
init: function(){
//great stuff here
}
};
bam.leagueStandings.data = $.bindable({
cache: {},
serviceParamsStandings: {
"sit_code": ["'h0'","'h1'","'h2'"]
},
serviceParamsWildCard: {
"sit_code": "'h0'"
},
_loadStandingsData: function (reqLeague,reqSeason) {
$.extend(bam.leagueStandings.data.serviceParamsStandings,{
"league_id": reqLeague,
"org_history.org_id": reqLeague,
"season": reqSeason
});
return $.ajax({
// url: "/test/standings.json",
url: "/lookup/json/named.milb_standings_display_flip.bam",
data: this.serviceParamsStandings,
dataType: "json",
traditional: true
});
},
_loadWildCardData: function (reqLeague,reqSeason) {
$.extend(bam.leagueStandings.data.serviceParamsWildCard,{
league_id: reqLeague,
season: reqSeason
});
return $.ajax({
// url: "/test/standings.json",
url: "/lookup/json/named.milb_standings_wildcard.bam",
data: this.serviceParamsWildCard,
dataType: "json",
traditional: true
});
},
load: function(league,season,sit_code) {
var ajaxRequests = [];
var _cache = this.cache;
default_sit_code = sit_code;
var wildcardReq = null;
$get("#standingsInfoHdr").empty();
$get("#legend .h1w").hide();
$get("#legend .h1wc").hide();
$get("#legend .cp").hide();
$get("#legend .cd").hide();
$get("#legend .cwc").hide();
$get("#loading").html("

").addClass("ldImg");
if(!_cache[season]){
this.cache[season] = [];
var standingsReq = this._loadStandingsData(league, season);
ajaxRequests.push(standingsReq);
wildcardReq = this._loadWildCardData(league, season);
ajaxRequests.push(wildcardReq);
return $.when.apply($, ajaxRequests)
.done(function (standingsData, wildcardData) {
bam.leagueStandings.data.process(standingsData, wildcardData, sit_code, league, season, 1);
})
.fail(function () {
bam.leagueStandings.data.trigger('onLoadError');
});
}
else {
if(!_cache[season][league]){
var standingsReq = this._loadStandingsData(league, season);
ajaxRequests.push(standingsReq);
wildcardReq = this._loadWildCardData(league, season);
ajaxRequests.push(wildcardReq);
return $.when.apply($, ajaxRequests)
.done(function (standingsData) {
bam.leagueStandings.data.process(standingsData, wildcardData, sit_code, league, season, 1);
})
.fail(function () {
bam.leagueStandings.data.trigger('onLoadError');
});
}
else {
bam.leagueStandings.data.process(_cache[season][league], _cache[season][league]["wildcard"], sit_code, league, season, 0);
}
}
},
process: function (standingsData, wildcardData, sit_code, league, season, makeDivs) {
var fields, teams,
ss,
totalSize=0,
teamsSize=0,
x=0,
y=0,
dA = 0,
c = 0,
c_i,
league_name,
team_link,
team_affil,
divisionData=[],
clinchIcons={
"h1w" : "0",
"h1wc" : "0",
"cp" : "0",
"cd" : "0",
"cwc" : "0"
},
standingsInfo = {},
standingsOutput = {},
processedData={"standings_display_flip":{"queryResults":{"row":[{}]}}};
var _cache = this.cache;
this.cache[season][league] = standingsData;
this.cache[season][league]["wildcard"] = wildcardData;
standingsInfo.showElim=false;
if (sit_code=="wc") {
fields = wildcardData[0].milb_standings_wildcard.standings_wild_card.queryResults.row;
teams = wildcardData[0].milb_standings_wildcard.team_all_season.queryResults.row;
ss = standingsData[0].milb_standings_display_flip.org_history.queryResults.row.split_season_sw;
league_name = standingsData[0].milb_standings_display_flip.org_history.queryResults.row.name_full;
totalSize = parseInt(wildcardData[0].milb_standings_wildcard.standings_wild_card.queryResults.totalSize,10);
teamsSize = parseInt(wildcardData[0].milb_standings_wildcard.team_all_season.queryResults.totalSize,10);
standingsInfo.showElim=true;
}
else {
fields = standingsData[0].milb_standings_display_flip.standings_all.queryResults.row;
teams = standingsData[0].milb_standings_display_flip.team_all_season.queryResults.row;
ss = standingsData[0].milb_standings_display_flip.org_history.queryResults.row.split_season_sw;
league_name = standingsData[0].milb_standings_display_flip.org_history.queryResults.row.name_full;
totalSize = parseInt(standingsData[0].milb_standings_display_flip.standings_all.queryResults.totalSize,10);
teamsSize = parseInt(standingsData[0].milb_standings_display_flip.team_all_season.queryResults.totalSize,10);
if ($.inArray(sit_code, elimCodes) > -1){
standingsInfo.showElim=true;
}
}
if (orgProps.length == 0){
orgProps.push("h0");
if (ss == "Y"){
orgProps.push("h1");
orgProps.push("h2");
}
}
if (totalSize == 1) {fields[0]= fields;}
if (!!fields){
for (var fl = totalSize; x
");
}
}
$("#standings").append("
");
}
standingsInfo.division_ids=divisions;
standingsInfo.division_names=divisionNames;
standingsInfo.orgProps=orgProps;
standingsInfo.league_id=league;
standingsInfo.league_name=league_name;
standingsInfo.season=season;
standingsInfo.wildcardType=wildcardType;
standingsInfo.sit_code=sit_code;
standingsInfo.legend=legend;
standingsInfo.legend.clinchIcons=clinchIcons;
if ((sit_code=="wc") && (wildcardType=="L")) {
processedData={"standings_display_flip":{"queryResults":{"row":[{}]}}};
processedData.division_id="wc";
processedData.division_name="Wild Card";
x=0;
for (var fl = totalSize; x ',
fields[x].team_full,
team_affil,
''
].join("");
c_i = fields[x].playoffs_flag_milb;
switch (c_i) {
case "*" : {
standingsInfo.legend.clinchIcons.h1w = "1";
break;
}
case "$" : {
standingsInfo.legend.clinchIcons.h1wc = "1";
break;
}
case "@" : {
standingsInfo.legend.clinchIcons.cp = "1";
break;
}
case "#" : {
standingsInfo.legend.clinchIcons.cd = "1";
break;
}
case "&" : {
standingsInfo.legend.clinchIcons.cwc = "1";
break;
}
case "*#" : {
standingsInfo.legend.clinchIcons.h1w = "1";
standingsInfo.legend.clinchIcons.cd = "1";
break;
}
};
processedData.standings_display_flip.queryResults.row[c] = {
"clinch_icon" : fields[x].playoffs_flag_milb,
"team_full" : team_link,
"w" : fields[x].w,
"l" : fields[x].l,
"pct" : fields[x].pct,
"gb" : fields[x].gb,
"elim" : fields[x].elim,
"home" : fields[x].home,
"away" : fields[x].away,
"vs_division" : fields[x].vs_division,
"last_ten" : fields[x].last_ten,
"streak" : fields[x].streak
}
c++;
}
divisionData[0] = processedData;
}
else {
for (ldiv in divisions) {
if (divisions.hasOwnProperty(ldiv)) {
processedData={"standings_display_flip":{"queryResults":{"row":[{}]}}};
processedData.division_id=divisions[ldiv];
processedData.division_name=divisionNames[ldiv];
c=0;
x=0;
for (var fl = totalSize; x ',
fields[x].team_full,
team_affil,
''
].join("");
processedData.standings_display_flip.queryResults.row[c] = {
"clinch_icon" : fields[x].playoffs_flag_milb,
"team_full" : team_link,
"w" : fields[x].w,
"l" : fields[x].l,
"pct" : fields[x].pct,
"gb" : fields[x].gb,
"elim" : fields[x].elim,
"home" : fields[x].home,
"away" : fields[x].away,
"vs_division" : fields[x].vs_division,
"last_ten" : fields[x].last_ten,
"streak" : fields[x].streak
}
c++;
}
}
divisionData[ldiv] = processedData;
// console.dir(processedData);
}
}
}
}
//console.dir(divisionData);
standingsOutput.standingsInfo = standingsInfo;
standingsOutput.standings = divisionData;
bam.leagueStandings.data.trigger('onStandingsSuccess', standingsOutput);
}
});
bam.leagueStandings.init();
bam.leagueStandings.load(league_id,season,default_sit_code);
});