forked from openlp/openlp
move main to websockets
This commit is contained in:
parent
251f197e45
commit
055280860c
@ -159,9 +159,13 @@ window.OpenLP = {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
pollServer: function () {
|
pollServer: function () {
|
||||||
$.getJSON(
|
if ("WebSocket" in window) {
|
||||||
"/api/poll",
|
// Let us open a web socket
|
||||||
function (data, status) {
|
var ws = new WebSocket('ws://' + location.hostname + ':4318/poll');
|
||||||
|
ws.binaryType = 'arraybuffer';
|
||||||
|
ws.onmessage = function (evt) {
|
||||||
|
var data = JSON.parse(String.fromCharCode.apply(null, new Uint8Array(evt.data)));
|
||||||
|
|
||||||
var prevItem = OpenLP.currentItem;
|
var prevItem = OpenLP.currentItem;
|
||||||
OpenLP.currentSlide = data.results.slide;
|
OpenLP.currentSlide = data.results.slide;
|
||||||
OpenLP.currentItem = data.results.item;
|
OpenLP.currentItem = data.results.item;
|
||||||
@ -206,7 +210,10 @@ window.OpenLP = {
|
|||||||
$("#slide-controller div[data-role=content] ul[data-role=listview]").listview("refresh");
|
$("#slide-controller div[data-role=content] ul[data-role=listview]").listview("refresh");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
} else {
|
||||||
|
// The browser doesn't support WebSocket
|
||||||
|
alert("WebSocket NOT supported by your Browser!");
|
||||||
|
}
|
||||||
},
|
},
|
||||||
nextItem: function (event) {
|
nextItem: function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@ -380,5 +387,4 @@ $.ajaxSetup({cache: false});
|
|||||||
$("#search").live("pageinit", function (event) {
|
$("#search").live("pageinit", function (event) {
|
||||||
OpenLP.getSearchablePlugins();
|
OpenLP.getSearchablePlugins();
|
||||||
});
|
});
|
||||||
setInterval("OpenLP.pollServer();", 500);
|
|
||||||
OpenLP.pollServer();
|
OpenLP.pollServer();
|
||||||
|
Loading…
Reference in New Issue
Block a user