2018-03-27 17:39:08 +00:00
|
|
|
/******************************************
|
|
|
|
|
|
|
|
THE SLIDESHOW
|
|
|
|
- background: fullscreen iframe (so can draw everywhere)
|
|
|
|
- foreground: words & pictures
|
|
|
|
|
|
|
|
******************************************/
|
2018-03-26 15:52:43 +00:00
|
|
|
|
|
|
|
var SLIDES = [];
|
|
|
|
|
|
|
|
function Slideshow(){
|
|
|
|
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
// The DOM & properties...
|
|
|
|
self.dom = $("#slideshow");
|
|
|
|
self.slideIndex = 0;
|
2018-03-28 17:12:05 +00:00
|
|
|
self.currentSlide = null;
|
|
|
|
self.currentState = null;
|
|
|
|
|
|
|
|
// My stuff...
|
|
|
|
self.boxes = new Boxes();
|
|
|
|
self.simulations = new Simulations();
|
2018-03-26 15:52:43 +00:00
|
|
|
|
|
|
|
// GOTO and NEXT
|
|
|
|
self.goto = function(index){
|
|
|
|
|
|
|
|
self.slideIndex = index;
|
2018-03-28 17:12:05 +00:00
|
|
|
self.currentSlide = SLIDES[self.slideIndex];
|
|
|
|
var slide = self.currentSlide;
|
2018-03-26 15:52:43 +00:00
|
|
|
|
2018-03-28 17:12:05 +00:00
|
|
|
// Clear?
|
|
|
|
if(slide.clear) self.clear();
|
2018-03-27 17:39:08 +00:00
|
|
|
|
2018-03-28 17:12:05 +00:00
|
|
|
// Add stuff
|
|
|
|
slide.add.forEach(function(childConfig){
|
|
|
|
switch(childConfig.type){
|
|
|
|
case "box":
|
|
|
|
self.boxes.add(childConfig);
|
|
|
|
break;
|
|
|
|
case "sim":
|
|
|
|
self.simulations.add(childConfig);
|
|
|
|
break;
|
|
|
|
}
|
2018-03-26 15:52:43 +00:00
|
|
|
});
|
|
|
|
|
2018-03-28 17:12:05 +00:00
|
|
|
// On start (if any)
|
|
|
|
self.currentState = {};
|
|
|
|
if(slide.onstart) slide.onstart(self, self.currentState);
|
|
|
|
|
2018-03-26 15:52:43 +00:00
|
|
|
};
|
|
|
|
self.gotoChapter = function(chapterID){
|
|
|
|
var index = SLIDES.findIndex(function(slide){
|
|
|
|
return slide.chapter == chapterID;
|
|
|
|
});
|
|
|
|
self.goto(index);
|
|
|
|
};
|
|
|
|
self.next = function(){
|
|
|
|
self.goto(self.slideIndex+1);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Clear out the DOM
|
|
|
|
self.clear = function(){
|
2018-03-28 17:12:05 +00:00
|
|
|
self.boxes.clear();
|
|
|
|
self.simulations.clear();
|
2018-03-26 15:52:43 +00:00
|
|
|
self.dom.innerHTML = "";
|
|
|
|
};
|
|
|
|
|
2018-03-27 19:20:22 +00:00
|
|
|
// Update
|
|
|
|
self.update = function(){
|
2018-03-28 17:12:05 +00:00
|
|
|
var slide = self.currentSlide;
|
|
|
|
self.simulations.update();
|
|
|
|
if(slide.onupdate) slide.onupdate(self, self.currentState);
|
2018-03-27 19:20:22 +00:00
|
|
|
};
|
|
|
|
|
2018-03-28 17:12:05 +00:00
|
|
|
// Draw
|
|
|
|
self.draw = function(){
|
|
|
|
self.simulations.draw();
|
|
|
|
}
|
|
|
|
|
2018-03-26 15:52:43 +00:00
|
|
|
}
|