forked from DGNum/gestioCOF
Use new WS class
This commit is contained in:
parent
32474a6865
commit
51acb4e00a
1 changed files with 4 additions and 10 deletions
|
@ -80,6 +80,8 @@
|
|||
$(document).ready(function() {
|
||||
'use strict';
|
||||
|
||||
var conflicts = new Set();
|
||||
|
||||
/**
|
||||
* Autofill new stock from other inputs
|
||||
*/
|
||||
|
@ -135,15 +137,7 @@ $(document).ready(function() {
|
|||
* Websocket
|
||||
*/
|
||||
|
||||
var conflicts = new Set();
|
||||
var websocket_msg_default = {'articles':[]}
|
||||
|
||||
var websocket_protocol = window.location.protocol == 'https:' ? 'wss' : 'ws';
|
||||
var location_host = window.location.host;
|
||||
var location_url = window.location.pathname.startsWith('/gestion/') ? location_host + '/gestion' : location_host;
|
||||
var socket = new ReconnectingWebSocket(websocket_protocol+"://" + location_url + "/ws/k-fet/k-psul/");
|
||||
socket.onmessage = function(e) {
|
||||
var data = $.extend({}, websocket_msg_default, JSON.parse(e.data));
|
||||
OperationWebSocket.add_handler(function(data) {
|
||||
for (let article of data['articles']) {
|
||||
var $line = $('input[value="'+article.id+'"]').parent();
|
||||
if ($line.find('.finished input').is(":checked")) {
|
||||
|
@ -162,7 +156,7 @@ $(document).ready(function() {
|
|||
$line.find('.current_stock').text(article.stock);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('input[type="submit"]').on("click", function(e) {
|
||||
e.preventDefault();
|
||||
|
|
Loading…
Reference in a new issue