annotate src/add-one-spectrum-index.js @ 1:7e3085fc60c1 draft default tip

master branch Updating
author lain
date Wed, 30 Aug 2023 14:21:18 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2 var token = "{{ PF_TOKEN_PLACEHOLDER }}" ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
3 if ({{ TAB_INDEX_PLACEHOLDER }} == 1) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
4 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
5
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
6 context_{{ TAB_INDEX_PLACEHOLDER }} = {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
7 prefix: "#accordion-{{ TAB_INDEX_PLACEHOLDER }} ",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
8 name: "Context[{{ TAB_INDEX_PLACEHOLDER }}]",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
9 produce_json: {{ PRODUCE_JSON_PLACEHOLDER }},
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
10 DEFAULT_MS_PEAK_VALUES: {{ MS_PEAK_VALUES_PLACEHOLDER }},
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
11 DEFAULT_DATA: {{ DEFAULT_DATA }},
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
12 peakforest_url: "{{ PF_URL_PLACEHOLDER }}",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
13 tab_index: "{{ TAB_INDEX_PLACEHOLDER }}",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
14 modeEditSpectrum: false,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
15 isSeparationFlowRateInit: false,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
16 isMSpeaksInit: false,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
17 isLC: false,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
18 isGC: false,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
19 isIC: false,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
20 hot_LC_SFG: null ,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
21 hot_MS_Peaks: null,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
22 hot_RCC_ADDED: null,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
23 jsonSpectrumType: null,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
24 isJsonSpectrumTypeComplete: false,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
25 jsonSample: null,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
26 isJsonSampleComplete: false,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
27 isJsonRCCaddedComplete: false,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
28 jsonChromato: null,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
29 isJsonChromatoComplete: false,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
30 jsonAnalyzer: null,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
31 isJsonAnalyzerComplete: false,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
32 jsonPeaksList: [],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
33 isJsonPeaksListComplete: false,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
34 jsonOtherMetadata: null,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
35 isJsonOtherMetadataComplete: false,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
36 jsonMolIonization: null,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
37 jsonMolIonBeam: null,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
38 cptPeakListTab: 0,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
39 jsonAnalyzerAcquisition: [],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
40 idMetadataMap: {},
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
41 listOfViewableSpectra: [],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
42 singlePick: true,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
43 multiPickLine: -1,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
44 subjects: [],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
45 fitlerSearchLoadlCpd: 5,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
46 inchikey: null,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
47 initialized: false,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
48 selected_ion_index: null,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
49 lock: {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
50 precursor_ion: false
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
51 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
52
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
53 sent_json: null,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
54
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
55 init: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
56
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
57 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
58
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
59 $(document).ready(() => self.on_ready());
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
60 $(document).ready(function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
61 console.log("adding click on open_tab_{{ TAB_INDEX_PLACEHOLDER }}.") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
62 var activate_tab = function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
63 if (self.initialized) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
64 return ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
65 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
66 self.auto_set_spec_type() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
67 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
68 if (self.is_ref()) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
69 $("#open_tab_{{ TAB_INDEX_PLACEHOLDER }}").click(activate_tab) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
70 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
71 if ({{ TAB_INDEX_PLACEHOLDER }} == 1) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
72 activate_tab() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
73 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
74 }) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
75
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
76 return (self) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
77
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
78 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
79
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
80 on_ready: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
81 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
82
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
83 $(self.prefix+".pickChemicalCompound").click(self.pickChemicalCompound);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
84 $(self.prefix+".add1spectrum").change(
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
85 function(){self.add1spectrum_change_handler(this)}
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
86 )
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
87 self.attach_search() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
88 self.add_date_check() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
89 self.populate_selects() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
90 self.add_change_handlers() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
91 self.show_hide_ms_ms2_fields() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
92 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
93
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
94 populate_selects: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
95 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
96 var choose_in_list ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
97
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
98 choose_in_list = `
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
99 <option value="" selected="selected" disabled="disabled">
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
100 choose in list&hellip;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
101 </option>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
102 ` ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
103 $("#add1spectrum-chromatoLC-method-{{ TAB_INDEX_PLACEHOLDER }}").append(choose_in_list) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
104 $("#add1spectrum-chromatoLC-colConstructor-{{ TAB_INDEX_PLACEHOLDER }}").append(choose_in_list) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
105 $("#add1spectrum-chromatoLC-separationSolvA-{{ TAB_INDEX_PLACEHOLDER }}").append(choose_in_list) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
106 $("#add1spectrum-chromatoLC-separationSolvB-{{ TAB_INDEX_PLACEHOLDER }}").append(choose_in_list) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
107 $("#add1spectrum-sample-lcmsSolvent-{{ TAB_INDEX_PLACEHOLDER }}").append(choose_in_list) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
108 $.getJSON("{{ PF_URL_PLACEHOLDER }}/webapp/resources/json/list-lc-methods.json", self.populate_lc_methods) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
109 $.getJSON("{{ PF_URL_PLACEHOLDER }}/webapp/resources/json/list-lc-columns.json", self.populate_lc_columns) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
110 $.getJSON("{{ PF_URL_PLACEHOLDER }}/webapp/resources/json/list-lc-solvents.json", self.populate_lc_solvents) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
111 $.getJSON("{{ PF_URL_PLACEHOLDER }}/webapp/resources/json/list-ms-ionization-methods.json", self.populate_ms_ionization) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
112 $.getJSON("{{ PF_URL_PLACEHOLDER }}/webapp/resources/json/list-lcms-solvents.json", self.populate_lcms_solvents) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
113 self.resetFromColors();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
114 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
115
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
116 attach_search: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
117 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
118
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
119 $("#add-one-cc-s1-value-{{ TAB_INDEX_PLACEHOLDER }}").bind("keypress", function(e) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
120 var code = e.keyCode || e.which;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
121 if (code == 13) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
122 self.searchLocalCompound();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
123 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
124 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
125 $("#add-one-cc-s1-value-{{ TAB_INDEX_PLACEHOLDER }}").typeahead({
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
126 source: function(query, process) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
127 return self.searchAjax();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
128 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
129 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
130 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
131
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
132 add_date_check: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
133 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
134
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
135 $("#add1spectrum-other-date-{{ TAB_INDEX_PLACEHOLDER }}").focusout(function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
136 var element = $(this) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
137 self.rm_warning(element);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
138 self.rm_success(element) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
139 if (element.val() == "") {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
140 element.parent().addClass("has-warning");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
141 } else {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
142 element.parent().addClass("has-success");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
143 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
144 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
145 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
146
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
147 populate_lc_methods: function(data) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
148 // load data from json
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
149 $.each(data.methods,function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
150 if (this.name !== undefined) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
151 if (this.value !== undefined) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
152 $("#add1spectrum-chromatoLC-method-{{ TAB_INDEX_PLACEHOLDER }}").append(
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
153 `<option value="${this.value}">${this.name}</option>`
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
154 );
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
155 } else {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
156 $("#add1spectrum-chromatoLC-method-{{ TAB_INDEX_PLACEHOLDER }}").append(
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
157 `<option disabled>${this.name}</option>`
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
158 );
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
159 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
160 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
161 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
162 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
163
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
164 populate_lc_columns: function(data) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
165 // load data from json
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
166 $.each(data.columns, function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
167 $("#add1spectrum-chromatoLC-colConstructor-{{ TAB_INDEX_PLACEHOLDER }}").append(
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
168 `<option value="${this.value}">${this.name}</option>`
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
169 );
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
170 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
171 $("#add1spectrum-chromatoLC-colConstructor-{{ TAB_INDEX_PLACEHOLDER }}").append(
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
172 '<option value="other" >Other</option>'
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
173 );
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
174 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
175
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
176 populate_lc_solvents: function(data) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
177 // load data from json
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
178 $.each(data.solvents, function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
179 $("#add1spectrum-chromatoLC-separationSolvA-{{ TAB_INDEX_PLACEHOLDER }}").append(
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
180 `<option value="${this.value}">${this.name}</option>`
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
181 );
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
182 $("#add1spectrum-chromatoLC-separationSolvB-{{ TAB_INDEX_PLACEHOLDER }}").append(
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
183 `<option value="${this.value}">${this.name}</option>`
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
184 );
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
185 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
186 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
187
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
188 populate_ms_ionization: function(data) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
189 // load data from json
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
190 $.each(data.methods,function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
191 if (this.name !==undefined) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
192 if (this.value !==undefined) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
193 $("#add1spectrum-analyzserMS-ionizationMethod-pos-{{ TAB_INDEX_PLACEHOLDER }}").append(
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
194 `<option value="${this.value}">${this.name}</option>`
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
195 );
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
196 $("#add1spectrum-analyzserMS-ionizationMethod-neg-{{ TAB_INDEX_PLACEHOLDER }}").append(
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
197 `<option value="${this.value}">${this.name}</option>`
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
198 );
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
199 } else {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
200 $("#add1spectrum-analyzserMS-ionizationMethod-pos-{{ TAB_INDEX_PLACEHOLDER }}").append(
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
201 `<option disabled>${this.name}</option>`
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
202 );
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
203 $("#add1spectrum-analyzserMS-ionizationMethod-neg-{{ TAB_INDEX_PLACEHOLDER }}").append(
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
204 `<option disabled>${this.name}</option>`
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
205 );
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
206 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
207 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
208 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
209 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
210
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
211 populate_lcms_solvents: function(data) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
212 // load data from json
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
213 $.each(data.solvents, function () {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
214 $("#add1spectrum-sample-lcmsSolvent-{{ TAB_INDEX_PLACEHOLDER }}").append(
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
215 `<option value="${this.value}" class="${this.classD}">${this.name}</option>`
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
216 );
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
217 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
218 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
219
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
220 add_change_handlers: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
221 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
222
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
223 $("#add1spectrum-ionTrapBeam-type-{{ TAB_INDEX_PLACEHOLDER }}").on("change", function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
224 var v = $("#add1spectrum-ionTrapBeam-type-{{ TAB_INDEX_PLACEHOLDER }}").val();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
225 $(self.prefix + ".add1spectrum-ionTrap").hide();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
226 if (v == "beam") {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
227 } else if (v == "trap") {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
228 $(self.prefix + ".add1spectrum-ionTrap").show();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
229 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
230 }) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
231 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
232
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
233 show_hide_ms_ms2_fields: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
234 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
235 $(self.prefix + " .disabled-if-ms").attr("disabled", self.is_ms())
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
236 $(self.prefix + " .disabled-if-msms").attr("disabled", self.is_ms2())
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
237 $(self.prefix + " .disabled-if-ms2").attr("disabled", self.is_ms2())
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
238 if (self.is_ms()) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
239 self.hide(self.prefix + " .hidden-if-ms") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
240 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
241 if (self.is_ms2()) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
242 self.hide(self.prefix + " .hidden-if-msms") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
243 self.hide(self.prefix + " .hidden-if-ms2") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
244 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
245 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
246
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
247 is_mix: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
248 return this.DEFAULT_DATA["sample_type"] == "compound-mix" ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
249 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
250
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
251 is_ref: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
252 return this.DEFAULT_DATA["sample_type"] == "compound-ref" ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
253 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
254
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
255 is_ms: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
256 return this.DEFAULT_DATA["spectrum_type"] == "LC_MS" ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
257 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
258
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
259 is_ms2: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
260 return this.DEFAULT_DATA["spectrum_type"] == "LC_MSMS" ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
261 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
262
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
263 is_other_in_mix() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
264 return this.is_mix() && {{ TAB_INDEX_PLACEHOLDER }} > 1 ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
265 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
266
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
267 hide: function(id) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
268 if (typeof id == Array) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
269 return (id.forEach(hide)) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
270 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
271 $(id).hide()
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
272 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
273
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
274 rm_success: function(element) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
275 return (this.rm_parent_class(element, "has-success"))
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
276 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
277 rm_error: function(element) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
278 return (this.rm_parent_class(element, "has-error"))
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
279 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
280 rm_warning: function(element) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
281 return (this.rm_parent_class(element, "has-warning"))
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
282 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
283 set_success: function(element) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
284 return (this.set_parent_class(element, "has-success"))
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
285 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
286 set_error: function(element) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
287 return (this.set_parent_class(element, "has-error"))
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
288 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
289 set_warning: function(element) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
290 return (this.set_parent_class(element, "has-warning"))
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
291 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
292 rm_parent_class: function(element, cls) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
293 var parent ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
294
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
295 if ((parent = element.parent()) == null) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
296 return false ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
297 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
298 return this.rm_class(parent, cls) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
299 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
300 set_parent_class: function(element, cls) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
301 var parent ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
302
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
303 if ((parent = element.parent()) == null) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
304 return false ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
305 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
306 return this.set_class(parent, cls) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
307 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
308 rm_class: function(element, cls) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
309 if (element.hasClass(cls)) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
310 element.removeClass(cls) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
311 return true ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
312 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
313 return false ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
314 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
315 set_class: function(element, cls) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
316 if (element.hasClass(cls)) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
317 return false ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
318 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
319 element.addClass(cls) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
320 return true ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
321 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
322 is_success: function(element) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
323 return (this.parent_has_class(element, "has-success"))
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
324 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
325 is_warning: function(element) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
326 return (this.parent_has_class(element, "has-warning"))
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
327 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
328 is_error: function(element) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
329 return (this.parent_has_class(element, "has-error"))
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
330 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
331 is_optional: function(element) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
332 return (element.hasClass("is-optional"))
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
333 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
334 is_mandatory: function(element) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
335 return (element.hasClass("is-mandatory"))
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
336 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
337 parent_has_class: function(element, cls) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
338 var parent ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
339
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
340 if ((parent = element.parent()) == null) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
341 return false ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
342 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
343 return (parent.hasClass(cls)) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
344 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
345
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
346 add1spectrum_change_handler: function(element) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
347 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
348 var idElem ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
349 var valElem ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
350 var isSuccess ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
351 var isWarning ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
352 var isError ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
353 var isOptional ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
354 var isMandatory ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
355
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
356 element = $(element) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
357 idElem = element.attr("id") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
358 valElem = element.val();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
359 console.log(`Change handler called for [${idElem}]=${valElem}`) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
360 if (idElem.split("-").slice(0, -1).join("-") == "add1spectrum-peaksMS-msPrecursorIon") {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
361 var index = idElem.split("-")[3] - 1 ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
362 if (all_contexts[index] !== null && all_contexts[index] !== undefined) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
363 all_contexts[index].sync_precursor_ion() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
364 if (all_contexts[index].hot_MS_Peaks != null) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
365 all_contexts[index].hot_MS_Peaks.render()
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
366 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
367 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
368 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
369 isSuccess = self.is_success(element);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
370 isWarning = self.is_warning(element);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
371 isError = self.is_error(element);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
372 isOptional = self.is_optional(element);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
373 isMandatory = self.is_mandatory(element);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
374
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
375 switch(idElem) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
376 case "add1spectrum-sample-type-{{ TAB_INDEX_PLACEHOLDER }}":
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
377 if (valElem == "compound-ref") {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
378 $("#add1spectrum-sample-type-compound-ref-{{ TAB_INDEX_PLACEHOLDER }}").show();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
379 $("#add1spectrum-sample-type-compound-mix-{{ TAB_INDEX_PLACEHOLDER }}").hide();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
380 $("#add1spectrum-sample-type-rcc-added-{{ TAB_INDEX_PLACEHOLDER }}").hide();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
381 } else if (valElem == "compound-mix") {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
382 $("#add1spectrum-sample-type-compound-mix-{{ TAB_INDEX_PLACEHOLDER }}").show();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
383 $("#add1spectrum-sample-type-compound-ref-{{ TAB_INDEX_PLACEHOLDER }}").hide();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
384 $("#add1spectrum-sample-type-rcc-added-{{ TAB_INDEX_PLACEHOLDER }}").show();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
385 self.handsontableRefChemCpdAdded(null);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
386 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
387 break;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
388 case "add1spectrum-chromatoLC-colConstructor-{{ TAB_INDEX_PLACEHOLDER }}":
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
389 self.resetElemColor("add1spectrum-chromatoLC-colConstructorOther-{{ TAB_INDEX_PLACEHOLDER }}");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
390 if (valElem == "" || valElem == null || valElem != "other" ) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
391 self.disableElem("add1spectrum-chromatoLC-colConstructorOther-{{ TAB_INDEX_PLACEHOLDER }}");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
392 } else {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
393 self.enableElem("add1spectrum-chromatoLC-colConstructorOther-{{ TAB_INDEX_PLACEHOLDER }}");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
394 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
395 break;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
396 case "add1spectrum-chromatoLC-method-{{ TAB_INDEX_PLACEHOLDER }}":
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
397 self.fulfillLCdata(valElem);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
398 break;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
399 case "add1spectrum-analyzserMS-ionizationMethod-pos-{{ TAB_INDEX_PLACEHOLDER }}":
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
400 if ($("#add1spectrum-analyzserMS-ionizationMethod-pos-{{ TAB_INDEX_PLACEHOLDER }}").val() != null) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
401 $($("#add1spectrum-peaksMS-polarity-{{ TAB_INDEX_PLACEHOLDER }} option")[1]).attr("disabled", false);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
402 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
403 break;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
404 case "add1spectrum-analyzserMS-ionizationMethod-neg-{{ TAB_INDEX_PLACEHOLDER }}":
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
405 if ($("#add1spectrum-analyzserMS-ionizationMethod-neg-{{ TAB_INDEX_PLACEHOLDER }}").val() != null) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
406 $($("#add1spectrum-peaksMS-polarity-{{ TAB_INDEX_PLACEHOLDER }} option")[2]).attr("disabled", false);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
407 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
408 break;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
409 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
410 if ((isMandatory || isOptional) && (valElem == "" || valElem == null)) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
411 if (isSuccess) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
412 self.rm_success(element) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
413 } else if (isWarning) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
414 self.rm_warning(element) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
415 } else if (isError) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
416 self.rm_error(element) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
417 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
418 if (isMandatory) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
419 self.set_error(element) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
420 } else {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
421 self.set_warning(element) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
422 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
423 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
424 if (isMandatory && (valElem != "" && valElem != null)) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
425 if (isError) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
426 self.rm_error(element) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
427 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
428 self.set_success(element) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
429 } else if (isOptional && valElem != "") {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
430 if (isWarning) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
431 self.rm_warning(element) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
432 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
433 self.set_success(element) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
434 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
435 if (element.parent().children("input").size() == 2) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
436 if (isMandatory) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
437 if (isSuccess) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
438 self.rm_success(element) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
439 } else if (isWarning) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
440 self.rm_warning(element) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
441 } else if (isError) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
442 self.rm_error(element) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
443 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
444 if (element.parent().children("input").toArray().some(
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
445 (el) => $(el).val() === null || $(el).val() === ""
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
446 )) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
447 self.set_error(element) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
448 } else {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
449 self.set_success(element) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
450 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
451 } else if (isOptional) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
452 isSuccess = self.is_success(element);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
453 isWarning = self.is_warning(element);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
454 isError = self.is_error(element);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
455 if (isSuccess) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
456 self.rm_success(element)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
457 } else if (isWarning) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
458 self.rm_warning(element) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
459 } else if (isError) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
460 self.rm_error(element) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
461 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
462 if (element.parent().children("input").toArray().some(
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
463 (el) => ($(el).val() == null || $(el).val() == "")
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
464 )) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
465 self.set_warning(element) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
466 } else {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
467 self.set_success(element) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
468 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
469 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
470 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
471 if (element.hasClass("one-or-more")) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
472 // get parent class
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
473 isSuccess = self.is_success(element);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
474 isWarning = self.is_warning(element);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
475 isError = self.is_error(element);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
476 // reset class
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
477 if (isSuccess) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
478 self.rm_success(element) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
479 } else if (isWarning) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
480 self.rm_warning(element) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
481 } else if (isError) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
482 self.rm_error(element) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
483 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
484 isTmpSuccess = false;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
485 $.each(element.parent().children("input"), function(id, child){
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
486 if ($(child).val() != null && $(child).val() != "") {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
487 isTmpSuccess = true;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
488 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
489 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
490 $.each(element.parent().children("select"), function(id, child){
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
491 if ($(child).val() != null && $(child).val() != "") {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
492 isTmpSuccess = true;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
493 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
494 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
495 // end parkour
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
496 element.parent().addClass(
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
497 isTmpSuccess ? "has-success" : "has-error"
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
498 );
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
499 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
500 // CHECK IF OK STEP 2
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
501 if (element.hasClass("add1spectrum-sampleForm")) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
502 var isBtnStep2OK = true;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
503 $.each($(self.prefix + ".add1spectrum-sampleForm"), (id, elem) => {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
504 if (self.is_error($(elem)) && $(elem).is(":visible")) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
505 isBtnStep2OK = false;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
506 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
507 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
508 if (isBtnStep2OK) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
509 self.rm_class($("#btnSwitch-gotoStep2-{{ TAB_INDEX_PLACEHOLDER }}"), "btn-disabled") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
510 self.set_class($("#btnSwitch-gotoStep2-{{ TAB_INDEX_PLACEHOLDER }}"), "btn-primary") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
511 $("#btnSwitch-gotoStep2-{{ TAB_INDEX_PLACEHOLDER }}").prop("disabled", false);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
512 } else {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
513 self.set_class($("#btnSwitch-gotoStep2-{{ TAB_INDEX_PLACEHOLDER }}"), "btn-disabled") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
514 self.rm_class($("#btnSwitch-gotoStep2-{{ TAB_INDEX_PLACEHOLDER }}"), "btn-primary") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
515 $("#btnSwitch-gotoStep2-{{ TAB_INDEX_PLACEHOLDER }}").prop("disabled", true);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
516 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
517 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
518 // CHECK IF OK STEP 3 - LC
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
519 if (
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
520 element.hasClass("add1spectrum-chromatoLCForm")
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
521 && $("#btnSwitch-gotoStep3-lc-{{ TAB_INDEX_PLACEHOLDER }}").is(":visible")
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
522 ) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
523 var isBtnStep3OK = true;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
524 $.each($(self.prefix+".add1spectrum-chromatoLCForm"), (id, elem) => {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
525 if (self.is_error($(elem)) && $(elem).is(":visible"))
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
526 isBtnStep3OK = false;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
527 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
528 if (isBtnStep3OK) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
529 self.rm_class($("#btnSwitch-gotoStep3-lc-{{ TAB_INDEX_PLACEHOLDER }}"), "btn-disabled") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
530 self.set_class($("#btnSwitch-gotoStep3-lc-{{ TAB_INDEX_PLACEHOLDER }}"), "btn-primary") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
531 $("#btnSwitch-gotoStep3-lc-{{ TAB_INDEX_PLACEHOLDER }}").prop("disabled", false);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
532 } else {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
533 self.set_class($("#btnSwitch-gotoStep3-lc-{{ TAB_INDEX_PLACEHOLDER }}"), "btn-disabled") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
534 self.rm_class($("#btnSwitch-gotoStep3-lc-{{ TAB_INDEX_PLACEHOLDER }}"), "btn-primary") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
535 $("#btnSwitch-gotoStep3-lc-{{ TAB_INDEX_PLACEHOLDER }}").prop("disabled", true);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
536 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
537 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
538 // TODO CHECK IF OK STEP 3 - GC
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
539 // CHECK IF OK STEP 4 - MS ANALYZER
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
540 if (
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
541 element.hasClass("add1spectrum-analyzerMSForm")
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
542 && $("#btnSwitch-gotoStep4-ms-{{ TAB_INDEX_PLACEHOLDER }}").is(":visible")
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
543 ) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
544 var isBtnStep4OK = true;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
545 $.each($(self.prefix+".add1spectrum-analyzerMSForm"), (id, elem) => {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
546 if (self.is_error($(elem)) && $(elem).is(":visible"))
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
547 isBtnStep4OK = false;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
548 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
549 if (isBtnStep4OK) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
550 self.rm_class($("#btnSwitch-gotoStep4-ms-{{ TAB_INDEX_PLACEHOLDER }}"), "btn-disabled") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
551 self.set_class($("#btnSwitch-gotoStep4-ms-{{ TAB_INDEX_PLACEHOLDER }}"), "btn-primary") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
552 $("#btnSwitch-gotoStep4-ms-{{ TAB_INDEX_PLACEHOLDER }}").prop("disabled", false);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
553 } else {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
554 self.set_class($("#btnSwitch-gotoStep4-ms-{{ TAB_INDEX_PLACEHOLDER }}"), "btn-disabled") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
555 self.rm_class($("#btnSwitch-gotoStep4-ms-{{ TAB_INDEX_PLACEHOLDER }}"), "btn-primary") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
556 $("#btnSwitch-gotoStep4-ms-{{ TAB_INDEX_PLACEHOLDER }}").prop("disabled", true);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
557 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
558 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
559 // CHECK IF OK STEP 5 - PEAKS
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
560 if (
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
561 element.hasClass("add1spectrum-peaksMSForm-peaklist")
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
562 && $("#btnSwitch-gotoStep5-ms-{{ TAB_INDEX_PLACEHOLDER }}").is(":visible")
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
563 ) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
564 var isBtnStep5OK = true;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
565 $.each($(self.prefix+".add1spectrum-peaksMSForm-peaklist"), (id, elem) => {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
566 if (self.is_error($(elem)) && $(elem).is(":visible"))
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
567 isBtnStep5OK = false;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
568 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
569 if (isBtnStep5OK && (self.is_ms() || self.a_ion_parent_is_selected())) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
570 self.rm_class($("#btnSwitch-gotoStep5-ms-{{ TAB_INDEX_PLACEHOLDER }}"), "btn-disabled") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
571 self.set_class($("#btnSwitch-gotoStep5-ms-{{ TAB_INDEX_PLACEHOLDER }}"), "btn-primary") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
572 $("#btnSwitch-gotoStep5-ms-{{ TAB_INDEX_PLACEHOLDER }}").prop("disabled", false);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
573 } else {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
574 self.set_class($("#btnSwitch-gotoStep5-ms-{{ TAB_INDEX_PLACEHOLDER }}"), "btn-disabled") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
575 self.rm_class($("#btnSwitch-gotoStep5-ms-{{ TAB_INDEX_PLACEHOLDER }}"), "btn-primary") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
576 $("#btnSwitch-gotoStep5-ms-{{ TAB_INDEX_PLACEHOLDER }}").prop("disabled", true);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
577 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
578 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
579 // CHECK IF OK STEP 6 - OTHER DATA
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
580 if (
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
581 element.hasClass("add1spectrum-otherForm")
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
582 && $("#btnSwitch-gotoStep6-{{ TAB_INDEX_PLACEHOLDER }}").is(":visible")
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
583 ) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
584 self.checkIfEnableSubmit() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
585 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
586 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
587
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
588 a_ion_parent_is_selected: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
589 return (this.get_selected_parent_ion_mz() !== null) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
590 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
591
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
592 get_selected_parent_ion_index: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
593 var curent_mz = this.get_selected_parent_ion_mz() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
594 if (curent_mz === null) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
595 return null;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
596 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
597 if (this.hot_MS_Peaks == undefined) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
598 return null ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
599 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
600 var data = this.hot_MS_Peaks.getData() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
601 for (var i = 0 ; i < data.length ; i += 1) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
602 if (Math.abs(data[i][0] - curent_mz) < 0.0001) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
603 return i ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
604 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
605 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
606 return null ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
607 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
608
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
609 get_selected_parent_ion_mz: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
610 return $(
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
611 "#add1spectrum-peaksMS-msPrecursorIon-{{ TAB_INDEX_PLACEHOLDER }}"
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
612 ).val() || null ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
613 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
614
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
615 auto_set_spec_type: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
616 console.log("auto_set_spec_type...") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
617 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
618 var id = `#set_${self.DEFAULT_DATA["spectrum_type"]}_spectrum_button` ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
619 var element = $(self.prefix + id) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
620 if (element.length) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
621 element.click() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
622 console.log(`auto_set_spec_type to ${self.DEFAULT_DATA["spectrum_type"]} ok.`)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
623 } else {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
624 console.log(element)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
625 console.log("Failed!")
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
626 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
627 if (self.DEFAULT_DATA["sample_type"]) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
628 self.auto_set_sample_type(self) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
629 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
630 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
631
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
632 auto_set_sample_type: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
633 console.log("auto_set_sample_type...") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
634 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
635 var id = "#add1spectrum-sample-type-{{ TAB_INDEX_PLACEHOLDER }}" ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
636 var element = $(id) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
637 if (element.length) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
638 element.val(self.DEFAULT_DATA["sample_type"]).change() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
639 console.log(`auto_set_sample_type to ${self.DEFAULT_DATA["sample_type"]} ok.`) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
640 if (self.DEFAULT_DATA["sample_type"] == "compound-ref") {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
641 $("#add1spectrum-sample-mixSolvent-{{ TAB_INDEX_PLACEHOLDER }}").val(
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
642 "H2O/ethanol (75/25)"
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
643 ).change() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
644 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
645 } else {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
646 console.log(element)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
647 console.log("Failed!")
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
648 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
649 if (self.DEFAULT_DATA["inchikey"]) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
650 setTimeout(() => self.auto_set_inchikey(self), 1000) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
651 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
652 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
653
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
654 auto_set_inchikey: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
655 console.log("auto_set_inchikey...") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
656 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
657 var id ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
658 var element ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
659 self.inchikey = self.DEFAULT_DATA["inchikey"] ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
660 if (self.is_ref()) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
661 id = "#add1spectrum-sample-inchikey-{{ TAB_INDEX_PLACEHOLDER }}:text" ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
662 element = $(id) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
663 if (element.length) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
664 console.log(`auto_set_inchikey to ${self.inchikey} ok.`)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
665 element.val(self.inchikey).change() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
666 console.log(`Inchikey set!`) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
667 } else {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
668 console.log(element)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
669 console.log("Failed!")
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
670 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
671 } else {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
672 for (var index = 0 ; index < all_contexts.length ; index += 1) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
673 if (all_contexts[index] === null || all_contexts[index] === undefined) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
674 continue;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
675 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
676 var inchikey = all_contexts[index].DEFAULT_DATA["inchikey"] ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
677 id = `#container_RCC_ADDED-1 tbody:nth(0) tr:nth(${index}) td:nth(1)` ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
678 element = $(id) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
679 if (element.length) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
680 console.log(`auto_set_inchikey to ${inchikey} ok.`)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
681 self.hot_RCC_ADDED.setDataAtCell(index, 1, inchikey) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
682 element.innerHTML = inchikey ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
683 element.change() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
684 console.log(element) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
685 console.log(`Inchikey set!`) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
686 } else {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
687 console.log(element)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
688 console.log("Failed!")
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
689 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
690 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
691 console.log(self.hot_RCC_ADDED)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
692 self.hot_RCC_ADDED.render() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
693 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
694 $("#btnSwitch-gotoStep2-{{ TAB_INDEX_PLACEHOLDER }}").click() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
695 if (self.DEFAULT_DATA["method"]) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
696 setTimeout(() => self.auto_set_method(self), 1000) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
697 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
698 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
699
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
700 auto_set_method: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
701 console.log("auto_set_method...") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
702 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
703 var id = "#add1spectrum-chromatoLC-method-{{ TAB_INDEX_PLACEHOLDER }}" ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
704 var element = $(id) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
705 element.length && element.val(self.DEFAULT_DATA["method"]).change() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
706 $("#btnSwitch-gotoStep3-lc-{{ TAB_INDEX_PLACEHOLDER }}").click() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
707 setTimeout(() => {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
708 (() => {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
709 $("#btnSwitch-gotoStep4-ms-{{ TAB_INDEX_PLACEHOLDER }}").click() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
710 console.log(`auto_set_method to ${self.DEFAULT_DATA["method"]} ok.`)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
711 if (self.DEFAULT_DATA["scan_type"]) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
712
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
713 // The scan type needs to be skipped, as it is already defined
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
714 // at build-time
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
715 // The code is kept for future modifications of this behavior
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
716 setTimeout(() => self.auto_set_scan_type(self, skip = true), 1000) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
717 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
718 })(self)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
719 }, 1000) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
720 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
721
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
722 auto_set_scan_type: function(skip = false) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
723 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
724 if (!skip) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
725 console.log("auto_set_scan_type...") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
726 var id = "#add1spectrum-peaksMS-msLevel-{{ TAB_INDEX_PLACEHOLDER }}" ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
727 var element = $(id) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
728 if (element.length) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
729 element.val(self.DEFAULT_DATA["scan_type"]).change() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
730 console.log(`auto_set_scan_type to ${self.DEFAULT_DATA["scan_type"]} ok.`)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
731 } else {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
732 console.log("Failed!")
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
733 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
734 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
735 if (self.DEFAULT_DATA["polarity"]) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
736 self.auto_set_polarity(self) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
737 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
738 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
739
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
740 auto_set_polarity: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
741 console.log("auto_set_polarity...") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
742 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
743 var id = "#add1spectrum-peaksMS-polarity-{{ TAB_INDEX_PLACEHOLDER }}" ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
744 var element = $(id) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
745 if (element.length) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
746 element.val(self.DEFAULT_DATA["polarity"]).change() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
747 console.log(`auto_set_polarity to ${self.DEFAULT_DATA["polarity"]} ok.`)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
748 } else {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
749 console.log("Failed!")
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
750 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
751 if (self.DEFAULT_DATA["resolution"]) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
752 self.auto_set_resolution(self) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
753 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
754 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
755
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
756 auto_set_resolution: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
757 console.log("auto_set_resolution...") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
758 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
759 var id = "#add1spectrum-peaksMS-resolution-{{ TAB_INDEX_PLACEHOLDER }}" ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
760 var element = $(id) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
761 if (element.length) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
762 element.val(self.DEFAULT_DATA["resolution"]).change() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
763 console.log(`auto_set_resolution to ${self.DEFAULT_DATA["resolution"]} ok.`)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
764 } else {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
765 console.log("Failed!")
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
766 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
767 if (self.DEFAULT_DATA["next"] || true) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
768 setTimeout(() => self.finish_initialized(self), 1000) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
769 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
770 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
771
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
772 finish_initialized: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
773 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
774 if (ctx() === self) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
775 self.initialized = true ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
776 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
777 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
778
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
779 //USED IN HTML
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
780 updateLCMSspectraViewer: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
781 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
782 var tab_no ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
783 console.log(`Updating spectral view for tab {{ TAB_INDEX_PLACEHOLDER }}`) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
784 // reset current viewer
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
785 $("#containter-lcms-spectrum-preview-{{ TAB_INDEX_PLACEHOLDER }}").empty();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
786 // reset data.
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
787
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
788 if (self.is_mix()) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
789 tab_no = 1 ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
790 } else {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
791 tab_no = {{ TAB_INDEX_PLACEHOLDER }} ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
792 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
793 var range_from = $(`#add1spectrum-peaksMS-rangeFrom-${tab_no}`) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
794 if ((spectrumMinPPM = Number(range_from.val())) == "") {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
795 spectrumMinPPM = 10000;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
796 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
797 var range_to = $(`#add1spectrum-peaksMS-rangeTo-${tab_no}`) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
798 if ((spectrumMaxPPM = Number(range_to.val())) == "") {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
799 spectrumMaxPPM = 0;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
800 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
801 maxGraph = 0;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
802 var localData = [];
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
803 var localDataAnnot = [];
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
804 // gather new data
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
805 // TODO switch tab in function of technic
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
806 $.each(self.hot_MS_Peaks.getData(), function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
807 if(this[0] != undefined && this[0] != "") {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
808 var x = (Number(this[0]));
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
809 var y = Number(this[2]);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
810 var a = this[6];
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
811 localData.push([(x-0.000001),-150]);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
812 localData.push([(x+0.000001),-150]);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
813 localData.push([x,y]);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
814 localDataAnnot[x] = a;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
815 if (x < spectrumMinPPM) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
816 spectrumMinPPM = x;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
817 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
818 if (x > spectrumMaxPPM) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
819 spectrumMaxPPM = x;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
820 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
821 if (y > maxGraph) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
822 maxGraph = y;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
823 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
824 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
825 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
826
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
827 // build new one
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
828 spectrumMinPPM = spectrumMinPPM - (0.1 * spectrumMinPPM);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
829 spectrumMaxPPM = spectrumMaxPPM + (0.1 * spectrumMaxPPM);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
830 maxGraph = maxGraph + (0.1 * maxGraph);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
831 localData.sort();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
832 console.log(localData)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
833 // build graph
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
834 $("#containter-lcms-spectrum-preview-{{ TAB_INDEX_PLACEHOLDER }}").highcharts({
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
835 chart: {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
836 zoomType: "x",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
837 spacingRight: 10,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
838 spacingLeft: 10,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
839 type: "scatter"
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
840 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
841 title: {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
842 text: "Spectrum Preview",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
843 useHTML: true
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
844 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
845 subtitle: {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
846 text: (
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
847 document.ontouchstart === undefined
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
848 ? "Select area"
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
849 : "Pinch the chart to zoom in"
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
850 )
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
851 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
852 xAxis: {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
853 type: "number",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
854 title: {text: "m/z"},
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
855 min: spectrumMinPPM,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
856 max: spectrumMaxPPM,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
857 labels: {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
858 formatter: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
859 return (Math.abs(this.value) + "");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
860 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
861 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
862 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
863 yAxis: {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
864 title: {text: "Relative Intensity (%)"},
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
865 min: 0,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
866 max: maxGraph
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
867 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
868 tooltip: {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
869 crosshairs: true,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
870 formatter: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
871 var compo = "";
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
872 return (
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
873 "<b>" + this.series.name
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
874 + "</b><br/>m/z:" + Math.abs(this.x) + ""
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
875 + ";<br/>Relative Intensity: " + this.y
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
876 + "%;<br/>Annotation: " + localDataAnnot[ this.x]
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
877 + ""
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
878 );
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
879 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
880 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
881 legend: {enabled: false},
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
882 plotOptions: {scatter: {}},
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
883 series: [{
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
884 name: "preview",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
885 showInLegend: true,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
886 color: "#f00",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
887 lineColor: "#f00",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
888 pointInterval: 10,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
889 pointStart: 100,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
890 lineWidth : 2,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
891 marker: {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
892 enabled: true,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
893 radius: 2,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
894 lineColor: "#f00"
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
895 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
896 data: localData,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
897 zIndex: 10
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
898 }]
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
899 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
900 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
901
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
902 //USED HERE
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
903 fulfillLCdata: function(jsonFileName) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
904 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
905 var url = `{{ PF_URL_PLACEHOLDER }}/webapp/resources/json/lc-methods/${jsonFileName}.json` ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
906 $.getJSON(url, function(json) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
907 // $.POST
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
908 console.log(json);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
909 // lc chromato
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
910 if (json.lc_chromatography != null) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
911 [
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
912 ["colConstructor", "column_constructor"],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
913 ["colConstructorOther", "column_constructor_other"],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
914 ["colName", "column_name"],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
915 ["colLength", "column_length"],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
916 ["colDiameter", "column_diameter"],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
917 ["colParticuleSize", "particule_size"],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
918 ["colTemperature", "column_temperature"],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
919 ["separationFlowRate", "separation_flow_rate"],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
920 ["separationSolvA", "separation_solvent_a"],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
921 ["separationSolvApH", "ph_solvent_a"],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
922 ["separationSolvB", "separation_solvent_b"],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
923 ["separationSolvBpH", "ph_solvent_b"]
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
924 ].forEach((arr) => {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
925 var el ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
926 console.log(arr)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
927 el = $(`#add1spectrum-chromatoLC-${arr[0]}-{{ TAB_INDEX_PLACEHOLDER }}`)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
928 el.val(json.lc_chromatography[arr[1]]) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
929 el.change()
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
930 })
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
931 try {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
932 $("#add1spectrum-chromatoLC-LCMode-{{ TAB_INDEX_PLACEHOLDER }}").val(json.lc_chromatography.LC_mode);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
933 $("#add1spectrum-chromatoLC-LCMode-{{ TAB_INDEX_PLACEHOLDER }}").change();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
934 } catch (e) {}
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
935 var handsontableSeparationFlowRateData = [] ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
936 if (json.lc_chromatography.separation_flow_gradient != null) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
937 $.each(json.lc_chromatography.separation_flow_gradient, function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
938 var e = [
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
939 "" + this.time,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
940 "" + this.solvA,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
941 "" + this.solvB
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
942 ];
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
943 handsontableSeparationFlowRateData.push(e);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
944 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
945 } else {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
946 handsontableSeparationFlowRateData = null;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
947 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
948 self.handsontableSeparationFlowRate(handsontableSeparationFlowRateData);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
949 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
950 // ms_analyzer
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
951 if (json.ms_analyzer != null) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
952 $("#add1spectrum-analyzer-ms-instrument-{{ TAB_INDEX_PLACEHOLDER }}").val(json.ms_analyzer.instrument);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
953 $("#add1spectrum-analyzer-ms-instrument-{{ TAB_INDEX_PLACEHOLDER }}").change();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
954 $("#add1spectrum-analyzer-ms-model-{{ TAB_INDEX_PLACEHOLDER }}").val(json.ms_analyzer.model);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
955 $("#add1spectrum-analyzer-ms-model-{{ TAB_INDEX_PLACEHOLDER }}").change();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
956 $("#add1spectrum-analyzer-ms-resolutionFWHM-{{ TAB_INDEX_PLACEHOLDER }}").val(json.ms_analyzer.resolution_FWHM);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
957 $("#add1spectrum-analyzer-ms-resolutionFWHM-{{ TAB_INDEX_PLACEHOLDER }}").change();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
958 $("#add1spectrum-analyzer-ms-ionAnalyzerType-{{ TAB_INDEX_PLACEHOLDER }}").val(json.ms_analyzer.ion_analyzer_type);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
959 $("#add1spectrum-analyzer-ms-ionAnalyzerType-{{ TAB_INDEX_PLACEHOLDER }}").change();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
960 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
961 if (json.molecule_ionization != null) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
962 ["pos", "neg"].forEach((mode) => {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
963 if (json.molecule_ionization[`mode_${mode}`] != null) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
964 [
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
965 ["ionizationMethod", "ionisation_method"],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
966 ["sprayGazFlow", "spray_gaz_flow"],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
967 ["vaporizerGazFlow", "vaporizer_gaz_flow"],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
968 ["vaporizerTemperature", "vaporizer_temperature"],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
969 ["sourceGazFlow", "source_gaz_flow"],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
970 ["ionTransferTubeTemperatureOrTransferCapillaryTemperature", "transfer_tube_or_capillary_temperature"],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
971 ["highVoltageOrCoronaVoltage", "voltage"],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
972 ].forEach((tuple) => {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
973 var el ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
974 var id = tuple[0] ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
975 var key = tuple[1] ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
976 el = $(`#add1spectrum-analyzserMS-${id}-${mode}-{{ TAB_INDEX_PLACEHOLDER }}`) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
977 console.log(el)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
978 el.val(json.molecule_ionization[`mode_${mode}`][key]);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
979 el.change() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
980 })
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
981 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
982 })
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
983 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
984
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
985 if (json.molecule_beamOrTrap != null) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
986 if (json.molecule_beamOrTrap.ion_beam != null) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
987 $("#add1spectrum-ionTrapBeam-type-{{ TAB_INDEX_PLACEHOLDER }}").val("beam").change();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
988 $("#add1spectrum-ionTrapBeam-ionGas-{{ TAB_INDEX_PLACEHOLDER }}").val(json.molecule_beamOrTrap.ion_beam.ion_gas).change();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
989 $("#add1spectrum-ionTrapBeam-ionGasPressureValue-{{ TAB_INDEX_PLACEHOLDER }}").val(json.molecule_beamOrTrap.ion_beam.ion_pressure_value).change();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
990 $("#add1spectrum-ionTrapBeam-ionGasPressureUnit-{{ TAB_INDEX_PLACEHOLDER }}").val(json.molecule_beamOrTrap.ion_beam.ion_pressure_unit).change();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
991 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
992 if (json.molecule_beamOrTrap.ion_trap != null) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
993 $("#add1spectrum-ionTrapBeam-type-{{ TAB_INDEX_PLACEHOLDER }}").val("trap").change();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
994 $("#add1spectrum-ionTrapBeam-ionGas-{{ TAB_INDEX_PLACEHOLDER }}").val(json.molecule_beamOrTrap.ion_trap.ion_gas).change();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
995 $("#add1spectrum-ionTrapBeam-ionGasPressureValue-{{ TAB_INDEX_PLACEHOLDER }}").val(json.molecule_beamOrTrap.ion_trap.ion_pressure_value).change();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
996 $("#add1spectrum-ionTrapBeam-ionGasPressureUnit-{{ TAB_INDEX_PLACEHOLDER }}").val(json.molecule_beamOrTrap.ion_trap.ion_pressure_unit).change();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
997 $("#add1spectrum-ionTrapBeam-ionNumber-{{ TAB_INDEX_PLACEHOLDER }}").val(json.molecule_beamOrTrap.ion_trap.ion_number).change();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
998 $("#add1spectrum-ionTrapBeam-ionFrequencyShift-{{ TAB_INDEX_PLACEHOLDER }}").val(json.molecule_beamOrTrap.ion_trap.ion_freq_shift).change();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
999 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1000 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1001 // other
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1002 if (json.other != null) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1003 $("#add1spectrum-other-author-{{ TAB_INDEX_PLACEHOLDER }}").val(json.other.data_authors);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1004 $("#add1spectrum-other-author-{{ TAB_INDEX_PLACEHOLDER }}").change();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1005 $("#add1spectrum-other-validator-{{ TAB_INDEX_PLACEHOLDER }}").val(json.other.data_validator);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1006 $("#add1spectrum-other-validator-{{ TAB_INDEX_PLACEHOLDER }}").change();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1007 $("#add1spectrum-other-date-{{ TAB_INDEX_PLACEHOLDER }}").val(json.other.acquisition_date);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1008 $("#add1spectrum-other-date-{{ TAB_INDEX_PLACEHOLDER }}").change();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1009 $("#add1spectrum-other-owner-{{ TAB_INDEX_PLACEHOLDER }}").val(json.other.data_ownership);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1010 $("#add1spectrum-other-owner-{{ TAB_INDEX_PLACEHOLDER }}").change();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1011 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1012 }).error(function(event, jqxhr, exception) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1013 if (event.status == 404) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1014 $("#alertBoxSelectTemplate-{{ TAB_INDEX_PLACEHOLDER }}").html(`
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1015 <div class="alert alert-danger alert-dismissible" role="alert">
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1016 <button type="button" class="close" data-dismiss="alert">
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1017 <span aria-hidden="true">&times;</span>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1018 <span class="sr-only"><spring:message code="alert.close" text="Close" /></span>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1019 </button>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1020 <strong>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1021 <spring:message code="alert.strong.error" text="Error!" />
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1022 </strong> unable to load pre-filled data!
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1023 </div>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1024 `);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1025 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1026 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1027 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1028
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1029 //USED HERE
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1030 resetFromColors: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1031
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1032 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1033 $.each($(self.prefix+".add1spectrum"), function(id, elem) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1034 element = $(elem)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1035 self.rm_success(element) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1036 self.rm_warning(element) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1037 self.rm_error(element) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1038 if ($(elem).hasClass("is-mandatory") && ($(elem).val() == "" || $(elem).val() == null)) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1039 self.set_error($(elem)) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1040 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1041 if ($(elem).hasClass("is-optional") && ($(elem).val() == "" || $(elem).val() == null)) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1042 self.set_warning($(elem)) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1043 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1044 if ($(elem).val() != "" && $(elem).val() != null) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1045 self.set_success($(elem)) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1046 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1047 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1048 $.each($(self.prefix+"button.switchStep"), function(id, elem) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1049 if (!$(this).hasClass("btn-disabled")) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1050 $(this).addClass("btn-disabled");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1051 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1052 if ($(this).hasClass("btn-primary")) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1053 $(this).removeClass("btn-primary");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1054 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1055 $(this).prop("disabled", true);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1056 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1057
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1058 // peak list: no data to check
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1059 $("#btnSwitch-gotoStep5-ms-{{ TAB_INDEX_PLACEHOLDER }}").removeClass("btn-disabled");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1060 $("#btnSwitch-gotoStep5-ms-{{ TAB_INDEX_PLACEHOLDER }}").addClass("btn-primary");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1061 $("#btnSwitch-gotoStep5-ms-{{ TAB_INDEX_PLACEHOLDER }}").prop("disabled", false);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1062
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1063 $("#add1spectrum-other-author-{{ TAB_INDEX_PLACEHOLDER }}").prop("disabled", false);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1064 $("#add1spectrum-other-validator-{{ TAB_INDEX_PLACEHOLDER }}").prop("disabled", false);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1065 $("#add1spectrum-other-date-{{ TAB_INDEX_PLACEHOLDER }}").prop("disabled", false);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1066 $("#add1spectrum-other-owner-{{ TAB_INDEX_PLACEHOLDER }}").prop("disabled", false);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1067 $("#add1spectrum-other-fileName-{{ TAB_INDEX_PLACEHOLDER }}").prop("disabled", false);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1068 $("#add1spectrum-other-fileSize-{{ TAB_INDEX_PLACEHOLDER }}").prop("disabled", false);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1069 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1070
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1071 //USED IN HTML
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1072 switchToStep: function(step) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1073
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1074 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1075 switch(step) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1076 case 2:
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1077 // hide after step 2 / alt step 2
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1078 $("#add1spectrum-chromatographyData-LC-{{ TAB_INDEX_PLACEHOLDER }}").hide();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1079 $("#add1spectrum-chromatographyData-GC-{{ TAB_INDEX_PLACEHOLDER }}").hide();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1080 $("#add1spectrum-analyserData-MS-{{ TAB_INDEX_PLACEHOLDER }}").hide();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1081 $("#add1spectrum-peaksData-MS-{{ TAB_INDEX_PLACEHOLDER }}").hide();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1082 $("#add1spectrum-otherData-{{ TAB_INDEX_PLACEHOLDER }}").hide();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1083 if ($("#step1sign-{{ TAB_INDEX_PLACEHOLDER }}").hasClass("fa-question-circle")) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1084 $("#step1sign-{{ TAB_INDEX_PLACEHOLDER }}").removeClass("fa-question-circle").addClass("fa-check-circle");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1085 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1086 if (self.is_ms()) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1087 $("#add1spectrum-chromatoLC-method-{{ TAB_INDEX_PLACEHOLDER }}").empty();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1088 $("#add1spectrum-chromatoLC-method-{{ TAB_INDEX_PLACEHOLDER }}").append(
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1089 '<option value="" selected="selected" disabled="disabled">choose in list&hellip;</option>'
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1090 );
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1091 $.getJSON("{{ PF_URL_PLACEHOLDER }}/webapp/resources/json/list-lc-methods.json", function(data) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1092 // load data from json
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1093 $.each(data.methods,function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1094 if (this.name !== undefined) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1095 if (this.value !== undefined) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1096 $("#add1spectrum-chromatoLC-method-{{ TAB_INDEX_PLACEHOLDER }}").append(
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1097 `<option value="${this.value}">${this.name}</option>`
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1098 );
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1099 } else {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1100 $("#add1spectrum-chromatoLC-method-{{ TAB_INDEX_PLACEHOLDER }}").append(
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1101 `<option disabled>${this.name}</option>`
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1102 );
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1103 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1104 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1105 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1106 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1107 } else if (self.is_ms2()) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1108 $("#add1spectrum-chromatoLC-method-{{ TAB_INDEX_PLACEHOLDER }}").empty();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1109 $("#add1spectrum-chromatoLC-method-{{ TAB_INDEX_PLACEHOLDER }}").append(
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1110 '<option value="" selected="selected" disabled="disabled">choose in list&hellip;</option>'
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1111 );
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1112 $.getJSON(
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1113 "{{ PF_URL_PLACEHOLDER }}/webapp/resources/json/list-lc-msms-methods.json",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1114 function(data) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1115 // load data from json
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1116 $.each(data.methods, function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1117 if (this.name !== undefined) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1118 if (this.value !== undefined) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1119 $("#add1spectrum-chromatoLC-method-{{ TAB_INDEX_PLACEHOLDER }}").append(
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1120 `<option value="${this.value}">${this.name}</option>`
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1121 );
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1122 } else {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1123 $("#add1spectrum-chromatoLC-method-{{ TAB_INDEX_PLACEHOLDER }}").append(
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1124 `<option disabled>${this.name}</option>`
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1125 );
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1126 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1127 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1128 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1129 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1130 );
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1131 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1132 // check panel to show
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1133 if (self.isLC) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1134 $("#add1spectrum-chromatographyData-LC-{{ TAB_INDEX_PLACEHOLDER }}").show();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1135 $("#linkActivateStep2-lc-{{ TAB_INDEX_PLACEHOLDER }}").trigger("click");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1136 var sign = $("#step2-lc-sign-{{ TAB_INDEX_PLACEHOLDER }}") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1137 self.rm_class(sign, "fa-check-circle") && self.set_class(sign, "fa-question-circle") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1138 if (!self.isSeparationFlowRateInit) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1139 self.handsontableSeparationFlowRate(null);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1140 self.isSeparationFlowRateInit = true;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1141 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1142 } else if (self.isGC) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1143 $("#add1spectrum-chromatographyData-GC-{{ TAB_INDEX_PLACEHOLDER }}").show();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1144 $("#linkActivateStep2-gc-{{ TAB_INDEX_PLACEHOLDER }}").trigger("click");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1145 var sign = $("#step2-gc-sign-{{ TAB_INDEX_PLACEHOLDER }}") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1146 sign.removeClass("fa-check-circle").addClass("fa-question-circle");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1147 if ($("#step2-gc-sign-{{ TAB_INDEX_PLACEHOLDER }}").hasClass("fa-check-circle")) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1148 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1149 } else if (self.isIC) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1150 $("#add1spectrum-chromatographyData-IC-{{ TAB_INDEX_PLACEHOLDER }}").show();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1151 $("#linkActivateStep2-ic-{{ TAB_INDEX_PLACEHOLDER }}").trigger("click");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1152 if ($("#step2-ic-sign-{{ TAB_INDEX_PLACEHOLDER }}").hasClass("fa-check-circle")) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1153 $("#step2-ic-sign-{{ TAB_INDEX_PLACEHOLDER }}").removeClass("fa-check-circle").addClass("fa-question-circle");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1154 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1155 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1156 break;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1157 case 3:
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1158 // hide after step 3 / alt step 3
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1159 $("#add1spectrum-analyserData-MS-{{ TAB_INDEX_PLACEHOLDER }}").hide();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1160 $("#add1spectrum-peaksData-MS-{{ TAB_INDEX_PLACEHOLDER }}").hide();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1161 $("#add1spectrum-otherData-{{ TAB_INDEX_PLACEHOLDER }}").hide();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1162 // step 2 ok
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1163 if ($("#step2-lc-sign-{{ TAB_INDEX_PLACEHOLDER }}").hasClass("fa-question-circle")) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1164 $("#step2-lc-sign-{{ TAB_INDEX_PLACEHOLDER }}").removeClass("fa-question-circle").addClass("fa-check-circle");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1165 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1166 if ($("#step2-gc-sign-{{ TAB_INDEX_PLACEHOLDER }}").hasClass("fa-question-circle")) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1167 $("#step2-gc-sign-{{ TAB_INDEX_PLACEHOLDER }}").removeClass("fa-question-circle").addClass("fa-check-circle");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1168 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1169 // check panel to show
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1170 if (self.is_ms() || self.is_ms2()) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1171 $("#add1spectrum-analyserData-MS-{{ TAB_INDEX_PLACEHOLDER }}").show();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1172 $("#linkActivateStep3-ms-{{ TAB_INDEX_PLACEHOLDER }}").trigger('click');
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1173 // debug display
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1174 [
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1175 "add1spectrum-analyzserMS-sprayGazFlow-pos",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1176 "add1spectrum-analyzserMS-sprayGazFlow-neg",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1177 "add1spectrum-analyzserMS-vaporizerGazFlow-pos",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1178 "add1spectrum-analyzserMS-vaporizerGazFlow-neg",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1179 "add1spectrum-analyzserMS-vaporizerTemperature-pos",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1180 "add1spectrum-analyzserMS-vaporizerTemperature-neg",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1181 "add1spectrum-analyzserMS-sourceGazFlow-pos",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1182 "add1spectrum-analyzserMS-sourceGazFlow-neg",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1183 "add1spectrum-analyzserMS-ionTransferTubeTemperatureOrTransferCapillaryTemperature-pos",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1184 "add1spectrum-analyzserMS-ionTransferTubeTemperatureOrTransferCapillaryTemperature-neg",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1185 "add1spectrum-analyzserMS-highVoltageOrCoronaVoltage-pos",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1186 "add1spectrum-analyzserMS-highVoltageOrCoronaVoltage-neg"
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1187 ].forEach((id) => {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1188 var element = $(`#id-{{ TAB_INDEX_PLACEHOLDER }}`)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1189 element.height(element.parent().children("span").height())
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1190 })
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1191 if ($("#step3-ms-sign-{{ TAB_INDEX_PLACEHOLDER }}").hasClass("fa-check-circle")) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1192 $("#step3-ms-sign-{{ TAB_INDEX_PLACEHOLDER }}").removeClass("fa-check-circle").addClass("fa-question-circle");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1193 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1194 // MSMS only
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1195 $(self.prefix+".enable-if-ms").attr("disabled", !self.is_ms());
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1196 $(self.prefix+".enable-if-msms").attr("disabled", !self.is_ms2());
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1197 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1198 // avoid display bug
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1199 $("#add1spectrum-analyzer-ms-instrument-{{ TAB_INDEX_PLACEHOLDER }}").change();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1200 break;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1201 case 4:
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1202 // hide after step 4 / alt step 4
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1203 $("#add1spectrum-peaksData-MS-{{ TAB_INDEX_PLACEHOLDER }}").hide();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1204 $("#add1spectrum-otherData-{{ TAB_INDEX_PLACEHOLDER }}").hide();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1205 // step 3 ok
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1206 if ($("#step3-ms-sign-{{ TAB_INDEX_PLACEHOLDER }}").hasClass("fa-question-circle")) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1207 $("#step3-ms-sign-{{ TAB_INDEX_PLACEHOLDER }}").removeClass("fa-question-circle").addClass("fa-check-circle");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1208 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1209 if (self.is_ms() || self.is_ms2()) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1210 $("#add1spectrum-peaksData-MS-{{ TAB_INDEX_PLACEHOLDER }}").show();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1211 $("#linkActivateStep4-ms-{{ TAB_INDEX_PLACEHOLDER }}").trigger("click");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1212 if ($("#step4-ms-sign-{{ TAB_INDEX_PLACEHOLDER }}").hasClass("fa-check-circle")) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1213 $("#step4-ms-sign-{{ TAB_INDEX_PLACEHOLDER }}").removeClass("fa-check-circle").addClass("fa-question-circle");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1214 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1215 // LC MS
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1216 if (!self.isMSpeaksInit) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1217 console.log(`self.is_mix(): ${self.is_mix()}`)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1218 if (self.is_mix()) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1219 all_contexts.forEach((context, index) => {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1220 if (context === null) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1221 return;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1222 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1223 context.handsontableMSpeaks(null) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1224 context.updateLCMSspectraViewer() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1225 context.isMSpeaksInit = true;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1226 $(context.prefix+".add1spectrum-peaksMSForm-peaklist-reset").val("").change();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1227 })
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1228 } else {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1229 self.handsontableMSpeaks(null);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1230 self.isMSpeaksInit = true;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1231 $(self.prefix+".add1spectrum-peaksMSForm-peaklist-reset").val("").change();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1232 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1233 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1234 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1235 // show ms tab
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1236 setTimeout(() => $("#container_MS_Peaks-{{ TAB_INDEX_PLACEHOLDER }}").trigger("click"), 250);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1237 $("#add1spectrum-peaksMS-msLevel-{{ TAB_INDEX_PLACEHOLDER }}").change();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1238 break;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1239 case 5:
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1240 // hide after step 5 / alt step 5
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1241 $("#add1spectrum-otherData-{{ TAB_INDEX_PLACEHOLDER }}").hide();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1242 // step 4 ok
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1243 if ($("#step4-ms-sign-{{ TAB_INDEX_PLACEHOLDER }}").hasClass("fa-question-circle")) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1244 $("#step4-ms-sign-{{ TAB_INDEX_PLACEHOLDER }}").removeClass("fa-question-circle").addClass("fa-check-circle");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1245 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1246 if ($("#step5sign-{{ TAB_INDEX_PLACEHOLDER }}").hasClass("fa-check-circle")) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1247 $("#step5sign-{{ TAB_INDEX_PLACEHOLDER }}").removeClass("fa-check-circle").addClass("fa-question-circle");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1248 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1249 $("#add1spectrum-otherData-{{ TAB_INDEX_PLACEHOLDER }}").show();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1250 $("#linkActivateStep5-{{ TAB_INDEX_PLACEHOLDER }}").trigger("click");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1251 // reset step 6 button
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1252 self.checkIfEnableSubmit();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1253 $("#import1SpectrumLoadingBare-{{ TAB_INDEX_PLACEHOLDER }}").hide();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1254 $("#import1SpectrumResults-{{ TAB_INDEX_PLACEHOLDER }}").hide();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1255 break;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1256 case 6:
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1257 self.postOneSpectrumFrom();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1258 self.cptPeakListTab++;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1259 break;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1260 case 7:
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1261 self.dumpOneSpectrumFrom();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1262 break;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1263 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1264 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1265
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1266 //USED HERE
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1267 resetElemColor: function(idElem) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1268
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1269 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1270 if ($(`#${idElem}`).parent().hasClass("has-success")) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1271 $(`#${idElem}`).parent().removeClass("has-success") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1272 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1273 if ($(`#${idElem}`).parent().hasClass("has-warning")) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1274 $(`#${idElem}`).parent().removeClass("has-warning") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1275 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1276 if ($(`#${idElem}`).parent().hasClass("has-error")) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1277 $(`#${idElem}`).parent().removeClass("has-error") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1278 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1279 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1280
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1281 //USED HERE
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1282 disableElem: function(idElem) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1283
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1284 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1285 $(`#${idElem}`).prop("disabled", true) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1286 $(`#${idElem}`).val("") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1287 if ($(`#${idElem}`).hasClass("is-mandatory")) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1288 $(`#${idElem}`).removeClass("is-mandatory") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1289 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1290 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1291
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1292 //USED HERE
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1293 enableElem: function(idElem) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1294
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1295 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1296 $(`#${idElem}`).prop("disabled", false) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1297 $(`#${idElem}`).parent().addClass("has-error") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1298 if (!$(`#${idElem}`).hasClass("is-mandatory")) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1299 $(`#${idElem}`).addClass("is-mandatory") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1300 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1301 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1302
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1303 //USED HERE
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1304 checkIfEnableSubmit: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1305
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1306 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1307 var isBtnStep6OK = true;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1308 $.each($(self.prefix+".add1spectrum-otherForm"), (id, elem) => {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1309 if (self.is_error($(elem)) && $(elem).is(":visible")) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1310 isBtnStep6OK = false;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1311 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1312 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1313 if (isBtnStep6OK) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1314 self.rm_class($("#btnSwitch-gotoStep6-{{ TAB_INDEX_PLACEHOLDER }}"), "btn-disabled") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1315 self.set_class($("#btnSwitch-gotoStep6-{{ TAB_INDEX_PLACEHOLDER }}"), "btn-primary") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1316 $("#btnSwitch-gotoStep6-{{ TAB_INDEX_PLACEHOLDER }}").prop("disabled", false);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1317 self.rm_class($("#btnSwitch-gotoStep7-{{ TAB_INDEX_PLACEHOLDER }}"), "btn-disabled") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1318 self.set_class($("#btnSwitch-gotoStep7-{{ TAB_INDEX_PLACEHOLDER }}"), "btn-primary") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1319 $("#btnSwitch-gotoStep7-{{ TAB_INDEX_PLACEHOLDER }}").prop("disabled", false);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1320 } else {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1321 if (!$("#btnSwitch-gotoStep6-{{ TAB_INDEX_PLACEHOLDER }}").hasClass("btn-disabled")) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1322 $("#btnSwitch-gotoStep6-{{ TAB_INDEX_PLACEHOLDER }}").addClass("btn-disabled");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1323 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1324 if ($("#btnSwitch-gotoStep6-{{ TAB_INDEX_PLACEHOLDER }}").hasClass("btn-primary")) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1325 $("#btnSwitch-gotoStep6-{{ TAB_INDEX_PLACEHOLDER }}").removeClass("btn-primary");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1326 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1327 $("#btnSwitch-gotoStep6-{{ TAB_INDEX_PLACEHOLDER }}").prop("disabled", true);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1328 if (!$("#btnSwitch-gotoStep7-{{ TAB_INDEX_PLACEHOLDER }}").hasClass("btn-disabled")) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1329 $("#btnSwitch-gotoStep7-{{ TAB_INDEX_PLACEHOLDER }}").addClass("btn-disabled");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1330 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1331 if ($("#btnSwitch-gotoStep7-{{ TAB_INDEX_PLACEHOLDER }}").hasClass("btn-primary")) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1332 $("#btnSwitch-gotoStep7-{{ TAB_INDEX_PLACEHOLDER }}").removeClass("btn-primary");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1333 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1334 $("#btnSwitch-gotoStep7-{{ TAB_INDEX_PLACEHOLDER }}").prop("disabled", true);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1335 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1336 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1337
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1338 //USED IN HTML
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1339 addOneSpectrum: function(type) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1340
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1341 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1342 // unlock
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1343 $(self.prefix+".add1spectrum-sampleForm").prop("disabled", false);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1344 $(self.prefix+".add1spectrum-chromatoLCForm").prop("disabled", false);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1345 $(self.prefix+".add1spectrum-analyzerMSForm").prop("disabled", false);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1346 $(self.prefix+".add1spectrum-otherForm").prop("disabled", false);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1347 $("#add1spectrum-chromatoLC-colConstructor-{{ TAB_INDEX_PLACEHOLDER }}").change();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1348 // reset
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1349 self.isLC = false;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1350 self.isGC = false;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1351 self.isIC = false;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1352 $("#alertBoxSubmitSpectrum-{{ TAB_INDEX_PLACEHOLDER }}").html("");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1353 // hide in all steps
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1354 $(self.prefix+".opt-ms").hide();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1355 $(self.prefix+".opt-msms").hide();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1356 // hide step 2
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1357 $("#add1spectrum-chromatographyData-LC-{{ TAB_INDEX_PLACEHOLDER }}").hide();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1358 $("#add1spectrum-chromatographyData-GC-{{ TAB_INDEX_PLACEHOLDER }}").hide();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1359 // hide step 3
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1360 $("#add1spectrum-analyserData-MS-{{ TAB_INDEX_PLACEHOLDER }}").hide();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1361 $(self.prefix+".add1spectrum-ionTrap").hide();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1362 // hide step 4
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1363 $("#add1spectrum-peaksData-MS-{{ TAB_INDEX_PLACEHOLDER }}").hide();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1364 // hide step 5
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1365 $("#add1spectrum-otherData-{{ TAB_INDEX_PLACEHOLDER }}").hide();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1366 // reset field step 1
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1367 $("#add1spectrum-sample-type-{{ TAB_INDEX_PLACEHOLDER }}").val("");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1368 $(self.prefix+".add1spectrum-sample-type-panel").hide();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1369 $(self.prefix+".add1spectrum-sampleForm").val("");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1370 $("#sample-bonus-display-{{ TAB_INDEX_PLACEHOLDER }}").html("");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1371 // reset field step 2
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1372 $(self.prefix+".add1spectrum-chromatoLCForm").val("");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1373 // reset field step 3
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1374 $(self.prefix+".add1spectrum-analyzerMSForm").val("");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1375 // reset field step 4
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1376 // reset peak lists / all tabs
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1377 self.isSeparationFlowRateInit = false;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1378 self.isMSpeaksInit = false;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1379 $(self.prefix+".handsontable").html("");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1380 // reset field step 5 => NO!
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1381 // set icon
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1382 $("#step0sign-{{ TAB_INDEX_PLACEHOLDER }}").removeClass("fa-question-circle").addClass("fa-check-circle");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1383 if ($("#step1sign-{{ TAB_INDEX_PLACEHOLDER }}").hasClass("fa-check-circle")) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1384 $("#step1sign-{{ TAB_INDEX_PLACEHOLDER }}").removeClass("fa-check-circle").addClass("fa-question-circle");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1385 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1386 // collapse step 0 / uncollaspe step 1
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1387 $("#linkActivateStep1-{{ TAB_INDEX_PLACEHOLDER }}").trigger("click");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1388 // show step 1 content
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1389 $("#add1spectrum-sampleData-{{ TAB_INDEX_PLACEHOLDER }}").show();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1390 switch(type) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1391 case 1:
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1392 // TODO GC-MS stuff
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1393 self.isGC = true;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1394 break;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1395 case 2:
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1396 // LC-MS stuff
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1397 self.isLC = true;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1398 $(self.prefix+".opt-ms").show();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1399 break;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1400 case 5:
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1401 // LC-MSMS stuff
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1402 self.isLC = true;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1403 $(self.prefix+".opt-ms").show();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1404 $(self.prefix+".opt-msms").show();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1405 break;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1406 case 6:
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1407 // IC-MS stuff
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1408 self.isIC = true;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1409 $(self.prefix+".opt-ms").show();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1410 break;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1411 case 7:
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1412 // IC-MSMS stuff
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1413 self.isIC = true;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1414 $(self.prefix+".opt-ms").show();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1415 $(self.prefix+".opt-msms").show();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1416 break;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1417 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1418 self.resetFromColors();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1419 // reset json obj to submit form
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1420 self.jsonSpectrumType = null;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1421 self.isJsonSpectrumTypeComplete = false;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1422 self.jsonSample = null;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1423 self.isJsonSampleComplete = false;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1424 self.isJsonRCCaddedComplete = false;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1425 self.jsonChromato = null;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1426 self.isJsonChromatoComplete = false;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1427 self.jsonAnalyzer = null;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1428 self.isJsonAnalyzerComplete = false;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1429 self.jsonPeaksList = [];
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1430 self.isJsonPeaksListComplete = false;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1431 self.jsonOtherMetadata = null;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1432 self.isJsonOtherMetadataComplete = false;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1433
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1434 self.cptPeakListTab = 0;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1435 self.jsonAnalyzerAcquisition = [];
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1436 self.idMetadataMap = {}
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1437 self.listOfViewableSpectra = [];
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1438
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1439 // spec MS
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1440 self.jsonMolIonization = null;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1441
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1442 // spec MSMS
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1443 self.jsonMolIonBeam = null;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1444
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1445 // try load cpd
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1446 if (self.inchikey !== null) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1447 self.loadJSCompound(self.inchikey);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1448 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1449 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1450
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1451 //USED HERE
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1452 loadJSCompound: function(inchikey) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1453 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1454
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1455 $("#add1spectrum-sample-type-{{ TAB_INDEX_PLACEHOLDER }}").val("compound-ref");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1456 $("#add1spectrum-sample-type-{{ TAB_INDEX_PLACEHOLDER }}").change();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1457 $("#add1spectrum-sample-inchikey-{{ TAB_INDEX_PLACEHOLDER }}").val(inchikey);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1458 $("#add1spectrum-sample-inchikey-{{ TAB_INDEX_PLACEHOLDER }}").change();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1459 if (inchidata[inchikey] !== null) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1460 return (set_inchi_data(inchidata[inchikey]), {{ TAB_INDEX_PLACEHOLDER }}) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1461 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1462 $.ajax({
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1463 type: "get",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1464 url: "{{ PF_URL_PLACEHOLDER }}/webapp/get-cpd-data",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1465 data: "inchikey="+inchikey,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1466 dataType: "json",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1467 success: function(data) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1468 if (data.success) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1469 set_inchi_data(data) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1470 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1471 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1472 error : function(data) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1473 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1474 }).always(function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1475 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1476 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1477
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1478 //USED HERE
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1479 handsontableSeparationFlowRate: function(data) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1480 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1481
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1482 // reset
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1483 $("#container_LC_SFG-{{ TAB_INDEX_PLACEHOLDER }}").html("");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1484 // init
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1485 var data_LC_SFG;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1486 if (data==null) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1487 data_LC_SFG = [
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1488 [ "", "", "" ],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1489 [ "", "", "" ],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1490 [ "", "", "" ],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1491 [ "", "", "" ],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1492 [ "", "", "" ],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1493 [ "", "", "" ],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1494 [ "", "", "" ],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1495 [ "", "", "" ],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1496 [ "", "", "" ],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1497 ];
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1498 } else {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1499 data_LC_SFG = data;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1500 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1501
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1502 var container_LC_SFG = document.getElementById("container_LC_SFG-{{ TAB_INDEX_PLACEHOLDER }}");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1503 self.hot_LC_SFG = new Handsontable(container_LC_SFG, {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1504 data : data_LC_SFG,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1505 minSpareRows : 1,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1506 colHeaders : true,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1507 colHeaders: ["time (min)", "solv. A (%)", "solv. B (%)"],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1508 contextMenu : false
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1509 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1510 Handsontable.Dom.addEvent(document.body, "click", function(e) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1511 var element = e.target || e.srcElement;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1512 if (element.nodeName == "BUTTON"&& element.name == "dump") {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1513 var name = element.getAttribute("data-dump");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1514 var instance = element.getAttribute("data-instance");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1515 self.hot_LC_SFG = window[instance];
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1516 console.log("data of " + name, self.hot_LC_SFG.getData());
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1517 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1518 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1519 $("#container_LC_SFG table.htCore-{{ TAB_INDEX_PLACEHOLDER }}").css("width","100%");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1520 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1521
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1522 //USED HERE
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1523 handsontableMSpeaks: function(data) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1524 console.log("handsontableMSpeaks")
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1525 console.log(data)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1526 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1527 var data_MS_Peaks ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1528 var container_MS_Peaks ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1529
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1530 if (data != null) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1531 data_MS_Peaks = data;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1532 } else {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1533 data_MS_Peaks = JSON.parse(JSON.stringify(self.DEFAULT_MS_PEAK_VALUES));
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1534 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1535 $("#container_MS_Peaks-{{ TAB_INDEX_PLACEHOLDER }}").html("");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1536 container_MS_Peaks = document.getElementById(
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1537 "container_MS_Peaks-{{ TAB_INDEX_PLACEHOLDER }}"
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1538 );
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1539 var colHeaders = [
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1540 "m/z", "absolute intensity", "relative intensity (%)", "delta (ppm)",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1541 "composition", "attribution", "Validated"
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1542 ]
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1543 var columns = [
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1544 {type: "numeric", format: "0.0000"},
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1545 {type: "numeric", format: "0.00"},
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1546 {type: "numeric", format: "0.00"},
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1547 {type: "numeric", format: "0.0000"},
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1548 {type: "text"},
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1549 {type: "text"},
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1550 {type: "checkbox"}
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1551 ] ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1552 if (self.is_ms2()) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1553 colHeaders.push("Parent ion") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1554 columns.push({type: "checkbox"}) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1555 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1556 self.hot_MS_Peaks = new Handsontable(container_MS_Peaks, {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1557 data: data_MS_Peaks,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1558 minSpareRows: 1,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1559 colHeaders: true,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1560 colHeaders: colHeaders,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1561 contextMenu: false,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1562 maxRows: data_MS_Peaks.length,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1563 minRows: data_MS_Peaks.length,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1564 columns: columns,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1565 afterChange: function(changes) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1566 if (self.lock.precursor_ion) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1567 return ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1568 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1569 self.lock.precursor_ion = true ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1570 try {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1571 changes?.forEach(([row, prop, old, value]) => {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1572 var data ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1573 var precursor_ion ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1574
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1575 var data = self.hot_MS_Peaks.getData() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1576 if (prop !== 7 || value !== true || data === undefined) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1577 return ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1578 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1579 for (var i = 0; i < data.length ; i += 1) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1580 data[i][7] = false ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1581 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1582 data[row][7] = true ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1583 precursor_ion = $(`#add1spectrum-peaksMS-msPrecursorIon-{{ TAB_INDEX_PLACEHOLDER }}`) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1584 console.log(`setting preco ion to ${data[row][0]}`) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1585 precursor_ion.val(data[row][0]) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1586 precursor_ion.change() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1587 self.hot_MS_Peaks.render() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1588 })
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1589 } finally {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1590 self.lock.precursor_ion = false ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1591 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1592 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1593 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1594 Handsontable.Dom.addEvent(document.body, "click", (e) => {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1595 var element ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1596 var name ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1597 var instance ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1598
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1599 element = e.target || e.srcElement ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1600 if (element.nodeName == "BUTTON" && element.name == "dump") {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1601 name = element.getAttribute("data-dump") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1602 instance = element.getAttribute("data-instance") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1603 self.hot_MS_Peaks = window[instance] ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1604 console.log("data of " + name, self.hot_MS_Peaks.getData()) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1605 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1606 }) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1607
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1608 $("#container_MS_Peaks-{{ TAB_INDEX_PLACEHOLDER }} table.htCore").css(
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1609 "width","100%"
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1610 ) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1611 if (self.is_ms2()) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1612 setTimeout(() => self.select_precursor_ion(), 200) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1613 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1614 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1615
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1616 change_tab: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1617 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1618 setTimeout(() => self.auto_select_ion_parent(), 1000) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1619 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1620
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1621 auto_select_ion_parent: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1622 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1623 if (!self.a_ion_parent_is_selected()) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1624 setTimeout(() => self.select_precursor_ion(), 1000) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1625 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1626 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1627
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1628 select_precursor_ion: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1629 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1630 var data ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1631 var precuirsor_ion ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1632
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1633 if (self.hot_MS_Peaks == null) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1634 return setTimeout(() => self.select_precursor_ion(), 200) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1635 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1636 console.log("Selecting ion preco for tab {{ TAB_INDEX_PLACEHOLDER }}")
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1637 data = self.hot_MS_Peaks.getData() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1638 for (var i = 0 ; i < data.length ; i += 1) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1639 if (data[i][5] === "[M+H]+" || data[i][5] === "[M+H]-" || data[i][2] == 100.0) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1640 precursor_ion = $("#add1spectrum-peaksMS-msPrecursorIon-{{ TAB_INDEX_PLACEHOLDER }}") ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1641 precursor_ion.val(data[i][0]) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1642 precursor_ion.change() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1643 return ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1644 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1645 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1646 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1647
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1648 sync_precursor_ion: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1649 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1650 var data ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1651
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1652 if (self.lock.precursor_ion || self.hot_MS_Peaks == undefined) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1653 return ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1654 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1655 self.lock.precursor_ion = true ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1656 console.log("Syncing precursor ion")
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1657 var val = $("#add1spectrum-peaksMS-msPrecursorIon-{{ TAB_INDEX_PLACEHOLDER }}").val() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1658 var data = self.hot_MS_Peaks.getData() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1659 for (var i = 0; i < data.length ; i += 1) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1660 if (Math.abs(data[i][0] - val) < 0.0001) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1661 for (var j = 0; j < data.length ; j += 1) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1662 data[j][7] = false ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1663 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1664 data[i][7] = true ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1665 self.hot_MS_Peaks.render() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1666 return ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1667 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1668 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1669 self.lock.precursor_ion = false ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1670 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1671
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1672 // USED HERE
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1673 handsontableRefChemCpdAdded: function(data) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1674 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1675 // reset
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1676 $("#container_RCC_ADDED-{{ TAB_INDEX_PLACEHOLDER }}").html("");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1677 $("#sample-bonus-display-{{ TAB_INDEX_PLACEHOLDER }}").html("");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1678 // init
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1679 var data_RCC_ADDED, colHeaderData, container_RCC_ADDED;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1680
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1681 colHeaderData = [
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1682 {data: "common name", type: "text"},
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1683 {data: "<b>InChIKey</b>", type: "text"},
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1684 {data: "composition", renderer: lightgrayRenderer},
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1685 {data: "<b>concentration (&micro;g/ml)</b>", type: "text"},
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1686 {data: "exact mass", renderer: lightgrayRenderer},
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1687 {data: "(M+H)+ or (M-H)-", renderer: lightgrayRenderer}
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1688 ] ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1689
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1690 if (data == null) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1691 data_RCC_ADDED = [
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1692 [ "", "", "","", "", "" ],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1693 [ "", "", "","", "", "" ],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1694 [ "", "", "","", "", "" ],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1695 [ "", "", "","", "", "" ],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1696 [ "", "", "","", "", "" ],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1697 [ "", "", "","", "", "" ],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1698 [ "", "", "","", "", "" ],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1699 [ "", "", "","", "", "" ],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1700 [ "", "", "","", "", "" ],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1701 [ "", "", "","", "", "" ],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1702 [ "", "", "","", "", "" ],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1703 [ "", "", "","", "", "" ],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1704 ];
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1705 } else {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1706 container_RCC_ADDED = data;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1707 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1708
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1709 container_RCC_ADDED = document.getElementById("container_RCC_ADDED-{{ TAB_INDEX_PLACEHOLDER }}");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1710 self.hot_RCC_ADDED = new Handsontable(container_RCC_ADDED, {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1711 data: data_RCC_ADDED,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1712 minSpareRows : 1,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1713 colHeaders : true,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1714 colHeaders: [
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1715 "common name",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1716 "<b>InChIKey</b>",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1717 "composition",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1718 "<b>concentration (&micro;g/ml)</b>",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1719 "exact mass",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1720 "(M+H)+ or (M-H)-"
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1721 ],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1722 contextMenu : false,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1723 columns: colHeaderData
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1724 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1725 function bindDumpButton_RCC_ADDED() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1726 Handsontable.Dom.addEvent(document.body, "click", (e) => {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1727 var element = e.target || e.srcElement;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1728 if (element.nodeName == "BUTTON"&& element.name == "dump") {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1729 var name = element.getAttribute("data-dump");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1730 var instance = element.getAttribute("data-instance");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1731 self.hot_RCC_ADDED = window[instance];
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1732 console.log("data of " + name, self.hot_RCC_ADDED.getData());
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1733 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1734 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1735 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1736 bindDumpButton_RCC_ADDED();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1737 $("#container_RCC_ADDED-{{ TAB_INDEX_PLACEHOLDER }} table.htCore").css("width","100%");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1738 // celect cell
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1739 self.hot_RCC_ADDED.selectCell(0, 0);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1740 // add select listener
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1741 self.hot_RCC_ADDED.addHook("afterSelection", (r, c) => self.hookSelection(r, c));
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1742 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1743
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1744 //USED HERE
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1745 hookSelection: function(r, c) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1746 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1747 if (c == 0 || c == 1 || c == 2)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1748 self.pickChemicalCompound4Mix(r);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1749 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1750
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1751 //USED HERE
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1752 postOneSpectrumFrom: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1753 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1754 $("#import1SpectrumLoadingBare-{{ TAB_INDEX_PLACEHOLDER }}").show();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1755
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1756 // II - form data -> json object
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1757 self.loadFomDataIntoJsonObjects();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1758 // II.A - check if json object complete
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1759 var alertMsg = self.getFormErrorMessage();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1760
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1761 if (alertMsg != "") {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1762 $("#alertBoxSubmitSpectrum-{{ TAB_INDEX_PLACEHOLDER }}").html(alertMsg);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1763 $("#import1SpectrumLoadingBare-{{ TAB_INDEX_PLACEHOLDER }}").hide();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1764 return false;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1765 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1766 // all OK: lock!
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1767 // lock sample
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1768 $(self.prefix+".add1spectrum-sampleForm").prop("disabled", true);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1769 // lock chromato
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1770 $(self.prefix+".add1spectrum-chromatoLCForm").prop("disabled", true);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1771 if (!$("#container_LC_SFG-{{ TAB_INDEX_PLACEHOLDER }}").is(":empty")) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1772 self.hot_LC_SFG.updateSettings({
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1773 cells: function(row, col, prop) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1774 var cellProperties = {};
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1775 cellProperties.readOnly = true;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1776 return cellProperties;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1777 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1778 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1779 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1780 if (!$("#container_MS_Peaks-{{ TAB_INDEX_PLACEHOLDER }}").is(":empty")) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1781 self.hot_MS_Peaks.updateSettings({
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1782 cells: function(row, col, prop) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1783 var cellProperties = {};
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1784 cellProperties.readOnly = true;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1785 return cellProperties;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1786 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1787 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1788 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1789 if (!$("#container_RCC_ADDED-{{ TAB_INDEX_PLACEHOLDER }}").is(":empty")) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1790 self.hot_RCC_ADDED.updateSettings({
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1791 cells: function(row, col, prop) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1792 var cellProperties = {};
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1793 cellProperties.readOnly = true;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1794 return cellProperties;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1795 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1796 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1797 self.hot_RCC_ADDED.removeHook(
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1798 "afterSelection",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1799 (r, c) => self.hookSelection(r, c)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1800 );
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1801 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1802
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1803 // lock analyzer
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1804 $(self.prefix+".add1spectrum-analyzerMSForm").prop("disabled", true);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1805 // lock other metadata field
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1806 $(self.prefix+".add1spectrum-otherForm").prop("disabled", true);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1807 // lock switch btn
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1808 $("#btnSwitch-gotoStep2-{{ TAB_INDEX_PLACEHOLDER }}").prop("disabled", true);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1809 $("#btnSwitch-gotoStep3-lc-{{ TAB_INDEX_PLACEHOLDER }}").prop("disabled", true);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1810 $("#btnSwitch-gotoStep4-ms-{{ TAB_INDEX_PLACEHOLDER }}").prop("disabled", true);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1811 self.postSpectrumToServer() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1812 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1813
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1814 postSpectrumToServer: function(jsonData, tab_index) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1815 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1816 var base_peakdata ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1817 var new_peakdata ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1818 var is_ms2 = self.is_ms2() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1819
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1820 if (self.is_mix()) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1821 if ({{ TAB_INDEX_PLACEHOLDER }} != 1) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1822 return ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1823 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1824 jsonData = self.gatherJsonObjects() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1825 all_mix_data = Object.assign({}, jsonData) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1826 all_mix_data["peaklists"] = [] ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1827 base_peakdata = Object.assign({}, jsonData["peaklists"][0]) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1828 all_contexts.forEach((context, index) => {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1829 if (context === null) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1830 return;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1831 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1832 new_peakdata = Object.assign({}, base_peakdata) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1833 context.loadFomDataIntoJsonObjects()
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1834 if (is_ms2) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1835 new_peakdata["precursor_ion"] = context.jsonPeaksList["precursor_ion"] ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1836 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1837 new_peakdata["peaklist"] = context.jsonPeaksList["peaklist"] ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1838 all_mix_data["peaklists"].push(new_peakdata)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1839 })
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1840 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1841 // II.B - rebuild json full object (with all metadata or just id if already in base)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1842 if (jsonData == null) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1843 jsonData = self.gatherJsonObjects();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1844 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1845 // II.C - add id metadata (if exist)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1846 var json_array = [] ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1847 if (!tab_index) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1848 tab_index = {{ TAB_INDEX_PLACEHOLDER }} ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1849 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1850 json_array[tab_index-1] = jsonData ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1851
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1852 // III - post json object
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1853 // III.A - success
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1854 self.sent_json = jsonData ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1855 console.warn(
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1856 "This data has been validated without going through the internal server!"
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1857 )
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1858 if ($("#step5sign-{{ TAB_INDEX_PLACEHOLDER }}").hasClass("fa-question-circle")) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1859 $("#step5sign-{{ TAB_INDEX_PLACEHOLDER }}").removeClass("fa-question-circle").addClass("fa-check-circle");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1860 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1861 if ($("#step5sign-{{ TAB_INDEX_PLACEHOLDER }}").hasClass("fa-spinner")) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1862 $("#step5sign-{{ TAB_INDEX_PLACEHOLDER }}").removeClass("fa-spinner fa-spin").addClass("fa-check-circle");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1863 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1864 $("#import1SpectrumLoadingBare-{{ TAB_INDEX_PLACEHOLDER }}").hide();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1865 $("#alertBoxSubmitSpectrum-{{ TAB_INDEX_PLACEHOLDER }}").html(`
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1866 <div class="alert alert-success alert-dismissible" role="alert">
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1867 <button type="button" class="close" data-dismiss="alert">
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1868 <span aria-hidden="true">&times;</span>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1869 <span class="sr-only">
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1870 <spring:message code="alert.close" text="Close" />
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1871 </span>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1872 </button>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1873 <strong>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1874 <spring:message code="alert.strong.info" text="Success!" />
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1875 </strong> Spectrum ready to be sent!
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1876 </div>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1877 `);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1878 return true;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1879 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1880
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1881 //USED HERE
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1882 loadFomDataIntoJsonObjects: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1883 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1884 // I - Spectrum type
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1885 self.isJsonSpectrumTypeComplete = false ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1886 if (self.isGC && self.is_ms()) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1887 self.jsonSpectrumType = "gc-ms" ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1888 } else if (self.isLC && self.is_ms()) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1889 self.jsonSpectrumType = "lc-ms" ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1890 } else if (self.isLC && self.is_ms2()) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1891 self.jsonSpectrumType = "lc-msms" ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1892 } else if (self.isGC && self.is_ms()) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1893 self.jsonSpectrumType = "ic-ms" ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1894 } else if (self.isLC && self.is_ms()) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1895 self.jsonSpectrumType = "ic-msms" ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1896 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1897 if (self.jsonSpectrumType != null && self.jsonSpectrumType != "") {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1898 self.isJsonSpectrumTypeComplete = true;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1899 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1900
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1901 // II - Sample
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1902 self.isJsonSampleComplete = true;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1903 self.isJsonRCCaddedComplete = true;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1904 self.jsonSample = {};
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1905
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1906 switch($("#add1spectrum-sample-type-{{ TAB_INDEX_PLACEHOLDER }}").val()) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1907 // II.A - chemical lib. compound
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1908 case "compound-ref":
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1909 if ($("#add1spectrum-sample-inchikey-{{ TAB_INDEX_PLACEHOLDER }}").val() == "") {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1910 return false;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1911 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1912 self.jsonSample["sample_type"] = "reference-chemical-compound";
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1913 self.jsonSample["inchikey"] = $("#add1spectrum-sample-inchikey-{{ TAB_INDEX_PLACEHOLDER }}").val();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1914 self.jsonSample["concentration"] = $("#add1spectrum-sample-concentration-{{ TAB_INDEX_PLACEHOLDER }}").val();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1915 if (self.is_ms()) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1916 self.jsonSample["solvent"] = $("#add1spectrum-sample-lcmsSolvent-{{ TAB_INDEX_PLACEHOLDER }}").val();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1917 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1918 self.isJsonSampleComplete = true;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1919 break;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1920 // II.B - chemical lib. compound mix
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1921 case "compound-mix":
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1922 // solvent
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1923 self.jsonSample["solvent"] = $("#add1spectrum-sample-mixSolvent-{{ TAB_INDEX_PLACEHOLDER }}").val();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1924 // cpd added
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1925 self.jsonSample.inchikeys_list = self.getRCCADDED();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1926 self.jsonSample.concentrations_list = self.getRCCADDEDConcentration();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1927 if (self.jsonSample.inchikeys_list.length == 0 && !self.is_other_in_mix()) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1928 self.isJsonRCCaddedComplete = false;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1929 console.log(`isJsonRCCaddedComplete: false`)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1930 return false;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1931 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1932 self.isJsonSampleComplete = true;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1933 break;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1934 default:
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1935 if (!self.is_other_in_mix()) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1936 return false;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1937 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1938 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1939
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1940 // III - Chromato
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1941 self.isJsonChromatoComplete = true;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1942 self.jsonChromato = {};
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1943
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1944 // III.A - no chromato
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1945 // nope?
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1946
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1947 // III.B - GC
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1948 if (self.isGC) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1949 self.isJsonChromatoComplete = false;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1950 // TODO
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1951 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1952
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1953 // III.C - LC
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1954 if (self.isLC) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1955 self.isJsonChromatoComplete = true;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1956 self.jsonChromato = {};
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1957 // check error
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1958 $.each($(self.prefix+".add1spectrum-chromatoLCForm").parent(), function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1959 if ($(this).hasClass("has-error"))
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1960 self.isJsonChromatoComplete = false;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1961 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1962 if (
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1963 !self.isJsonChromatoComplete
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1964 && !self.is_other_in_mix()
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1965 ) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1966 console.log(`isJsonChromatoComplete: false`)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1967 return false;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1968 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1969 var id = `#add1spectrum-chromatoLC-method-{{ TAB_INDEX_PLACEHOLDER }}` ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1970 self.jsonChromato["method"] = $(`${id} option:selected`).text();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1971 [
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1972 ["column_constructor", "colConstructor"],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1973 ["column_constructor_other", "colConstructorOther"],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1974 ["column_name", "colName"],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1975 ["column_length", "colLength"],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1976 ["column_diameter", "colDiameter"],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1977 ["particule_size", "colParticuleSize"],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1978 ["column_temperature", "colTemperature"],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1979 ["mode", "LCMode"],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1980 ["separation_flow_rate", "separationFlowRate"],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1981 ["solvent_a", "separationSolvA"],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1982 ["solvent_a_ph", "separationSolvApH"],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1983 ["solvent_b", "separationSolvB"],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1984 ["solvent_b_ph", "separationSolvBApH"]
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1985 ].forEach((field) => {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1986 id = `#add1spectrum-chromatoLC-${field[1]}-{{ TAB_INDEX_PLACEHOLDER }}` ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1987 self.jsonChromato[field[0]] = $(id).val();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1988 })
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1989 // fulfill json object
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1990
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1991 jsonSFG = [];
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1992 var formatData = {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1993 time: [],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1994 solvent_a_percent: [],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1995 solvent_b_percent: []
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1996 };
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1997 var uniq_times = [] ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1998 $.each(self.hot_LC_SFG.getData(), function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
1999 var time = this[0] ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2000 if (time != "" && time !== null) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2001 if (
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2002 !isNaN(time)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2003 && !isNaN(this[1])
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2004 && !isNaN(this[2])
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2005 && ! (time in uniq_times)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2006 ) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2007 formatData["time"].push(Number(time));
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2008 formatData["solvent_a_percent"].push(Number(this[1]));
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2009 formatData["solvent_b_percent"].push(Number(this[2]));
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2010 uniq_times.push(time) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2011 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2012 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2013 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2014 self.jsonChromato.separation_flow_gradient = formatData;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2015 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2016
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2017 // III.D - IC
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2018 if (self.isIC) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2019 self.isJsonChromatoComplete = false;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2020 // TODO
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2021 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2022
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2023 // IV - Analyzer
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2024 self.isJsonAnalyzerComplete = true;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2025 self.isJsonAnalyzer = {};
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2026 // IV.A - MS
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2027 if (self.is_ms() || self.is_ms2()) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2028 self.isJsonAnalyzerComplete = true;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2029 self.jsonAnalyzer = {};
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2030 // check error
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2031 $.each($(self.prefix+".add1spectrum-analyzerMSForm").parent(), function(){
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2032 if ($(this).hasClass("has-error"))
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2033 self.isJsonAnalyzerComplete = false;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2034 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2035 if (
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2036 !self.isJsonAnalyzerComplete
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2037 && !self.is_other_in_mix()
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2038 ) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2039 console.log(`isJsonAnalyzerComplete: false`)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2040 return false;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2041 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2042
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2043 // fulfill json object
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2044 self.jsonAnalyzer["instrument_name"] = $("#add1spectrum-analyzer-ms-instrument-{{ TAB_INDEX_PLACEHOLDER }}").val();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2045 self.jsonAnalyzer["instrument_model"] = $("#add1spectrum-analyzer-ms-model-{{ TAB_INDEX_PLACEHOLDER }}").val();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2046 self.jsonAnalyzer["instrument_brand"] = $("#add1spectrum-analyzer-ms-model-{{ TAB_INDEX_PLACEHOLDER }}").val();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2047 self.jsonAnalyzer["ion_analyzer_type"] = $("#add1spectrum-analyzer-ms-ionAnalyzerType-{{ TAB_INDEX_PLACEHOLDER }}").val();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2048
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2049 if (self.is_ms2()) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2050 // MSMS ion BEAM or TRAP
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2051 self.jsonMolIonBeam = {}
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2052 var jsonIonTrapBeam = {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2053 ion_gas: $("#add1spectrum-ionTrapBeam-ionGas-{{ TAB_INDEX_PLACEHOLDER }}").val(),
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2054 ion_pressure_value: $("#add1spectrum-ionTrapBeam-ionGasPressureValue-{{ TAB_INDEX_PLACEHOLDER }}").val(),
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2055 ion_pressure_unit: $("#add1spectrum-ionTrapBeam-ionGasPressureUnit-{{ TAB_INDEX_PLACEHOLDER }}").val()
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2056 } ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2057 var key = null ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2058 if ($("#add1spectrum-ionTrapBeam-type-{{ TAB_INDEX_PLACEHOLDER }}").val() == "trap") {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2059 // sp
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2060 jsonIonTrapBeam["ion_freq_shift"] = $("#add1spectrum-ionTrapBeam-ionFrequencyShift-{{ TAB_INDEX_PLACEHOLDER }}").val();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2061 jsonIonTrapBeam["ion_number"] = $("#add1spectrum-ionTrapBeam-ionNumber-{{ TAB_INDEX_PLACEHOLDER }}").val();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2062 key = "ion_trap" ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2063 } else if ($("#add1spectrum-ionTrapBeam-type-{{ TAB_INDEX_PLACEHOLDER }}").val() == "beam") {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2064 key = "ion_beam_storage" ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2065 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2066 if (key !== null) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2067 self.jsonMolIonBeam[key] = jsonIonTrapBeam;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2068 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2069 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2070
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2071 self.jsonMolIonization = {};
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2072 var json_mode ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2073 ["pos", "neg"].forEach((kind) => {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2074 json_mode = {} ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2075 [
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2076 ["ionisation_method", "ionizationMethod"],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2077 ["spray_gas_flow", "sprayGazFlow"],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2078 ["vaporizer_gas_flow", "vaporizerGazFlow"],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2079 ["vaporizer_temperature", "vaporizerTemperature"],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2080 ["source_gas_flow", "sourceGazFlow"],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2081 ["transfer_tube_or_capillary_temperature", "ionTransferTubeTemperatureOrTransferCapillaryTemperature"],
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2082 ["high_voltage", "highVoltageOrCoronaVoltage"]
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2083 ].forEach((field) => {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2084 var id = `#add1spectrum-analyzserMS-${field[1]}-${kind}-{{ TAB_INDEX_PLACEHOLDER }}` ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2085 json_mode[field[0]] = $(id).val() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2086 })
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2087 self.jsonMolIonization[`mode_${kind}`] = json_mode ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2088 })
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2089 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2090
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2091 // IV.B - NMR
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2092 if (self.is_ms() || self.is_ms2()) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2093 self.isJsonPeaksListComplete = false;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2094 // init
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2095 var peaklist = [];
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2096 var peakdata = {};
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2097 var spectrumData = {};
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2098 // peaklist
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2099 var ms_peak_data = self.hot_MS_Peaks.getData();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2100 $.each(ms_peak_data, function(index) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2101 var data = ms_peak_data[index] ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2102 var formatData = {};
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2103 if (
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2104 data[0] != ""
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2105 && !isNaN(data[0])
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2106 // && !isNaN(data[2])
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2107 && (data[6] === "true" || data[6] === true)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2108 ) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2109 peaklist.push({
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2110 mz: Number(data[0]),
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2111 ri: Number(data[2]),
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2112 delta_ppm: Number(data[3]),
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2113 composition: (data[4]),
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2114 annotation: (data[5])
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2115 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2116 self.isJsonPeaksListComplete = true;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2117 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2118 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2119 // peak list data
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2120 peakdata["scan_type"] = (
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2121 self.is_ms2() ? "ms2" : "ms"
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2122 );
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2123 peakdata["polarity"] = $("#add1spectrum-peaksMS-polarity-{{ TAB_INDEX_PLACEHOLDER }}").val();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2124 peakdata["resolution"] = $("#add1spectrum-peaksMS-resolution-{{ TAB_INDEX_PLACEHOLDER }}").val();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2125 peakdata["curation"] = $("#add1spectrum-peaksMS-curation-{{ TAB_INDEX_PLACEHOLDER }}").val();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2126 peakdata["mz_from"] = $("#add1spectrum-peaksMS-rangeFrom-{{ TAB_INDEX_PLACEHOLDER }}").val();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2127 peakdata["mz_to"] = $("#add1spectrum-peaksMS-rangeTo-{{ TAB_INDEX_PLACEHOLDER }}").val();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2128 peakdata["retention_min_time_from"] = $("#add1spectrum-peaksMS-rtMinFrom-{{ TAB_INDEX_PLACEHOLDER }}").val();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2129 peakdata["retention_min_time_to"] = $("#add1spectrum-peaksMS-rtMinTo-{{ TAB_INDEX_PLACEHOLDER }}").val();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2130 peakdata["rt_solv_from"] = $("#add1spectrum-peaksMS-rtSolvFrom-{{ TAB_INDEX_PLACEHOLDER }}").val();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2131 peakdata["rt_solv_to"] = $("#add1spectrum-peaksMS-rtSolvTo-{{ TAB_INDEX_PLACEHOLDER }}").val();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2132 peakdata["resolution_FWHM"] = $("#add1spectrum-analyzer-ms-resolutionFWHM-{{ TAB_INDEX_PLACEHOLDER }}").val();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2133 if (self.is_ms2()) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2134 var data = self.hot_MS_Peaks.getData() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2135 if (data.length != 0) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2136 var selected_ion = self.get_selected_parent_ion_index() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2137 if (selected_ion !== null) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2138 peakdata["precursor_ion"] = data[selected_ion][0] ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2139 peakdata["precursor_spectrum_id"] = null ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2140 } else {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2141 peakdata["precursor_ion"] = self.get_selected_parent_ion_mz() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2142 peakdata["precursor_spectrum_id"] = null ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2143 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2144 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2145 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2146 peakdata["peaklist"] = peaklist;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2147 self.jsonPeaksList = peakdata;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2148 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2149
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2150 self.isJsonOtherMetadataComplete = true;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2151 self.jsonOtherMetadata = {};
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2152 // check error
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2153 $.each($(self.prefix+".add1spectrum-otherForm").parent(), function(){
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2154 if ($(this).hasClass("has-error"))
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2155 self.isJsonOtherMetadataComplete = false;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2156 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2157 if (!self.isJsonOtherMetadataComplete && !self.is_other_in_mix()) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2158 console.log(`isJsonOtherMetadataComplete: false`)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2159 return false;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2160 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2161 self.jsonOtherMetadata["data_authors"] = $("#add1spectrum-other-author-{{ TAB_INDEX_PLACEHOLDER }}").val();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2162 self.jsonOtherMetadata["data_validator"] = $("#add1spectrum-other-validator-{{ TAB_INDEX_PLACEHOLDER }}").val();;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2163 self.jsonOtherMetadata["acquisition_date"] = $("#add1spectrum-other-date-{{ TAB_INDEX_PLACEHOLDER }}").val();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2164 if (!self.jsonOtherMetadata["acquisition_date"]) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2165 self.jsonOtherMetadata["acquisition_date"] = null ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2166 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2167 self.jsonOtherMetadata["data_ownership"] = $("#add1spectrum-other-owner-{{ TAB_INDEX_PLACEHOLDER }}").val();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2168 self.jsonOtherMetadata["raw_file_name"] = $("#add1spectrum-other-fileName-{{ TAB_INDEX_PLACEHOLDER }}").val();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2169 self.jsonOtherMetadata["raw_file_size"] = $("#add1spectrum-other-fileSize-{{ TAB_INDEX_PLACEHOLDER }}").val();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2170 return true;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2171 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2172
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2173 //USED HERE
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2174 getFormErrorMessage: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2175 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2176 var alertMsg = "";
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2177 if (!self.isJsonSpectrumTypeComplete) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2178 alertMsg = `
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2179 <div class="alert alert-danger alert-dismissible" role="alert">
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2180 <button type="button" class="close" data-dismiss="alert">
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2181 <span aria-hidden="true">&times;</span>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2182 <span class="sr-only">
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2183 <spring:message code="alert.close" text="Close" />
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2184 </span>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2185 </button>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2186 <strong>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2187 <spring:message code="alert.strong.error" text="Error!" />
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2188 </strong> Error processing spectrum type!
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2189 </div>` ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2190 } else if (!self.isJsonSampleComplete) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2191 alertMsg = `
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2192 <div class="alert alert-danger alert-dismissible" role="alert">
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2193 <button type="button" class="close" data-dismiss="alert">
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2194 <span aria-hidden="true">&times;</span>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2195 <span class="sr-only">
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2196 <spring:message code="alert.close" text="Close" />
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2197 </span>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2198 </button>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2199 <strong>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2200 <spring:message code="alert.strong.error" text="Error!" />
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2201 </strong> Missing mandatory data into sample section!
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2202 <br />
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2203 <a
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2204 href="#"
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2205 onclick="$('#linkActivateStep1-{{ TAB_INDEX_PLACEHOLDER }}').trigger('click');"
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2206 >Go to this section</a>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2207 </div>` ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2208 } else if (!self.isJsonRCCaddedComplete) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2209 alertMsg = `
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2210 <div class="alert alert-danger alert-dismissible" role="alert">
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2211 <button type="button" class="close" data-dismiss="alert">
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2212 <span aria-hidden="true">&times;</span>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2213 <span class="sr-only">
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2214 <spring:message code="alert.close" text="Close" />
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2215 </span>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2216 </button>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2217 <strong>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2218 <spring:message code="alert.strong.error" text="Error!" />
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2219 </strong> Pease enter at least ONE compound in mix into sample section!
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2220 <br />
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2221 <a
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2222 href="#"
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2223 onclick="$('#linkActivateStep1-{{ TAB_INDEX_PLACEHOLDER }}').trigger('click');"
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2224 >Go to this section</a>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2225 </div>`;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2226 } else if (!self.isJsonChromatoComplete) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2227 alertMsg = `
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2228 <div class="alert alert-danger alert-dismissible" role="alert">
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2229 <button type="button" class="close" data-dismiss="alert">
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2230 <span aria-hidden="true">&times;</span>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2231 <span class="sr-only">
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2232 <spring:message code="alert.close" text="Close" />
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2233 </span>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2234 </button>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2235 <strong>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2236 <spring:message code="alert.strong.error" text="Error!" />
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2237 </strong> Missing data in chromatography section!
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2238 ` ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2239 if (self.is_ms()) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2240 alertMsg += `
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2241 <br />
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2242 <a
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2243 href="#"
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2244 onclick="$('#linkActivateStep4-ms-{{ TAB_INDEX_PLACEHOLDER }}').trigger('click');"
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2245 >Go to this section</a>`;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2246 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2247 alertMsg += ' </div>';
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2248 } else if (!self.isJsonPeaksListComplete) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2249 alertMsg = `
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2250 <div class="alert alert-danger alert-dismissible" role="alert">
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2251 <button type="button" class="close" data-dismiss="alert">
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2252 <span aria-hidden="true">&times;</span>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2253 <span class="sr-only">
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2254 <spring:message code="alert.close" text="Close" />
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2255 </span>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2256 </button>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2257 <strong>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2258 <spring:message code="alert.strong.error" text="Error!" />
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2259 </strong> Missing peaklist!
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2260 ` ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2261 if (self.is_ms()) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2262 alertMsg += `
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2263 <br />
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2264 <a
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2265 href="#"
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2266 onclick="$('#linkActivateStep4-ms-{{ TAB_INDEX_PLACEHOLDER }}').trigger('click');"
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2267 >Go to this section</a>`;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2268 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2269 alertMsg += ' </div>';
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2270 } else if (self.is_mix() && self.is_ms2()) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2271 for (var i = 0 ; i < all_contexts.length ; i += 1) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2272 if (all_contexts[i] === null || all_contexts[i] === undefined) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2273 continue;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2274 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2275 if (all_contexts[i].get_selected_parent_ion_index() === null) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2276 return alertMsg + `
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2277 <div class="alert alert-danger alert-dismissible" role="alert">
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2278 <button type="button" class="close" data-dismiss="alert">
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2279 <span aria-hidden="true">&times;</span>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2280 <span class="sr-only">
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2281 <spring:message code="alert.close" text="Close" />
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2282 </span>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2283 </button>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2284 <strong>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2285 <spring:message code="alert.strong.error" text="Error!" />
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2286 </strong> Select precursor ion in all peak lists!
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2287 </div>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2288 `
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2289 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2290 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2291 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2292 // TODO other
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2293 return alertMsg;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2294 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2295
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2296 //USED HERE
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2297 gatherJsonObjects: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2298 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2299 var jsonData = {};
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2300 if (self.is_mix()) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2301 jsonData["sample_type"] = "mix_of_reference_chemical_compounds" ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2302 } else {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2303 jsonData["sample_type"] = "reference_chemical_compound" ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2304 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2305 jsonData["spectrum_type"] = self.jsonSpectrumType.toUpperCase().replaceAll("-", "");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2306 jsonData["sample"] = self.jsonSample;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2307 if (self.isLC) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2308 jsonData["chromatography"] = self.jsonChromato;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2309 } else if (self.isGC) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2310 jsonData["chromatography"] = self.jsonChromato;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2311 } else if (self.isIC) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2312 jsonData["chromatography"] = self.jsonChromato;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2313 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2314 if (self.is_ms()) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2315 jsonData["analyzer"] = self.jsonAnalyzer;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2316 var molecule_ionization = self.jsonMolIonization;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2317 jsonData["ionization_mode_positive"] = molecule_ionization["mode_pos"] ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2318 jsonData["ionization_mode_negative"] = molecule_ionization["mode_neg"] ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2319 jsonData["peaklists"] = [self.jsonPeaksList] ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2320 } else if (self.is_ms2()) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2321 jsonData["analyzer"] = self.jsonAnalyzer;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2322 var molecule_ionization = self.jsonMolIonization;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2323 jsonData["ionization_mode_positive"] = molecule_ionization["mode_pos"] ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2324 jsonData["ionization_mode_negative"] = molecule_ionization["mode_neg"] ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2325 if (self.jsonMolIonBeam != null) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2326 jsonData["ion_beam_storage"] = self.jsonMolIonBeam["ion_beam_storage"];
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2327 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2328 jsonData["peaklists"] = [self.jsonPeaksList] ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2329 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2330 jsonData["other_metadata"] = self.jsonOtherMetadata;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2331 return jsonData;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2332 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2333
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2334 //USED IN HTML
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2335 pickChemicalCompound: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2336 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2337 self.singlePick = true;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2338 $("#modalPickCompound-{{ TAB_INDEX_PLACEHOLDER }}").modal("show");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2339 $("#add-one-cc-s1-value-{{ TAB_INDEX_PLACEHOLDER }}").focus();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2340 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2341
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2342 //USED HERE
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2343 pickChemicalCompound4Mix: function(rowNumber) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2344 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2345 self.singlePick = false;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2346 self.multiPickLine = rowNumber;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2347 $("#modalPickCompound-{{ TAB_INDEX_PLACEHOLDER }}").modal("show");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2348 $("#add-one-cc-s1-value-{{ TAB_INDEX_PLACEHOLDER }}").focus();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2349 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2350
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2351 //USED HERE
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2352 searchAjax: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2353 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2354 var results ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2355 var rawQuery = $('#add-one-cc-s1-value-{{ TAB_INDEX_PLACEHOLDER }}').val();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2356 if (rawQuery.length > 2) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2357 return [] ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2358 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2359 results = [] ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2360 $.ajax({
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2361 type: "post",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2362 url: "{{ PF_URL_PLACEHOLDER }}/webapp/search",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2363 dataType: "json",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2364 async: false,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2365 data: "query=" + $("#add-one-cc-s1-value-{{ TAB_INDEX_PLACEHOLDER }}").val(),
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2366 success: function(json) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2367 if (json.success) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2368 $.each(json.compoundNames, function(){
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2369 results.push(this.name) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2370 }) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2371 $.each(json.compounds, function(){
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2372 if (this.inChIKey.indexOf(rawQuery)) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2373 results.push(this.inChIKey) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2374 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2375 }) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2376 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2377 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2378 error : function(xhr) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2379 self.subjects = [] ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2380 console.log(xhr) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2381 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2382 }) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2383 return results ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2384 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2385
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2386 //USED HERE
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2387 searchLocalCompound: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2388 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2389 $("#load-step-1-{{ TAB_INDEX_PLACEHOLDER }}").show();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2390 $.ajax({
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2391 type: "get",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2392 url: "{{ PF_URL_PLACEHOLDER }}/rest/v2/compounds",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2393 async: true,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2394 data: "limit=1&query=" + $('#add-one-cc-s1-value-{{ TAB_INDEX_PLACEHOLDER }}').val() + "&query_filter=" + self.fitlerSearchLoadlCpd+"&token={{ PF_TOKEN_PLACEHOLDER }}",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2395 success: function(data) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2396 data = data[0] ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2397 var id = parseInt(data["id"]) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2398 var name = data["name"] ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2399 var inchikey = data["inchikey"] ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2400 var inchi = data["inchi"] ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2401 data = `
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2402 <div class="table-responsive">
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2403 <table id="tabPickCpd-{{ TAB_INDEX_PLACEHOLDER }}" class="table table-bordered table-hover table-striped tablesorter" style="cursor: pointer;">
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2404 <thead>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2405 <tr>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2406 <th class="header">Chemical Name <i class="fa fa-sort"></i></th>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2407 <th class="header">Monoisotopic Mass <i class="fa fa-sort"></i></th>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2408 <th class="header">Formula <i class="fa fa-sort"></i></th>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2409 <th class="header" style="">Structure</th>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2410 </tr>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2411 </thead>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2412 <tbody>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2413 <tr class="success" onclick="loadCompoundInForm(${id}, '${inchikey}', '${inchi}', '${data["formula"]}', '${data["exactMass"]}' , 100);">
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2414 <td style="vertical-align: middle;">
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2415 <span id="cpt-load-name-${id}-{{ TAB_INDEX_PLACEHOLDER }}">${name}</span>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2416 <br><small style="white-space: nowrap;">${inchikey}</small>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2417 </td>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2418 <td style="vertical-align: middle;" class="compoundMass">${data["exactMass"]}</td>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2419 <td style="vertical-align: middle;" class="compoundFormula">${data["formula"]}</sub></td>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2420 <td><span class="avatar">
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2421 <img class="compoundSVG" src="{{ PF_URL_PLACEHOLDER }}/webapp/image/generic/${inchikey}" alt="${name}">
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2422 </span>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2423 </td>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2424 </tr>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2425 </tbody>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2426 </table>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2427 <small><sup><b>*</b></sup>: Generic Compounds (abstract "flat" compound without (+) or (-) center).</small>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2428 <` + "script" + ` type="text/javascript">
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2429 $("#tabPickCpd-{{ TAB_INDEX_PLACEHOLDER }}").tablesorter();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2430 $.each($(self.prefix+".compoundFormula"), function(id, elem) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2431 var rawFromula = $(elem).text();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2432 var formatedFormula = rawFromula;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2433 try {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2434 $.each($.unique( rawFromula.match(/\d+/g)), function(keyF, valF) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2435 var re = new RegExp(valF,"g");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2436 formatedFormula = formatedFormula.replace(re, "<sub>" + valF + "</sub>");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2437 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2438 } catch (e){}
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2439 formatedFormula = formatedFormula.replace("</sub><sub>", "");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2440 $(elem).html(formatedFormula);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2441 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2442 $.each($(self.prefix+".compoundMass"), function(id, elem) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2443 var exactMass = parseFloat( $(elem).text());
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2444 exactMass = roundNumber(exactMass,7)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2445 $(elem).html(exactMass);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2446 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2447 </` + "script" + `>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2448
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2449 </div>
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2450 <` + "script" + ` type="text/javascript">
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2451 var listOfRefCompoundsMatch = null;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2452
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2453 loadCompoundInForm = function(id, inchikey, inchi, composition, exactMass, type) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2454 if (ctx().modeEditSpectrum) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2455 var name = $("#cpt-load-name-" + id + "-{{ TAB_INDEX_PLACEHOLDER }}").html();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2456 if (ctx().multiPickLine >= 0) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2457 ctx().hot_RCC_ADDED.setDataAtCell(ctx().multiPickLine, 0, name);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2458
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2459 // restet form
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2460 setTimeout(function(){
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2461 $("#add-one-cc-s1-value-{{ TAB_INDEX_PLACEHOLDER }}").val("");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2462 $("#ok-step-1-{{ TAB_INDEX_PLACEHOLDER }}").html("");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2463 }, 200);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2464 // img
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2465 var typeS = "chemical";
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2466 if (type == 100)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2467 typeS = "generic";
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2468 else if (type == 101)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2469 typeS = "chemical";
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2470 // '<img class="mixRCCadd'+ctx().multiPickLine+' compoundSVGZoom" src="{{ PF_URL_PLACEHOLDER }}/webapp/image/'+typeS+'/'+inchikey+'" alt="'+name+'">'
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2471 var currentCpt = {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2472 "name": name,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2473 "type": typeS,
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2474 "concentration": "?",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2475 "inchikey": inchikey
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2476 };
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2477 updatedCpdMixData[name] = currentCpt;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2478 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2479 // display
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2480 $("#modalPickCompound-{{ TAB_INDEX_PLACEHOLDER }}").modal("hide");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2481 $("#modalEditSpectrum-{{ TAB_INDEX_PLACEHOLDER }} .modal-dialog").show();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2482 return;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2483 } // else: add one spectrum
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2484 var name = $("#cpt-load-name-" + id + "-{{ TAB_INDEX_PLACEHOLDER }}").html();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2485 if (ctx().singlePick) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2486 $("#add1spectrum-sample-inchikey-{{ TAB_INDEX_PLACEHOLDER }}").val(inchikey);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2487 $("#add1spectrum-sample-inchikey-{{ TAB_INDEX_PLACEHOLDER }}").change();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2488 $("#add1spectrum-sample-inchi-{{ TAB_INDEX_PLACEHOLDER }}").val(inchi);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2489 $("#add1spectrum-sample-inchi-{{ TAB_INDEX_PLACEHOLDER }}").change();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2490 $("#add1spectrum-sample-commonName-{{ TAB_INDEX_PLACEHOLDER }}").val(name);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2491 $("#add1spectrum-sample-commonName-{{ TAB_INDEX_PLACEHOLDER }}").change();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2492
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2493 $("#importspectrum-sample-inchikey-{{ TAB_INDEX_PLACEHOLDER }}").val(inchikey);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2494 $("#importspectrum-sample-inchikey-{{ TAB_INDEX_PLACEHOLDER }}").change();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2495 } else if (ctx().multiPickLine >= 0) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2496 ctx().hot_RCC_ADDED.setDataAtCell(ctx().multiPickLine, 0, name);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2497 ctx().hot_RCC_ADDED.setDataAtCell(ctx().multiPickLine, 1, inchikey);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2498 ctx().hot_RCC_ADDED.setDataAtCell(ctx().multiPickLine, 2, composition);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2499 ctx().hot_RCC_ADDED.setDataAtCell(ctx().multiPickLine, 4, exactMass);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2500 // restet form
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2501 setTimeout(function(){
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2502 $("#add-one-cc-s1-value-{{ TAB_INDEX_PLACEHOLDER }}").val("");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2503 $("#ok-step-1-{{ TAB_INDEX_PLACEHOLDER }}").html("");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2504 }, 200);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2505 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2506 var typeS = "chemical";
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2507 if (type == 100)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2508 typeS = "generic";
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2509 else if (type == 101)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2510 typeS = "chemical";
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2511 if (ctx().singlePick)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2512 $("#sample-bonus-display-{{ TAB_INDEX_PLACEHOLDER }}").html('<img class="" src="{{ PF_URL_PLACEHOLDER }}/webapp/image/'+typeS+'/'+inchikey+'" alt="'+name+'">');
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2513 else {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2514 // delete
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2515 $(ctx().prefix+"img.mixRCCadd"+ctx().multiPickLine).remove();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2516 // add
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2517 $("#sample-bonus-display-{{ TAB_INDEX_PLACEHOLDER }}").append('<img class="mixRCCadd'+ctx().multiPickLine+' compoundSVGZoom" src="{{ PF_URL_PLACEHOLDER }}/webapp/image/'+typeS+'/'+inchikey+'" alt="'+name+'">');
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2518 $(ctx().prefix+"img.mixRCCadd"+ctx().multiPickLine+"").mouseenter(function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2519 $(this).removeClass("compoundSVGZoom");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2520 }).mouseleave(function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2521 $(this).addClass("compoundSVGZoom");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2522 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2523 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2524 $("#modalPickCompound-{{ TAB_INDEX_PLACEHOLDER }}").modal("hide");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2525 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2526 </` + "script" + `></` + "div" + `>` ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2527 $("#ok-step-1-{{ TAB_INDEX_PLACEHOLDER }}").html(data);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2528 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2529 error : function(xhr) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2530 // log
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2531 console.log(xhr);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2532 // error
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2533 $("#ok-step-1-{{ TAB_INDEX_PLACEHOLDER }}").html("Error: could not process request.");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2534 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2535 }).always(function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2536 $("#load-step-1-{{ TAB_INDEX_PLACEHOLDER }}").hide();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2537 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2538 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2539
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2540 //USED HERE
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2541 getRCCADDED: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2542 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2543 jsonRCC_ADDED = [];
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2544 $.each(self.hot_RCC_ADDED.getData(), function(){
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2545 var formatData = {};
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2546 if ("<b>InChIKey</b>" in this && this["<b>InChIKey</b>"]!= undefined && this["<b>InChIKey</b>"] != "") {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2547 jsonRCC_ADDED.push(this["<b>InChIKey</b>"]);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2548 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2549 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2550 return jsonRCC_ADDED;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2551 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2552
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2553 //USED HERE
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2554 getRCCADDEDConcentration: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2555 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2556 jsonRCC_ADDED = [];
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2557 $.each(self.hot_RCC_ADDED.getData(), function(){
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2558 var formatData = {};
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2559 if ("<b>InChIKey</b>" in this && this["<b>InChIKey</b>"]!= undefined && this["<b>InChIKey</b>"] != "") {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2560 jsonRCC_ADDED.push(this["<b>concentration (&micro;g/ml)</b>"]);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2561 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2562 });
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2563 return jsonRCC_ADDED;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2564 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2565
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2566 //USED IN HTML
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2567 clearLine: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2568 var self = this ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2569 // restet form
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2570 setTimeout(function(){
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2571 $("#add-one-cc-s1-value-{{ TAB_INDEX_PLACEHOLDER }}").val("");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2572 $("#ok-step-1-{{ TAB_INDEX_PLACEHOLDER }}").html("");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2573 }, 200);
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2574 $(self.prefix+"img.mixRCCadd"+self.multiPickLine).remove();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2575 if (self.singlePick) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2576 $("#add1spectrum-sample-inchikey-{{ TAB_INDEX_PLACEHOLDER }}").val("");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2577 $("#add1spectrum-sample-inchikey-{{ TAB_INDEX_PLACEHOLDER }}").change();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2578 $("#add1spectrum-sample-inchi-{{ TAB_INDEX_PLACEHOLDER }}").val("");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2579 $("#add1spectrum-sample-inchi-{{ TAB_INDEX_PLACEHOLDER }}").change();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2580 $("#add1spectrum-sample-commonName-{{ TAB_INDEX_PLACEHOLDER }}").val("");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2581 $("#add1spectrum-sample-commonName-{{ TAB_INDEX_PLACEHOLDER }}").change();
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2582 $("#sample-bonus-display-{{ TAB_INDEX_PLACEHOLDER }}").html("");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2583 } else if (self.multiPickLine >= 0) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2584 for(var i = 0 ; i < 6 ; i += 1) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2585 self.hot_RCC_ADDED.setDataAtCell(self.multiPickLine, i, "");
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2586 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2587 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2588 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2589
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2590 exit: function() {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2591 $.ajax({type: "get", url: "/quit", async: true, success: ()=>window.close()});
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2592 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2593
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2594 } ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2595
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2596 $.ajax({
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2597 type: "get",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2598 url: "{{ PF_URL_PLACEHOLDER }}/webapp/get-cpd-data?token={{ PF_TOKEN_PLACEHOLDER }}",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2599 data: "inchikey=" + "{{ INCHIKEY_PLACEHOLDER }}",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2600 dataType: "json",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2601 success: function(data) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2602 if (data.success) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2603 var self = context_{{ TAB_INDEX_PLACEHOLDER }} ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2604 console.log(`inchikey {{ INCHIKEY_PLACEHOLDER }} found!!`)
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2605 inchidata["{{ INCHIKEY_PLACEHOLDER }}"] = data ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2606 self.init() ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2607 self.fitlerSearchLoadlCpd = 5;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2608 self.inchikey = null;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2609 all_contexts[{{ TAB_INDEX_PLACEHOLDER }}] = self ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2610 } else {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2611 no_success(
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2612 {{ TAB_INDEX_PLACEHOLDER }},
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2613 "{{ INCHIKEY_PLACEHOLDER }}",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2614 {{ DEFAULT_DATA }}["name"]
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2615 ) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2616 all_contexts[{{ TAB_INDEX_PLACEHOLDER }}] = null ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2617 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2618 },
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2619 error : function(data) {
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2620 no_success(
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2621 {{ TAB_INDEX_PLACEHOLDER }},
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2622 "{{ INCHIKEY_PLACEHOLDER }}",
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2623 {{ DEFAULT_DATA }}["name"]
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2624 ) ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2625 all_contexts[{{ TAB_INDEX_PLACEHOLDER }}] = null ;
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2626 }
7e3085fc60c1 master branch Updating
lain
parents:
diff changeset
2627 }).always(() => null);