|
|
@@ -83,9 +83,9 @@ function Slide(dir) { |
|
|
|
sendfile(res, pathlib.join(dir, name)); |
|
|
|
} |
|
|
|
|
|
|
|
self.dirExists = function() { |
|
|
|
self.indexExists = function() { |
|
|
|
try { |
|
|
|
fs.accessSync(dir, fs.F_OK); |
|
|
|
fs.accessSync(pathlib.join(dir, "index.html")); |
|
|
|
return true; |
|
|
|
} catch (err) { |
|
|
|
return false; |
|
|
@@ -162,8 +162,7 @@ function Slideshow(dir, changeInterval) { |
|
|
|
slideIndex += 1; |
|
|
|
|
|
|
|
// Go to the next slide, or restart |
|
|
|
if ((slideIndex >= slides.length) |
|
|
|
|| (!slides[slideIndex].dirExists())) { |
|
|
|
if ((slideIndex >= slides.length)) { |
|
|
|
clearTimeout(nextTimeout); |
|
|
|
init(); |
|
|
|
} else { |
|
|
@@ -171,8 +170,15 @@ function Slideshow(dir, changeInterval) { |
|
|
|
nextTimeout = setTimeout(next, changeInterval); |
|
|
|
} |
|
|
|
|
|
|
|
// End all awaiting connections to notify slide change |
|
|
|
self.sendEvent("next", { name: currentSlide.name }); |
|
|
|
// End all awaiting connections to notify slide change, |
|
|
|
if (currentSlide.indexExists()) { |
|
|
|
self.sendEvent("next", { name: currentSlide.name }); |
|
|
|
|
|
|
|
// Or go to the next slide if the current one doesn't have an index.html |
|
|
|
} else { |
|
|
|
clearTimeout(nextTimeout); |
|
|
|
setTimeout(next, 0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
self.next = next; |