Commit 606e973a authored by marc duez's avatar marc duez

model.js : store settings in localStorage only when function are called by user

parent b978da76
Pipeline #162682 failed with stages
in 13 minutes and 56 seconds
......@@ -203,52 +203,55 @@
</div>
<div class="menu_box">
size display</br>
<label for="menuNotation_scientific" class="buttonSelector" onclick="m.changeNotation('scientific', true)">
<label for="menuNotation_scientific" class="buttonSelector" onclick="m.changeNotation('scientific', true, true)">
<input id="menuNotation_scientific" type="radio" name="notation" value="scientific" />scientific notation
</label>
<label for="menuNotation_percent" class="buttonSelector" onclick="m.changeNotation('percent', true)">
<label for="menuNotation_percent" class="buttonSelector" onclick="m.changeNotation('percent', true, true)">
<input id="menuNotation_percent" type="radio" name="notation" value="percent" checked />percent
</label>
</div>
<div class="menu_box">
sample key</br>
<label for="menuTimeForm_name" class="buttonSelector" onclick="m.changeTimeFormat('name', true)">
<label for="menuTimeForm_name" class="buttonSelector" onclick="m.changeTimeFormat('name', true, true)">
<input id="menuTimeForm_name" type="radio" name="time" value="name" checked />name
</label>
<label for="menuTimeForm_short_name" class="buttonSelector" onclick="m.changeTimeFormat('short_name', true)">
<label for="menuTimeForm_short_name" class="buttonSelector" onclick="m.changeTimeFormat('short_name', true, true)">
<input id="menuTimeForm_short_name" type="radio" name="time" value="short_name" />name (short)
</label>
<label for="menuTimeForm_sampling_date" class="buttonSelector" onclick="m.changeTimeFormat('sampling_date', true)">
<label for="menuTimeForm_sampling_date" class="buttonSelector" onclick="m.changeTimeFormat('sampling_date', true, true)">
<input id="menuTimeForm_sampling_date" type="radio" name="time" value="sampling_date" />sampling date
</label>
<label for="menuTimeForm_delta_date" class="buttonSelector" onclick="m.changeTimeFormat('delta_date', true)">
<label for="menuTimeForm_delta_date" class="buttonSelector" onclick="m.changeTimeFormat('delta_date', true, true)">
<input id="menuTimeForm_delta_date" type="radio" name="time" value="delta_date" />day after first sample
</label>
</div>
<div class="menu_box">
N regions in clone names</br>
<label for="menuCloneNot_nucleotide_number" class="buttonSelector" onclick="m.changeCloneNotation('nucleotide_number', true)">
<label for="menuCloneNot_nucleotide_number" class="buttonSelector" onclick="m.changeCloneNotation('nucleotide_number', true, true)">
<input id="menuCloneNot_nucleotide_number" type="radio" name="show_name" value="nucleotide_number" />length
</label>
<label for="menuCloneNot_short_sequence" class="buttonSelector" onclick="m.changeCloneNotation('short_sequence', true)">
<label for="menuCloneNot_short_sequence" class="buttonSelector" onclick="m.changeCloneNotation('short_sequence', true, true)">
<input id="menuCloneNot_short_sequence" type="radio" name="show_name" value="short_sequence" checked />sequence (when short)
</label>
<label for="menuCloneNot_full_sequence" class="buttonSelector" onclick="m.changeCloneNotation('full_sequence', true)">
<label for="menuCloneNot_full_sequence" class="buttonSelector" onclick="m.changeCloneNotation('full_sequence', true, true)">
<input id="menuCloneNot_full_sequence" type="radio" name="show_name" value="full_sequence" />sequence (always)
</label>
</div>
<div class="menu_box">
alleles in clone names</br>
<label for="menuAlleleNot_never" class="buttonSelector" onclick="m.changeAlleleNotation('never', true)">
<label for="menuAlleleNot_never" class="buttonSelector" onclick="m.changeAlleleNotation('never', true, true)">
<input id="menuAlleleNot_never" type="radio" name="menu_allele" value="never" />never
</label>
<label for="menuAlleleNot_when_not_01" class="buttonSelector" onclick="m.changeAlleleNotation('when_not_01', true)">
<label for="menuAlleleNot_when_not_01" class="buttonSelector" onclick="m.changeAlleleNotation('when_not_01', true, true)">
<input id="menuAlleleNot_when_not_01" type="radio" name="menu_allele" value="when_not_01" checked />when not *01
</label>
<label for="menuAlleleNot_always" class="buttonSelector" onclick="m.changeAlleleNotation('always', true)">
<label for="menuAlleleNot_always" class="buttonSelector" onclick="m.changeAlleleNotation('always', true, true)">
<input id="menuAlleleNot_always" type="radio" name="menu_allele" value="always" />always
</label>
</div>
<div class="menu_box">
<a class="buttonSelector" onclick="m.resetSettings();">reset settings</a>
</div>
<div class="menu_box devel-mode">
......
......@@ -382,10 +382,10 @@ Model.prototype = {
}
}, //end initClones
changeCloneNotation: function(cloneNotationType, update) {
changeCloneNotation: function(cloneNotationType, update, save) {
this.cloneNotationType = cloneNotationType
if (this.localStorage) localStorage.setItem('cloneNotation', cloneNotationType)
if (this.localStorage && save) localStorage.setItem('cloneNotation', cloneNotationType)
var menu = document.getElementById("menuCloneNot_" + cloneNotationType)
if (menu) menu.checked = true
......@@ -395,10 +395,10 @@ changeCloneNotation: function(cloneNotationType, update) {
},
changeAlleleNotation: function(alleleNotation, update) {
changeAlleleNotation: function(alleleNotation, update, save) {
this.alleleNotation = alleleNotation;
if (this.localStorage) localStorage.setItem('alleleNotation', alleleNotation)
if (this.localStorage && save) localStorage.setItem('alleleNotation', alleleNotation)
var menu = document.getElementById("menuAlleleNot_" + alleleNotation)
if (menu) menu.checked = true
......@@ -2454,11 +2454,12 @@ changeAlleleNotation: function(alleleNotation, update) {
/**
* change default notation display for sizes
* @param {string} notation - notation type ('scientific' , 'percent')
* @pram {bool} update - will update the display after
* @param {bool} update - will update the display after
* @param {bool} save - will save value in user preferences (localStorage)
* */
changeNotation: function (notation, update) {
changeNotation: function (notation, update, save) {
this.notation_type = notation
if (this.localStorage) localStorage.setItem('notation', notation)
if (this.localStorage && save) localStorage.setItem('notation', notation)
var menu = document.getElementById("menuNotation_" + notation)
if (menu) menu.checked = true
......@@ -2469,11 +2470,12 @@ changeAlleleNotation: function(alleleNotation, update) {
/**
* change default time format for sample/time names
* @param {string} notation - format ('name', 'sampling_date', 'delta_date', 'delta_date_no_zero')
* @pram {bool} update - will update the display after
* @param {bool} update - will update the display after
* @param {bool} save - will save value in user preferences (localStorage)
* */
changeTimeFormat: function (time, update) {
changeTimeFormat: function (time, update, save) {
this.time_type = time
if (this.localStorage) localStorage.setItem('timeFormat', time)
if (this.localStorage && save) localStorage.setItem('timeFormat', time)
var menu = document.getElementById("menuTimeForm_" + time)
if (menu) menu.checked = true
......@@ -2484,13 +2486,14 @@ changeAlleleNotation: function(alleleNotation, update) {
/**
* change default color method
* @param {string} colorM
* @pram {bool} update - will update the display after default = true
* @param {bool} update - will update the display after default = true
* @param {bool} save - will save value in user preferences (localStorage)
* */
changeColorMethod: function (colorM, update) {
changeColorMethod: function (colorM, update, save) {
update = (update==undefined) ? true : update;
this.colorMethod = colorM
if (this.localStorage) localStorage.setItem('colorMethod', colorM)
if (this.localStorage && save) localStorage.setItem('colorMethod', colorM)
var menu = document.getElementById("color_menu_select")
if (menu) menu.value = colorM
......@@ -2499,6 +2502,16 @@ changeAlleleNotation: function(alleleNotation, update) {
for (var i = 0; i<this.clones.length; i++) list.push(i)
this.updateElemStyle(list)
},
resetSettings: function () {
localStorage.clear()
this.changeColorMethod("Tag", false)
this.changeNotation("percent", false)
this.changeTimeFormat("name", false)
this.changeAlleleNotation("when_not_01", false)
this.changeCloneNotation("short_sequence", false)
console.log({ msg: "user preferences have been reset", type: "flash", priority: 2 });
},
/**
* convert visible clones to csv
......
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