host is taken from url

This commit is contained in:
2021-02-15 18:40:40 +01:00
parent 1da7645519
commit b84deda5c9
2 changed files with 13 additions and 6 deletions

1
.idea/workspace.xml generated
View File

@@ -20,7 +20,6 @@
</component>
<component name="ChangeListManager">
<list default="true" id="458cde88-df3d-44bc-9d57-a33823e2f1a6" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/static/js/datatransfer.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/static/js/datatransfer.js" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />

View File

@@ -3,10 +3,11 @@ var clientUUID;
var json;
var jsonIndex = 0;
var htable_row = 0;
var host = getDomain();
const C_UUID = 'mock-uuid';
function getData(){
loadCookies();
$.getJSON('http://localhost:8097/mock/json/'+clientUUID, function(data) {
$.getJSON(host + '/mock/json/'+clientUUID, function(data) {
json = data;
clientUUID = json[jsonIndex].clientUUID;
setCookies();
@@ -16,6 +17,13 @@ function getData(){
});
}
function getDomain(){
var url = window.location.href;
var arr = url.split("/");
var result = arr[0] + "//" + arr[2];
return result;
}
function refreshData(){
fillMessageList();
console.log("List initiated");
@@ -50,7 +58,7 @@ function getCookie(cname) {
function updateData(){
var updatedJson = generateJson();
var request = $.ajax({
url: 'http://localhost:8097/mock/json',
url: host + '/mock/json',
type: 'PUT',
data: JSON.stringify(updatedJson, null, 2),
dataType: "json",
@@ -64,7 +72,7 @@ function updateData(){
function addMessage(){
var request = $.ajax({
url: 'http://localhost:8097/mock/json/'+clientUUID,
url: host + '/mock/json/'+clientUUID,
type: 'POST',
});
request.done(function () {
@@ -75,7 +83,7 @@ function addMessage(){
function removeTile(id){
var jsonObject = findJsonById(id);
var request = $.ajax({
url: 'http://localhost:8097/mock/json/'+clientUUID + '/' + id,
url: host + '/mock/json/'+clientUUID + '/' + id,
type: 'DELETE',
});
request.done(function () {
@@ -110,7 +118,7 @@ function fillStaticFields(uuid, id, mediaType, body, httpStatus){
}
function createLink(uuid, id){
var link = 'http://localhost:8097/klaus/v1/get/'+uuid+'/'+id;
var link = host + '/klaus/v1/get/'+uuid+'/'+id;
return link;
}