2933 |
14 Nov 14 |
olle |
1 |
|
2933 |
14 Nov 14 |
olle |
var Plate = function() |
2933 |
14 Nov 14 |
olle |
3 |
{ |
2933 |
14 Nov 14 |
olle |
var plate = {}; |
2933 |
14 Nov 14 |
olle |
plate.rows = 8; |
2933 |
14 Nov 14 |
olle |
plate.columns = 12; |
2933 |
14 Nov 14 |
olle |
plate.wells = []; |
2933 |
14 Nov 14 |
olle |
plate.poolSchema = null; |
2933 |
14 Nov 14 |
olle |
plate.wellPainter = null; |
2933 |
14 Nov 14 |
olle |
10 |
|
2933 |
14 Nov 14 |
olle |
11 |
/** |
2933 |
14 Nov 14 |
olle |
Initialize a plate with the given number of rows and columns. |
2933 |
14 Nov 14 |
olle |
13 |
*/ |
2933 |
14 Nov 14 |
olle |
plate.init = function(rows, columns, poolSchema, wellPainter) |
2933 |
14 Nov 14 |
olle |
15 |
{ |
2933 |
14 Nov 14 |
olle |
if (rows) plate.rows = rows; |
2933 |
14 Nov 14 |
olle |
if (columns) plate.columns = columns; |
2933 |
14 Nov 14 |
olle |
if (poolSchema) plate.poolSchema = poolSchema; |
2933 |
14 Nov 14 |
olle |
if (wellPainter) plate.wellPainter = wellPainter; |
2933 |
14 Nov 14 |
olle |
20 |
|
2933 |
14 Nov 14 |
olle |
for (var c = 0; c < plate.columns; c++) |
2933 |
14 Nov 14 |
olle |
22 |
{ |
2933 |
14 Nov 14 |
olle |
for (var r = 0; r < plate.rows; r++) |
2933 |
14 Nov 14 |
olle |
24 |
{ |
2933 |
14 Nov 14 |
olle |
plate.wells[plate.wells.length] = new Well(r, c); |
2933 |
14 Nov 14 |
olle |
26 |
} |
2933 |
14 Nov 14 |
olle |
27 |
} |
2933 |
14 Nov 14 |
olle |
28 |
} |
2933 |
14 Nov 14 |
olle |
29 |
|
2933 |
14 Nov 14 |
olle |
30 |
/** |
2933 |
14 Nov 14 |
olle |
Change the pool layout schema for the plate. |
2933 |
14 Nov 14 |
olle |
32 |
*/ |
2933 |
14 Nov 14 |
olle |
plate.setPoolSchema = function(poolSchema) |
2933 |
14 Nov 14 |
olle |
34 |
{ |
2933 |
14 Nov 14 |
olle |
plate.poolSchema = poolSchema; |
2933 |
14 Nov 14 |
olle |
36 |
} |
2933 |
14 Nov 14 |
olle |
37 |
|
2933 |
14 Nov 14 |
olle |
38 |
/** |
2933 |
14 Nov 14 |
olle |
Change the well painter for the plate. |
2933 |
14 Nov 14 |
olle |
40 |
*/ |
2933 |
14 Nov 14 |
olle |
plate.setWellPainter = function(wellPainter) |
2933 |
14 Nov 14 |
olle |
42 |
{ |
2933 |
14 Nov 14 |
olle |
plate.wellPainter = wellPainter; |
2933 |
14 Nov 14 |
olle |
44 |
} |
2933 |
14 Nov 14 |
olle |
45 |
|
2933 |
14 Nov 14 |
olle |
46 |
/** |
2933 |
14 Nov 14 |
olle |
Get the number of rows on the plate. |
2933 |
14 Nov 14 |
olle |
48 |
*/ |
2933 |
14 Nov 14 |
olle |
plate.getRows = function() |
2933 |
14 Nov 14 |
olle |
50 |
{ |
2933 |
14 Nov 14 |
olle |
return plate.rows; |
2933 |
14 Nov 14 |
olle |
52 |
} |
2933 |
14 Nov 14 |
olle |
53 |
|
2933 |
14 Nov 14 |
olle |
54 |
/** |
2933 |
14 Nov 14 |
olle |
Get the number of columns on the plate. |
2933 |
14 Nov 14 |
olle |
56 |
*/ |
2933 |
14 Nov 14 |
olle |
plate.getColumns = function() |
2933 |
14 Nov 14 |
olle |
58 |
{ |
2933 |
14 Nov 14 |
olle |
return plate.columns; |
2933 |
14 Nov 14 |
olle |
60 |
} |
2933 |
14 Nov 14 |
olle |
61 |
|
2933 |
14 Nov 14 |
olle |
62 |
/** |
2933 |
14 Nov 14 |
olle |
Get the number of pools on the plate. |
2933 |
14 Nov 14 |
olle |
If no schema has been set, 0 is returned. |
2933 |
14 Nov 14 |
olle |
65 |
*/ |
2933 |
14 Nov 14 |
olle |
plate.getPools = function() |
2933 |
14 Nov 14 |
olle |
67 |
{ |
2933 |
14 Nov 14 |
olle |
return plate.poolSchema ? plate.poolSchema.numPools : 0; |
2933 |
14 Nov 14 |
olle |
69 |
} |
2933 |
14 Nov 14 |
olle |
70 |
|
2933 |
14 Nov 14 |
olle |
71 |
/** |
2933 |
14 Nov 14 |
olle |
Get all wells on the plate. |
2933 |
14 Nov 14 |
olle |
73 |
*/ |
2933 |
14 Nov 14 |
olle |
plate.getWells = function() |
2933 |
14 Nov 14 |
olle |
75 |
{ |
2933 |
14 Nov 14 |
olle |
return plate.wells; |
2933 |
14 Nov 14 |
olle |
77 |
} |
2933 |
14 Nov 14 |
olle |
78 |
|
2933 |
14 Nov 14 |
olle |
79 |
/** |
2933 |
14 Nov 14 |
olle |
Get all wells in the given row. First row is 0. |
2933 |
14 Nov 14 |
olle |
81 |
*/ |
2933 |
14 Nov 14 |
olle |
plate.getRow = function(row) |
2933 |
14 Nov 14 |
olle |
83 |
{ |
2933 |
14 Nov 14 |
olle |
var result = []; |
2933 |
14 Nov 14 |
olle |
for (var i = row; result.length < plate.columns; i += plate.rows) |
2933 |
14 Nov 14 |
olle |
86 |
{ |
2933 |
14 Nov 14 |
olle |
result[result.length] = plate.wells[i]; |
2933 |
14 Nov 14 |
olle |
88 |
} |
2933 |
14 Nov 14 |
olle |
return result; |
2933 |
14 Nov 14 |
olle |
90 |
} |
2933 |
14 Nov 14 |
olle |
91 |
|
2933 |
14 Nov 14 |
olle |
92 |
/** |
2933 |
14 Nov 14 |
olle |
Get all wells in the given column. First column is 0. |
2933 |
14 Nov 14 |
olle |
94 |
*/ |
2933 |
14 Nov 14 |
olle |
plate.getColumn = function(column) |
2933 |
14 Nov 14 |
olle |
96 |
{ |
2933 |
14 Nov 14 |
olle |
var result = []; |
2933 |
14 Nov 14 |
olle |
for (var i = column*plate.rows; result.length < plate.rows; i++) |
2933 |
14 Nov 14 |
olle |
99 |
{ |
2933 |
14 Nov 14 |
olle |
result[result.length] = plate.wells[i]; |
2933 |
14 Nov 14 |
olle |
101 |
} |
2933 |
14 Nov 14 |
olle |
return result; |
2933 |
14 Nov 14 |
olle |
103 |
} |
2933 |
14 Nov 14 |
olle |
104 |
|
2933 |
14 Nov 14 |
olle |
105 |
|
2933 |
14 Nov 14 |
olle |
106 |
/** |
2933 |
14 Nov 14 |
olle |
Get all wells in the given pool number. Which wells are selected, |
2933 |
14 Nov 14 |
olle |
depends on the pool schema. First pool number is 0. |
2933 |
14 Nov 14 |
olle |
109 |
*/ |
2933 |
14 Nov 14 |
olle |
plate.getPool = function(poolNum) |
2933 |
14 Nov 14 |
olle |
111 |
{ |
2933 |
14 Nov 14 |
olle |
return plate.poolSchema.getWellsInPool(plate, poolNum); |
2933 |
14 Nov 14 |
olle |
113 |
} |
2933 |
14 Nov 14 |
olle |
114 |
|
2933 |
14 Nov 14 |
olle |
115 |
/** |
2933 |
14 Nov 14 |
olle |
Get the well at the given coordinate. |
2933 |
14 Nov 14 |
olle |
117 |
*/ |
2933 |
14 Nov 14 |
olle |
plate.getWell = function(row, column) |
2933 |
14 Nov 14 |
olle |
119 |
{ |
2933 |
14 Nov 14 |
olle |
return plate.wells[row + column * plate.rows]; |
2933 |
14 Nov 14 |
olle |
121 |
} |
2933 |
14 Nov 14 |
olle |
122 |
|
2933 |
14 Nov 14 |
olle |
123 |
/** |
2933 |
14 Nov 14 |
olle |
Get all wells that contains extract with a given name. |
2933 |
14 Nov 14 |
olle |
125 |
*/ |
2933 |
14 Nov 14 |
olle |
plate.getWellsByName = function(name) |
2933 |
14 Nov 14 |
olle |
127 |
{ |
2933 |
14 Nov 14 |
olle |
var result = []; |
2933 |
14 Nov 14 |
olle |
for (var i = 0; i < plate.wells.length; i++) |
2933 |
14 Nov 14 |
olle |
130 |
{ |
2933 |
14 Nov 14 |
olle |
var well = plate.wells[i]; |
2933 |
14 Nov 14 |
olle |
if (well.extract && well.extract.name == name) |
2933 |
14 Nov 14 |
olle |
133 |
{ |
2933 |
14 Nov 14 |
olle |
result[result.length] = plate.wells[i]; |
2933 |
14 Nov 14 |
olle |
135 |
} |
2933 |
14 Nov 14 |
olle |
136 |
} |
2933 |
14 Nov 14 |
olle |
return result; |
2933 |
14 Nov 14 |
olle |
138 |
} |
2933 |
14 Nov 14 |
olle |
139 |
|
2933 |
14 Nov 14 |
olle |
140 |
/** |
2933 |
14 Nov 14 |
olle |
Get all wells that are selected. |
2933 |
14 Nov 14 |
olle |
142 |
*/ |
2933 |
14 Nov 14 |
olle |
plate.getSelected = function() |
2933 |
14 Nov 14 |
olle |
144 |
{ |
2933 |
14 Nov 14 |
olle |
var selected = []; |
2933 |
14 Nov 14 |
olle |
for (var i = 0; i < plate.wells.length; i++) |
2933 |
14 Nov 14 |
olle |
147 |
{ |
2933 |
14 Nov 14 |
olle |
var well = plate.wells[i]; |
2933 |
14 Nov 14 |
olle |
if (well.selected) |
2933 |
14 Nov 14 |
olle |
150 |
{ |
2933 |
14 Nov 14 |
olle |
selected[selected.length] = well; |
2933 |
14 Nov 14 |
olle |
152 |
} |
2933 |
14 Nov 14 |
olle |
153 |
} |
2933 |
14 Nov 14 |
olle |
return selected; |
2933 |
14 Nov 14 |
olle |
155 |
} |
2933 |
14 Nov 14 |
olle |
156 |
|
2933 |
14 Nov 14 |
olle |
157 |
/** |
2933 |
14 Nov 14 |
olle |
Set the selected status for all wells in the array. |
2933 |
14 Nov 14 |
olle |
The wells are automatically repainted. |
2933 |
14 Nov 14 |
olle |
160 |
*/ |
2933 |
14 Nov 14 |
olle |
plate.setSelected = function(wells, select) |
2933 |
14 Nov 14 |
olle |
162 |
{ |
2933 |
14 Nov 14 |
olle |
for (var i = 0; i < wells.length; i++) |
2933 |
14 Nov 14 |
olle |
164 |
{ |
2933 |
14 Nov 14 |
olle |
var well = wells[i]; |
2933 |
14 Nov 14 |
olle |
well.selected = select; |
2933 |
14 Nov 14 |
olle |
well.paint(plate.wellPainter, plate.poolSchema); |
2933 |
14 Nov 14 |
olle |
168 |
} |
2933 |
14 Nov 14 |
olle |
169 |
} |
2933 |
14 Nov 14 |
olle |
170 |
|
2933 |
14 Nov 14 |
olle |
171 |
/** |
2933 |
14 Nov 14 |
olle |
Toggle the selected status for all wells in the array. |
2933 |
14 Nov 14 |
olle |
The next status is determined by the current status of |
2933 |
14 Nov 14 |
olle |
the first well in the array. |
2933 |
14 Nov 14 |
olle |
175 |
*/ |
2933 |
14 Nov 14 |
olle |
plate.toggleSelected = function(wells) |
2933 |
14 Nov 14 |
olle |
177 |
{ |
2933 |
14 Nov 14 |
olle |
if (wells.length == 0) return; |
2933 |
14 Nov 14 |
olle |
plate.setSelected(wells, !wells[0].selected); |
2933 |
14 Nov 14 |
olle |
180 |
} |
2933 |
14 Nov 14 |
olle |
181 |
|
2933 |
14 Nov 14 |
olle |
182 |
/** |
2933 |
14 Nov 14 |
olle |
Enable or disable highlight of the given wells. |
2933 |
14 Nov 14 |
olle |
184 |
*/ |
2933 |
14 Nov 14 |
olle |
plate.setHighlight = function(wells, highlightClass, on) |
2933 |
14 Nov 14 |
olle |
186 |
{ |
2933 |
14 Nov 14 |
olle |
var tmpClass = on ? highlightClass : null; |
2933 |
14 Nov 14 |
olle |
for (var i = 0; i < wells.length; i++) |
2933 |
14 Nov 14 |
olle |
189 |
{ |
2933 |
14 Nov 14 |
olle |
var well = wells[i]; |
2933 |
14 Nov 14 |
olle |
well.highlightClass = tmpClass; |
2933 |
14 Nov 14 |
olle |
Doc.addOrRemoveClass(well.tag, highlightClass, on); |
2933 |
14 Nov 14 |
olle |
193 |
} |
2933 |
14 Nov 14 |
olle |
194 |
} |
2933 |
14 Nov 14 |
olle |
195 |
|
2933 |
14 Nov 14 |
olle |
196 |
/** |
2933 |
14 Nov 14 |
olle |
Paint the given wells. |
2933 |
14 Nov 14 |
olle |
198 |
*/ |
2933 |
14 Nov 14 |
olle |
plate.paint = function(wells) |
2933 |
14 Nov 14 |
olle |
200 |
{ |
2933 |
14 Nov 14 |
olle |
for (var i = 0; i < wells.length; i++) |
2933 |
14 Nov 14 |
olle |
202 |
{ |
2933 |
14 Nov 14 |
olle |
wells[i].paint(plate.wellPainter, plate.poolSchema); |
2933 |
14 Nov 14 |
olle |
204 |
} |
2933 |
14 Nov 14 |
olle |
205 |
} |
2933 |
14 Nov 14 |
olle |
206 |
|
2933 |
14 Nov 14 |
olle |
207 |
/** |
2933 |
14 Nov 14 |
olle |
Check if the plate have any replicated extracts. Eg. extracts that are |
2933 |
14 Nov 14 |
olle |
found in more than one well. If a name is given, only extracts with that |
2933 |
14 Nov 14 |
olle |
name is checked, otherwise the complete plate is checked. The |
2933 |
14 Nov 14 |
olle |
result of the check is stored in the 'replicate' flag of the well. |
2933 |
14 Nov 14 |
olle |
212 |
*/ |
2933 |
14 Nov 14 |
olle |
plate.checkReplicates = function(name, noRepaint) |
2933 |
14 Nov 14 |
olle |
214 |
{ |
2933 |
14 Nov 14 |
olle |
var result = []; |
2933 |
14 Nov 14 |
olle |
if (name) |
2933 |
14 Nov 14 |
olle |
217 |
{ |
2933 |
14 Nov 14 |
olle |
// If a name has been given, it is relatively easy |
2933 |
14 Nov 14 |
olle |
var wells = plate.getWellsByName(name); |
2933 |
14 Nov 14 |
olle |
var isReplicate = wells.length > 1; |
2933 |
14 Nov 14 |
olle |
for (var i = 0; i < wells.length; i++) |
2933 |
14 Nov 14 |
olle |
222 |
{ |
2933 |
14 Nov 14 |
olle |
var well = wells[i]; |
2933 |
14 Nov 14 |
olle |
if (well.replicate != isReplicate) |
2933 |
14 Nov 14 |
olle |
225 |
{ |
2933 |
14 Nov 14 |
olle |
well.replicate = isReplicate; |
2933 |
14 Nov 14 |
olle |
if (!noRepaint) well.paint(plate.wellPainter, plate.poolSchema); |
2933 |
14 Nov 14 |
olle |
228 |
} |
2933 |
14 Nov 14 |
olle |
229 |
} |
2933 |
14 Nov 14 |
olle |
230 |
} |
2933 |
14 Nov 14 |
olle |
else |
2933 |
14 Nov 14 |
olle |
232 |
{ |
2933 |
14 Nov 14 |
olle |
// No name, we begin by counting the number of times we find any given name |
2933 |
14 Nov 14 |
olle |
var nameCount = []; |
2933 |
14 Nov 14 |
olle |
for (var i = 0; i < plate.wells.length; i++) |
2933 |
14 Nov 14 |
olle |
236 |
{ |
2933 |
14 Nov 14 |
olle |
var well = plate.wells[i]; |
2933 |
14 Nov 14 |
olle |
// Ignore empty wells and wells with 'Stratagene' or external |
2933 |
14 Nov 14 |
olle |
if (well.extract && !well.extract.stratagene && !well.extract.external) |
2933 |
14 Nov 14 |
olle |
240 |
{ |
2933 |
14 Nov 14 |
olle |
nameCount[well.extract.name] = 1 + (nameCount[well.extract.name] || 0); |
2933 |
14 Nov 14 |
olle |
242 |
} |
2933 |
14 Nov 14 |
olle |
243 |
} |
2933 |
14 Nov 14 |
olle |
// Then, we update the status for all wells |
2933 |
14 Nov 14 |
olle |
for (var i = 0; i < plate.wells.length; i++) |
2933 |
14 Nov 14 |
olle |
246 |
{ |
2933 |
14 Nov 14 |
olle |
var well = plate.wells[i]; |
2933 |
14 Nov 14 |
olle |
if (well.extract) |
2933 |
14 Nov 14 |
olle |
249 |
{ |
2933 |
14 Nov 14 |
olle |
var isReplicate = nameCount[well.extract.name] > 1; |
2933 |
14 Nov 14 |
olle |
if (well.replicate != isReplicate) |
2933 |
14 Nov 14 |
olle |
252 |
{ |
2933 |
14 Nov 14 |
olle |
well.replicate = isReplicate; |
2933 |
14 Nov 14 |
olle |
if (!noRepaint) well.paint(plate.wellPainter, plate.poolSchema); |
2933 |
14 Nov 14 |
olle |
255 |
} |
2933 |
14 Nov 14 |
olle |
256 |
} |
2933 |
14 Nov 14 |
olle |
257 |
} |
2933 |
14 Nov 14 |
olle |
258 |
} |
2933 |
14 Nov 14 |
olle |
259 |
} |
2933 |
14 Nov 14 |
olle |
260 |
|
2933 |
14 Nov 14 |
olle |
return plate; |
2933 |
14 Nov 14 |
olle |
262 |
}(); |
2933 |
14 Nov 14 |
olle |
263 |
|
2933 |
14 Nov 14 |
olle |
264 |
/** |
2933 |
14 Nov 14 |
olle |
Represents a well on the plate. Each well is created when |
2933 |
14 Nov 14 |
olle |
the page is loaded and is initially empty. |
2933 |
14 Nov 14 |
olle |
267 |
*/ |
2933 |
14 Nov 14 |
olle |
function Well(row, column) |
2933 |
14 Nov 14 |
olle |
269 |
{ |
2933 |
14 Nov 14 |
olle |
this.row = row; |
2933 |
14 Nov 14 |
olle |
this.column = column; |
2933 |
14 Nov 14 |
olle |
this.selected = false; |
2933 |
14 Nov 14 |
olle |
this.highlighClass = null; |
2933 |
14 Nov 14 |
olle |
this.extract = null; |
2933 |
14 Nov 14 |
olle |
this.duplicates = null; |
2933 |
14 Nov 14 |
olle |
this.replicate = false; |
2933 |
14 Nov 14 |
olle |
this.warning = null; |
2933 |
14 Nov 14 |
olle |
this.error = null; |
2933 |
14 Nov 14 |
olle |
279 |
|
2933 |
14 Nov 14 |
olle |
this.tag = document.getElementById('well.'+row+'.'+column); |
2933 |
14 Nov 14 |
olle |
281 |
} |
2933 |
14 Nov 14 |
olle |
282 |
|
2933 |
14 Nov 14 |
olle |
283 |
/** |
2933 |
14 Nov 14 |
olle |
Set the extract item that is put into this well. Use |
2933 |
14 Nov 14 |
olle |
'null' to clear the well. The extract should always |
2933 |
14 Nov 14 |
olle |
have a 'name' property, and an 'id' property if it |
2933 |
14 Nov 14 |
olle |
exists in the database. |
2933 |
14 Nov 14 |
olle |
288 |
*/ |
2933 |
14 Nov 14 |
olle |
Well.prototype.setExtract = function(extract) |
2933 |
14 Nov 14 |
olle |
290 |
{ |
2933 |
14 Nov 14 |
olle |
this.extract = extract; |
2933 |
14 Nov 14 |
olle |
this.duplicates = null; |
2933 |
14 Nov 14 |
olle |
this.replicate = false; |
2933 |
14 Nov 14 |
olle |
if (extract && this.clipboard) this.doneWithCopy(); |
2933 |
14 Nov 14 |
olle |
295 |
} |
2933 |
14 Nov 14 |
olle |
296 |
|
2933 |
14 Nov 14 |
olle |
297 |
/** |
2933 |
14 Nov 14 |
olle |
Set duplicate extract items in this well. This can |
2933 |
14 Nov 14 |
olle |
happen when using a file import if the same location |
2933 |
14 Nov 14 |
olle |
is specified twice and is an error condition which |
2933 |
14 Nov 14 |
olle |
must be resolved. |
2933 |
14 Nov 14 |
olle |
302 |
*/ |
2933 |
14 Nov 14 |
olle |
Well.prototype.addDuplicate = function(extract) |
2933 |
14 Nov 14 |
olle |
304 |
{ |
2933 |
14 Nov 14 |
olle |
if (!this.duplicates) |
2933 |
14 Nov 14 |
olle |
306 |
{ |
2933 |
14 Nov 14 |
olle |
this.duplicates = []; |
2933 |
14 Nov 14 |
olle |
this.duplicates[0] = this.extract.name; |
2933 |
14 Nov 14 |
olle |
309 |
} |
2933 |
14 Nov 14 |
olle |
this.duplicates[this.duplicates.length] = extract.name; |
2933 |
14 Nov 14 |
olle |
311 |
} |
2933 |
14 Nov 14 |
olle |
312 |
|
2933 |
14 Nov 14 |
olle |
313 |
/** |
2933 |
14 Nov 14 |
olle |
Create a copy-object holding information about this well. |
2933 |
14 Nov 14 |
olle |
The copy has 'well' property pointing to this well and |
2933 |
14 Nov 14 |
olle |
'name' property holding the extract name if the well is not |
2933 |
14 Nov 14 |
olle |
empty. The 'clipboard' flag of this well is set to true. |
2933 |
14 Nov 14 |
olle |
318 |
*/ |
2933 |
14 Nov 14 |
olle |
Well.prototype.makeCopy = function() |
2933 |
14 Nov 14 |
olle |
320 |
{ |
2933 |
14 Nov 14 |
olle |
var cp = {}; |
2933 |
14 Nov 14 |
olle |
cp.well = this; |
2933 |
14 Nov 14 |
olle |
cp.name = this.extract ? this.extract.name : null; |
2933 |
14 Nov 14 |
olle |
cp.comment = this.extract ? this.extract.comment : null; |
2933 |
14 Nov 14 |
olle |
this.clipboard = true; |
2933 |
14 Nov 14 |
olle |
this.copyText = cp.name; |
2933 |
14 Nov 14 |
olle |
return cp; |
2933 |
14 Nov 14 |
olle |
328 |
} |
2933 |
14 Nov 14 |
olle |
329 |
|
2933 |
14 Nov 14 |
olle |
330 |
/** |
2933 |
14 Nov 14 |
olle |
Unset the 'clipboard' flag for this well. |
2933 |
14 Nov 14 |
olle |
332 |
*/ |
2933 |
14 Nov 14 |
olle |
Well.prototype.doneWithCopy = function() |
2933 |
14 Nov 14 |
olle |
334 |
{ |
2933 |
14 Nov 14 |
olle |
this.clipboard = false; |
2933 |
14 Nov 14 |
olle |
this.copyText = null; |
2933 |
14 Nov 14 |
olle |
337 |
} |
2933 |
14 Nov 14 |
olle |
338 |
|
2933 |
14 Nov 14 |
olle |
Well.prototype.setWarning = function(warning) |
2933 |
14 Nov 14 |
olle |
340 |
{ |
2933 |
14 Nov 14 |
olle |
this.warning = warning; |
2933 |
14 Nov 14 |
olle |
342 |
} |
2933 |
14 Nov 14 |
olle |
343 |
|
2933 |
14 Nov 14 |
olle |
Well.prototype.hasWarning = function() |
2933 |
14 Nov 14 |
olle |
345 |
{ |
2933 |
14 Nov 14 |
olle |
return this.warning != null; |
2933 |
14 Nov 14 |
olle |
347 |
} |
2933 |
14 Nov 14 |
olle |
348 |
|
2933 |
14 Nov 14 |
olle |
Well.prototype.setError = function(error) |
2933 |
14 Nov 14 |
olle |
350 |
{ |
2933 |
14 Nov 14 |
olle |
this.error = error; |
2933 |
14 Nov 14 |
olle |
352 |
} |
2933 |
14 Nov 14 |
olle |
353 |
|
2933 |
14 Nov 14 |
olle |
Well.prototype.hasError = function() |
2933 |
14 Nov 14 |
olle |
355 |
{ |
2933 |
14 Nov 14 |
olle |
return this.error != null; |
2933 |
14 Nov 14 |
olle |
357 |
} |
2933 |
14 Nov 14 |
olle |
358 |
|
2933 |
14 Nov 14 |
olle |
Well.prototype.getClassName = function(wellPainter, poolSchema) |
2933 |
14 Nov 14 |
olle |
360 |
{ |
2933 |
14 Nov 14 |
olle |
var c = this.column; |
2933 |
14 Nov 14 |
olle |
var cls = 'well col-'+c; |
2933 |
14 Nov 14 |
olle |
if (this.selected) cls += ' selected'; |
2933 |
14 Nov 14 |
olle |
if (this.clipboard) cls += ' clipboard'; |
2933 |
14 Nov 14 |
olle |
if (!this.extract) cls += ' empty'; |
2933 |
14 Nov 14 |
olle |
if (this.hasError()) cls += ' err'; |
2933 |
14 Nov 14 |
olle |
if (this.hasWarning()) cls += ' warning'; |
2933 |
14 Nov 14 |
olle |
if (this.highlightClass) cls += ' ' + this.highlightClass; |
2933 |
14 Nov 14 |
olle |
369 |
|
2933 |
14 Nov 14 |
olle |
if (poolSchema) |
2933 |
14 Nov 14 |
olle |
371 |
{ |
2933 |
14 Nov 14 |
olle |
cls += ' ' + poolSchema.getClassNameForWell(this, wellPainter); |
2933 |
14 Nov 14 |
olle |
373 |
} |
2933 |
14 Nov 14 |
olle |
if (wellPainter) |
2933 |
14 Nov 14 |
olle |
375 |
{ |
2933 |
14 Nov 14 |
olle |
cls += ' ' + wellPainter.getClassNameForWell(this, poolSchema); |
2933 |
14 Nov 14 |
olle |
377 |
} |
2933 |
14 Nov 14 |
olle |
return cls; |
2933 |
14 Nov 14 |
olle |
379 |
} |
2933 |
14 Nov 14 |
olle |
380 |
|
2933 |
14 Nov 14 |
olle |
Well.prototype.getText = function(wellPainter, poolSchema) |
2933 |
14 Nov 14 |
olle |
382 |
{ |
2933 |
14 Nov 14 |
olle |
var text = ''; |
2933 |
14 Nov 14 |
olle |
if (wellPainter) |
2933 |
14 Nov 14 |
olle |
385 |
{ |
2933 |
14 Nov 14 |
olle |
text = wellPainter.getWellText(this, poolSchema); |
2933 |
14 Nov 14 |
olle |
387 |
} |
2933 |
14 Nov 14 |
olle |
else |
2933 |
14 Nov 14 |
olle |
389 |
{ |
2933 |
14 Nov 14 |
olle |
if (this.extract) |
2933 |
14 Nov 14 |
olle |
391 |
{ |
2933 |
14 Nov 14 |
olle |
text += '<div class="name">'+this.extract.name+'</div>' |
2933 |
14 Nov 14 |
olle |
393 |
} |
2933 |
14 Nov 14 |
olle |
394 |
} |
2933 |
14 Nov 14 |
olle |
if (this.hasError()) |
2933 |
14 Nov 14 |
olle |
396 |
{ |
2933 |
14 Nov 14 |
olle |
text += '<div class="err-msg">'+this.error + '</div>'; |
2933 |
14 Nov 14 |
olle |
398 |
} |
2933 |
14 Nov 14 |
olle |
if (this.hasWarning()) |
2933 |
14 Nov 14 |
olle |
400 |
{ |
2933 |
14 Nov 14 |
olle |
text += '<div class="warn-msg">'+this.warning + '</div>'; |
2933 |
14 Nov 14 |
olle |
402 |
} |
2933 |
14 Nov 14 |
olle |
return text; |
2933 |
14 Nov 14 |
olle |
404 |
} |
2933 |
14 Nov 14 |
olle |
405 |
|
2933 |
14 Nov 14 |
olle |
Well.prototype.paint = function(wellPainter, poolSchema) |
2933 |
14 Nov 14 |
olle |
407 |
{ |
2933 |
14 Nov 14 |
olle |
this.warning = null; |
2933 |
14 Nov 14 |
olle |
this.error = null; |
2933 |
14 Nov 14 |
olle |
this.tag.innerHTML = this.getText(wellPainter, poolSchema); |
2933 |
14 Nov 14 |
olle |
this.tag.className = this.getClassName(wellPainter, poolSchema); |
2933 |
14 Nov 14 |
olle |
412 |
} |
2933 |
14 Nov 14 |
olle |
413 |
|
2933 |
14 Nov 14 |
olle |
414 |
|