T157 Added uuid as cookie
This commit is contained in:
		| @@ -7,12 +7,16 @@ | ||||
| //TODO: Add getData() recall after PUT, POST or DELETE | ||||
| //TODO: Add delete buttons for headers | ||||
| //TODO: Add delete buttons for messages | ||||
|  | ||||
| var clientUUID; | ||||
| var json; | ||||
| var jsonIndex = 0; | ||||
| function getData(uuid){ | ||||
|     $.getJSON('http://localhost:8097/mock/json', function(data) { | ||||
| const C_UUID = 'mock-uuid'; | ||||
| function getData(){ | ||||
|     loadCookies(); | ||||
|     $.getJSON('http://localhost:8097/mock/json/'+clientUUID, function(data) { | ||||
|         json = data; | ||||
|         clientUUID = json[jsonIndex].clientUUID; | ||||
|         setCookies(); | ||||
|         console.log(JSON.stringify(json)); | ||||
|         console.log("Json received"); | ||||
|         fillMessageList(); | ||||
| @@ -23,6 +27,30 @@ function getData(uuid){ | ||||
|     }); | ||||
| } | ||||
|  | ||||
| function setCookies(){ | ||||
|     document.cookie = C_UUID + '=' +clientUUID+';'; | ||||
| } | ||||
|  | ||||
| function loadCookies(){ | ||||
|     clientUUID = getCookie(C_UUID); | ||||
| } | ||||
|  | ||||
| function getCookie(cname) { | ||||
|     var name = cname + '='; | ||||
|     var decodedCookie = decodeURIComponent(document.cookie); | ||||
|     var ca = decodedCookie.split(';'); | ||||
|     for(var i = 0; i <ca.length; i++) { | ||||
|         var c = ca[i]; | ||||
|         while (c.charAt(0) == ' ') { | ||||
|             c = c.substring(1); | ||||
|         } | ||||
|         if (c.indexOf(name) == 0) { | ||||
|             return c.substring(name.length, c.length); | ||||
|         } | ||||
|     } | ||||
|     return ''; | ||||
| } | ||||
|  | ||||
| function updateData(){ | ||||
|     var updatedJson = generateJson(); | ||||
|     $.ajax({ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user