Skip to content

Instantly share code, notes, and snippets.

@kaecy
Last active December 26, 2015 09:39
Show Gist options
  • Save kaecy/7131227 to your computer and use it in GitHub Desktop.
Save kaecy/7131227 to your computer and use it in GitHub Desktop.
var projector = new Object();
var Slide = function(path, caption){this.path = path; this.caption = caption;}
// events hook
onload = initialize;
// relative path or absolute - doesn't matter, caption
var slides = [
new Slide('neko/red_scarf.jpg', 'I am very smart'),
new Slide('neko/awakening.jpg', 'Wahhh! I just woke up'),
new Slide('neko/coy_neko.jpg', 'Ah I\'m embarrassed. Hen-tai!'),
new Slide('neko/braids_and_bows.png', 'How does this look')
]
function initialize() {
projector.image = document.getElementById('currentSlide');
projector.caption = document.getElementById('caption');
change(0);
}
function change(slide_num) {
var slide = slides[slide_num];
// image
projector.image.src = slide.path;
projector.image.alt = slide.path;
// caption
if (!projector.caption.hasChildNodes())
projector.caption.appendChild(document.createTextNode(''));
projector.caption.firstChild.nodeValue = slide.caption;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment