1
0
Fork 0
mirror of https://github.com/Yetangitu/ampache synced 2025-10-04 10:19:25 +02:00

Add Server-Sent Events on catalog actions

This commit is contained in:
Afterster 2015-02-02 22:45:57 +01:00
parent a9d74c58ad
commit c763103bee
11 changed files with 314 additions and 179 deletions

View file

@ -33,6 +33,38 @@ function loadContentPage(url)
});
}
var sseSource = null;
function sse_worker(url) {
if(typeof(EventSource) !== "undefined") {
sseSource = new EventSource(url);
sseSource.onmessage = function(event) {
eval(event.data);
};
sseSource.onopen = function() {
displayNotification('Connected through Server-Sent Events, processing...', 5000);
};
sseSource.onerror = function() {
displayNotification('Server-Sent Events connection error. Re-connection...', 5000);
};
} else {
// Server-Sent Events not supported, call the update in ajax and the output result
$.get(url + '&html=1', function (data) {
$("#guts").append(data);
}, 'html')
}
}
function stop_sse_worker() {
if (sseSource !== null) {
sseSource.close();
sseSource = null;
}
}
function display_sse_error(error) {
displayNotification('ERROR: ' + error, 10000);
}
$(function() {
var newHash = "";