Skip to content

Commit 274fa95

Browse files
committed
This addresses issue #159
While working on #160, I realized that the way that sponsors were chosen was sub-optimal. The issues is discussed in issue #159 and this commit addresses those issues. This closes #159.
1 parent d8e7053 commit 274fa95

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed
Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,45 @@
11
$(document).ready(function() {
2+
// These are the sponsors
23
var groups = ["CyDesign", "Wolfram", "Modelon", "Maplesoft", "DS",
34
"Ricardo", "ITI", "GlobalCrown", "Siemens",
45
"ST", "OSMC", "dofware", "BauschGall", "TUHH", "Schlegel"];
6+
7+
// This is the order we will show them in (for this page load)
8+
var order = _.shuffle(groups);
9+
10+
// This is the current one being shown
11+
var current = 0;
12+
13+
// This terminates animation if someone clicks on a thumbnail
514
var stopAnimation = false;
615

16+
// This "shows" the sponsor identified by the given id
717
var showSponsor = function(id) {
818
$(".sentry").hide();
919
$(".thumbnail").removeClass("thumbshadow");
1020
$("#sentry-"+id).show();
1121
$("#thumbnail-"+id).addClass("thumbshadow");
1222
};
1323

14-
var pickRandom = function() {
15-
console.log("pickRandom called");
24+
// This shows the current sponsor (and then sets the next sponsor to be current)
25+
var showCurrent = function() {
1626
if (stopAnimation) return;
17-
console.log("Picking a random sponsor");
18-
var id = groups[Math.floor(Math.random()*groups.length)];
19-
console.log("Sponsor: "+id);
20-
showSponsor(id);
21-
setTimeout(pickRandom, 5000);
27+
showSponsor(order[current]);
28+
current = (current + 1) % order.length;
29+
setTimeout(showCurrent, 5000);
2230
}
2331

32+
// This sets an on-click callback on various thumbnails
2433
for(var i=0;i<groups.length;i++) {
2534
(function() {
2635
var j = i;
2736
$("#thumbnail-"+groups[j]).click(function () {
2837
stopAnimation = true;
29-
console.log("Show "+groups[j]);
3038
showSponsor(groups[j]);
3139
});
3240
})();
3341
}
3442

3543
$(".sentry").hide();
36-
pickRandom();
44+
showCurrent();
3745
});

0 commit comments

Comments
 (0)