Implement Queue for Socialwall frontend
This commit is contained in:
parent
429210c5b6
commit
6b31de0620
|
@ -79,17 +79,36 @@
|
||||||
<div style="clear:both"></div>
|
<div style="clear:both"></div>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var exampleSocket = new WebSocket("ws://192.168.2.108:8000/ws");
|
var queue = [];
|
||||||
|
|
||||||
|
var exampleSocket = new WebSocket("ws://Marvins-MacBook-Pro.local:8000/ws");
|
||||||
exampleSocket.onopen = function (event) {
|
exampleSocket.onopen = function (event) {
|
||||||
console.log("WS: Connection open!");
|
console.log("WS: Connection open");
|
||||||
console.log("Proto: " + exampleSocket.protocol);
|
|
||||||
exampleSocket.send("Here's some text that the server is urgently awaiting!");
|
|
||||||
};
|
};
|
||||||
exampleSocket.onmessage = function (event) {
|
exampleSocket.onmessage = function (event) {
|
||||||
|
console.log("WS: Received message");
|
||||||
IT = JSON.parse(event.data);
|
IT = JSON.parse(event.data);
|
||||||
document.getElementById("snapwall_image").src = IT["Path"];
|
if (IT["State"] === 1) {
|
||||||
|
queue.push(IT);
|
||||||
|
}
|
||||||
console.log(event.data);
|
console.log(event.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function displayNewSnap() {
|
||||||
|
var item = queue.shift();
|
||||||
|
if (item) {
|
||||||
|
document.getElementById("snapwall_image").src = item["Path"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setInterval(function() {
|
||||||
|
displayNewSnap();
|
||||||
|
}, 7000); // 7 seconds
|
||||||
|
|
||||||
|
/* TODO: Load initial approved images to be able to show
|
||||||
|
* something, even when reloading
|
||||||
|
*/
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
Loading…
Reference in a new issue