blob: 95d4c68689c67f05eb97c3ad9614bfa6d3daa8ad (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
function getXSRFToken() {
var cookies = getCookies();
var XSRFToken = {
name:'',
value:''
};
//var contextRoot = getContextRoot();
var hasXSRFToken = false;
for(var name in cookies) {
if(name == "XSRF-TOKEN") {
XSRFToken.name = name;
XSRFToken.value = cookies[name];
hasXSRFToken = true;
}
}
return (hasXSRFToken==false)?null:XSRFToken;
}
function getCookies() {
var cookies = { };
if (document.cookie && document.cookie != '') {
var split = document.cookie.split(';');
for (var i = 0; i < split.length; i++) {
var name_value = split[i].split("=");
name_value[0] = name_value[0].replace(/^ /, '');
cookies[decodeURIComponent(name_value[0])] = decodeURIComponent(name_value[1]);
}
}
return cookies;
}
function getContextRoot(){
var pathName = window.location.pathname;
var pathArray = pathName.split( '/' );
var contextRoot='';
if(pathArray.length!=0 && pathArray.length>=1)
contextRoot = pathArray[1];
return contextRoot;
}
|