1809 |
25 Jan 13 |
nicklas |
1 |
|
1809 |
25 Jan 13 |
nicklas |
var Plate = function() |
1809 |
25 Jan 13 |
nicklas |
3 |
{ |
1809 |
25 Jan 13 |
nicklas |
var plate = {}; |
1809 |
25 Jan 13 |
nicklas |
plate.rows = 8; |
1809 |
25 Jan 13 |
nicklas |
plate.columns = 12; |
1809 |
25 Jan 13 |
nicklas |
plate.wells = []; |
1809 |
25 Jan 13 |
nicklas |
plate.poolSchema = null; |
1809 |
25 Jan 13 |
nicklas |
plate.wellPainter = null; |
1809 |
25 Jan 13 |
nicklas |
10 |
|
1809 |
25 Jan 13 |
nicklas |
11 |
/** |
1809 |
25 Jan 13 |
nicklas |
Initialize a plate with the given number of rows and columns. |
1809 |
25 Jan 13 |
nicklas |
13 |
*/ |
1809 |
25 Jan 13 |
nicklas |
plate.init = function(rows, columns, poolSchema, wellPainter) |
1809 |
25 Jan 13 |
nicklas |
15 |
{ |
1809 |
25 Jan 13 |
nicklas |
if (rows) plate.rows = rows; |
1809 |
25 Jan 13 |
nicklas |
if (columns) plate.columns = columns; |
1809 |
25 Jan 13 |
nicklas |
if (poolSchema) plate.poolSchema = poolSchema; |
1809 |
25 Jan 13 |
nicklas |
if (wellPainter) plate.wellPainter = wellPainter; |
1809 |
25 Jan 13 |
nicklas |
20 |
|
1809 |
25 Jan 13 |
nicklas |
for (var c = 0; c < plate.columns; c++) |
1809 |
25 Jan 13 |
nicklas |
22 |
{ |
1809 |
25 Jan 13 |
nicklas |
for (var r = 0; r < plate.rows; r++) |
1809 |
25 Jan 13 |
nicklas |
24 |
{ |
1809 |
25 Jan 13 |
nicklas |
plate.wells[plate.wells.length] = new Well(r, c); |
1809 |
25 Jan 13 |
nicklas |
26 |
} |
1809 |
25 Jan 13 |
nicklas |
27 |
} |
1809 |
25 Jan 13 |
nicklas |
28 |
} |
1809 |
25 Jan 13 |
nicklas |
29 |
|
1809 |
25 Jan 13 |
nicklas |
30 |
/** |
1809 |
25 Jan 13 |
nicklas |
Change the pool layout schema for the plate. |
1809 |
25 Jan 13 |
nicklas |
32 |
*/ |
1809 |
25 Jan 13 |
nicklas |
plate.setPoolSchema = function(poolSchema) |
1809 |
25 Jan 13 |
nicklas |
34 |
{ |
1809 |
25 Jan 13 |
nicklas |
plate.poolSchema = poolSchema; |
1809 |
25 Jan 13 |
nicklas |
36 |
} |
1809 |
25 Jan 13 |
nicklas |
37 |
|
1809 |
25 Jan 13 |
nicklas |
38 |
/** |
1809 |
25 Jan 13 |
nicklas |
Change the well painter for the plate. |
1809 |
25 Jan 13 |
nicklas |
40 |
*/ |
1809 |
25 Jan 13 |
nicklas |
plate.setWellPainter = function(wellPainter) |
1809 |
25 Jan 13 |
nicklas |
42 |
{ |
1809 |
25 Jan 13 |
nicklas |
plate.wellPainter = wellPainter; |
1809 |
25 Jan 13 |
nicklas |
44 |
} |
1809 |
25 Jan 13 |
nicklas |
45 |
|
1809 |
25 Jan 13 |
nicklas |
46 |
/** |
1809 |
25 Jan 13 |
nicklas |
Get the number of rows on the plate. |
1809 |
25 Jan 13 |
nicklas |
48 |
*/ |
1809 |
25 Jan 13 |
nicklas |
plate.getRows = function() |
1809 |
25 Jan 13 |
nicklas |
50 |
{ |
1809 |
25 Jan 13 |
nicklas |
return plate.rows; |
1809 |
25 Jan 13 |
nicklas |
52 |
} |
1809 |
25 Jan 13 |
nicklas |
53 |
|
1809 |
25 Jan 13 |
nicklas |
54 |
/** |
1809 |
25 Jan 13 |
nicklas |
Get the number of columns on the plate. |
1809 |
25 Jan 13 |
nicklas |
56 |
*/ |
1809 |
25 Jan 13 |
nicklas |
plate.getColumns = function() |
1809 |
25 Jan 13 |
nicklas |
58 |
{ |
1809 |
25 Jan 13 |
nicklas |
return plate.columns; |
1809 |
25 Jan 13 |
nicklas |
60 |
} |
1809 |
25 Jan 13 |
nicklas |
61 |
|
1809 |
25 Jan 13 |
nicklas |
62 |
/** |
1809 |
25 Jan 13 |
nicklas |
Get the number of pools on the plate. |
1809 |
25 Jan 13 |
nicklas |
If no schema has been set, 0 is returned. |
1809 |
25 Jan 13 |
nicklas |
65 |
*/ |
1809 |
25 Jan 13 |
nicklas |
plate.getPools = function() |
1809 |
25 Jan 13 |
nicklas |
67 |
{ |
1934 |
17 Apr 13 |
nicklas |
return plate.poolSchema ? plate.poolSchema.numPools : 0; |
1809 |
25 Jan 13 |
nicklas |
69 |
} |
1809 |
25 Jan 13 |
nicklas |
70 |
|
1809 |
25 Jan 13 |
nicklas |
71 |
/** |
1809 |
25 Jan 13 |
nicklas |
Get all wells on the plate. |
1809 |
25 Jan 13 |
nicklas |
73 |
*/ |
1809 |
25 Jan 13 |
nicklas |
plate.getWells = function() |
1809 |
25 Jan 13 |
nicklas |
75 |
{ |
1809 |
25 Jan 13 |
nicklas |
return plate.wells; |
1809 |
25 Jan 13 |
nicklas |
77 |
} |
1809 |
25 Jan 13 |
nicklas |
78 |
|
1809 |
25 Jan 13 |
nicklas |
79 |
/** |
1809 |
25 Jan 13 |
nicklas |
Get all wells in the given row. First row is 0. |
1809 |
25 Jan 13 |
nicklas |
81 |
*/ |
1809 |
25 Jan 13 |
nicklas |
plate.getRow = function(row) |
1809 |
25 Jan 13 |
nicklas |
83 |
{ |
1809 |
25 Jan 13 |
nicklas |
var result = []; |
1809 |
25 Jan 13 |
nicklas |
for (var i = row; result.length < plate.columns; i += plate.rows) |
1809 |
25 Jan 13 |
nicklas |
86 |
{ |
1809 |
25 Jan 13 |
nicklas |
result[result.length] = plate.wells[i]; |
1809 |
25 Jan 13 |
nicklas |
88 |
} |
1809 |
25 Jan 13 |
nicklas |
return result; |
1809 |
25 Jan 13 |
nicklas |
90 |
} |
1809 |
25 Jan 13 |
nicklas |
91 |
|
1809 |
25 Jan 13 |
nicklas |
92 |
/** |
1809 |
25 Jan 13 |
nicklas |
Get all wells in the given column. First column is 0. |
1809 |
25 Jan 13 |
nicklas |
94 |
*/ |
1809 |
25 Jan 13 |
nicklas |
plate.getColumn = function(column) |
1809 |
25 Jan 13 |
nicklas |
96 |
{ |
1809 |
25 Jan 13 |
nicklas |
var result = []; |
1809 |
25 Jan 13 |
nicklas |
for (var i = column*plate.rows; result.length < plate.rows; i++) |
1809 |
25 Jan 13 |
nicklas |
99 |
{ |
1809 |
25 Jan 13 |
nicklas |
result[result.length] = plate.wells[i]; |
1809 |
25 Jan 13 |
nicklas |
101 |
} |
1809 |
25 Jan 13 |
nicklas |
return result; |
1809 |
25 Jan 13 |
nicklas |
103 |
} |
1809 |
25 Jan 13 |
nicklas |
104 |
|
1809 |
25 Jan 13 |
nicklas |
105 |
|
1809 |
25 Jan 13 |
nicklas |
106 |
/** |
1809 |
25 Jan 13 |
nicklas |
Get all wells in the given pool number. Which wells are selected, |
1809 |
25 Jan 13 |
nicklas |
depends on the pool schema. First pool number is 0. |
1809 |
25 Jan 13 |
nicklas |
109 |
*/ |
1809 |
25 Jan 13 |
nicklas |
plate.getPool = function(poolNum) |
1809 |
25 Jan 13 |
nicklas |
111 |
{ |
1809 |
25 Jan 13 |
nicklas |
return plate.poolSchema.getWellsInPool(plate, poolNum); |
1809 |
25 Jan 13 |
nicklas |
113 |
} |
1809 |
25 Jan 13 |
nicklas |
114 |
|
1809 |
25 Jan 13 |
nicklas |
115 |
/** |
1809 |
25 Jan 13 |
nicklas |
Get the well at the given coordinate. |
1809 |
25 Jan 13 |
nicklas |
117 |
*/ |
1809 |
25 Jan 13 |
nicklas |
plate.getWell = function(row, column) |
1809 |
25 Jan 13 |
nicklas |
119 |
{ |
1809 |
25 Jan 13 |
nicklas |
return plate.wells[row + column * plate.rows]; |
1809 |
25 Jan 13 |
nicklas |
121 |
} |
1809 |
25 Jan 13 |
nicklas |
122 |
|
1809 |
25 Jan 13 |
nicklas |
123 |
/** |
5631 |
27 Sep 19 |
nicklas |
Get well by location string (A1, B2, etc.) |
5631 |
27 Sep 19 |
nicklas |
125 |
*/ |
5631 |
27 Sep 19 |
nicklas |
plate.getWellByLocation = function(location) |
5631 |
27 Sep 19 |
nicklas |
127 |
{ |
5631 |
27 Sep 19 |
nicklas |
var row = Reggie.alphaToWell(location.substring(0,1)); |
5631 |
27 Sep 19 |
nicklas |
var column = parseInt(location.substring(1))-1; |
5631 |
27 Sep 19 |
nicklas |
return plate.getWell(row, column); |
5631 |
27 Sep 19 |
nicklas |
131 |
} |
5631 |
27 Sep 19 |
nicklas |
132 |
|
5631 |
27 Sep 19 |
nicklas |
133 |
/** |
1809 |
25 Jan 13 |
nicklas |
Get all wells that contains extract with a given name. |
1809 |
25 Jan 13 |
nicklas |
135 |
*/ |
1809 |
25 Jan 13 |
nicklas |
plate.getWellsByName = function(name) |
1809 |
25 Jan 13 |
nicklas |
137 |
{ |
1809 |
25 Jan 13 |
nicklas |
var result = []; |
1809 |
25 Jan 13 |
nicklas |
for (var i = 0; i < plate.wells.length; i++) |
1809 |
25 Jan 13 |
nicklas |
140 |
{ |
1809 |
25 Jan 13 |
nicklas |
var well = plate.wells[i]; |
1809 |
25 Jan 13 |
nicklas |
if (well.extract && well.extract.name == name) |
1809 |
25 Jan 13 |
nicklas |
143 |
{ |
1809 |
25 Jan 13 |
nicklas |
result[result.length] = plate.wells[i]; |
1809 |
25 Jan 13 |
nicklas |
145 |
} |
1809 |
25 Jan 13 |
nicklas |
146 |
} |
1809 |
25 Jan 13 |
nicklas |
return result; |
1809 |
25 Jan 13 |
nicklas |
148 |
} |
1809 |
25 Jan 13 |
nicklas |
149 |
|
1809 |
25 Jan 13 |
nicklas |
150 |
/** |
1809 |
25 Jan 13 |
nicklas |
Get all wells that are selected. |
1809 |
25 Jan 13 |
nicklas |
152 |
*/ |
1809 |
25 Jan 13 |
nicklas |
plate.getSelected = function() |
1809 |
25 Jan 13 |
nicklas |
154 |
{ |
1809 |
25 Jan 13 |
nicklas |
var selected = []; |
1809 |
25 Jan 13 |
nicklas |
for (var i = 0; i < plate.wells.length; i++) |
1809 |
25 Jan 13 |
nicklas |
157 |
{ |
1809 |
25 Jan 13 |
nicklas |
var well = plate.wells[i]; |
1809 |
25 Jan 13 |
nicklas |
if (well.selected) |
1809 |
25 Jan 13 |
nicklas |
160 |
{ |
1809 |
25 Jan 13 |
nicklas |
selected[selected.length] = well; |
1809 |
25 Jan 13 |
nicklas |
162 |
} |
1809 |
25 Jan 13 |
nicklas |
163 |
} |
1809 |
25 Jan 13 |
nicklas |
return selected; |
1809 |
25 Jan 13 |
nicklas |
165 |
} |
1809 |
25 Jan 13 |
nicklas |
166 |
|
1809 |
25 Jan 13 |
nicklas |
167 |
/** |
1809 |
25 Jan 13 |
nicklas |
Set the selected status for all wells in the array. |
1809 |
25 Jan 13 |
nicklas |
The wells are automatically repainted. |
1809 |
25 Jan 13 |
nicklas |
170 |
*/ |
1809 |
25 Jan 13 |
nicklas |
plate.setSelected = function(wells, select) |
1809 |
25 Jan 13 |
nicklas |
172 |
{ |
1809 |
25 Jan 13 |
nicklas |
for (var i = 0; i < wells.length; i++) |
1809 |
25 Jan 13 |
nicklas |
174 |
{ |
1809 |
25 Jan 13 |
nicklas |
var well = wells[i]; |
1809 |
25 Jan 13 |
nicklas |
well.selected = select; |
1809 |
25 Jan 13 |
nicklas |
well.paint(plate.wellPainter, plate.poolSchema); |
1809 |
25 Jan 13 |
nicklas |
178 |
} |
1809 |
25 Jan 13 |
nicklas |
179 |
} |
1809 |
25 Jan 13 |
nicklas |
180 |
|
1809 |
25 Jan 13 |
nicklas |
181 |
/** |
3645 |
03 Dec 15 |
nicklas |
Get all wells which are used (well.extract has been set) |
3645 |
03 Dec 15 |
nicklas |
183 |
*/ |
3645 |
03 Dec 15 |
nicklas |
plate.getUsed = function() |
3645 |
03 Dec 15 |
nicklas |
185 |
{ |
3645 |
03 Dec 15 |
nicklas |
var used = []; |
3645 |
03 Dec 15 |
nicklas |
for (var i = 0; i < plate.wells.length; i++) |
3645 |
03 Dec 15 |
nicklas |
188 |
{ |
3645 |
03 Dec 15 |
nicklas |
var well = plate.wells[i]; |
3645 |
03 Dec 15 |
nicklas |
if (well.extract) |
3645 |
03 Dec 15 |
nicklas |
191 |
{ |
3645 |
03 Dec 15 |
nicklas |
used[used.length] = well; |
3645 |
03 Dec 15 |
nicklas |
193 |
} |
3645 |
03 Dec 15 |
nicklas |
194 |
} |
3645 |
03 Dec 15 |
nicklas |
return used; |
3645 |
03 Dec 15 |
nicklas |
196 |
} |
3645 |
03 Dec 15 |
nicklas |
197 |
|
3645 |
03 Dec 15 |
nicklas |
198 |
/** |
5631 |
27 Sep 19 |
nicklas |
Remove extract from all wells. |
5631 |
27 Sep 19 |
nicklas |
200 |
*/ |
5631 |
27 Sep 19 |
nicklas |
plate.clear = function(wells, clearSelected) |
5631 |
27 Sep 19 |
nicklas |
202 |
{ |
5631 |
27 Sep 19 |
nicklas |
if (wells.length == 0) return; |
5631 |
27 Sep 19 |
nicklas |
for (var i = 0; i < wells.length; i++) |
5631 |
27 Sep 19 |
nicklas |
205 |
{ |
5631 |
27 Sep 19 |
nicklas |
var well = wells[i]; |
5631 |
27 Sep 19 |
nicklas |
well.extract = null; |
5631 |
27 Sep 19 |
nicklas |
well.poolNum = -1; |
5631 |
27 Sep 19 |
nicklas |
if (clearSelected) well.selected = false; |
5631 |
27 Sep 19 |
nicklas |
210 |
} |
5631 |
27 Sep 19 |
nicklas |
211 |
} |
5631 |
27 Sep 19 |
nicklas |
212 |
|
5631 |
27 Sep 19 |
nicklas |
213 |
/** |
1809 |
25 Jan 13 |
nicklas |
Toggle the selected status for all wells in the array. |
1809 |
25 Jan 13 |
nicklas |
The next status is determined by the current status of |
1809 |
25 Jan 13 |
nicklas |
the first well in the array. |
1809 |
25 Jan 13 |
nicklas |
217 |
*/ |
1809 |
25 Jan 13 |
nicklas |
plate.toggleSelected = function(wells) |
1809 |
25 Jan 13 |
nicklas |
219 |
{ |
1809 |
25 Jan 13 |
nicklas |
if (wells.length == 0) return; |
1809 |
25 Jan 13 |
nicklas |
plate.setSelected(wells, !wells[0].selected); |
1809 |
25 Jan 13 |
nicklas |
222 |
} |
1809 |
25 Jan 13 |
nicklas |
223 |
|
1809 |
25 Jan 13 |
nicklas |
224 |
/** |
1809 |
25 Jan 13 |
nicklas |
Enable or disable highlight of the given wells. |
1809 |
25 Jan 13 |
nicklas |
226 |
*/ |
1809 |
25 Jan 13 |
nicklas |
plate.setHighlight = function(wells, highlightClass, on) |
1809 |
25 Jan 13 |
nicklas |
228 |
{ |
1809 |
25 Jan 13 |
nicklas |
var tmpClass = on ? highlightClass : null; |
1809 |
25 Jan 13 |
nicklas |
for (var i = 0; i < wells.length; i++) |
1809 |
25 Jan 13 |
nicklas |
231 |
{ |
1809 |
25 Jan 13 |
nicklas |
var well = wells[i]; |
1809 |
25 Jan 13 |
nicklas |
well.highlightClass = tmpClass; |
2803 |
14 Oct 14 |
nicklas |
Doc.addOrRemoveClass(well.tag, highlightClass, on); |
1809 |
25 Jan 13 |
nicklas |
235 |
} |
1809 |
25 Jan 13 |
nicklas |
236 |
} |
1809 |
25 Jan 13 |
nicklas |
237 |
|
1809 |
25 Jan 13 |
nicklas |
238 |
/** |
1809 |
25 Jan 13 |
nicklas |
Paint the given wells. |
1809 |
25 Jan 13 |
nicklas |
240 |
*/ |
1809 |
25 Jan 13 |
nicklas |
plate.paint = function(wells) |
1809 |
25 Jan 13 |
nicklas |
242 |
{ |
1809 |
25 Jan 13 |
nicklas |
for (var i = 0; i < wells.length; i++) |
1809 |
25 Jan 13 |
nicklas |
244 |
{ |
1809 |
25 Jan 13 |
nicklas |
wells[i].paint(plate.wellPainter, plate.poolSchema); |
1809 |
25 Jan 13 |
nicklas |
246 |
} |
1809 |
25 Jan 13 |
nicklas |
247 |
} |
1809 |
25 Jan 13 |
nicklas |
248 |
|
1809 |
25 Jan 13 |
nicklas |
249 |
/** |
1809 |
25 Jan 13 |
nicklas |
Check if the plate have any replicated extracts. Eg. extracts that are |
1809 |
25 Jan 13 |
nicklas |
found in more than one well. If a name is given, only extracts with that |
1809 |
25 Jan 13 |
nicklas |
name is checked, otherwise the complete plate is checked. The |
1809 |
25 Jan 13 |
nicklas |
result of the check is stored in the 'replicate' flag of the well. |
1809 |
25 Jan 13 |
nicklas |
254 |
*/ |
1809 |
25 Jan 13 |
nicklas |
plate.checkReplicates = function(name, noRepaint) |
1809 |
25 Jan 13 |
nicklas |
256 |
{ |
1809 |
25 Jan 13 |
nicklas |
var result = []; |
1809 |
25 Jan 13 |
nicklas |
if (name) |
1809 |
25 Jan 13 |
nicklas |
259 |
{ |
1809 |
25 Jan 13 |
nicklas |
// If a name has been given, it is relatively easy |
1809 |
25 Jan 13 |
nicklas |
var wells = plate.getWellsByName(name); |
1809 |
25 Jan 13 |
nicklas |
var isReplicate = wells.length > 1; |
1809 |
25 Jan 13 |
nicklas |
for (var i = 0; i < wells.length; i++) |
1809 |
25 Jan 13 |
nicklas |
264 |
{ |
1809 |
25 Jan 13 |
nicklas |
var well = wells[i]; |
1809 |
25 Jan 13 |
nicklas |
if (well.replicate != isReplicate) |
1809 |
25 Jan 13 |
nicklas |
267 |
{ |
1809 |
25 Jan 13 |
nicklas |
well.replicate = isReplicate; |
1809 |
25 Jan 13 |
nicklas |
if (!noRepaint) well.paint(plate.wellPainter, plate.poolSchema); |
1809 |
25 Jan 13 |
nicklas |
270 |
} |
1809 |
25 Jan 13 |
nicklas |
271 |
} |
1809 |
25 Jan 13 |
nicklas |
272 |
} |
1809 |
25 Jan 13 |
nicklas |
else |
1809 |
25 Jan 13 |
nicklas |
274 |
{ |
1809 |
25 Jan 13 |
nicklas |
// No name, we begin by counting the number of times we find any given name |
1809 |
25 Jan 13 |
nicklas |
var nameCount = []; |
1809 |
25 Jan 13 |
nicklas |
for (var i = 0; i < plate.wells.length; i++) |
1809 |
25 Jan 13 |
nicklas |
278 |
{ |
1809 |
25 Jan 13 |
nicklas |
var well = plate.wells[i]; |
1809 |
25 Jan 13 |
nicklas |
// Ignore empty wells and wells with 'Stratagene' or external |
1809 |
25 Jan 13 |
nicklas |
if (well.extract && !well.extract.stratagene && !well.extract.external) |
1809 |
25 Jan 13 |
nicklas |
282 |
{ |
1809 |
25 Jan 13 |
nicklas |
nameCount[well.extract.name] = 1 + (nameCount[well.extract.name] || 0); |
1809 |
25 Jan 13 |
nicklas |
284 |
} |
1809 |
25 Jan 13 |
nicklas |
285 |
} |
1809 |
25 Jan 13 |
nicklas |
// Then, we update the status for all wells |
1809 |
25 Jan 13 |
nicklas |
for (var i = 0; i < plate.wells.length; i++) |
1809 |
25 Jan 13 |
nicklas |
288 |
{ |
1809 |
25 Jan 13 |
nicklas |
var well = plate.wells[i]; |
1809 |
25 Jan 13 |
nicklas |
if (well.extract) |
1809 |
25 Jan 13 |
nicklas |
291 |
{ |
1809 |
25 Jan 13 |
nicklas |
var isReplicate = nameCount[well.extract.name] > 1; |
1809 |
25 Jan 13 |
nicklas |
if (well.replicate != isReplicate) |
1809 |
25 Jan 13 |
nicklas |
294 |
{ |
1809 |
25 Jan 13 |
nicklas |
well.replicate = isReplicate; |
1809 |
25 Jan 13 |
nicklas |
if (!noRepaint) well.paint(plate.wellPainter, plate.poolSchema); |
1809 |
25 Jan 13 |
nicklas |
297 |
} |
1809 |
25 Jan 13 |
nicklas |
298 |
} |
1809 |
25 Jan 13 |
nicklas |
299 |
} |
1809 |
25 Jan 13 |
nicklas |
300 |
} |
1809 |
25 Jan 13 |
nicklas |
301 |
} |
1809 |
25 Jan 13 |
nicklas |
302 |
|
1809 |
25 Jan 13 |
nicklas |
return plate; |
1809 |
25 Jan 13 |
nicklas |
304 |
}(); |
1809 |
25 Jan 13 |
nicklas |
305 |
|
1809 |
25 Jan 13 |
nicklas |
306 |
/** |
1809 |
25 Jan 13 |
nicklas |
Represents a well on the plate. Each well is created when |
1809 |
25 Jan 13 |
nicklas |
the page is loaded and is initially empty. |
1809 |
25 Jan 13 |
nicklas |
309 |
*/ |
1809 |
25 Jan 13 |
nicklas |
function Well(row, column) |
1809 |
25 Jan 13 |
nicklas |
311 |
{ |
1809 |
25 Jan 13 |
nicklas |
this.row = row; |
1809 |
25 Jan 13 |
nicklas |
this.column = column; |
1809 |
25 Jan 13 |
nicklas |
this.selected = false; |
1809 |
25 Jan 13 |
nicklas |
this.highlighClass = null; |
1809 |
25 Jan 13 |
nicklas |
this.extract = null; |
1809 |
25 Jan 13 |
nicklas |
this.duplicates = null; |
1809 |
25 Jan 13 |
nicklas |
this.replicate = false; |
1809 |
25 Jan 13 |
nicklas |
this.warning = null; |
1809 |
25 Jan 13 |
nicklas |
this.error = null; |
1809 |
25 Jan 13 |
nicklas |
321 |
|
1809 |
25 Jan 13 |
nicklas |
this.tag = document.getElementById('well.'+row+'.'+column); |
1809 |
25 Jan 13 |
nicklas |
323 |
} |
1809 |
25 Jan 13 |
nicklas |
324 |
|
1809 |
25 Jan 13 |
nicklas |
325 |
/** |
1809 |
25 Jan 13 |
nicklas |
Set the extract item that is put into this well. Use |
1809 |
25 Jan 13 |
nicklas |
'null' to clear the well. The extract should always |
1809 |
25 Jan 13 |
nicklas |
have a 'name' property, and an 'id' property if it |
1809 |
25 Jan 13 |
nicklas |
exists in the database. |
1809 |
25 Jan 13 |
nicklas |
330 |
*/ |
1809 |
25 Jan 13 |
nicklas |
Well.prototype.setExtract = function(extract) |
1809 |
25 Jan 13 |
nicklas |
332 |
{ |
1809 |
25 Jan 13 |
nicklas |
this.extract = extract; |
1809 |
25 Jan 13 |
nicklas |
this.duplicates = null; |
1809 |
25 Jan 13 |
nicklas |
this.replicate = false; |
1809 |
25 Jan 13 |
nicklas |
if (extract && this.clipboard) this.doneWithCopy(); |
1809 |
25 Jan 13 |
nicklas |
337 |
} |
1809 |
25 Jan 13 |
nicklas |
338 |
|
1809 |
25 Jan 13 |
nicklas |
339 |
/** |
1809 |
25 Jan 13 |
nicklas |
Set duplicate extract items in this well. This can |
1809 |
25 Jan 13 |
nicklas |
happen when using a file import if the same location |
1809 |
25 Jan 13 |
nicklas |
is specified twice and is an error condition which |
1809 |
25 Jan 13 |
nicklas |
must be resolved. |
1809 |
25 Jan 13 |
nicklas |
344 |
*/ |
1809 |
25 Jan 13 |
nicklas |
Well.prototype.addDuplicate = function(extract) |
1809 |
25 Jan 13 |
nicklas |
346 |
{ |
1809 |
25 Jan 13 |
nicklas |
if (!this.duplicates) |
1809 |
25 Jan 13 |
nicklas |
348 |
{ |
1809 |
25 Jan 13 |
nicklas |
this.duplicates = []; |
1809 |
25 Jan 13 |
nicklas |
this.duplicates[0] = this.extract.name; |
1809 |
25 Jan 13 |
nicklas |
351 |
} |
1809 |
25 Jan 13 |
nicklas |
this.duplicates[this.duplicates.length] = extract.name; |
1809 |
25 Jan 13 |
nicklas |
353 |
} |
1809 |
25 Jan 13 |
nicklas |
354 |
|
1809 |
25 Jan 13 |
nicklas |
355 |
/** |
1809 |
25 Jan 13 |
nicklas |
Create a copy-object holding information about this well. |
1809 |
25 Jan 13 |
nicklas |
The copy has 'well' property pointing to this well and |
1809 |
25 Jan 13 |
nicklas |
'name' property holding the extract name if the well is not |
1809 |
25 Jan 13 |
nicklas |
empty. The 'clipboard' flag of this well is set to true. |
1809 |
25 Jan 13 |
nicklas |
360 |
*/ |
1809 |
25 Jan 13 |
nicklas |
Well.prototype.makeCopy = function() |
1809 |
25 Jan 13 |
nicklas |
362 |
{ |
1809 |
25 Jan 13 |
nicklas |
var cp = {}; |
1809 |
25 Jan 13 |
nicklas |
cp.well = this; |
1809 |
25 Jan 13 |
nicklas |
cp.name = this.extract ? this.extract.name : null; |
1816 |
31 Jan 13 |
nicklas |
cp.comment = this.extract ? this.extract.comment : null; |
1809 |
25 Jan 13 |
nicklas |
this.clipboard = true; |
1809 |
25 Jan 13 |
nicklas |
this.copyText = cp.name; |
1809 |
25 Jan 13 |
nicklas |
return cp; |
1809 |
25 Jan 13 |
nicklas |
370 |
} |
1809 |
25 Jan 13 |
nicklas |
371 |
|
1809 |
25 Jan 13 |
nicklas |
372 |
/** |
1809 |
25 Jan 13 |
nicklas |
Unset the 'clipboard' flag for this well. |
1809 |
25 Jan 13 |
nicklas |
374 |
*/ |
1809 |
25 Jan 13 |
nicklas |
Well.prototype.doneWithCopy = function() |
1809 |
25 Jan 13 |
nicklas |
376 |
{ |
1809 |
25 Jan 13 |
nicklas |
this.clipboard = false; |
1809 |
25 Jan 13 |
nicklas |
this.copyText = null; |
1809 |
25 Jan 13 |
nicklas |
379 |
} |
1809 |
25 Jan 13 |
nicklas |
380 |
|
1809 |
25 Jan 13 |
nicklas |
Well.prototype.setWarning = function(warning) |
1809 |
25 Jan 13 |
nicklas |
382 |
{ |
1809 |
25 Jan 13 |
nicklas |
this.warning = warning; |
1809 |
25 Jan 13 |
nicklas |
384 |
} |
1809 |
25 Jan 13 |
nicklas |
385 |
|
1809 |
25 Jan 13 |
nicklas |
Well.prototype.hasWarning = function() |
1809 |
25 Jan 13 |
nicklas |
387 |
{ |
5631 |
27 Sep 19 |
nicklas |
return this.warning != null || this.extract && this.extract.warning != null; |
1809 |
25 Jan 13 |
nicklas |
389 |
} |
1809 |
25 Jan 13 |
nicklas |
390 |
|
1809 |
25 Jan 13 |
nicklas |
Well.prototype.setError = function(error) |
1809 |
25 Jan 13 |
nicklas |
392 |
{ |
1809 |
25 Jan 13 |
nicklas |
this.error = error; |
1809 |
25 Jan 13 |
nicklas |
394 |
} |
1809 |
25 Jan 13 |
nicklas |
395 |
|
1809 |
25 Jan 13 |
nicklas |
Well.prototype.hasError = function() |
1809 |
25 Jan 13 |
nicklas |
397 |
{ |
5631 |
27 Sep 19 |
nicklas |
return this.error != null || this.extract && this.extract.error != null; |
1809 |
25 Jan 13 |
nicklas |
399 |
} |
1809 |
25 Jan 13 |
nicklas |
400 |
|
1809 |
25 Jan 13 |
nicklas |
Well.prototype.getClassName = function(wellPainter, poolSchema) |
1809 |
25 Jan 13 |
nicklas |
402 |
{ |
1809 |
25 Jan 13 |
nicklas |
var c = this.column; |
1809 |
25 Jan 13 |
nicklas |
var cls = 'well col-'+c; |
1809 |
25 Jan 13 |
nicklas |
if (this.selected) cls += ' selected'; |
1809 |
25 Jan 13 |
nicklas |
if (this.clipboard) cls += ' clipboard'; |
1960 |
06 May 13 |
nicklas |
if (!this.extract) cls += ' empty'; |
1809 |
25 Jan 13 |
nicklas |
if (this.hasError()) cls += ' err'; |
1809 |
25 Jan 13 |
nicklas |
if (this.hasWarning()) cls += ' warning'; |
1809 |
25 Jan 13 |
nicklas |
if (this.highlightClass) cls += ' ' + this.highlightClass; |
1809 |
25 Jan 13 |
nicklas |
411 |
|
1809 |
25 Jan 13 |
nicklas |
if (poolSchema) |
1809 |
25 Jan 13 |
nicklas |
413 |
{ |
1810 |
28 Jan 13 |
nicklas |
cls += ' ' + poolSchema.getClassNameForWell(this, wellPainter); |
1809 |
25 Jan 13 |
nicklas |
415 |
} |
1809 |
25 Jan 13 |
nicklas |
if (wellPainter) |
1809 |
25 Jan 13 |
nicklas |
417 |
{ |
1810 |
28 Jan 13 |
nicklas |
cls += ' ' + wellPainter.getClassNameForWell(this, poolSchema); |
1809 |
25 Jan 13 |
nicklas |
419 |
} |
1809 |
25 Jan 13 |
nicklas |
return cls; |
1809 |
25 Jan 13 |
nicklas |
421 |
} |
1809 |
25 Jan 13 |
nicklas |
422 |
|
1809 |
25 Jan 13 |
nicklas |
Well.prototype.getText = function(wellPainter, poolSchema) |
1809 |
25 Jan 13 |
nicklas |
424 |
{ |
1809 |
25 Jan 13 |
nicklas |
var text = ''; |
1809 |
25 Jan 13 |
nicklas |
if (wellPainter) |
1809 |
25 Jan 13 |
nicklas |
427 |
{ |
1810 |
28 Jan 13 |
nicklas |
text = wellPainter.getWellText(this, poolSchema); |
1809 |
25 Jan 13 |
nicklas |
429 |
} |
1809 |
25 Jan 13 |
nicklas |
else |
1809 |
25 Jan 13 |
nicklas |
431 |
{ |
1809 |
25 Jan 13 |
nicklas |
if (this.extract) |
1809 |
25 Jan 13 |
nicklas |
433 |
{ |
1809 |
25 Jan 13 |
nicklas |
text += '<div class="name">'+this.extract.name+'</div>' |
1809 |
25 Jan 13 |
nicklas |
435 |
} |
1809 |
25 Jan 13 |
nicklas |
436 |
} |
1809 |
25 Jan 13 |
nicklas |
if (this.hasError()) |
1809 |
25 Jan 13 |
nicklas |
438 |
{ |
5631 |
27 Sep 19 |
nicklas |
text += '<div class="err-msg">'+(this.error || this.extract.error)+'</div>'; |
1809 |
25 Jan 13 |
nicklas |
440 |
} |
1809 |
25 Jan 13 |
nicklas |
if (this.hasWarning()) |
1809 |
25 Jan 13 |
nicklas |
442 |
{ |
5631 |
27 Sep 19 |
nicklas |
text += '<div class="warn-msg">'+(this.warning || this.extract.warning)+'</div>'; |
1809 |
25 Jan 13 |
nicklas |
444 |
} |
1809 |
25 Jan 13 |
nicklas |
return text; |
1809 |
25 Jan 13 |
nicklas |
446 |
} |
1809 |
25 Jan 13 |
nicklas |
447 |
|
1809 |
25 Jan 13 |
nicklas |
Well.prototype.paint = function(wellPainter, poolSchema) |
1809 |
25 Jan 13 |
nicklas |
449 |
{ |
1809 |
25 Jan 13 |
nicklas |
this.warning = null; |
1809 |
25 Jan 13 |
nicklas |
this.error = null; |
1809 |
25 Jan 13 |
nicklas |
this.tag.innerHTML = this.getText(wellPainter, poolSchema); |
1809 |
25 Jan 13 |
nicklas |
this.tag.className = this.getClassName(wellPainter, poolSchema); |
1809 |
25 Jan 13 |
nicklas |
454 |
} |
1809 |
25 Jan 13 |
nicklas |
455 |
|
1809 |
25 Jan 13 |
nicklas |
456 |
|