Renamed slideshow -> slide.

This commit is contained in:
Patrick Fairbank
2014-08-25 20:18:37 -07:00
parent 903a45030b
commit 450cd6766b
11 changed files with 174 additions and 172 deletions

View File

@@ -317,13 +317,15 @@ var transitionSponsorToScore = function(callback) {
// Load and Prioritize Sponsor Data
var sponsors;
var sponsorIndex = [];
var lastSponsor;
var initializeSponsorDisplay = function() {
$.getJSON("/api/sponsors", function(data) {
$.getJSON("/api/sponsor_slides", function(data) {
sponsors = data;
// Invert Priorities
$.each(sponsors, function(index){
var priorityCount = 10 / sponsors[index]['Priority'];
var priorityCount = 10 / sponsors[index]["Priority"];
for(i=0; i<priorityCount; i++){
sponsorIndex.push(index);
}
@@ -333,32 +335,34 @@ var initializeSponsorDisplay = function() {
loadNextSponsor(true);
if(sponsors.length > 1)
loadNextSponsor();
$('.carousel#sponsor').on('slid.bs.carousel', function(){
$(".carousel#sponsor").on("slid.bs.carousel", function(){
loadNextSponsor();
$('#sponsorContainer').children()[0].remove();
$("#sponsorContainer").children()[0].remove();
});
});
}
var lastSponsor;
};
var loadNextSponsor = function(active) {
// Don't load same sponsor twice in a row
var currentSponsor = sponsorIndex[Math.round(Math.random()*sponsorIndex.length)];
while(currentSponsor == lastSponsor){
currentSponsor = sponsorIndex[Math.round(Math.random()*sponsorIndex.length)];
var currentSponsor = sponsorIndex[Math.round(Math.random() * sponsorIndex.length)];
while(currentSponsor == lastSponsor) {
currentSponsor = sponsorIndex[Math.round(Math.random() * sponsorIndex.length)];
}
lastSponsor = currentSponsor;
currentSponsor = sponsors[currentSponsor];
if(active == true)
active = 'active'
else
active = '';
if(currentSponsor['Image'].length)
$('#sponsorContainer').append('<div class="item '+active+'"><img src="/static/img/sponsors/'+currentSponsor['Image']+'" /><h1>'+currentSponsor['Subtitle']+'</h1></div>');
else
$('#sponsorContainer').append('<div class="item '+active+'"><h2>'+currentSponsor['Line1']+'<br />'+currentSponsor['Line2']+'</h2><h1>'+currentSponsor['Subtitle']+'</h1></div>');
}
if (active == true) {
active = "active"
} else {
active = "";
}
if (currentSponsor["Image"].length) {
$("#sponsorContainer").append('<div class="item '+active+'"><img src="/static/img/sponsors/'+currentSponsor['Image']+'" /><h1>'+currentSponsor['Subtitle']+'</h1></div>');
} else {
$("#sponsorContainer").append('<div class="item '+active+'"><h2>'+currentSponsor['Line1']+'<br />'+currentSponsor['Line2']+'</h2><h1>'+currentSponsor['Subtitle']+'</h1></div>');
}
};
$(function() {