diff --git a/css/style.css b/css/style.css index d5949ff4..35d8c15c 100644 --- a/css/style.css +++ b/css/style.css @@ -1238,12 +1238,20 @@ text-align:left; .table-condensed>tbody>tr>td>button{ font-size:0.9em; } +table.ads{ + max-width:100%; +} table.ads > tbody > tr > td > input.ad_time { max-width: 80px; } table.ads > tbody > tr > td > input.name { max-width: 775px; } +table.ads > tbody > tr > td > select.name, table.ads > tbody > tr > td > input.name { + width:100%; + min-width:300px; + } + .schedule > li > div > table.ads{ max-width:1024px; } diff --git a/js/ads/schedule.js b/js/ads/schedule.js index 22a6f71c..49f32b4b 100644 --- a/js/ads/schedule.js +++ b/js/ads/schedule.js @@ -38,15 +38,11 @@ Schedule.prototype = { $('.loading_bar').hide(); }); }); - - - },function(error){ this_.init(); }); }, getSchedule:function(date){ - var date = this.formatDate(date); return $.ajax({ type:"GET", @@ -73,8 +69,15 @@ Schedule.prototype = { for(var j = 0; j < num_ads; j++){ var element = $('#show_'+i+"_"+j).find('select.name'); - if(this_.showtimes[i].ads[j].type != 'announcement') element.html(this_['templates'][this_.showtimes[i].ads[j].type].html()); - element.val(this_.showtimes[i].ads[j].name); + if(this_.showtimes[i].ads[j].type != 'announcement'){ + element.html(this_['templates'][this_.showtimes[i].ads[j].type].html()); + if(this_.showtimes[i].ads[j].name){ + element.attr('value',this_.showtimes[i].ads[j].name); + } + else{ + element.val("Any "+this_.showtimes[i].ads[j].type); + } + } } } }); @@ -114,74 +117,43 @@ Schedule.prototype = { url:"api2/public/SAM/categorylist/"+categories[item], async: true, }); + this.getCategory(item,promises); } - $.when(promises['ad']).then(function(response){ - this_['ad'] = response.sort(function(a,b){ - if(a.title.toString() > b.title.toString()) return 1; - if(a.title.toString() < b.title.toString()) return -1; - return 0; - }); - - this_['cat-promises'].push(this_.createCategoryTemplate('ad')); - } - ); - $.when(promises['ubc']).then(function(response){ - this_['ubc'] = response.sort(function(a,b){ - if(a.title.toString() > b.title.toString()) return 1; - if(a.title.toString() < b.title.toString()) return -1; - return 0; - }); - - this_['cat-promises'].push(this_.createCategoryTemplate('ubc')); - }); - $.when(promises['community']).then(function(response){ - this_['community'] = response.sort(function(a,b){ - if(a.title.toString() > b.title.toString()) return 1; - if(a.title.toString() < b.title.toString()) return -1; - return 0; - }); - - this_['cat-promises'].push(this_.createCategoryTemplate('community')); - }); - $.when(promises['timely']).then(function(response){ - this_['timely'] = response.sort(function(a,b){ - if(a.title.toString() > b.title.toString()) return 1; - if(a.title.toString() < b.title.toString()) return -1; - return 0; - }); - - this_['cat-promises']['timely-cat'] = this_.createCategoryTemplate('timely'); - }); - $.when(promises['promo']).then(function(response){ - this_['promo'] = response.sort(function(a,b){ - if(a.title.toString() > b.title.toString()) return 1; - if(a.title.toString() < b.title.toString()) return -1; - return 0; - }); - - this_['cat-promises'].push(this_.createCategoryTemplate('promo')); - }); - $.when(promises['id']).then(function(response){ - this_['id'] = response.sort(function(a,b){ - if(a.title.toString() > b.title.toString()) return 1; - if(a.title.toString() < b.title.toString()) return -1; - return 0; - }); - - this_['cat-promises'].push(this_.createCategoryTemplate('id')); - }); - - $.when(promises['ubc'],promises['community'],promises['timely']).then(function(ubc,community,timely){ - for(var item in ubc[0]){ this_.psa.push(ubc[0][item]); } - for(var item in community[0]){ this_.psa.push(community[0][item]); } - for(var item in timely[0]){ this_.psa.push(timely[0][item]); } - this_.psa = this_.psa - - this_['cat-promises'].push(this_.createCategoryTemplate('psa')); - }); + this.combinePSAs(promises); return promises; }, + getCategory:function(category,promises){ + var this_ = this; + $.when(promises[category]).then( + function(response){ + this_[category] = response.sort(function(a,b){ + if(a.title.toString() > b.title.toString()) return 1; + if(a.title.toString() < b.title.toString()) return -1; + return 0; + }); + + this_['cat-promises'].push(this_.createCategoryTemplate(category)); + }, + function(error){ + this_.getCategory(category); + } + ); + }, + combinePSAs:function(promises){ + var this_ = this; + $.when(promises['ubc'],promises['community'],promises['timely']).then( + function(ubc,community,timely){ + for(var item in ubc[0]){ this_.psa.push(ubc[0][item]); } + for(var item in community[0]){ this_.psa.push(community[0][item]); } + for(var item in timely[0]){ this_.psa.push(timely[0][item]); } + this_.psa = this_.psa + this_['cat-promises'].push(this_.createCategoryTemplate('psa')); + },function(error){ + this_.combinePSAs(promises); + } + ); + }, createCategoryTemplate:function(item){ var this_ = this; var ad_list = this[item];