aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/assets
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-09-25 14:29:48 +0300
committerGravatar Vitaly Takmazov2018-09-25 14:29:48 +0300
commitfabda656e6e6aef1daf0b102e8112fa261822775 (patch)
treeeeca8e967106fe1dc4593a89ecf4fa53b4a4fdf2 /juick-server/src/main/assets
parent68789ca6c3972db476a325cd5c1bdc70cd7962f6 (diff)
scripts: relative urls to api
Diffstat (limited to 'juick-server/src/main/assets')
-rw-r--r--juick-server/src/main/assets/scripts.js12
1 files 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 => {