Commit 6f859a41 authored by Ryan Herbert's avatar Ryan Herbert Committed by Mathieu Giraud

url.js refactor update()

reading from the model and updating the url accordingly
parent 9eee0edf
...@@ -24,30 +24,48 @@ Url.prototype= { ...@@ -24,30 +24,48 @@ Url.prototype= {
* */ * */
update: function () { update: function () {
if (!$(".devel-mode:visible").length && typeof this.window.mocked == "undefined") // get selected clones
return ;
var selectedList = this.m.getSelected(); var selectedList = this.m.getSelected();
var params_dict = this.url_dict; var params_dict = this.url_dict;
params_dict.clone = selectedList.join(); if (selectedList.length > 0) {
params_dict.clone = selectedList.join();
} else {
delete params_dict.clone;
}
// get scatterplot settings
if (this.sp.select_preset.selectedIndex!=this.sp.default_preset) { if (this.sp.select_preset.selectedIndex!=this.sp.default_preset) {
params_dict.plot = this.sp.splitX+','+this.sp.splitY+','+this.sp.mode; params_dict.plot = this.sp.splitX+','+this.sp.splitY+','+this.sp.mode;
} else { } else {
delete params_dict[this.sp.mode]; delete params_dict[this.sp.mode];
} }
var params_list = []; // get sample_set/patient/run, config...
for (var key in params_dict){ var straight_params = this.getStraightParams();
if ((typeof key != "undefined" && key !== "") && (typeof params_dict[key]!= "undefined" && params_dict[key] !== '')) { for (var i = 0; i < straight_params.length; i++) {
params_list.push(key+"="+params_dict[key]) var p = straight_params[i];
if (typeof this.m[p] !== "undefined") {
params_dict[p] = this.m[p];
} }
} }
new_url = "?" + params_list.join("&"); if (typeof this.m.custom !== "undefined") {
this.window.history.pushState('plop', 'plop', new_url); var custom_ids = [];
this.updateModel() var custom_split = this.m.custom.split('&');
for (var j = 0; j < custom_split.length; j++) {
if (custom_split[j] !== "") {
custom_ids.push(custom_split[j].split('=')[1]);
}
}
params_dict.custom = custom_ids.join(',');
}
params = this.generateParamsString(params_dict);
this.pushUrl(params);
this.url_dict = params_dict;
}, },
/** /**
......
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