mort hace 8 años
padre
commit
a2bbb1feb0
Se han modificado 2 ficheros con 32 adiciones y 22 borrados
  1. 4
    4
      index.html
  2. 28
    18
      server.js

+ 4
- 4
index.html Ver fichero

position: absolute; position: absolute;
top: 6px; top: 6px;
right: 6px; right: 6px;
backgrounud: white;
display: none; display: none;
} }
#_msg.active { #_msg.active {
._content img.fullscreen { ._content img.fullscreen {
width: auto; width: auto;
} }
._content img.fullscreen.stretch {
width: 100%;
}


#_overlay { #_overlay {
transition: opacity <<transition_time>>s; transition: opacity <<transition_time>>s;
<!-- Fetch polyfill --> <!-- Fetch polyfill -->
<script src="/polyfills.js"></script> <script src="/polyfills.js"></script>


<!-- Handle reloading -->
<script> <script>
</script>
<script>

(function fullscreen() { (function fullscreen() {
var elem = document.body; var elem = document.body;
var rFS = elem.requestFullScreen || var rFS = elem.requestFullScreen ||

+ 28
- 18
server.js Ver fichero

var currentSlide = null; var currentSlide = null;
var awaiters = []; var awaiters = [];
var slides = []; var slides = [];
var slideIndex = 0;
var nextTimeout;


self.sendEvent = function(evt, args) { self.sendEvent = function(evt, args) {
var str = JSON.stringify({ evt: evt, args: args }); var str = JSON.stringify({ evt: evt, args: args });
} }
} }


function next() {
slideIndex += 1;

// Go to the next slide, or restart
if ((slideIndex >= slides.length)
|| (!slides[slideIndex].dirExists())) {
clearTimeout(nextTimeout);
init();
} else {
currentSlide = slides[slideIndex];
nextTimeout = setTimeout(next, changeInterval);
}

// End all awaiting connections to notify slide change
self.sendEvent("next", { name: currentSlide.name });
}

self.next = next;

// This function starts the slideshow and goes through the slides // This function starts the slideshow and goes through the slides
// one by one. When done, it starts again by calling this function again. // one by one. When done, it starts again by calling this function again.
function init() { function init() {
.sort() .sort()
.map(file => Slide(pathlib.join(dir, file))); .map(file => Slide(pathlib.join(dir, file)));


var slideIndex = 0;
slideIndex = 0;
currentSlide = slides[slideIndex]; currentSlide = slides[slideIndex];


var interval = setInterval(() => {
slideIndex += 1;

// Go to the next slide, or restart
if ((slideIndex >= slides.length)
|| (!slides[slideIndex].dirExists())) {
clearInterval(interval);
init();
} else {
currentSlide = slides[slideIndex];
}

// End all awaiting connections to notify slide change
self.sendEvent("next", { name: currentSlide.name });
}, changeInterval);
nextTimeout = setTimeout(next, changeInterval);
} }
init(); init();




var slideshow = Slideshow(conf.slides, conf.interval); var slideshow = Slideshow(conf.slides, conf.interval);


function onexit() {
function onexit(code) {
console.log("exiting", code);
slideshow.sendEvent("reload"); slideshow.sendEvent("reload");
process.exit(); process.exit();
} }
process.on("SIGINT", onexit); process.on("SIGINT", onexit);
process.on("SIGTERM", onexit); process.on("SIGTERM", onexit);


process.on("uncaughtException", onexit);

var server = http.createServer((req, res) => { var server = http.createServer((req, res) => {
slideshow.serve(req, res); slideshow.serve(req, res);
}); });
server.on("error", err => { server.on("error", err => {
console.error(err.toString());
console.error(err);
system.exit(1); system.exit(1);
}); });
server.listen(conf.port); server.listen(conf.port);

Cargando…
Cancelar
Guardar