This repository has been archived on 2023-02-07. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
flamenco-manager/static/imagewatch.js
T
Sybren A. Stüvel f09148640c Send immediate notification when browser connects to SSE events.
This fixes an incompatibility of the "latest image" server-side event
system with Firefox. Firefox really want to have an immediate event on the
SSE channel, or it'll think that the connection wasn't made properly.
2018-02-09 11:37:28 +01:00

16 lines
565 B
JavaScript

var source = new EventSource('/imagewatch');
source.addEventListener('image', function (event) {
var filename = event.data;
if (console) console.log(filename);
var url = '/static/' + filename + '?' + new Date().getTime();
$('#last_rendered_image').attr('src', url);
$('body.imageviewer').css('background-image', 'url(' + url + ')');
}, false);
// For debugging purposes this can be handy:
// source.addEventListener('notification', function (event) {
// console.log("Received notification from image watcher:", event.data);
// }, false);