Skip to content

Commit

Permalink
Merge branch 'adschedule_loading'
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanFriday committed Jan 14, 2016
2 parents c305186 + af3889f commit 8d70f54
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 70 deletions.
8 changes: 8 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
112 changes: 42 additions & 70 deletions js/ads/schedule.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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);
}
}
}
}
});
Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit 8d70f54

Please sign in to comment.