Commit 0515f46b authored by Mikaël Salson's avatar Mikaël Salson

crossDomain.js, tools.js: Factorize code to access the proxy

parent e34210a3
Pipeline #105084 passed with stages
in 10 minutes and 57 seconds
......@@ -161,15 +161,7 @@ function imgtPostForSegmenter(species, data, system, segmenter, override_imgt_op
//disabled due to security concerns
//form.action = "http://www.imgt.org/IMGT_vquest/vquest";
//using proxy on server to allow requests on other site than vidjil one's in JS.
if (typeof config != 'undefined' && typeof config.proxy != 'undefined') {
form.action = config.proxy+"/imgt"
} else {
console.log({
"type": "flash",
"msg": "Your installation doesn't seem to have an associated proxy.",
"priority": 2
});
}
form.action = getProxy()+"imgt";
form.method = "POST";
for (var k in imgtInput) {
......@@ -433,15 +425,7 @@ function assignSubsetsPost(species, data, system) {
form.target = "_blank";
form.enctype = 'multipart/form-data';
form.name = 'assignsubsets';
if (typeof config != 'undefined' && typeof config.proxy != 'undefined') {
form.action = config.proxy+"/assign_subsets"
} else {
console.log({
"type": "flash",
"msg": "Your installation doesn't seem to have an associated proxy.",
"priority": 2
});
}
form.action = getProxy()+"assign_subsets";
form.method = "POST";
var formData = {};
formData.fastatext = data;
......
......@@ -766,4 +766,22 @@ function getNFirstSequences(data, n) {
}
}
/**
* @return a proxy URL if one can be obtained in the config (ending with /) or
* throws an exception and logs the error.
*/
function getProxy() {
if (typeof config != 'undefined') {
if (typeof config.proxy != 'undefined') {
return config.proxy+"/";
} else if (typeof config.db_address != 'undefined') {
return config.db_address+"/proxy/";
}
}
console.log({
"type": "flash",
"msg": "Your installation doesn't seem to have an associated proxy.",
"priority": 2
});
throw "No proxy";
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment