From 51acb4e00aae09ed8e7ab7536c92c65ef380e3a9 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Mon, 3 Apr 2017 16:05:18 -0300 Subject: [PATCH] Use new WS class --- kfet/templates/kfet/inventory_create.html | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/kfet/templates/kfet/inventory_create.html b/kfet/templates/kfet/inventory_create.html index 1098f1f8..d8109f8e 100644 --- a/kfet/templates/kfet/inventory_create.html +++ b/kfet/templates/kfet/inventory_create.html @@ -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();