|
1 | 1 | $(document).ready(function() {
|
| 2 | + // These are the sponsors |
2 | 3 | var groups = ["CyDesign", "Wolfram", "Modelon", "Maplesoft", "DS",
|
3 | 4 | "Ricardo", "ITI", "GlobalCrown", "Siemens",
|
4 | 5 | "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 |
5 | 14 | var stopAnimation = false;
|
6 | 15 |
|
| 16 | + // This "shows" the sponsor identified by the given id |
7 | 17 | var showSponsor = function(id) {
|
8 | 18 | $(".sentry").hide();
|
9 | 19 | $(".thumbnail").removeClass("thumbshadow");
|
10 | 20 | $("#sentry-"+id).show();
|
11 | 21 | $("#thumbnail-"+id).addClass("thumbshadow");
|
12 | 22 | };
|
13 | 23 |
|
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() { |
16 | 26 | 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); |
22 | 30 | }
|
23 | 31 |
|
| 32 | + // This sets an on-click callback on various thumbnails |
24 | 33 | for(var i=0;i<groups.length;i++) {
|
25 | 34 | (function() {
|
26 | 35 | var j = i;
|
27 | 36 | $("#thumbnail-"+groups[j]).click(function () {
|
28 | 37 | stopAnimation = true;
|
29 |
| - console.log("Show "+groups[j]); |
30 | 38 | showSponsor(groups[j]);
|
31 | 39 | });
|
32 | 40 | })();
|
33 | 41 | }
|
34 | 42 |
|
35 | 43 | $(".sentry").hide();
|
36 |
| - pickRandom(); |
| 44 | + showCurrent(); |
37 | 45 | });
|
0 commit comments