From 413df0806dd170f82c6b33b46179160b7572bfc5 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Fri, 31 Mar 2017 15:10:41 -0300 Subject: [PATCH] Add url get method --- kfet/static/kfet/js/kfet.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/kfet/static/kfet/js/kfet.js b/kfet/static/kfet/js/kfet.js index aa4b7739..1398fedb 100644 --- a/kfet/static/kfet/js/kfet.js +++ b/kfet/static/kfet/js/kfet.js @@ -40,13 +40,18 @@ class Websocket { constructor(data) { $.extend(this, this.constructor.default_data, data); } - - listen(handle_func) { - var that = this; + + get url() { 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 + this.relative_url); + + return websocket_protocol+"://" + location_url + this.relative_url ; + } + + listen(handle_func) { + var that = this; + var socket = new ReconnectingWebSocket(this.url); socket.onmessage = function(e) { var data = $.extend({}, that.default_msg, JSON.parse(e.data));