Commit f0eee838 authored by marc duez's avatar marc duez

rebase

parent 811d0ae6
......@@ -126,12 +126,7 @@ try {
*/
var shortcut = new Shortcut(m)
var myUrl;
if (window.location.origin === "null") {
myUrl = new Url(m);
} else {
myUrl = new PositionalUrl(m);
}
var myUrl = new Url(m);
m.url_manager = myUrl;
//TODO
......
function Url(model, win) {
View.call(this, model);
this.m = model;
this.window = (typeof win != "undefined") ? win : window
......@@ -33,9 +32,9 @@ Url.prototype= {
}
// get sample_set/patient/run, config...
var straight_params = this.getStraightParams();
for (var i = 0; i < straight_params.length; i++) {
var p = straight_params[i];
var positionnal_params = this.getPositionnalParams();
for (var i = 0; i < positionnal_params.length; i++) {
var p = positionnal_params[i];
if (typeof this.m[p] !== "undefined") {
params_dict[p] = this.m[p];
}
......@@ -62,6 +61,7 @@ Url.prototype= {
/**
* update(size/style/position) a list of selected clones <br>
* a slight function for operation who impact only a bunch of clones (merge/split/...)
* @abstract
* @param {integer[]} list - array of clone index
* */
updateElem : function (list) {
......@@ -71,6 +71,7 @@ Url.prototype= {
/**
* update(style only) a list of selected clones <br>
* a slight function for operation who impact only styles of clones (select/focus)
* @abstract
* @param {integer[]} list - array of clone index
* */
updateElemStyle : function () {
......@@ -79,10 +80,10 @@ Url.prototype= {
applyURL : function() {
var straight_params = this.getStraightParams();
for (var i = 0; i < straight_params.length; i++) {
if (typeof this.url_dict[straight_params[i]] !== "undefined") {
this.m[straight_params[i]] = this.url_dict[straight_params[i]];
var positionnal_params = this.getPositionnalParams();
for (var i = 0; i < positionnal_params.length; i++) {
if (typeof this.url_dict[positionnal_params[i]] !== "undefined") {
this.m[positionnal_params[i]] = this.url_dict[positionnal_params[i]];
}
}
......@@ -90,7 +91,7 @@ Url.prototype= {
var clones = this.url_dict.clone.split(',');
for (var j = 0; j < clones.length; j++) {
var c = this.m.clone(clones[j]);
if (typeof c !== "undefined" && c.isInteractable()) {
if (typeof c !== "undefined" && !c.isVirtual()) {
c.select = true;
}
}
......@@ -108,20 +109,10 @@ Url.prototype= {
parseUrlParams:function () {
params={}
var url = this.window.location;
var url_param = [];
if (url.search.length > 0) {
url_param = url.search.substr(1).split("&");
}
var url = window.location;
var url_param = url.search.substr(1).split("&");
for (var i = 0; i < url_param.length; i++) {
var tmparr = url_param[i].split("=");
// if the format isn't respected ignore parameter
if (tmparr.length !== 2) {
console.log("incorrect parameter: " + url_param[i]);
continue;
}
var p = params[tmparr[0]];
var key = this.encoder.decode(tmparr[0]);
var val = tmparr[1];
......@@ -135,41 +126,53 @@ Url.prototype= {
params[key].push(val);
}
}
var positionnal_params = url.pathname.substr(1).split('-');
var pos_param_keys = this.getPositionnalParams();
if (positionnal_params.length > 1 && positionnal_params[0] != "index.html")
for (var j = 0; j < positionnal_params.length; j++) {
params[pos_param_keys[j]] = positionnal_params[j];
}
return params
},
generateParamsString: function(params_dict) {
var params_list = [];
var positionnal_params = [];
for (var key in params_dict){
var val = params_dict[key];
if ((typeof key != "undefined" && key !== "") && (typeof val != "undefined")) {
var encoded = this.encoder.encode(key);
if (val.constructor !== Array && val !== '') {
params_list.push(encoded+"="+val)
} else if (val.constructor === Array) {
for (var i = 0; i < val.length; i++) {
params_list.push(encoded+"="+val[i]);
var pos = this.getPosition(key);
if (pos >= 0) {
positionnal_params[pos] = val;
} else {
var encoded = this.encoder.encode(key);
if (val.constructor !== Array && val !== '') {
params_list.push(encoded+"="+val)
} else if (val.constructor === Array) {
for (var i = 0; i < val.length; i++) {
params_list.push(encoded+"="+val[i]);
}
}
}
}
}
return params_list.join("&");
return positionnal_params.join('-') + '?' + params_list.join("&");
},
pushUrl: function(params) {
var new_url;
new_url = this.window.location.pathname + '?' + params;
try {
this.window.history.pushState('plop', 'plop', new_url);
} catch(error) {
console.log(error);
}
var new_url = params;
this.window.history.pushState('plop', 'plop', new_url);
},
getStraightParams: function() {
getPositionnalParams: function() {
return ["sample_set_id", "config"];
},
getPosition: function(param) {
return this.getPositionnalParams().indexOf(param);
},
loadUrl: function(db, args, filename) {
this.url_dict = args;
var newParams = this.generateParamsString(args);
......@@ -186,62 +189,6 @@ Url.prototype= {
};
Url.prototype = $.extend(Object.create(View.prototype), Url.prototype);
function PositionalUrl(model, win) {
Url.call(this, model, win);
}
PositionalUrl.prototype = Object.create(Url.prototype);
PositionalUrl.prototype.parseUrlParams = function() {
var params = Url.prototype.parseUrlParams.call(this);
var url = this.window.location;
var slash_params = url.pathname.substr(1).split('/');
var positional_params = [];
for (var k = 0; k < slash_params.length; k++) {
if(slash_params[k] !== 'b' && slash_params[k] !== "index.html" && slash_params[k] !== "")
positional_params.push(slash_params[k]);
}
var pos_param_keys = this.getStraightParams();
for (var j = 0; j < positional_params.length; j++) {
params[pos_param_keys[j]] = positional_params[j];
}
return params;
}
PositionalUrl.prototype.generateParamsString = function(params_dict) {
var params_list = [];
var positional_params = [];
for (var key in params_dict){
var val = params_dict[key];
if ((typeof key != "undefined" && key !== "") && (typeof val != "undefined")) {
var pos = this.getPosition(key);
if (pos >= 0) {
positional_params[pos] = val;
} else {
var encoded = this.encoder.encode(key);
if (val.constructor !== Array && val !== '') {
params_list.push(encoded+"="+val)
} else if (val.constructor === Array) {
for (var i = 0; i < val.length; i++) {
params_list.push(encoded+"="+val[i]);
}
}
}
}
}
return '/' + positional_params.join('/') + '?' + params_list.join("&");
}
PositionalUrl.prototype.pushUrl = function(params) {
var new_url = this.window.location.href.split('b')[0] + 'b' + params;
console.log("new url: " + new_url);
this.window.history.pushState('plop', 'plop', new_url);
};
PositionalUrl.prototype.getPosition = function(param) {
return this.getStraightParams().indexOf(param);
};
function UrlEncoder() {
this.encoding = {
......
......@@ -42,6 +42,8 @@ server {
error_page 405 = $1;
}
#rewrite ^/([0-9]*)-([0-9]*)?(.*)$ /index.html?sample_set_id=$1&config=$2&$3 last;
location ~ ^/(client|c|browser) {
rewrite /(client|c|browser)(.*)$ /b$2 redirect;
}
......
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