Commit b2e59752 authored by Mathieu Giraud's avatar Mathieu Giraud
Browse files

Merge branch 'feature-c/improve_file_menu' into 'dev'

Loading HTTP URL from the file menu

See merge request !210
parents 6ceca6f6 901e640a
Pipeline #29748 passed with stages
in 54 seconds
......@@ -221,6 +221,7 @@ deploy_review:
stage: deploy_review
script:
- make -C browser icons
- echo "$REVIEW_CONFIG_JS" > browser/js/conf.js
- rsync -av --delete browser $DEPLOY_SERVER:$DEPLOY_SERVER_PATH$CI_BUILD_REF_SLUG
environment:
name: review/$CI_BUILD_REF_NAME
......
......@@ -32,7 +32,8 @@ var config = {
"path" : "/browser/data/",
"file" : [
"Stanford-S22.vidjil",
"L2-LIL-2.vidjil"
"L2-LIL-2.vidjil",
"http://www.vidjil.org/2016-lr/demo/LIL-L2.vidjil"
]
},
*/
......
......@@ -40,7 +40,7 @@ function initMenu () {
type: "GET",
timeout: 5000,
crossDomain: true,
url: config.file_menu.path + config.file_menu.file[0],
url: prepend_path_if_not_web(config.file_menu.file[0], config.file_menu.path),
success: function (result) {
$('#static_file_menu').css("display", "")
var demo_file = document.getElementById("fileSelector").firstChild
......@@ -50,7 +50,8 @@ function initMenu () {
var a = document.createElement('a');
a.className = "buttonSelector"
a.onclick = function () {
m.loadDataUrl(config.file_menu.path + config.file_menu.file[i])
var url = prepend_path_if_not_web(config.file_menu.file[i], config.file_menu.path);
m.loadDataUrl(url)
}
a.appendChild(document.createTextNode(config.file_menu.file[i]))
......
......@@ -110,6 +110,20 @@ function correctIMGTPositionsForInsertions(data) {
}
}
/**
* Prepend a path before a filepath if that filepath is not a web path.
* @param file: a path to a file may be relative, absolute or web path
* @param path: a directory path
* @return file iff it is a web path (ie. starting with http or ftp)
* path + file otherwise
*/
function prepend_path_if_not_web(file, path) {
if (file.startsWith('http') || file.startsWith('ftp')) {
return file;
}
return path + file;
}
/**
* Take in parameter the JSON result of CloneDB for one clone
* Return a hash whose keys are URLs to sample sets and configs.
......
......@@ -54,6 +54,12 @@ QUnit.test("test rounding functions", function(assert) {
}
);
QUnit.test("prepend_path_if_not_web", function(assert) {
assert.equal(prepend_path_if_not_web('/tata', 'toto'), 'toto/tata');
assert.equal(prepend_path_if_not_web('http://toto', 'toto'), 'http://toto');
assert.equal(prepend_path_if_not_web('ftp://toto', 'toto'), 'ftp://toto');
});
QUnit.test("processCloneDBContents", function(assert) {
var emptyResult = [];
assert.deepEqual(processCloneDBContents(emptyResult), {'original': [],
......
Supports Markdown
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