diff --git a/static/css/common.css b/static/css/common.css new file mode 100644 index 0000000..560894e --- /dev/null +++ b/static/css/common.css @@ -0,0 +1,2 @@ +.floatRight{float: right;} +.clear{clear: both;} \ No newline at end of file diff --git a/static/html/chat_main.html b/static/html/chat_main.html index bf44c32..6fb1aa8 100644 --- a/static/html/chat_main.html +++ b/static/html/chat_main.html @@ -5,7 +5,9 @@ 聊天界面 + + @@ -122,8 +124,9 @@ - - 发送 + + 发送 +
@@ -167,7 +170,7 @@ leftTabActive:"first", users:[], usersMap:[], - server:"wss://"+window.location.host+"/chat_server", + server:getWsBaseUrl()+"/chat_server", socket:null, messageContent:"", currentGuest:"", diff --git a/static/html/chat_page.html b/static/html/chat_page.html index fa9c928..74afddc 100644 --- a/static/html/chat_page.html +++ b/static/html/chat_page.html @@ -6,6 +6,7 @@ GO-FLY咨询页 + @@ -132,7 +133,7 @@ delimiters:["<{","}>"], data: { window:window, - server:"wss://"+window.location.host+"/chat_server", + server:getWsBaseUrl()+"/chat_server", socket:null, msgList:[], messageContent:"", diff --git a/static/js/functions.js b/static/js/functions.js new file mode 100644 index 0000000..2cca994 --- /dev/null +++ b/static/js/functions.js @@ -0,0 +1,20 @@ +function getBaseUrl() { + var ishttps = 'https:' == document.location.protocol ? true : false; + var url = window.location.host; + if (ishttps) { + url = 'https://' + url; + } else { + url = 'http://' + url; + } + return url; +} +function getWsBaseUrl() { + var ishttps = 'https:' == document.location.protocol ? true : false; + var url = window.location.host; + if (ishttps) { + url = 'wss://' + url; + } else { + url = 'ws://' + url; + } + return url; +} \ No newline at end of file