From fabda656e6e6aef1daf0b102e8112fa261822775 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 25 Sep 2018 14:29:48 +0300 Subject: scripts: relative urls to api --- juick-server/src/main/assets/scripts.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/juick-server/src/main/assets/scripts.js b/juick-server/src/main/assets/scripts.js index 8e0c8eaa..289ccb43 100644 --- a/juick-server/src/main/assets/scripts.js +++ b/juick-server/src/main/assets/scripts.js @@ -126,8 +126,8 @@ var ws, pageTitle; function initWS() { - let url = (window.location.protocol === 'https:' ? 'wss' : 'ws') + ':' - + '//api.juick.com/ws/'; + let url = new URL('/ws/', window.location.href); + url.protocol = url.protocol.replace('http', 'ws') let hash = document.getElementById('body').getAttribute('data-hash'); if (hash) { url += '?hash=' + hash; @@ -524,7 +524,7 @@ function resultMessage(str) { function likeMessage(e, mid) { if (confirm(i18n('message.likeThisMessage?'))) { - fetch('//api.juick.com/like?mid=' + mid + fetch('/api/like?mid=' + mid + '&hash=' + document.getElementById('body').getAttribute('data-hash'), { method: 'POST', mode: 'cors', @@ -545,7 +545,7 @@ function likeMessage(e, mid) { /******************************************************************************/ function setPopular(e, mid, popular) { - fetch('//api.juick.com/messages/set_popular?mid=' + mid + fetch('/api/messages/set_popular?mid=' + mid + '&popular=' + popular + '&hash=' + document.getElementById('body').getAttribute('data-hash'), { credentials: 'same-origin' @@ -557,7 +557,7 @@ function setPopular(e, mid, popular) { } function setPrivacy(e, mid) { - fetch('//api.juick.com/messages/set_privacy?mid=' + mid + fetch('/api/messages/set_privacy?mid=' + mid + '&hash=' + document.getElementById('body').getAttribute('data-hash'), { credentials: 'same-origin' }) @@ -568,7 +568,7 @@ function setPrivacy(e, mid) { } function getTags() { - fetch('//api.juick.com/tags?hash=' + document.getElementById('body').getAttribute('data-hash'), { + fetch('/api/tags?hash=' + document.getElementById('body').getAttribute('data-hash'), { credentials: 'same-origin' }) .then(response => { -- cgit v1.2.3