5390 |
29 Apr 19 |
nicklas |
var MipsPlate = function() |
5390 |
29 Apr 19 |
nicklas |
2 |
{ |
5390 |
29 Apr 19 |
nicklas |
var mips = {}; |
5390 |
29 Apr 19 |
nicklas |
var barcodesByName = []; |
5390 |
29 Apr 19 |
nicklas |
var hasInitProtocols = false; |
5390 |
29 Apr 19 |
nicklas |
6 |
|
5390 |
29 Apr 19 |
nicklas |
var debug = 0; |
5390 |
29 Apr 19 |
nicklas |
8 |
|
5392 |
02 May 19 |
nicklas |
var plateTypeNormalizedDNA; |
5390 |
29 Apr 19 |
nicklas |
var subtypeDna; |
5390 |
29 Apr 19 |
nicklas |
var subtypeDnaNormalized; |
5390 |
29 Apr 19 |
nicklas |
12 |
|
5390 |
29 Apr 19 |
nicklas |
// Page initialization |
5390 |
29 Apr 19 |
nicklas |
mips.initPage = function() |
5390 |
29 Apr 19 |
nicklas |
15 |
{ |
5390 |
29 Apr 19 |
nicklas |
16 |
|
5390 |
29 Apr 19 |
nicklas |
// Step 1 |
5390 |
29 Apr 19 |
nicklas |
Events.addEventHandler('step-1', 'wizard-validate', mips.validateStep1); |
5390 |
29 Apr 19 |
nicklas |
19 |
|
5392 |
02 May 19 |
nicklas |
Buttons.addClickHandler('btnAddAliquotPlates', mips.addAliquotPlates); |
5392 |
02 May 19 |
nicklas |
Buttons.addClickHandler('btnRemoveAliquotPlates', mips.removeAliquotPlates); |
5454 |
28 May 19 |
nicklas |
Buttons.addClickHandler('moveUp', mips.movePlate); |
5454 |
28 May 19 |
nicklas |
Buttons.addClickHandler('moveDown', mips.movePlate); |
5392 |
02 May 19 |
nicklas |
Events.addEventHandler('plates', 'base-selected', mips.aliquotPlateSelected); |
5448 |
27 May 19 |
nicklas |
25 |
|
5440 |
20 May 19 |
nicklas |
Events.addEventHandler('pool-row', 'click', mips.togglePool); |
5440 |
20 May 19 |
nicklas |
Events.addEventHandler('pool-row', 'mouseover', mips.highlightPool); |
5440 |
20 May 19 |
nicklas |
Events.addEventHandler('pool-row', 'mouseout', mips.highlightPool); |
5446 |
24 May 19 |
nicklas |
Events.addEventHandler('plate-row', 'click', mips.togglePool); |
5446 |
24 May 19 |
nicklas |
Events.addEventHandler('plate-row', 'mouseover', mips.highlightGroup); |
5446 |
24 May 19 |
nicklas |
Events.addEventHandler('plate-row', 'mouseout', mips.highlightGroup); |
5440 |
20 May 19 |
nicklas |
32 |
|
5390 |
29 Apr 19 |
nicklas |
// Navigation |
5390 |
29 Apr 19 |
nicklas |
Buttons.addClickHandler('gocancel', Wizard.cancelWizard); |
5390 |
29 Apr 19 |
nicklas |
Buttons.addClickHandler('gorestart', Wizard.restartWizard); |
5390 |
29 Apr 19 |
nicklas |
Buttons.addClickHandler('gonext', Wizard.goNextOnClick); |
5390 |
29 Apr 19 |
nicklas |
Buttons.addClickHandler('goregister', Wizard.goRegister); |
5390 |
29 Apr 19 |
nicklas |
38 |
|
5390 |
29 Apr 19 |
nicklas |
// Final registration |
5390 |
29 Apr 19 |
nicklas |
Events.addEventHandler('wizard', 'wizard-submit', mips.submit); |
5390 |
29 Apr 19 |
nicklas |
41 |
|
5390 |
29 Apr 19 |
nicklas |
var url = '../Mips.servlet?ID='+App.getSessionId(); |
5390 |
29 Apr 19 |
nicklas |
url += '&cmd=GetNextAutoGeneratedPlateName'; |
5390 |
29 Apr 19 |
nicklas |
url += '&bioPlateType=MIPS'; |
5390 |
29 Apr 19 |
nicklas |
Wizard.showLoadingAnimation('Loading next MIPs plate'); |
5390 |
29 Apr 19 |
nicklas |
Wizard.asyncJsonRequest(url, mips.nextPlateNameLoaded); |
5390 |
29 Apr 19 |
nicklas |
47 |
} |
5390 |
29 Apr 19 |
nicklas |
48 |
|
5390 |
29 Apr 19 |
nicklas |
mips.nextPlateNameLoaded = function(response) |
5390 |
29 Apr 19 |
nicklas |
50 |
{ |
5390 |
29 Apr 19 |
nicklas |
Plate.name = response.name; |
5390 |
29 Apr 19 |
nicklas |
Doc.element('plateName').innerHTML = Strings.encodeTags(Plate.name); |
5390 |
29 Apr 19 |
nicklas |
53 |
|
5390 |
29 Apr 19 |
nicklas |
var columns = 12; |
5390 |
29 Apr 19 |
nicklas |
var rows = 8; |
5392 |
02 May 19 |
nicklas |
Plate.init(rows, columns, WellPainter); |
5390 |
29 Apr 19 |
nicklas |
Plate.paint(Plate.getWells()); |
5390 |
29 Apr 19 |
nicklas |
58 |
|
5390 |
29 Apr 19 |
nicklas |
Doc.show('step-1'); |
5390 |
29 Apr 19 |
nicklas |
Doc.show('gocancel'); |
5390 |
29 Apr 19 |
nicklas |
Doc.show('goregister'); |
5390 |
29 Apr 19 |
nicklas |
62 |
|
5390 |
29 Apr 19 |
nicklas |
window.addEventListener('beforeunload', mips.confirmLeaveWizard); |
5526 |
25 Jun 19 |
nicklas |
Wizard.keepSessionAlive(); |
5390 |
29 Apr 19 |
nicklas |
65 |
} |
5390 |
29 Apr 19 |
nicklas |
66 |
|
5413 |
09 May 19 |
nicklas |
mips.toggleInfo = function(event) |
5413 |
09 May 19 |
nicklas |
68 |
{ |
5413 |
09 May 19 |
nicklas |
var show = event.currentTarget.checked; |
5413 |
09 May 19 |
nicklas |
Doc.addOrRemoveClass('plate', 'hide-'+event.currentTarget.id, !show); |
5413 |
09 May 19 |
nicklas |
71 |
} |
5413 |
09 May 19 |
nicklas |
72 |
|
5414 |
09 May 19 |
nicklas |
73 |
|
5414 |
09 May 19 |
nicklas |
74 |
|
5390 |
29 Apr 19 |
nicklas |
75 |
/** |
5390 |
29 Apr 19 |
nicklas |
Ask for confirmation to abort if DNA has been placed on the plate. |
5390 |
29 Apr 19 |
nicklas |
77 |
*/ |
5390 |
29 Apr 19 |
nicklas |
mips.confirmLeaveWizard = function(event) |
5390 |
29 Apr 19 |
nicklas |
79 |
{ |
5390 |
29 Apr 19 |
nicklas |
if (Plate.getUsed().length > 0) |
5390 |
29 Apr 19 |
nicklas |
81 |
{ |
5390 |
29 Apr 19 |
nicklas |
event.preventDefault(); |
5390 |
29 Apr 19 |
nicklas |
83 |
} |
5390 |
29 Apr 19 |
nicklas |
84 |
} |
5390 |
29 Apr 19 |
nicklas |
85 |
|
5390 |
29 Apr 19 |
nicklas |
mips.validateStep1 = function(event) |
5390 |
29 Apr 19 |
nicklas |
87 |
{ |
5390 |
29 Apr 19 |
nicklas |
var numErrors = 0; |
5390 |
29 Apr 19 |
nicklas |
var numWarnings = 0; |
5390 |
29 Apr 19 |
nicklas |
var numDna = 0; |
5390 |
29 Apr 19 |
nicklas |
var wells = Plate.getWells(); |
5390 |
29 Apr 19 |
nicklas |
for (var i = 0; i < wells.length; i++) |
5390 |
29 Apr 19 |
nicklas |
93 |
{ |
5390 |
29 Apr 19 |
nicklas |
var well = wells[i]; |
5390 |
29 Apr 19 |
nicklas |
var dna = well.extract; |
5390 |
29 Apr 19 |
nicklas |
if (well.hasWarning()) |
5390 |
29 Apr 19 |
nicklas |
97 |
{ |
5390 |
29 Apr 19 |
nicklas |
numWarnings++; |
5390 |
29 Apr 19 |
nicklas |
99 |
} |
5390 |
29 Apr 19 |
nicklas |
if (well.hasError()) |
5390 |
29 Apr 19 |
nicklas |
101 |
{ |
5390 |
29 Apr 19 |
nicklas |
numErrors++; |
5390 |
29 Apr 19 |
nicklas |
103 |
} |
5390 |
29 Apr 19 |
nicklas |
else |
5390 |
29 Apr 19 |
nicklas |
105 |
{ |
5390 |
29 Apr 19 |
nicklas |
if (dna && dna.id) numDna++; |
5390 |
29 Apr 19 |
nicklas |
107 |
} |
5390 |
29 Apr 19 |
nicklas |
108 |
} |
5390 |
29 Apr 19 |
nicklas |
109 |
|
5390 |
29 Apr 19 |
nicklas |
if (numErrors > 0) |
5390 |
29 Apr 19 |
nicklas |
111 |
{ |
5390 |
29 Apr 19 |
nicklas |
event.preventDefault(); |
5390 |
29 Apr 19 |
nicklas |
return; |
5390 |
29 Apr 19 |
nicklas |
114 |
} |
5390 |
29 Apr 19 |
nicklas |
115 |
|
5390 |
29 Apr 19 |
nicklas |
if (numDna == 0) |
5390 |
29 Apr 19 |
nicklas |
117 |
{ |
5455 |
28 May 19 |
nicklas |
Wizard.showGoNextConfirmation(false, 'The plate is empty!'); |
5390 |
29 Apr 19 |
nicklas |
event.preventDefault(); |
5390 |
29 Apr 19 |
nicklas |
return; |
5390 |
29 Apr 19 |
nicklas |
121 |
} |
5390 |
29 Apr 19 |
nicklas |
122 |
} |
5390 |
29 Apr 19 |
nicklas |
123 |
|
5454 |
28 May 19 |
nicklas |
mips.movePlate = function(event) |
5392 |
02 May 19 |
nicklas |
125 |
{ |
5454 |
28 May 19 |
nicklas |
var moveDown = Data.int(event.currentTarget, 'down'); |
5454 |
28 May 19 |
nicklas |
Forms.moveListOptions('plates', moveDown); |
5454 |
28 May 19 |
nicklas |
mips.layoutFromAliquotPlates(); |
5392 |
02 May 19 |
nicklas |
129 |
} |
5392 |
02 May 19 |
nicklas |
130 |
|
5454 |
28 May 19 |
nicklas |
131 |
|
5392 |
02 May 19 |
nicklas |
// Temporary array for holding selected aliqout plates before loading more information via the servlet |
5392 |
02 May 19 |
nicklas |
var newPlates; |
5392 |
02 May 19 |
nicklas |
134 |
/** |
5392 |
02 May 19 |
nicklas |
Open dialog for adding more aliquot plates. |
5392 |
02 May 19 |
nicklas |
136 |
*/ |
6824 |
30 Aug 22 |
nicklas |
mips.addAliquotPlates = function(event) |
5392 |
02 May 19 |
nicklas |
138 |
{ |
5392 |
02 May 19 |
nicklas |
var frm = document.forms['reggie']; |
5392 |
02 May 19 |
nicklas |
var emptyColumn = Plate.getFirstEmptyColumn(); |
5392 |
02 May 19 |
nicklas |
if (emptyColumn == -1) |
5392 |
02 May 19 |
nicklas |
142 |
{ |
5392 |
02 May 19 |
nicklas |
Forms.showNotification(event.currentTarget, 'There are no more empty columns.'); |
5392 |
02 May 19 |
nicklas |
return; |
5392 |
02 May 19 |
nicklas |
145 |
} |
5458 |
29 May 19 |
nicklas |
146 |
|
5458 |
29 May 19 |
nicklas |
newPlates = []; // Clear the temp array |
5458 |
29 May 19 |
nicklas |
var current = []; // Filter out currently included plates |
5392 |
02 May 19 |
nicklas |
var plates = frm.plates; |
5392 |
02 May 19 |
nicklas |
for (var plateNo = 0; plateNo < plates.length; plateNo++) |
5392 |
02 May 19 |
nicklas |
151 |
{ |
5392 |
02 May 19 |
nicklas |
current[current.length] = plates[plateNo].value; |
5392 |
02 May 19 |
nicklas |
153 |
} |
5458 |
29 May 19 |
nicklas |
154 |
|
5458 |
29 May 19 |
nicklas |
var url = 'select_aliquot_plates.jsp?ID='+App.getSessionId(); |
5458 |
29 May 19 |
nicklas |
if (current.length > 0) url += '&ignore='+current.join(','); |
5460 |
03 Jun 19 |
nicklas |
Dialogs.openPopup(url, 'SelectAliquotPlates', 900, 600); |
5392 |
02 May 19 |
nicklas |
158 |
} |
5392 |
02 May 19 |
nicklas |
159 |
|
5392 |
02 May 19 |
nicklas |
160 |
/** |
5392 |
02 May 19 |
nicklas |
Removes the selected aliquot plates. |
5392 |
02 May 19 |
nicklas |
162 |
*/ |
5392 |
02 May 19 |
nicklas |
mips.removeAliquotPlates = function() |
5392 |
02 May 19 |
nicklas |
164 |
{ |
5392 |
02 May 19 |
nicklas |
var frm = document.forms['reggie']; |
5392 |
02 May 19 |
nicklas |
var plates = frm.plates; |
5392 |
02 May 19 |
nicklas |
for (var plateNo = 0; plateNo < plates.length; plateNo++) |
5392 |
02 May 19 |
nicklas |
168 |
{ |
5392 |
02 May 19 |
nicklas |
if (plates[plateNo].selected) plates[plateNo--] = null; |
5392 |
02 May 19 |
nicklas |
170 |
} |
5392 |
02 May 19 |
nicklas |
mips.layoutFromAliquotPlates(); |
5392 |
02 May 19 |
nicklas |
172 |
} |
5392 |
02 May 19 |
nicklas |
173 |
|
5392 |
02 May 19 |
nicklas |
174 |
|
5392 |
02 May 19 |
nicklas |
175 |
/** |
5392 |
02 May 19 |
nicklas |
Callback when a new aliquot plate has been selected for including on the MIPs plate. |
5392 |
02 May 19 |
nicklas |
Adds selected plates to the temp array. When all have been collected, a request |
5392 |
02 May 19 |
nicklas |
to server is made to load more information about the DNA on the plate(s). |
5392 |
02 May 19 |
nicklas |
179 |
*/ |
5392 |
02 May 19 |
nicklas |
mips.aliquotPlateSelected = function(event) |
5392 |
02 May 19 |
nicklas |
181 |
{ |
5392 |
02 May 19 |
nicklas |
var frm = document.forms['reggie']; |
5392 |
02 May 19 |
nicklas |
var name = event.detail.name; |
5392 |
02 May 19 |
nicklas |
var id = event.detail.id; |
5392 |
02 May 19 |
nicklas |
185 |
|
5392 |
02 May 19 |
nicklas |
// Check if the selected plate is a new plate or not |
5392 |
02 May 19 |
nicklas |
var plateList = frm.plates; |
5392 |
02 May 19 |
nicklas |
var isNew = true; |
5392 |
02 May 19 |
nicklas |
for (var i = 0; i < plateList.length; i++) |
5392 |
02 May 19 |
nicklas |
190 |
{ |
5458 |
29 May 19 |
nicklas |
if (plateList[i].plate.id == id) |
5392 |
02 May 19 |
nicklas |
192 |
{ |
5392 |
02 May 19 |
nicklas |
isNew = false; |
5392 |
02 May 19 |
nicklas |
break; |
5392 |
02 May 19 |
nicklas |
195 |
} |
5392 |
02 May 19 |
nicklas |
196 |
} |
5392 |
02 May 19 |
nicklas |
if (isNew) |
5392 |
02 May 19 |
nicklas |
198 |
{ |
5392 |
02 May 19 |
nicklas |
newPlates[newPlates.length] = id; |
5392 |
02 May 19 |
nicklas |
200 |
} |
5392 |
02 May 19 |
nicklas |
201 |
|
5392 |
02 May 19 |
nicklas |
// Load information about DNA on the plates |
5392 |
02 May 19 |
nicklas |
if (event.detail.remaining == 0 && newPlates.length > 0) |
5392 |
02 May 19 |
nicklas |
204 |
{ |
5392 |
02 May 19 |
nicklas |
var url = '../Mips.servlet?ID='+App.getSessionId(); |
5392 |
02 May 19 |
nicklas |
url += '&cmd=GetUnusedAliquotsFromPlates'; |
5392 |
02 May 19 |
nicklas |
url += '&plates='+newPlates.join(','); |
5392 |
02 May 19 |
nicklas |
Wizard.showLoadingAnimation('Loading aliquots from ' + encodeURIComponent(event.detail.name)); |
5392 |
02 May 19 |
nicklas |
Wizard.asyncJsonRequest(url, mips.aliquotsAndPlatesLoaded); |
5458 |
29 May 19 |
nicklas |
newPlates = []; |
5392 |
02 May 19 |
nicklas |
211 |
} |
5392 |
02 May 19 |
nicklas |
212 |
} |
5392 |
02 May 19 |
nicklas |
213 |
|
5392 |
02 May 19 |
nicklas |
214 |
/** |
5392 |
02 May 19 |
nicklas |
Callback after we have got DNA information for the new plates. |
5392 |
02 May 19 |
nicklas |
216 |
*/ |
5392 |
02 May 19 |
nicklas |
mips.aliquotsAndPlatesLoaded = function(response) |
5392 |
02 May 19 |
nicklas |
218 |
{ |
5392 |
02 May 19 |
nicklas |
var frm = document.forms['reggie']; |
5392 |
02 May 19 |
nicklas |
var plates = response.plates; |
5418 |
10 May 19 |
nicklas |
var emptyPlates = []; |
5392 |
02 May 19 |
nicklas |
for (var plateNo = 0; plateNo < plates.length; plateNo++) |
5392 |
02 May 19 |
nicklas |
223 |
{ |
5392 |
02 May 19 |
nicklas |
var plate = plates[plateNo]; |
5392 |
02 May 19 |
nicklas |
var aliquots = plate.aliquots; |
5418 |
10 May 19 |
nicklas |
if (aliquots.length > 0) |
5418 |
10 May 19 |
nicklas |
227 |
{ |
5454 |
28 May 19 |
nicklas |
var option = new Option(plate.name + ' ('+aliquots.length+' aliquots)', plate.id); |
5418 |
10 May 19 |
nicklas |
option.plate = plate; |
5418 |
10 May 19 |
nicklas |
frm.plates[frm.plates.length] = option; |
5418 |
10 May 19 |
nicklas |
231 |
} |
5418 |
10 May 19 |
nicklas |
else |
5418 |
10 May 19 |
nicklas |
233 |
{ |
5418 |
10 May 19 |
nicklas |
emptyPlates[emptyPlates.length] = plate.name; |
5418 |
10 May 19 |
nicklas |
235 |
} |
5392 |
02 May 19 |
nicklas |
236 |
} |
5418 |
10 May 19 |
nicklas |
if (emptyPlates.length > 0) |
5418 |
10 May 19 |
nicklas |
238 |
{ |
5418 |
10 May 19 |
nicklas |
var isOrAre = emptyPlates.length == 1 ? ' is' : ' are'; |
5454 |
28 May 19 |
nicklas |
Forms.showNotification('btnAddAliquotPlates', Strings.encodeTags(emptyPlates.join(', ')) + isOrAre + ' empty'); |
5418 |
10 May 19 |
nicklas |
241 |
} |
5392 |
02 May 19 |
nicklas |
mips.layoutFromAliquotPlates(); |
5392 |
02 May 19 |
nicklas |
243 |
} |
5392 |
02 May 19 |
nicklas |
244 |
|
5392 |
02 May 19 |
nicklas |
245 |
/** |
5392 |
02 May 19 |
nicklas |
Auto-layout the MIPs plate from the selected aliquot plates. |
5392 |
02 May 19 |
nicklas |
247 |
*/ |
5392 |
02 May 19 |
nicklas |
mips.layoutFromAliquotPlates = function() |
5392 |
02 May 19 |
nicklas |
249 |
{ |
5392 |
02 May 19 |
nicklas |
var frm = document.forms['reggie']; |
5392 |
02 May 19 |
nicklas |
var wells = Plate.getWells(); |
5392 |
02 May 19 |
nicklas |
Plate.clear(wells, true); |
5448 |
27 May 19 |
nicklas |
Doc.hide('pool-row'); |
5448 |
27 May 19 |
nicklas |
Doc.hide('plate-row'); |
5454 |
28 May 19 |
nicklas |
Doc.hide('unplaced-aliquots'); |
5448 |
27 May 19 |
nicklas |
Wizard.hideGoNextConfirmation(); |
5446 |
24 May 19 |
nicklas |
COLUMN_DATA = new Array(Plate.columns); |
5440 |
20 May 19 |
nicklas |
258 |
|
5392 |
02 May 19 |
nicklas |
var plates = frm.plates; |
5446 |
24 May 19 |
nicklas |
var mipsCurrentColumn = -1; // Current column on MIPs plate |
5454 |
28 May 19 |
nicklas |
PLATE_LOOP: |
5392 |
02 May 19 |
nicklas |
for (var plateNo = 0; plateNo < plates.length; plateNo++) |
5392 |
02 May 19 |
nicklas |
263 |
{ |
5392 |
02 May 19 |
nicklas |
var plate = plates[plateNo].plate; |
5392 |
02 May 19 |
nicklas |
var selected = plates[plateNo].selected; |
5392 |
02 May 19 |
nicklas |
var aliquots = plate.aliquots; |
5446 |
24 May 19 |
nicklas |
var aliquotCurrentColumn = -1; // Current column on the aliquot plate |
5392 |
02 May 19 |
nicklas |
268 |
|
5417 |
10 May 19 |
nicklas |
plate.numPlacedAliquots = 0; |
5440 |
20 May 19 |
nicklas |
plate.columnSpan = 0; |
5446 |
24 May 19 |
nicklas |
for (var aqNo = 0; aqNo < aliquots.length; aqNo++) |
5392 |
02 May 19 |
nicklas |
272 |
{ |
5392 |
02 May 19 |
nicklas |
var aliquot = aliquots[aqNo]; |
5446 |
24 May 19 |
nicklas |
if (aliquot.bioWell.column != aliquotCurrentColumn) |
5446 |
24 May 19 |
nicklas |
275 |
{ |
5446 |
24 May 19 |
nicklas |
mipsCurrentColumn++; |
5454 |
28 May 19 |
nicklas |
if (mipsCurrentColumn >= Plate.columns) |
5454 |
28 May 19 |
nicklas |
278 |
{ |
5454 |
28 May 19 |
nicklas |
var remain = aliquots.length - aqNo; |
5454 |
28 May 19 |
nicklas |
Doc.element('unplaced-aliquots').innerHTML = remain + ' aliquots from ' +Strings.encodeTags(plate.name) + ' could not be placed'; |
5454 |
28 May 19 |
nicklas |
Doc.show('unplaced-aliquots', 'table-cell'); |
5454 |
28 May 19 |
nicklas |
plateNo++; |
5454 |
28 May 19 |
nicklas |
break PLATE_LOOP; |
5454 |
28 May 19 |
nicklas |
284 |
} |
5446 |
24 May 19 |
nicklas |
aliquotCurrentColumn = aliquot.bioWell.column; |
5446 |
24 May 19 |
nicklas |
plate.columnSpan++; |
5446 |
24 May 19 |
nicklas |
var col = {}; |
5446 |
24 May 19 |
nicklas |
col.plateId = plate.id; |
5446 |
24 May 19 |
nicklas |
COLUMN_DATA[mipsCurrentColumn] = col; |
5446 |
24 May 19 |
nicklas |
290 |
} |
5446 |
24 May 19 |
nicklas |
var well = Plate.getWell(aliquot.bioWell.row, mipsCurrentColumn); |
5413 |
09 May 19 |
nicklas |
well.setExtract(aliquot); |
5454 |
28 May 19 |
nicklas |
//well.selected = selected; |
5417 |
10 May 19 |
nicklas |
plate.numPlacedAliquots++; |
5392 |
02 May 19 |
nicklas |
295 |
} |
5392 |
02 May 19 |
nicklas |
296 |
} |
5454 |
28 May 19 |
nicklas |
//if (plateNo < plates.length) frm.plates.length = plateNo; |
5446 |
24 May 19 |
nicklas |
298 |
|
5603 |
13 Sep 19 |
nicklas |
// Analyze columns on the MIPs plate with resepect to MIPS_Panel and PoolVolume |
5446 |
24 May 19 |
nicklas |
for (var colNo = 0; colNo < Plate.columns; colNo++) |
5446 |
24 May 19 |
nicklas |
301 |
{ |
5446 |
24 May 19 |
nicklas |
col = COLUMN_DATA[colNo]; |
5446 |
24 May 19 |
nicklas |
if (!col) |
5446 |
24 May 19 |
nicklas |
304 |
{ |
5446 |
24 May 19 |
nicklas |
col = {}; |
5446 |
24 May 19 |
nicklas |
COLUMN_DATA[colNo] = col; |
5446 |
24 May 19 |
nicklas |
307 |
} |
5448 |
27 May 19 |
nicklas |
col.numAliquots = 0; |
5603 |
13 Sep 19 |
nicklas |
col.panelCounter = new ItemCounter(); |
5448 |
27 May 19 |
nicklas |
col.poolVolumeCounter = new ItemCounter(); |
5446 |
24 May 19 |
nicklas |
for (var rowNo = 0; rowNo < Plate.rows; rowNo++) |
5446 |
24 May 19 |
nicklas |
312 |
{ |
5446 |
24 May 19 |
nicklas |
var well = Plate.getWell(rowNo, colNo); |
5446 |
24 May 19 |
nicklas |
if (well.extract) |
5446 |
24 May 19 |
nicklas |
315 |
{ |
5446 |
24 May 19 |
nicklas |
var aliquot = well.extract; |
5448 |
27 May 19 |
nicklas |
col.numAliquots++; |
5603 |
13 Sep 19 |
nicklas |
col.panelCounter.count(aliquot.MIPS_Panel); |
5448 |
27 May 19 |
nicklas |
col.poolVolumeCounter.count(aliquot.MIPS_PoolVolume); |
5446 |
24 May 19 |
nicklas |
320 |
} |
5446 |
24 May 19 |
nicklas |
321 |
} |
5603 |
13 Sep 19 |
nicklas |
col.MIPS_Panel = col.panelCounter.maxKey; |
5603 |
13 Sep 19 |
nicklas |
col.isMissingMIPSPanel = col.panelCounter.numCounted != col.numAliquots; |
5603 |
13 Sep 19 |
nicklas |
col.hasMultipleMIPSPanels = col.panelCounter.numKeys() > 1; |
5448 |
27 May 19 |
nicklas |
col.MIPS_PoolVolume = col.poolVolumeCounter.maxKey; |
5448 |
27 May 19 |
nicklas |
col.hasMultiplePoolVolumes = col.poolVolumeCounter.numKeys() > 1; |
5446 |
24 May 19 |
nicklas |
327 |
} |
5446 |
24 May 19 |
nicklas |
328 |
|
5455 |
28 May 19 |
nicklas |
if (plates.length > 0) |
5455 |
28 May 19 |
nicklas |
330 |
{ |
5455 |
28 May 19 |
nicklas |
mips.buildPoolRow(); |
5455 |
28 May 19 |
nicklas |
mips.buildPlateRow(); |
5455 |
28 May 19 |
nicklas |
333 |
} |
5392 |
02 May 19 |
nicklas |
Plate.paint(wells); |
5448 |
27 May 19 |
nicklas |
335 |
|
5448 |
27 May 19 |
nicklas |
var wells = Plate.getWells(); |
5448 |
27 May 19 |
nicklas |
var numWarnings = 0; |
5448 |
27 May 19 |
nicklas |
for (var i = 0; i < wells.length; i++) |
5448 |
27 May 19 |
nicklas |
339 |
{ |
5448 |
27 May 19 |
nicklas |
var well = wells[i]; |
5448 |
27 May 19 |
nicklas |
if (well.hasWarning()) |
5448 |
27 May 19 |
nicklas |
342 |
{ |
5448 |
27 May 19 |
nicklas |
numWarnings++; |
5448 |
27 May 19 |
nicklas |
344 |
} |
5448 |
27 May 19 |
nicklas |
345 |
} |
5448 |
27 May 19 |
nicklas |
346 |
|
5448 |
27 May 19 |
nicklas |
if (numWarnings > 0) |
5448 |
27 May 19 |
nicklas |
348 |
{ |
5448 |
27 May 19 |
nicklas |
Wizard.showGoNextConfirmation(true, 'Check to verify registration of plate with warnings.'); |
5448 |
27 May 19 |
nicklas |
350 |
} |
5392 |
02 May 19 |
nicklas |
351 |
} |
5392 |
02 May 19 |
nicklas |
352 |
|
5448 |
27 May 19 |
nicklas |
mips.buildPoolRow = function() |
5440 |
20 May 19 |
nicklas |
354 |
{ |
5440 |
20 May 19 |
nicklas |
var html = '<th></th>'; |
5603 |
13 Sep 19 |
nicklas |
var pools = []; // A 'pool' is a number of columns with the same MIPS_Panel |
5446 |
24 May 19 |
nicklas |
var currentPool = {}; |
5446 |
24 May 19 |
nicklas |
358 |
|
5446 |
24 May 19 |
nicklas |
for (var colNo = 0; colNo < COLUMN_DATA.length; colNo++) |
5446 |
24 May 19 |
nicklas |
360 |
{ |
5446 |
24 May 19 |
nicklas |
var col = COLUMN_DATA[colNo]; |
5603 |
13 Sep 19 |
nicklas |
if ((col.MIPS_Panel != currentPool.name) || (col.numAliquots == 0 && currentPool.numAliquots != 0)) |
5446 |
24 May 19 |
nicklas |
363 |
{ |
5603 |
13 Sep 19 |
nicklas |
// The column has a different MIPS_Panel than the previous one so we create a new pool |
5446 |
24 May 19 |
nicklas |
currentPool = {}; |
5603 |
13 Sep 19 |
nicklas |
currentPool.name = col.MIPS_Panel; |
5446 |
24 May 19 |
nicklas |
currentPool.startCol = colNo; |
5446 |
24 May 19 |
nicklas |
currentPool.columnSpan = 1; |
5603 |
13 Sep 19 |
nicklas |
currentPool.hasMultipleMIPSPanels = col.hasMultipleMIPSPanels; |
5448 |
27 May 19 |
nicklas |
currentPool.hasMultiplePoolVolumes = col.hasMultiplePoolVolumes; |
5603 |
13 Sep 19 |
nicklas |
currentPool.isMissingMIPSPanel = col.isMissingMIPSPanel; |
5448 |
27 May 19 |
nicklas |
currentPool.numAliquots = col.numAliquots; |
5446 |
24 May 19 |
nicklas |
pools[pools.length] = currentPool; |
5446 |
24 May 19 |
nicklas |
374 |
} |
5446 |
24 May 19 |
nicklas |
else if (currentPool) |
5446 |
24 May 19 |
nicklas |
376 |
{ |
5604 |
13 Sep 19 |
nicklas |
// The column has the same MIPS_Panel as the previous one, we make the pool span across multiple columns |
5446 |
24 May 19 |
nicklas |
currentPool.columnSpan++; |
5448 |
27 May 19 |
nicklas |
currentPool.numAliquots += col.numAliquots; |
5603 |
13 Sep 19 |
nicklas |
if (col.isMissingMIPSPanel) currentPool.isMissingMIPSPanel = true; |
5603 |
13 Sep 19 |
nicklas |
if (col.hasMultipleMIPSPanels) currentPool.hasMultipleMIPSPanels = true; |
5448 |
27 May 19 |
nicklas |
if (col.hasMultiplePoolVolumes) currentPool.hasMultiplePoolVolumes = true; |
5446 |
24 May 19 |
nicklas |
383 |
} |
5446 |
24 May 19 |
nicklas |
384 |
} |
5446 |
24 May 19 |
nicklas |
385 |
|
5446 |
24 May 19 |
nicklas |
colNo = 0; |
5446 |
24 May 19 |
nicklas |
for (var poolNo = 0; poolNo < pools.length; poolNo++) |
5446 |
24 May 19 |
nicklas |
388 |
{ |
5446 |
24 May 19 |
nicklas |
var pool = pools[poolNo]; |
5446 |
24 May 19 |
nicklas |
var poolClass = 'pool link'; |
5446 |
24 May 19 |
nicklas |
var poolText = null; |
5454 |
28 May 19 |
nicklas |
392 |
|
5454 |
28 May 19 |
nicklas |
COLUMN_DATA[colNo].poolClass = 'pool-left'; |
5446 |
24 May 19 |
nicklas |
if (pool.columnSpan == 1) |
5446 |
24 May 19 |
nicklas |
395 |
{ |
5454 |
28 May 19 |
nicklas |
if (pool.name) COLUMN_DATA[colNo].poolClass += ' pool-right'; |
5446 |
24 May 19 |
nicklas |
397 |
} |
5446 |
24 May 19 |
nicklas |
else |
5446 |
24 May 19 |
nicklas |
399 |
{ |
5454 |
28 May 19 |
nicklas |
if (pool.name) |
5446 |
24 May 19 |
nicklas |
401 |
{ |
5454 |
28 May 19 |
nicklas |
for (var i = 1; i < pool.columnSpan-1; i++) |
5454 |
28 May 19 |
nicklas |
403 |
{ |
5454 |
28 May 19 |
nicklas |
COLUMN_DATA[colNo+i].poolClass = 'pool-middle'; |
5454 |
28 May 19 |
nicklas |
405 |
} |
5454 |
28 May 19 |
nicklas |
COLUMN_DATA[colNo+pool.columnSpan-1].poolClass = 'pool-right'; |
5446 |
24 May 19 |
nicklas |
407 |
} |
5446 |
24 May 19 |
nicklas |
408 |
} |
5446 |
24 May 19 |
nicklas |
409 |
|
5448 |
27 May 19 |
nicklas |
if (pool.numAliquots > 0) |
5446 |
24 May 19 |
nicklas |
411 |
{ |
5603 |
13 Sep 19 |
nicklas |
if (pool.hasMultiplePoolVolumes || pool.isMissingMIPSPanel) |
5446 |
24 May 19 |
nicklas |
413 |
{ |
5446 |
24 May 19 |
nicklas |
poolClass += ' pool-warning'; |
5603 |
13 Sep 19 |
nicklas |
if (pool.isMissingMIPSPanel) |
5448 |
27 May 19 |
nicklas |
416 |
{ |
5603 |
13 Sep 19 |
nicklas |
poolText = 'Some aliquots have no MIPS_Panel!'; |
5448 |
27 May 19 |
nicklas |
418 |
} |
5520 |
20 Jun 19 |
nicklas |
else if (pool.hasMultiplePoolVolumes) |
5448 |
27 May 19 |
nicklas |
420 |
{ |
5520 |
20 Jun 19 |
nicklas |
poolText = 'Some aliquots have a different pool volume!'; |
5448 |
27 May 19 |
nicklas |
422 |
} |
5446 |
24 May 19 |
nicklas |
423 |
} |
5520 |
20 Jun 19 |
nicklas |
if (pool.name) poolClass += ' ' + MipsColor.getColor(pool.name); |
5446 |
24 May 19 |
nicklas |
html += '<th id="pool.' + poolNo + '" colspan="'+pool.columnSpan+'"'; |
5446 |
24 May 19 |
nicklas |
html += ' class="'+poolClass+'"'; |
5446 |
24 May 19 |
nicklas |
html += ' data-start-col="'+pool.startCol+'"'; |
5446 |
24 May 19 |
nicklas |
html += ' data-end-col="'+(pool.startCol+pool.columnSpan-1)+'"'; |
5446 |
24 May 19 |
nicklas |
if (poolText) html += ' title="'+poolText+'"'; |
5603 |
13 Sep 19 |
nicklas |
html += '>'+Strings.encodeTags(pool.name || 'No MIPS_Panel')+'</th>'; |
5446 |
24 May 19 |
nicklas |
431 |
} |
5446 |
24 May 19 |
nicklas |
else |
5446 |
24 May 19 |
nicklas |
433 |
{ |
5446 |
24 May 19 |
nicklas |
poolClass = ''; |
5446 |
24 May 19 |
nicklas |
if (colNo > 0) poolClass += ' nopool-after-pool'; |
5446 |
24 May 19 |
nicklas |
if (colNo + pool.columnSpan < 12) poolClass += ' nopool-before-pool'; |
5446 |
24 May 19 |
nicklas |
html += '<th colspan="'+pool.columnSpan+'"'; |
5446 |
24 May 19 |
nicklas |
html += ' class="'+poolClass+'"'; |
5446 |
24 May 19 |
nicklas |
html += '></th>'; |
5446 |
24 May 19 |
nicklas |
440 |
} |
5446 |
24 May 19 |
nicklas |
colNo += pool.columnSpan; |
5446 |
24 May 19 |
nicklas |
442 |
} |
5454 |
28 May 19 |
nicklas |
html += '<td style="padding:0;"></td>'; |
5446 |
24 May 19 |
nicklas |
444 |
|
5448 |
27 May 19 |
nicklas |
var row = Doc.element('pool-row'); |
5446 |
24 May 19 |
nicklas |
row.innerHTML = html; |
5446 |
24 May 19 |
nicklas |
Doc.show(row); |
5446 |
24 May 19 |
nicklas |
448 |
} |
5446 |
24 May 19 |
nicklas |
449 |
|
5446 |
24 May 19 |
nicklas |
mips.buildPlateRow = function() |
5446 |
24 May 19 |
nicklas |
451 |
{ |
5446 |
24 May 19 |
nicklas |
var html = '<th></th>'; |
5440 |
20 May 19 |
nicklas |
var totalSpan = 0; |
5440 |
20 May 19 |
nicklas |
var colNo = 0; |
5454 |
28 May 19 |
nicklas |
for (var plateNo = 0; plateNo < plates.length && colNo < Plate.columns; plateNo++) |
5440 |
20 May 19 |
nicklas |
456 |
{ |
5440 |
20 May 19 |
nicklas |
var plate = plates[plateNo].plate; |
5454 |
28 May 19 |
nicklas |
var poolClass = 'group link'; |
5454 |
28 May 19 |
nicklas |
var poolText = null; |
5446 |
24 May 19 |
nicklas |
460 |
|
5440 |
20 May 19 |
nicklas |
if (plate.columnSpan == 1) |
5440 |
20 May 19 |
nicklas |
462 |
{ |
5446 |
24 May 19 |
nicklas |
COLUMN_DATA[colNo].groupClass = 'group-left group-right'; |
5440 |
20 May 19 |
nicklas |
464 |
} |
5440 |
20 May 19 |
nicklas |
else |
5440 |
20 May 19 |
nicklas |
466 |
{ |
5446 |
24 May 19 |
nicklas |
COLUMN_DATA[colNo].groupClass = 'group-left'; |
5440 |
20 May 19 |
nicklas |
for (var i = 1; i < plate.columnSpan-1; i++) |
5440 |
20 May 19 |
nicklas |
469 |
{ |
5446 |
24 May 19 |
nicklas |
COLUMN_DATA[colNo+i].groupClass = 'group-middle'; |
5440 |
20 May 19 |
nicklas |
471 |
} |
5446 |
24 May 19 |
nicklas |
COLUMN_DATA[colNo+plate.columnSpan-1].groupClass = 'group-right'; |
5440 |
20 May 19 |
nicklas |
473 |
} |
5446 |
24 May 19 |
nicklas |
474 |
|
5454 |
28 May 19 |
nicklas |
if (plate.numPlacedAliquots != plate.aliquots.length) |
5454 |
28 May 19 |
nicklas |
476 |
{ |
5454 |
28 May 19 |
nicklas |
poolClass += ' pool-warning'; |
5454 |
28 May 19 |
nicklas |
poolText = 'This plate has ' + (plate.aliquots.length - plate.numPlacedAliquots) + ' more aliquots'; |
5454 |
28 May 19 |
nicklas |
479 |
} |
5454 |
28 May 19 |
nicklas |
480 |
|
5446 |
24 May 19 |
nicklas |
html += '<th id="group.' + plateNo + '" colspan="'+plate.columnSpan+'"'; |
5440 |
20 May 19 |
nicklas |
html += ' class="'+poolClass+'"'; |
5446 |
24 May 19 |
nicklas |
html += ' data-start-col="' + colNo + '"'; |
5446 |
24 May 19 |
nicklas |
html += ' data-end-col="' + (colNo+plate.columnSpan-1) + '"'; |
5454 |
28 May 19 |
nicklas |
if (poolText) html += ' title="'+poolText+'"'; |
5440 |
20 May 19 |
nicklas |
html += '>'+Strings.encodeTags(plate.name)+'</th>'; |
5446 |
24 May 19 |
nicklas |
colNo += plate.columnSpan; |
5440 |
20 May 19 |
nicklas |
488 |
} |
5454 |
28 May 19 |
nicklas |
if (colNo < Plate.columns) |
5440 |
20 May 19 |
nicklas |
490 |
{ |
5454 |
28 May 19 |
nicklas |
html += '<th class="nopool-after-pool" colspan="'+(Plate.columns-colNo)+'"></th>'; |
5440 |
20 May 19 |
nicklas |
492 |
} |
5454 |
28 May 19 |
nicklas |
html += '<td style="padding:0;"></td>'; |
5446 |
24 May 19 |
nicklas |
var row = document.getElementById('plate-row'); |
5440 |
20 May 19 |
nicklas |
row.innerHTML = html; |
5446 |
24 May 19 |
nicklas |
Doc.show(row); |
5440 |
20 May 19 |
nicklas |
497 |
} |
5440 |
20 May 19 |
nicklas |
498 |
|
5390 |
29 Apr 19 |
nicklas |
mips.submit = function() |
5390 |
29 Apr 19 |
nicklas |
500 |
{ |
5390 |
29 Apr 19 |
nicklas |
var frm = document.forms['reggie']; |
5390 |
29 Apr 19 |
nicklas |
502 |
|
5390 |
29 Apr 19 |
nicklas |
var submitInfo = {}; |
5390 |
29 Apr 19 |
nicklas |
504 |
|
5417 |
10 May 19 |
nicklas |
var mipsPlate = {}; |
5417 |
10 May 19 |
nicklas |
mipsPlate.name = Plate.name; |
5417 |
10 May 19 |
nicklas |
mipsPlate.comments = frm.comments.value; |
5417 |
10 May 19 |
nicklas |
mipsPlate.wells = []; |
5417 |
10 May 19 |
nicklas |
submitInfo.mipsPlate = mipsPlate; |
5390 |
29 Apr 19 |
nicklas |
510 |
|
5417 |
10 May 19 |
nicklas |
var aliquotPlates = []; |
5417 |
10 May 19 |
nicklas |
submitInfo.aliquotPlates = aliquotPlates |
5417 |
10 May 19 |
nicklas |
for (var i = 0; i < frm.plates.length; i++) |
5417 |
10 May 19 |
nicklas |
514 |
{ |
5417 |
10 May 19 |
nicklas |
var plate = frm.plates[i].plate; |
5417 |
10 May 19 |
nicklas |
var tmp = {}; |
5417 |
10 May 19 |
nicklas |
tmp.id = plate.id; |
5417 |
10 May 19 |
nicklas |
tmp.numAliquots = plate.aliquots.length; |
5417 |
10 May 19 |
nicklas |
tmp.numPlacedAliquots = plate.numPlacedAliquots; |
5417 |
10 May 19 |
nicklas |
aliquotPlates[i] = tmp; |
5417 |
10 May 19 |
nicklas |
521 |
} |
5390 |
29 Apr 19 |
nicklas |
522 |
|
5390 |
29 Apr 19 |
nicklas |
var wells = Plate.getWells(); |
5390 |
29 Apr 19 |
nicklas |
for (var i = 0; i < wells.length; i++) |
5390 |
29 Apr 19 |
nicklas |
525 |
{ |
5390 |
29 Apr 19 |
nicklas |
var well = wells[i]; |
5418 |
10 May 19 |
nicklas |
var aliquot = well.extract; |
5418 |
10 May 19 |
nicklas |
if (aliquot && aliquot.id) |
5390 |
29 Apr 19 |
nicklas |
529 |
{ |
5390 |
29 Apr 19 |
nicklas |
var tmp = {}; |
5390 |
29 Apr 19 |
nicklas |
tmp.row = well.row; |
5390 |
29 Apr 19 |
nicklas |
tmp.column = well.column; |
5418 |
10 May 19 |
nicklas |
tmp.aliquot = {}; |
5418 |
10 May 19 |
nicklas |
tmp.aliquot.id = aliquot.id; |
5417 |
10 May 19 |
nicklas |
mipsPlate.wells[mipsPlate.wells.length] = tmp; |
5390 |
29 Apr 19 |
nicklas |
536 |
} |
5390 |
29 Apr 19 |
nicklas |
537 |
} |
5417 |
10 May 19 |
nicklas |
538 |
|
5390 |
29 Apr 19 |
nicklas |
var url = '../Mips.servlet?ID='+App.getSessionId(); |
5417 |
10 May 19 |
nicklas |
url += '&cmd=CreateMIPsPlate'; |
5390 |
29 Apr 19 |
nicklas |
Wizard.showLoadingAnimation('Performing registration...'); |
5390 |
29 Apr 19 |
nicklas |
Wizard.asyncJsonRequest(url, mips.submissionResults, 'POST', JSON.stringify(submitInfo)); |
5390 |
29 Apr 19 |
nicklas |
543 |
} |
5390 |
29 Apr 19 |
nicklas |
544 |
|
5390 |
29 Apr 19 |
nicklas |
mips.submissionResults = function(response) |
5390 |
29 Apr 19 |
nicklas |
546 |
{ |
5390 |
29 Apr 19 |
nicklas |
window.removeEventListener('beforeunload', mips.confirmLeaveWizard); |
5390 |
29 Apr 19 |
nicklas |
Wizard.showFinalMessage(response.messages); |
5390 |
29 Apr 19 |
nicklas |
Doc.show('gorestart'); |
5390 |
29 Apr 19 |
nicklas |
550 |
} |
5390 |
29 Apr 19 |
nicklas |
551 |
|
5390 |
29 Apr 19 |
nicklas |
mips.initElements = function(element, autoInit) |
5390 |
29 Apr 19 |
nicklas |
553 |
{ |
5390 |
29 Apr 19 |
nicklas |
if (autoInit == 'plate-col') |
5390 |
29 Apr 19 |
nicklas |
555 |
{ |
5390 |
29 Apr 19 |
nicklas |
Events.addEventHandler(element, 'click', mips.toggleColumn); |
5390 |
29 Apr 19 |
nicklas |
Events.addEventHandler(element, 'mouseover', mips.highlightColumn); |
5390 |
29 Apr 19 |
nicklas |
Events.addEventHandler(element, 'mouseout', mips.highlightColumn); |
5390 |
29 Apr 19 |
nicklas |
559 |
} |
5390 |
29 Apr 19 |
nicklas |
else if (autoInit == 'plate-row') |
5390 |
29 Apr 19 |
nicklas |
561 |
{ |
5390 |
29 Apr 19 |
nicklas |
Events.addEventHandler(element, 'click', mips.toggleRow); |
5390 |
29 Apr 19 |
nicklas |
Events.addEventHandler(element, 'mouseover', mips.highlightRow); |
5390 |
29 Apr 19 |
nicklas |
Events.addEventHandler(element, 'mouseout', mips.highlightRow); |
5390 |
29 Apr 19 |
nicklas |
565 |
} |
5390 |
29 Apr 19 |
nicklas |
else if (autoInit == 'plate-well') |
5390 |
29 Apr 19 |
nicklas |
567 |
{ |
5390 |
29 Apr 19 |
nicklas |
Events.addEventHandler(element, 'click', mips.toggleWell); |
5390 |
29 Apr 19 |
nicklas |
569 |
} |
5390 |
29 Apr 19 |
nicklas |
570 |
} |
5390 |
29 Apr 19 |
nicklas |
571 |
|
5390 |
29 Apr 19 |
nicklas |
// Toggle the selected status of a single well |
5390 |
29 Apr 19 |
nicklas |
mips.toggleWell = function(event) |
5390 |
29 Apr 19 |
nicklas |
574 |
{ |
5390 |
29 Apr 19 |
nicklas |
var row = Data.int(event.currentTarget, 'row'); |
5390 |
29 Apr 19 |
nicklas |
var column = Data.int(event.currentTarget, 'col'); |
5390 |
29 Apr 19 |
nicklas |
var well = Plate.getWell(row, column); |
5390 |
29 Apr 19 |
nicklas |
Plate.toggleSelected([well]); |
5390 |
29 Apr 19 |
nicklas |
579 |
} |
5390 |
29 Apr 19 |
nicklas |
580 |
|
5390 |
29 Apr 19 |
nicklas |
// Toggle the selected status of a complete row |
5390 |
29 Apr 19 |
nicklas |
mips.toggleRow = function(event) |
5390 |
29 Apr 19 |
nicklas |
583 |
{ |
5390 |
29 Apr 19 |
nicklas |
var row = Data.int(event.currentTarget, 'row'); |
5390 |
29 Apr 19 |
nicklas |
Plate.toggleSelected(Plate.getRow(row)); |
5390 |
29 Apr 19 |
nicklas |
586 |
} |
5390 |
29 Apr 19 |
nicklas |
587 |
|
5390 |
29 Apr 19 |
nicklas |
// Toggle the selected status of a complete column |
5390 |
29 Apr 19 |
nicklas |
mips.toggleColumn = function(event) |
5390 |
29 Apr 19 |
nicklas |
590 |
{ |
5390 |
29 Apr 19 |
nicklas |
var column = Data.int(event.currentTarget, 'col'); |
5390 |
29 Apr 19 |
nicklas |
Plate.toggleSelected(Plate.getColumn(column)); |
5390 |
29 Apr 19 |
nicklas |
593 |
} |
5390 |
29 Apr 19 |
nicklas |
594 |
|
5440 |
20 May 19 |
nicklas |
// Toggle the selected status of a pool |
5440 |
20 May 19 |
nicklas |
mips.togglePool = function(event) |
5440 |
20 May 19 |
nicklas |
597 |
{ |
5446 |
24 May 19 |
nicklas |
var startCol = Data.int(event.target, 'start-col'); |
5446 |
24 May 19 |
nicklas |
var endCol = Data.int(event.target, 'end-col'); |
5446 |
24 May 19 |
nicklas |
Plate.toggleSelected(Plate.getPool(startCol, endCol)); |
5440 |
20 May 19 |
nicklas |
601 |
} |
5440 |
20 May 19 |
nicklas |
602 |
|
5390 |
29 Apr 19 |
nicklas |
// Highlight enable/disable all wells in a column |
5390 |
29 Apr 19 |
nicklas |
mips.highlightColumn = function(event) |
5390 |
29 Apr 19 |
nicklas |
605 |
{ |
5390 |
29 Apr 19 |
nicklas |
var column = Data.int(event.currentTarget, 'col'); |
5390 |
29 Apr 19 |
nicklas |
var on = event.type == 'mouseover'; |
5390 |
29 Apr 19 |
nicklas |
608 |
|
5390 |
29 Apr 19 |
nicklas |
Doc.addOrRemoveClass(event.currentTarget, 'highlight-column', on); |
5390 |
29 Apr 19 |
nicklas |
var wells = Plate.getColumn(column); |
5390 |
29 Apr 19 |
nicklas |
Plate.setHighlight(wells, 'highlight-column', on); |
5390 |
29 Apr 19 |
nicklas |
612 |
} |
5390 |
29 Apr 19 |
nicklas |
613 |
|
5390 |
29 Apr 19 |
nicklas |
// Highlight enable/disable all wells in a row |
5390 |
29 Apr 19 |
nicklas |
mips.highlightRow = function(event) |
5390 |
29 Apr 19 |
nicklas |
616 |
{ |
5390 |
29 Apr 19 |
nicklas |
var row = Data.int(event.currentTarget, 'row'); |
5390 |
29 Apr 19 |
nicklas |
var on = event.type == 'mouseover'; |
5390 |
29 Apr 19 |
nicklas |
619 |
|
5390 |
29 Apr 19 |
nicklas |
Doc.addOrRemoveClass(event.currentTarget, 'highlight-row', on); |
5390 |
29 Apr 19 |
nicklas |
var wells = Plate.getRow(row); |
5390 |
29 Apr 19 |
nicklas |
Plate.setHighlight(wells, 'highlight-row', on); |
5390 |
29 Apr 19 |
nicklas |
623 |
} |
5390 |
29 Apr 19 |
nicklas |
624 |
|
5440 |
20 May 19 |
nicklas |
// Highligt enable/disable all wells in a pool |
5440 |
20 May 19 |
nicklas |
mips.highlightPool = function(event) |
5440 |
20 May 19 |
nicklas |
627 |
{ |
5446 |
24 May 19 |
nicklas |
var startCol = Data.int(event.target, 'start-col'); |
5446 |
24 May 19 |
nicklas |
var endCol = Data.int(event.target, 'end-col'); |
5440 |
20 May 19 |
nicklas |
var on = event.type == 'mouseover'; |
5446 |
24 May 19 |
nicklas |
Doc.addOrRemoveClass(event.target, 'highlight-pool', on); |
5446 |
24 May 19 |
nicklas |
var wells = Plate.getPool(startCol, endCol); |
5446 |
24 May 19 |
nicklas |
Plate.setHighlight(wells, 'highlight-pool', on); |
5440 |
20 May 19 |
nicklas |
634 |
} |
5440 |
20 May 19 |
nicklas |
635 |
|
5446 |
24 May 19 |
nicklas |
// Highligt enable/disable all wells in a pool |
5446 |
24 May 19 |
nicklas |
mips.highlightGroup = function(event) |
5446 |
24 May 19 |
nicklas |
638 |
{ |
5446 |
24 May 19 |
nicklas |
var startCol = Data.int(event.target, 'start-col'); |
5446 |
24 May 19 |
nicklas |
var endCol = Data.int(event.target, 'end-col'); |
5446 |
24 May 19 |
nicklas |
var on = event.type == 'mouseover'; |
5446 |
24 May 19 |
nicklas |
Doc.addOrRemoveClass(event.target, 'highlight-group', on); |
5446 |
24 May 19 |
nicklas |
var wells = Plate.getPool(startCol, endCol); |
5446 |
24 May 19 |
nicklas |
Plate.setHighlight(wells, 'highlight-group', on); |
5446 |
24 May 19 |
nicklas |
645 |
} |
5446 |
24 May 19 |
nicklas |
646 |
|
5390 |
29 Apr 19 |
nicklas |
return mips; |
5390 |
29 Apr 19 |
nicklas |
648 |
}(); |
5390 |
29 Apr 19 |
nicklas |
649 |
|
5390 |
29 Apr 19 |
nicklas |
Doc.onLoad(MipsPlate.initPage); |
5390 |
29 Apr 19 |
nicklas |
Doc.addElementInitializer(MipsPlate.initElements); |
5390 |
29 Apr 19 |
nicklas |
652 |
|
5446 |
24 May 19 |
nicklas |
var COLUMN_DATA = []; |
5440 |
20 May 19 |
nicklas |
654 |
|
5390 |
29 Apr 19 |
nicklas |
var WellPainter = function() |
5390 |
29 Apr 19 |
nicklas |
656 |
{ |
5390 |
29 Apr 19 |
nicklas |
var painter = {}; |
5390 |
29 Apr 19 |
nicklas |
658 |
|
5390 |
29 Apr 19 |
nicklas |
// Add class indicators for replicates and QC assigned wells |
5390 |
29 Apr 19 |
nicklas |
painter.getClassNameForWell = function(well) |
5390 |
29 Apr 19 |
nicklas |
661 |
{ |
5390 |
29 Apr 19 |
nicklas |
var cls = ''; |
5390 |
29 Apr 19 |
nicklas |
if (well.extract) |
5390 |
29 Apr 19 |
nicklas |
664 |
{ |
5413 |
09 May 19 |
nicklas |
cls += ' primary'; |
5603 |
13 Sep 19 |
nicklas |
if (well.extract.MIPS_Panel) cls += ' ' + MipsColor.getColor(well.extract.MIPS_Panel); |
5390 |
29 Apr 19 |
nicklas |
667 |
} |
5390 |
29 Apr 19 |
nicklas |
if (well.column == Plate.columns-1) cls += ' last-child'; |
5446 |
24 May 19 |
nicklas |
if (COLUMN_DATA[well.column]) |
5446 |
24 May 19 |
nicklas |
670 |
{ |
5448 |
27 May 19 |
nicklas |
cls += ' ' + (COLUMN_DATA[well.column].poolClass || ''); |
5448 |
27 May 19 |
nicklas |
cls += ' ' + (COLUMN_DATA[well.column].groupClass || ''); |
5446 |
24 May 19 |
nicklas |
673 |
} |
5390 |
29 Apr 19 |
nicklas |
return cls; |
5390 |
29 Apr 19 |
nicklas |
675 |
} |
5390 |
29 Apr 19 |
nicklas |
676 |
|
5390 |
29 Apr 19 |
nicklas |
painter.getWellText = function(well) |
5390 |
29 Apr 19 |
nicklas |
678 |
{ |
5390 |
29 Apr 19 |
nicklas |
var text = ''; |
5390 |
29 Apr 19 |
nicklas |
if (well.extract) |
5390 |
29 Apr 19 |
nicklas |
681 |
{ |
5390 |
29 Apr 19 |
nicklas |
// The well contains DNA |
5413 |
09 May 19 |
nicklas |
var aliquot = well.extract; |
5481 |
11 Jun 19 |
nicklas |
text += '<div class="name">'+Reggie.softLineBreaks(Strings.encodeTags(aliquot.name))+'</div>'; |
5390 |
29 Apr 19 |
nicklas |
685 |
|
5390 |
29 Apr 19 |
nicklas |
var warningMsg = []; |
5413 |
09 May 19 |
nicklas |
if (aliquot.bioWell) |
5390 |
29 Apr 19 |
nicklas |
688 |
{ |
5413 |
09 May 19 |
nicklas |
var dnaWell = aliquot.bioWell; |
5440 |
20 May 19 |
nicklas |
text += '<div class="location">['+dnaWell.location+']</div>'; |
5390 |
29 Apr 19 |
nicklas |
691 |
} |
5392 |
02 May 19 |
nicklas |
else |
5390 |
29 Apr 19 |
nicklas |
693 |
{ |
5461 |
03 Jun 19 |
nicklas |
warningMsg[warningMsg.length] = 'No location!'; |
5390 |
29 Apr 19 |
nicklas |
695 |
} |
5448 |
27 May 19 |
nicklas |
696 |
|
5448 |
27 May 19 |
nicklas |
if (aliquot.MIPS_PoolVolume != null) |
5414 |
09 May 19 |
nicklas |
698 |
{ |
5461 |
03 Jun 19 |
nicklas |
text += '<div class="volume">'+Numbers.formatNumber(aliquot.MIPS_PoolVolume, 0, 'µl')+'</div>'; |
5448 |
27 May 19 |
nicklas |
if (aliquot.MIPS_PoolVolume != COLUMN_DATA[well.column].MIPS_PoolVolume) |
5414 |
09 May 19 |
nicklas |
701 |
{ |
5461 |
03 Jun 19 |
nicklas |
warningMsg[warningMsg.length] = 'PoolVolume!'; |
5414 |
09 May 19 |
nicklas |
703 |
} |
5414 |
09 May 19 |
nicklas |
704 |
} |
5603 |
13 Sep 19 |
nicklas |
if (aliquot.MIPS_Panel != null) |
5414 |
09 May 19 |
nicklas |
706 |
{ |
5603 |
13 Sep 19 |
nicklas |
text += '<div class="mips-panel">'+Strings.encodeTags(aliquot.MIPS_Panel)+'</div>'; |
5414 |
09 May 19 |
nicklas |
708 |
} |
5448 |
27 May 19 |
nicklas |
else |
5390 |
29 Apr 19 |
nicklas |
710 |
{ |
5603 |
13 Sep 19 |
nicklas |
well.setError('No MIPS_Panel'); |
5392 |
02 May 19 |
nicklas |
712 |
} |
5413 |
09 May 19 |
nicklas |
713 |
|
5448 |
27 May 19 |
nicklas |
if (aliquot.MIPS_Form != null || aliquot.MIPS_NormalTumor != null) |
5390 |
29 Apr 19 |
nicklas |
715 |
{ |
5448 |
27 May 19 |
nicklas |
text += '<div class="mips-form">'; |
5448 |
27 May 19 |
nicklas |
if (aliquot.MIPS_NormalTumor != null) text += '<span>'+Strings.encodeTags(aliquot.MIPS_NormalTumor)+'</span>'; |
5448 |
27 May 19 |
nicklas |
if (aliquot.MIPS_Form != null) text += '<span>'+Strings.encodeTags(aliquot.MIPS_Form)+'</span>'; |
5448 |
27 May 19 |
nicklas |
text += '</div>'; |
5390 |
29 Apr 19 |
nicklas |
720 |
} |
5413 |
09 May 19 |
nicklas |
721 |
|
5413 |
09 May 19 |
nicklas |
if (aliquot.comment) |
5413 |
09 May 19 |
nicklas |
723 |
{ |
5413 |
09 May 19 |
nicklas |
text += '<div class="comment">'+Strings.encodeTags(aliquot.comment)+'</div>'; |
5413 |
09 May 19 |
nicklas |
725 |
} |
5413 |
09 May 19 |
nicklas |
726 |
|
5413 |
09 May 19 |
nicklas |
if (aliquot.DO_NOT_USE) |
5413 |
09 May 19 |
nicklas |
728 |
{ |
5413 |
09 May 19 |
nicklas |
warningMsg[warningMsg.length] = 'DoNotUse-'+Strings.encodeTags(aliquot.DO_NOT_USE); |
5413 |
09 May 19 |
nicklas |
730 |
} |
5390 |
29 Apr 19 |
nicklas |
if (warningMsg.length > 0) |
5390 |
29 Apr 19 |
nicklas |
732 |
{ |
5390 |
29 Apr 19 |
nicklas |
well.setWarning(warningMsg.join('; ')); |
5390 |
29 Apr 19 |
nicklas |
734 |
} |
5390 |
29 Apr 19 |
nicklas |
735 |
} |
5390 |
29 Apr 19 |
nicklas |
else |
5390 |
29 Apr 19 |
nicklas |
737 |
{ |
5390 |
29 Apr 19 |
nicklas |
text = 'empty'; |
5390 |
29 Apr 19 |
nicklas |
739 |
} |
5390 |
29 Apr 19 |
nicklas |
740 |
|
5390 |
29 Apr 19 |
nicklas |
return text; |
5390 |
29 Apr 19 |
nicklas |
742 |
} |
5390 |
29 Apr 19 |
nicklas |
743 |
|
5390 |
29 Apr 19 |
nicklas |
return painter; |
5390 |
29 Apr 19 |
nicklas |
745 |
}(); |