From 6fbb3874883cf0e4c0d470ec54788b63cac243a1 Mon Sep 17 00:00:00 2001 From: Tad Wang Date: Thu, 21 Jan 2016 11:53:56 +0800 Subject: [PATCH] fix wss support for web_monitor_uri Https support --- jlog/views.py | 2 +- templates/jlog/log_online.html | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/jlog/views.py b/jlog/views.py index ff0eaf1c0..e2565250e 100644 --- a/jlog/views.py +++ b/jlog/views.py @@ -66,7 +66,7 @@ def log_list(request, offset): contact_list, p, contacts, page_range, current_page, show_first, show_end = pages(posts, request) - web_monitor_uri = 'ws://%s/monitor' % WEB_SOCKET_HOST + web_monitor_uri = '%s/monitor' % WEB_SOCKET_HOST web_kill_uri = 'http://%s/kill' % WEB_SOCKET_HOST session_id = request.session.session_key return render_to_response('jlog/log_%s.html' % offset, locals(), context_instance=RequestContext(request)) diff --git a/templates/jlog/log_online.html b/templates/jlog/log_online.html index 14e55f957..d934a125e 100644 --- a/templates/jlog/log_online.html +++ b/templates/jlog/log_online.html @@ -136,8 +136,13 @@ {# })#} {# });#} function init(obj){ + var protocol = "ws://"; + if (window.location.protocol == 'https:') { + protocol = 'wss://'; + } + var file_path = obj.attr('file_path'); - var wsUri = '{{ web_monitor_uri }}'; + var wsUri = protocol + '{{ web_monitor_uri }}'; var socket = new WebSocket(wsUri + '?file_path=' + file_path); var term = new Terminal({