Mercurial > hg > orthanc
comparison OrthancExplorer/explorer.js @ 3509:5405d51e040d
Orthanc Explorer: include the url search params into HTTP headers to the Rest API to ease usage of the Authorization plugin
author | Alain Mazy <alain@mazy.be> |
---|---|
date | Tue, 03 Sep 2019 09:49:10 +0200 |
parents | e54ca78059bd |
children | 1a65beb5e52f |
comparison
equal
deleted
inserted
replaced
3508:70524b4acc72 | 3509:5405d51e040d |
---|---|
88 currentUuid.length > 0) | 88 currentUuid.length > 0) |
89 { | 89 { |
90 Refresh(); | 90 Refresh(); |
91 } | 91 } |
92 }); | 92 }); |
93 | |
94 var GetUrlParametersAsDict = function getUrlParametersAsDict(sParam) { | |
95 var urlVariables = window.location.search.substring(1).split('&'); | |
96 var dict = {}; | |
97 | |
98 for (var i = 0; i < urlVariables.length; i++) { | |
99 var split = urlVariables[i].split('='); | |
100 | |
101 if (split.length == 2) { | |
102 dict[split[0]] = split[1]; | |
103 } | |
104 } | |
105 return dict; | |
106 }; | |
107 | |
108 var initSearchParams = GetUrlParametersAsDict(); | |
109 | |
110 /* Copy all url search parameters into HTTP headers in every request to the Rest API. | |
111 Thanks to this behaviour, you may specify a ?token=xxx in your url and this will be passed | |
112 as the "token" header in every request to the API allowing you to use the authorization plugin */ | |
113 $.ajaxSetup( | |
114 { | |
115 headers : initSearchParams | |
116 } | |
117 ); | |
93 | 118 |
94 | 119 |
95 function SplitLongUid(s) | 120 function SplitLongUid(s) |
96 { | 121 { |
97 return '<span>' + s.substr(0, s.length / 2) + '</span> <span>' + s.substr(s.length / 2, s.length - s.length / 2) + '</span>'; | 122 return '<span>' + s.substr(0, s.length / 2) + '</span> <span>' + s.substr(s.length / 2, s.length - s.length / 2) + '</span>'; |