mirror of
https://github.com/Team254/cheesy-arena-lite.git
synced 2026-03-09 21:56:50 -04:00
Renamed slideshow -> slide.
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user