Mercurial > repos > lain > ms_to_peakforest_it
annotate common.js @ 0:b58b229c4cbf draft
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
author | lain |
---|---|
date | Fri, 03 Mar 2023 14:10:24 +0000 |
parents | |
children |
rev | line source |
---|---|
0
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
1 |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
2 this.ctx = () => context; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
3 var all_contexts = [] ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
4 var inchidata = {} ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
5 var all_mix_data = {} ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
6 function no_success(tab_index, inchi, data) { |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
7 console.log(`inchikey ${inchi} not found...`) ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
8 console.log(`disabling ${data} ...`) |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
9 disable_tab( |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
10 tab_index, |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
11 "red", |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
12 "This compound has not been found on peakforest" |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
13 ) ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
14 } |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
15 |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
16 function disable_tab(tab_index, color, title) { |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
17 var element = $(`#open_tab_${tab_index}`) ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
18 element.attr("disabled", "disabled").off("click"); |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
19 element.attr("onclick", null) ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
20 element.attr("title", title) ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
21 element.attr("data-toggle", null) ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
22 element.attr("href", null) ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
23 element.css("color", color) ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
24 element.css("cursor", "not-allowed") ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
25 } |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
26 |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
27 function send_everything_to_peakforest(url, token) { |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
28 var bundles ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
29 if (context.is_mix()) { |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
30 bundles = [all_mix_data] ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
31 } else { |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
32 bundles = create_dataset_bundles() ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
33 } |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
34 bundles.forEach((bundle, index) => { |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
35 console.log(bundle) |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
36 $.ajax({ |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
37 type: "post", |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
38 url: `${url}/rest/v2/spectrum?token=${token}`, |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
39 data: JSON.stringify(bundle), |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
40 contentType: "application/json" |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
41 }) |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
42 }) |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
43 // console.log(bundles) |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
44 } |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
45 |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
46 function create_dataset_bundles() { |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
47 var bundles = [] ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
48 var data ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
49 all_contexts.forEach((context, index) => { |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
50 if ((data = context.sent_json) === null) { |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
51 return ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
52 } |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
53 if (bundles.length === 0) { |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
54 // console.log("First metadata!") |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
55 return bundles.push(data) ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
56 } |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
57 if (merge_in_bundle(bundles, data)) { |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
58 // console.log("Merged!") |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
59 } else { |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
60 // console.log("New metadata!") |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
61 } |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
62 }) ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
63 return bundles ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
64 } |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
65 |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
66 function merge_in_bundle(bundles, data) { |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
67 for(var i = 0 ; i < bundles.length ; i += 1) { |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
68 if ( |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
69 identical(bundles[i]["sample"], data["sample"]) |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
70 && identical(bundles[i]["chromatography"], data["chromatography"]) |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
71 && identical(bundles[i]["analyzer"], data["analyzer"]) |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
72 && identical(bundles[i]["ionization_mode_positive"], data["ionization_mode_positive"]) |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
73 && identical(bundles[i]["ionization_mode_negative"], data["ionization_mode_negative"]) |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
74 && identical(bundles[i]["other_metadata"], data["other_metadata"]) |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
75 ) { |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
76 bundles[i]["peaklists"].push(data["peaklists"][0]) ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
77 return true ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
78 } else { |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
79 continue ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
80 console.log( |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
81 "sample: " |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
82 + identical(bundles[i]["sample"], data["sample"]) |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
83 ) |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
84 console.log( |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
85 "chromatography: " |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
86 + identical(bundles[i]["chromatography"], data["chromatography"]) |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
87 ) |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
88 console.log( |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
89 "analyzer: " |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
90 + identical(bundles[i]["analyzer"], data["analyzer"]) |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
91 ) |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
92 console.log( |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
93 "ionization_mode_positive: " |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
94 + identical(bundles[i]["ionization_mode_positive"], data["ionization_mode_positive"]) |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
95 ) |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
96 console.log( |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
97 "ionization_mode_negative: " |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
98 + identical(bundles[i]["ionization_mode_negative"], data["ionization_mode_negative"]) |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
99 ) |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
100 console.log( |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
101 "other_metadata: " |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
102 + identical(bundles[i]["other_metadata"], data["other_metadata"]) |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
103 ) |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
104 } |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
105 } |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
106 bundles.push(data) ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
107 return false ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
108 } |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
109 |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
110 function identical(left, right) { |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
111 if (typeof left !== typeof right) { |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
112 return false ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
113 } |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
114 if (left === null) { |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
115 return right === null ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
116 } |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
117 if (right === null) { |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
118 return left === null ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
119 } |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
120 switch (typeof left) { |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
121 case "array": |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
122 return identical_array(left, right) ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
123 break ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
124 case "object": |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
125 return identical_object(left, right) ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
126 break ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
127 default: |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
128 break ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
129 } |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
130 return (left === right) |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
131 } |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
132 |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
133 function identical_array(left, right) { |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
134 if (right.length !== left.length) { |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
135 return false ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
136 } |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
137 for(var i = 0 ; i < left.length ; i += 1) { |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
138 if (!identical(left[i], right[i])) { |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
139 return false ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
140 } |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
141 } |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
142 return true ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
143 } |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
144 |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
145 function identical_object(left, right) { |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
146 var left_keys ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
147 |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
148 if (!( |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
149 share_keys(left, right) |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
150 && share_keys(right, left) |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
151 )) { |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
152 return true ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
153 } |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
154 left_keys = Object.keys(left) ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
155 for (var i = 0 ; i < left_keys.length ; i += 1){ |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
156 if (!identical(left[left_keys[i]], right[left_keys[i]])) { |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
157 return false ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
158 } |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
159 } |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
160 return true ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
161 } |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
162 |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
163 function share_keys(left, right) { |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
164 var left_keys ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
165 var right_keys ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
166 |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
167 left_keys = Object.keys(left) ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
168 right_keys = Object.keys(right) ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
169 for(var i = 0 ; i < left_keys.length ; i += 1) { |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
170 if (!right_keys.includes(left_keys[i])) { |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
171 return false ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
172 } |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
173 } |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
174 return true ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
175 } |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
176 |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
177 var set_inchi_data = function(data, tab_index) { |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
178 inchidata[data.inchikey] = data ; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
179 $(`#add1spectrum-sample-inchi-${tab_index}`).val(data.inchi); |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
180 $(`#add1spectrum-sample-inchi-${tab_index}`).change(); |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
181 $(`#add1spectrum-sample-commonName-${tab_index}`).val(data.name); |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
182 $(`#add1spectrum-sample-commonName-${tab_index}`).change(); |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
183 $(`#sample-bonus-display-${tab_index}`).html( |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
184 `<img |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
185 class="" |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
186 src="{{ PF_URL_PLACEHOLDER }}/webapp/image/${data.type}/${data.inchikey}" |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
187 alt="${data.name}" |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
188 >` |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
189 ); |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
190 } |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
191 |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
192 var lightgrayRenderer = function(instance, td, row, col, prop, value, cellProperties) { |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
193 Handsontable.renderers.TextRenderer.apply(this, arguments); |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
194 td.style.backgroundColor = "#EEE"; |
b58b229c4cbf
planemo upload commit 523a9c8df173302ad38e9f15e7d82eab01736551-dirty
lain
parents:
diff
changeset
|
195 } |