5397 |
03 May 19 |
nicklas |
var ImportPlates = function() |
5397 |
03 May 19 |
nicklas |
2 |
{ |
5397 |
03 May 19 |
nicklas |
var mips = {}; |
5397 |
03 May 19 |
nicklas |
var debug = 0; |
5397 |
03 May 19 |
nicklas |
5 |
|
5397 |
03 May 19 |
nicklas |
var prefixIsValid = false; |
5397 |
03 May 19 |
nicklas |
7 |
|
5397 |
03 May 19 |
nicklas |
var importData; |
5397 |
03 May 19 |
nicklas |
9 |
|
5397 |
03 May 19 |
nicklas |
// Page initialization |
5397 |
03 May 19 |
nicklas |
mips.initPage = function() |
5397 |
03 May 19 |
nicklas |
12 |
{ |
5397 |
03 May 19 |
nicklas |
// Step 1 |
5397 |
03 May 19 |
nicklas |
Events.addEventHandler('step-1', 'wizard-validate', mips.validateStep1); |
5397 |
03 May 19 |
nicklas |
15 |
|
5397 |
03 May 19 |
nicklas |
Events.addEventHandler('prefix', 'change', mips.prefixOnChange); |
5397 |
03 May 19 |
nicklas |
Events.addEventHandler('prefix', 'keypress', Wizard.focusOnEnter); |
5397 |
03 May 19 |
nicklas |
Wizard.initFileSelectionField('importfile'); |
5397 |
03 May 19 |
nicklas |
Events.addEventHandler('importfile', 'change', mips.importFileOnChange); |
5397 |
03 May 19 |
nicklas |
Events.addEventHandler('sheet', 'change', mips.worksheetOnChange); |
5397 |
03 May 19 |
nicklas |
21 |
|
5397 |
03 May 19 |
nicklas |
Events.addEventHandler('plateNames', 'change', mips.displayAliquotsOnPlate); |
5397 |
03 May 19 |
nicklas |
23 |
|
5444 |
23 May 19 |
nicklas |
Events.addEventHandler('pool-row', 'click', mips.togglePool); |
5444 |
23 May 19 |
nicklas |
Events.addEventHandler('pool-row', 'mouseover', mips.highlightPool); |
5444 |
23 May 19 |
nicklas |
Events.addEventHandler('pool-row', 'mouseout', mips.highlightPool); |
5444 |
23 May 19 |
nicklas |
27 |
|
5397 |
03 May 19 |
nicklas |
// Navigation |
5397 |
03 May 19 |
nicklas |
Buttons.addClickHandler('gocancel', Wizard.cancelWizard); |
5397 |
03 May 19 |
nicklas |
Buttons.addClickHandler('gorestart', Wizard.restartWizard); |
5397 |
03 May 19 |
nicklas |
Buttons.addClickHandler('gonext', Wizard.goNextOnClick); |
5397 |
03 May 19 |
nicklas |
Buttons.addClickHandler('goregister', Wizard.goRegister); |
5397 |
03 May 19 |
nicklas |
33 |
|
5397 |
03 May 19 |
nicklas |
// Final registration |
5397 |
03 May 19 |
nicklas |
Events.addEventHandler('wizard', 'wizard-submit', mips.submit); |
5397 |
03 May 19 |
nicklas |
36 |
|
5397 |
03 May 19 |
nicklas |
Plate.init(8, 12, WellPainter); |
5397 |
03 May 19 |
nicklas |
Plate.paint(Plate.getWells()); |
5397 |
03 May 19 |
nicklas |
window.addEventListener('beforeunload', mips.confirmLeaveWizard); |
5526 |
25 Jun 19 |
nicklas |
Wizard.keepSessionAlive(); |
5397 |
03 May 19 |
nicklas |
41 |
|
5397 |
03 May 19 |
nicklas |
Doc.show('step-1'); |
5397 |
03 May 19 |
nicklas |
Doc.show('gocancel'); |
5397 |
03 May 19 |
nicklas |
Doc.show('goregister'); |
5397 |
03 May 19 |
nicklas |
Events.sendChangeEvent('prefix'); |
5397 |
03 May 19 |
nicklas |
46 |
} |
5397 |
03 May 19 |
nicklas |
47 |
|
5397 |
03 May 19 |
nicklas |
48 |
/** |
5397 |
03 May 19 |
nicklas |
Ask for confirmation to abort if DNA has been placed on the plate. |
5397 |
03 May 19 |
nicklas |
50 |
*/ |
5397 |
03 May 19 |
nicklas |
mips.confirmLeaveWizard = function(event) |
5397 |
03 May 19 |
nicklas |
52 |
{ |
5397 |
03 May 19 |
nicklas |
if (Plate.getUsed().length > 0) |
5397 |
03 May 19 |
nicklas |
54 |
{ |
5397 |
03 May 19 |
nicklas |
event.preventDefault(); |
5397 |
03 May 19 |
nicklas |
56 |
} |
5397 |
03 May 19 |
nicklas |
57 |
} |
5397 |
03 May 19 |
nicklas |
58 |
|
5397 |
03 May 19 |
nicklas |
mips.prefixOnChange = function() |
5397 |
03 May 19 |
nicklas |
60 |
{ |
5397 |
03 May 19 |
nicklas |
var frm = document.forms['reggie']; |
5397 |
03 May 19 |
nicklas |
Wizard.setInputStatus('prefix'); |
5397 |
03 May 19 |
nicklas |
63 |
|
5397 |
03 May 19 |
nicklas |
var prefix = frm.prefix.value.toUpperCase().replace(/_/g, ''); |
5397 |
03 May 19 |
nicklas |
prefixIsValid = false; |
5397 |
03 May 19 |
nicklas |
if (prefix.length < 2) |
5397 |
03 May 19 |
nicklas |
67 |
{ |
5397 |
03 May 19 |
nicklas |
Wizard.setInputStatus('prefix', 'invalid', 'The prefix should have at least 2 characters.'); |
5397 |
03 May 19 |
nicklas |
frm.prefix.focus(); |
5397 |
03 May 19 |
nicklas |
return; |
5397 |
03 May 19 |
nicklas |
71 |
} |
5397 |
03 May 19 |
nicklas |
72 |
|
5397 |
03 May 19 |
nicklas |
frm.prefix.value = prefix+'_'; |
5397 |
03 May 19 |
nicklas |
Wizard.setInputStatus('prefix', 'valid'); |
5397 |
03 May 19 |
nicklas |
prefixIsValid = true; |
5397 |
03 May 19 |
nicklas |
76 |
|
5397 |
03 May 19 |
nicklas |
mips.prevalidateImportFile(); |
5397 |
03 May 19 |
nicklas |
78 |
} |
5397 |
03 May 19 |
nicklas |
79 |
|
5397 |
03 May 19 |
nicklas |
mips.importFileOnChange = function() |
5397 |
03 May 19 |
nicklas |
81 |
{ |
5397 |
03 May 19 |
nicklas |
Doc.hide('worksheetSection'); |
5447 |
24 May 19 |
nicklas |
Doc.hide('worksheetSection.help'); |
5397 |
03 May 19 |
nicklas |
mips.prevalidateImportFile(); |
5397 |
03 May 19 |
nicklas |
85 |
} |
5397 |
03 May 19 |
nicklas |
86 |
|
5397 |
03 May 19 |
nicklas |
mips.worksheetOnChange = function() |
5397 |
03 May 19 |
nicklas |
88 |
{ |
5397 |
03 May 19 |
nicklas |
mips.prevalidateImportFile(); |
5397 |
03 May 19 |
nicklas |
90 |
} |
5397 |
03 May 19 |
nicklas |
91 |
|
5397 |
03 May 19 |
nicklas |
mips.validateStep1 = function(event) |
5397 |
03 May 19 |
nicklas |
93 |
{ |
5399 |
06 May 19 |
nicklas |
if (!prefixIsValid || !Wizard.isValid('importfile')) |
5399 |
06 May 19 |
nicklas |
95 |
{ |
5399 |
06 May 19 |
nicklas |
event.preventDefault(); |
5399 |
06 May 19 |
nicklas |
97 |
} |
5397 |
03 May 19 |
nicklas |
98 |
} |
5397 |
03 May 19 |
nicklas |
99 |
|
5397 |
03 May 19 |
nicklas |
mips.prevalidateImportFile = function() |
5397 |
03 May 19 |
nicklas |
101 |
{ |
5397 |
03 May 19 |
nicklas |
Doc.hide('platePreview'); |
5447 |
24 May 19 |
nicklas |
Doc.hide('pool-row'); |
5401 |
07 May 19 |
nicklas |
Wizard.hideWizardStatus(); |
5444 |
23 May 19 |
nicklas |
Wizard.hideGoNextConfirmation(); |
5397 |
03 May 19 |
nicklas |
106 |
|
5397 |
03 May 19 |
nicklas |
var frm = document.forms['reggie']; |
5397 |
03 May 19 |
nicklas |
var path = frm.importfile.value; |
5397 |
03 May 19 |
nicklas |
if (!prefixIsValid || path == '') return; |
5397 |
03 May 19 |
nicklas |
110 |
|
5397 |
03 May 19 |
nicklas |
Wizard.setInputStatus('importfile'); |
5397 |
03 May 19 |
nicklas |
Data.set('importfile', 'valid', 0); |
5397 |
03 May 19 |
nicklas |
113 |
|
5397 |
03 May 19 |
nicklas |
var url = '../Mips.servlet?ID='+App.getSessionId(); |
5397 |
03 May 19 |
nicklas |
url += '&cmd=PreValidateImportFile'; |
5397 |
03 May 19 |
nicklas |
url += '&path='+encodeURIComponent(path); |
5397 |
03 May 19 |
nicklas |
url += '&prefix='+encodeURIComponent(frm.prefix.value); |
5397 |
03 May 19 |
nicklas |
url += '&sheet='+encodeURIComponent(frm.sheet.value); |
5397 |
03 May 19 |
nicklas |
119 |
|
5401 |
07 May 19 |
nicklas |
Wizard.showLoadingAnimation('Validating ' + Strings.encodeTags(path)); |
5397 |
03 May 19 |
nicklas |
Wizard.asyncJsonRequest(url, mips.onImportFileValidated, 'POST'); |
5397 |
03 May 19 |
nicklas |
122 |
} |
5397 |
03 May 19 |
nicklas |
123 |
|
5397 |
03 May 19 |
nicklas |
mips.onImportFileValidated = function(response) |
5397 |
03 May 19 |
nicklas |
125 |
{ |
5397 |
03 May 19 |
nicklas |
var frm = document.forms['reggie']; |
5397 |
03 May 19 |
nicklas |
127 |
|
5397 |
03 May 19 |
nicklas |
Wizard.setInputStatus('importfile'); |
5397 |
03 May 19 |
nicklas |
Wizard.showFinalMessage(response.messages); |
5397 |
03 May 19 |
nicklas |
130 |
|
5397 |
03 May 19 |
nicklas |
importData = response.importFile; |
5397 |
03 May 19 |
nicklas |
132 |
|
5397 |
03 May 19 |
nicklas |
var sheetNames = importData.sheetNames; |
5397 |
03 May 19 |
nicklas |
if (sheetNames && sheetNames.length) |
5397 |
03 May 19 |
nicklas |
135 |
{ |
5397 |
03 May 19 |
nicklas |
var currentSheet = frm.sheet.value; |
5397 |
03 May 19 |
nicklas |
frm.sheet.length = 0; |
5397 |
03 May 19 |
nicklas |
for (var sNo = 0; sNo < sheetNames.length; sNo++) |
5397 |
03 May 19 |
nicklas |
139 |
{ |
5397 |
03 May 19 |
nicklas |
var sheet = sheetNames[sNo]; |
5397 |
03 May 19 |
nicklas |
frm.sheet[frm.sheet.length] = new Option(sheet, sheet, false, currentSheet == sheet); |
5397 |
03 May 19 |
nicklas |
142 |
} |
5447 |
24 May 19 |
nicklas |
if (frm.sheet.length > 1) |
5447 |
24 May 19 |
nicklas |
144 |
{ |
5447 |
24 May 19 |
nicklas |
Doc.show('worksheetSection'); |
5447 |
24 May 19 |
nicklas |
Doc.show('worksheetSection.help'); |
5447 |
24 May 19 |
nicklas |
147 |
} |
5397 |
03 May 19 |
nicklas |
148 |
} |
5397 |
03 May 19 |
nicklas |
149 |
|
5397 |
03 May 19 |
nicklas |
var plates = importData.plates; |
5397 |
03 May 19 |
nicklas |
frm.plateNames.length = 0; |
5399 |
06 May 19 |
nicklas |
152 |
|
5397 |
03 May 19 |
nicklas |
if (plates && plates.length) |
5397 |
03 May 19 |
nicklas |
154 |
{ |
5397 |
03 May 19 |
nicklas |
for (var pNo = 0; pNo < plates.length; pNo++) |
5397 |
03 May 19 |
nicklas |
156 |
{ |
5397 |
03 May 19 |
nicklas |
var plate = plates[pNo]; |
5399 |
06 May 19 |
nicklas |
var text = plate.name; |
5399 |
06 May 19 |
nicklas |
if (plate.error) |
5399 |
06 May 19 |
nicklas |
160 |
{ |
5399 |
06 May 19 |
nicklas |
text += ' (' + plate.error + ')'; |
5399 |
06 May 19 |
nicklas |
162 |
} |
5399 |
06 May 19 |
nicklas |
else |
5399 |
06 May 19 |
nicklas |
164 |
{ |
5399 |
06 May 19 |
nicklas |
text += ' (' + plate.aliquots.length + ' aliquots)'; |
5399 |
06 May 19 |
nicklas |
166 |
} |
5399 |
06 May 19 |
nicklas |
frm.plateNames[frm.plateNames.length] = new Option(text); |
5397 |
03 May 19 |
nicklas |
168 |
} |
5397 |
03 May 19 |
nicklas |
169 |
} |
5397 |
03 May 19 |
nicklas |
170 |
|
5397 |
03 May 19 |
nicklas |
if (importData.valid) |
5397 |
03 May 19 |
nicklas |
172 |
{ |
5397 |
03 May 19 |
nicklas |
Wizard.setInputStatus('importfile', importData.warnings > 0 ? 'warning' : 'valid'); |
5397 |
03 May 19 |
nicklas |
Data.set('importfile', 'valid', 1); |
5444 |
23 May 19 |
nicklas |
if (importData.warnings > 0) |
5444 |
23 May 19 |
nicklas |
176 |
{ |
5444 |
23 May 19 |
nicklas |
Wizard.showGoNextConfirmation(true, 'Check to verify registration of plate with warnings.'); |
5444 |
23 May 19 |
nicklas |
178 |
} |
5397 |
03 May 19 |
nicklas |
179 |
} |
5397 |
03 May 19 |
nicklas |
else |
5397 |
03 May 19 |
nicklas |
181 |
{ |
5397 |
03 May 19 |
nicklas |
Wizard.setInputStatus('importfile', 'invalid'); |
5444 |
23 May 19 |
nicklas |
183 |
} |
5399 |
06 May 19 |
nicklas |
184 |
|
5403 |
08 May 19 |
nicklas |
mips.displayAliquotsOnPlate(); |
5397 |
03 May 19 |
nicklas |
186 |
} |
5397 |
03 May 19 |
nicklas |
187 |
|
5397 |
03 May 19 |
nicklas |
mips.displayAliquotsOnPlate = function() |
5397 |
03 May 19 |
nicklas |
189 |
{ |
5403 |
08 May 19 |
nicklas |
Doc.element('filename').innerHTML = Strings.encodeTags(importData.filename); |
5403 |
08 May 19 |
nicklas |
Doc.element('numPlates').innerHTML = importData.numPlates; |
5403 |
08 May 19 |
nicklas |
Doc.element('numAliquots').innerHTML = importData.numAliquots; |
5403 |
08 May 19 |
nicklas |
Doc.element('numErrors').innerHTML = importData.errors; |
5403 |
08 May 19 |
nicklas |
Doc.element('numWarnings').innerHTML = importData.warnings; |
5403 |
08 May 19 |
nicklas |
195 |
|
5403 |
08 May 19 |
nicklas |
Doc.element('importPossible').innerHTML = importData.valid ? '<img src="../images/ok.png">Import is possible!' : '<img src="../images/error.png">Import is not possible!'; |
5403 |
08 May 19 |
nicklas |
197 |
|
5397 |
03 May 19 |
nicklas |
Doc.show('platePreview'); |
5397 |
03 May 19 |
nicklas |
var frm = document.forms['reggie']; |
5397 |
03 May 19 |
nicklas |
var plateIndex = frm.plateNames.selectedIndex; |
5397 |
03 May 19 |
nicklas |
201 |
|
5397 |
03 May 19 |
nicklas |
var wells = Plate.getWells(); |
5397 |
03 May 19 |
nicklas |
Plate.clear(wells); |
5518 |
20 Jun 19 |
nicklas |
MipsColor.reset(); |
5447 |
24 May 19 |
nicklas |
COLUMN_CLASSES = new Array(Plate.columns); |
5447 |
24 May 19 |
nicklas |
206 |
|
5403 |
08 May 19 |
nicklas |
if (plateIndex >= 0 && importData.plates.length > plateIndex) |
5397 |
03 May 19 |
nicklas |
208 |
{ |
5403 |
08 May 19 |
nicklas |
var plate = importData.plates[plateIndex]; |
5403 |
08 May 19 |
nicklas |
var aliquots = plate.aliquots; |
5403 |
08 May 19 |
nicklas |
for (var aNo = 0; aNo < aliquots.length; aNo++) |
5399 |
06 May 19 |
nicklas |
212 |
{ |
5403 |
08 May 19 |
nicklas |
var aliquot = aliquots[aNo]; |
5403 |
08 May 19 |
nicklas |
var well = Plate.getWellByLocation(aliquot.location); |
5403 |
08 May 19 |
nicklas |
if (well && !well.extract) |
5403 |
08 May 19 |
nicklas |
216 |
{ |
5403 |
08 May 19 |
nicklas |
if (plate.error && !aliquot.error) aliquot.error = plate.error; |
5403 |
08 May 19 |
nicklas |
well.setExtract(aliquot); |
5403 |
08 May 19 |
nicklas |
219 |
} |
5399 |
06 May 19 |
nicklas |
220 |
} |
5444 |
23 May 19 |
nicklas |
mips.buildPoolTableRow(plate); |
5397 |
03 May 19 |
nicklas |
222 |
} |
5397 |
03 May 19 |
nicklas |
Plate.paint(wells); |
5397 |
03 May 19 |
nicklas |
224 |
} |
5397 |
03 May 19 |
nicklas |
225 |
|
5444 |
23 May 19 |
nicklas |
mips.buildPoolTableRow = function(plate) |
5444 |
23 May 19 |
nicklas |
227 |
{ |
5444 |
23 May 19 |
nicklas |
var html = '<th></th>'; |
5444 |
23 May 19 |
nicklas |
var columns = plate.columns; |
5600 |
13 Sep 19 |
nicklas |
var pools = []; // A 'pool' is a number of columns with the same MIPS_Panel |
5444 |
23 May 19 |
nicklas |
var currentPool = {}; |
5444 |
23 May 19 |
nicklas |
232 |
|
5444 |
23 May 19 |
nicklas |
var poolNum = -1; |
5444 |
23 May 19 |
nicklas |
for (var colNo = 0; colNo < columns.length; colNo++) |
5444 |
23 May 19 |
nicklas |
235 |
{ |
5444 |
23 May 19 |
nicklas |
var col = columns[colNo]; |
5600 |
13 Sep 19 |
nicklas |
if (col.MIPS_Panel != currentPool.name) |
5444 |
23 May 19 |
nicklas |
238 |
{ |
5600 |
13 Sep 19 |
nicklas |
// The column has a different MIPS_Panel than the previous one so we create a new pool |
5444 |
23 May 19 |
nicklas |
currentPool = {}; |
5600 |
13 Sep 19 |
nicklas |
currentPool.name = col.MIPS_Panel; |
5446 |
24 May 19 |
nicklas |
currentPool.startCol = colNo; |
5444 |
23 May 19 |
nicklas |
currentPool.columnSpan = 1; |
5600 |
13 Sep 19 |
nicklas |
currentPool.hasMultipleMIPSPanels = col.hasMultipleMIPSPanels; |
5447 |
24 May 19 |
nicklas |
currentPool.hasMultiplePoolVolumes = col.hasMultiplePoolVolumes; |
5444 |
23 May 19 |
nicklas |
pools[pools.length] = currentPool; |
5444 |
23 May 19 |
nicklas |
poolNum++; |
5444 |
23 May 19 |
nicklas |
248 |
} |
5444 |
23 May 19 |
nicklas |
else if (currentPool) |
5444 |
23 May 19 |
nicklas |
250 |
{ |
5600 |
13 Sep 19 |
nicklas |
// The column has the same MIPS_Panel as the previous one, we make the pool span across multiple columns |
5444 |
23 May 19 |
nicklas |
currentPool.columnSpan++; |
5600 |
13 Sep 19 |
nicklas |
if (col.hasMultipleMIPSPanels) currentPool.hasMultipleMIPSPanels = true; |
5447 |
24 May 19 |
nicklas |
if (col.hasMultiplePoolVolumes) currentPool.hasMultiplePoolVolumes = true; |
5444 |
23 May 19 |
nicklas |
255 |
} |
5444 |
23 May 19 |
nicklas |
256 |
} |
5444 |
23 May 19 |
nicklas |
257 |
|
5444 |
23 May 19 |
nicklas |
colNo = 0; |
5444 |
23 May 19 |
nicklas |
for (var poolNo = 0; poolNo < pools.length; poolNo++) |
5444 |
23 May 19 |
nicklas |
260 |
{ |
5444 |
23 May 19 |
nicklas |
var pool = pools[poolNo]; |
5444 |
23 May 19 |
nicklas |
var poolClass = 'pool link'; |
5444 |
23 May 19 |
nicklas |
var poolText = null; |
5444 |
23 May 19 |
nicklas |
264 |
|
5444 |
23 May 19 |
nicklas |
if (pool.columnSpan == 1) |
5444 |
23 May 19 |
nicklas |
266 |
{ |
5444 |
23 May 19 |
nicklas |
COLUMN_CLASSES[colNo] = 'pool-left pool-right'; |
5444 |
23 May 19 |
nicklas |
268 |
} |
5444 |
23 May 19 |
nicklas |
else |
5444 |
23 May 19 |
nicklas |
270 |
{ |
5444 |
23 May 19 |
nicklas |
COLUMN_CLASSES[colNo] = 'pool-left'; |
5444 |
23 May 19 |
nicklas |
for (var i = 1; i < pool.columnSpan-1; i++) |
5444 |
23 May 19 |
nicklas |
273 |
{ |
5444 |
23 May 19 |
nicklas |
COLUMN_CLASSES[colNo+i] = 'pool-middle'; |
5444 |
23 May 19 |
nicklas |
275 |
} |
5444 |
23 May 19 |
nicklas |
COLUMN_CLASSES[colNo+pool.columnSpan-1] = 'pool-right'; |
5444 |
23 May 19 |
nicklas |
277 |
} |
5444 |
23 May 19 |
nicklas |
278 |
|
5444 |
23 May 19 |
nicklas |
if (pool.name) |
5444 |
23 May 19 |
nicklas |
280 |
{ |
5518 |
20 Jun 19 |
nicklas |
if (pool.hasMultiplePoolVolumes) |
5444 |
23 May 19 |
nicklas |
282 |
{ |
5444 |
23 May 19 |
nicklas |
poolClass += ' pool-warning'; |
5518 |
20 Jun 19 |
nicklas |
poolText = 'Some aliquots have a different pool volume!'; |
5444 |
23 May 19 |
nicklas |
285 |
} |
5518 |
20 Jun 19 |
nicklas |
poolClass += ' ' + MipsColor.getColor(pool.name); |
5444 |
23 May 19 |
nicklas |
html += '<th id="pool.' + poolNo + '" colspan="'+pool.columnSpan+'"'; |
5444 |
23 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) + '"'; |
5444 |
23 May 19 |
nicklas |
if (poolText) html += ' title="'+poolText+'"'; |
5444 |
23 May 19 |
nicklas |
html += '>'+Strings.encodeTags(pool.name)+'</th>'; |
5444 |
23 May 19 |
nicklas |
293 |
} |
5444 |
23 May 19 |
nicklas |
else |
5444 |
23 May 19 |
nicklas |
295 |
{ |
5444 |
23 May 19 |
nicklas |
poolClass = ''; |
5444 |
23 May 19 |
nicklas |
if (colNo > 0) poolClass += ' nopool-after-pool'; |
5444 |
23 May 19 |
nicklas |
if (colNo + pool.columnSpan < 12) poolClass += ' nopool-before-pool'; |
5444 |
23 May 19 |
nicklas |
html += '<th colspan="'+pool.columnSpan+'"'; |
5444 |
23 May 19 |
nicklas |
html += ' class="'+poolClass+'"'; |
5444 |
23 May 19 |
nicklas |
html += '></th>'; |
5444 |
23 May 19 |
nicklas |
302 |
} |
5444 |
23 May 19 |
nicklas |
colNo += pool.columnSpan; |
5444 |
23 May 19 |
nicklas |
304 |
} |
5444 |
23 May 19 |
nicklas |
305 |
|
5447 |
24 May 19 |
nicklas |
Doc.element('pool-row').innerHTML = html; |
5447 |
24 May 19 |
nicklas |
Doc.show('pool-row'); |
5444 |
23 May 19 |
nicklas |
308 |
} |
5444 |
23 May 19 |
nicklas |
309 |
|
5400 |
06 May 19 |
nicklas |
mips.submit = function() |
5400 |
06 May 19 |
nicklas |
311 |
{ |
5400 |
06 May 19 |
nicklas |
var frm = document.forms['reggie']; |
5400 |
06 May 19 |
nicklas |
var path = frm.importfile.value; |
5400 |
06 May 19 |
nicklas |
314 |
|
5400 |
06 May 19 |
nicklas |
var url = '../Mips.servlet?ID='+App.getSessionId(); |
5400 |
06 May 19 |
nicklas |
url += '&cmd=ImportAliquotsFromFile'; |
5400 |
06 May 19 |
nicklas |
url += '&path='+encodeURIComponent(path); |
5400 |
06 May 19 |
nicklas |
url += '&prefix='+encodeURIComponent(frm.prefix.value); |
5400 |
06 May 19 |
nicklas |
url += '&sheet='+encodeURIComponent(frm.sheet.value); |
5400 |
06 May 19 |
nicklas |
320 |
|
5400 |
06 May 19 |
nicklas |
Wizard.showLoadingAnimation('Performing registration...'); |
5400 |
06 May 19 |
nicklas |
Wizard.asyncJsonRequest(url, mips.submissionResults, 'POST'); |
5400 |
06 May 19 |
nicklas |
323 |
} |
5400 |
06 May 19 |
nicklas |
324 |
|
5400 |
06 May 19 |
nicklas |
mips.submissionResults = function(response) |
5400 |
06 May 19 |
nicklas |
326 |
{ |
5400 |
06 May 19 |
nicklas |
window.removeEventListener('beforeunload', mips.confirmLeaveWizard); |
5400 |
06 May 19 |
nicklas |
Wizard.showFinalMessage(response.messages); |
5400 |
06 May 19 |
nicklas |
Doc.show('gorestart'); |
5400 |
06 May 19 |
nicklas |
330 |
} |
5400 |
06 May 19 |
nicklas |
331 |
|
5397 |
03 May 19 |
nicklas |
mips.initElements = function(element, autoInit) |
5397 |
03 May 19 |
nicklas |
333 |
{ |
5397 |
03 May 19 |
nicklas |
if (autoInit == 'plate-col') |
5397 |
03 May 19 |
nicklas |
335 |
{ |
5397 |
03 May 19 |
nicklas |
Events.addEventHandler(element, 'click', mips.toggleColumn); |
5397 |
03 May 19 |
nicklas |
Events.addEventHandler(element, 'mouseover', mips.highlightColumn); |
5397 |
03 May 19 |
nicklas |
Events.addEventHandler(element, 'mouseout', mips.highlightColumn); |
5397 |
03 May 19 |
nicklas |
339 |
} |
5397 |
03 May 19 |
nicklas |
else if (autoInit == 'plate-row') |
5397 |
03 May 19 |
nicklas |
341 |
{ |
5397 |
03 May 19 |
nicklas |
Events.addEventHandler(element, 'click', mips.toggleRow); |
5397 |
03 May 19 |
nicklas |
Events.addEventHandler(element, 'mouseover', mips.highlightRow); |
5397 |
03 May 19 |
nicklas |
Events.addEventHandler(element, 'mouseout', mips.highlightRow); |
5397 |
03 May 19 |
nicklas |
345 |
} |
5397 |
03 May 19 |
nicklas |
else if (autoInit == 'plate-well') |
5397 |
03 May 19 |
nicklas |
347 |
{ |
5397 |
03 May 19 |
nicklas |
Events.addEventHandler(element, 'click', mips.toggleWell); |
5397 |
03 May 19 |
nicklas |
349 |
} |
5397 |
03 May 19 |
nicklas |
350 |
} |
5397 |
03 May 19 |
nicklas |
351 |
|
5397 |
03 May 19 |
nicklas |
// Toggle the selected status of a single well |
5397 |
03 May 19 |
nicklas |
mips.toggleWell = function(event) |
5397 |
03 May 19 |
nicklas |
354 |
{ |
5397 |
03 May 19 |
nicklas |
var row = Data.int(event.currentTarget, 'row'); |
5397 |
03 May 19 |
nicklas |
var column = Data.int(event.currentTarget, 'col'); |
5397 |
03 May 19 |
nicklas |
var well = Plate.getWell(row, column); |
5397 |
03 May 19 |
nicklas |
Plate.toggleSelected([well]); |
5397 |
03 May 19 |
nicklas |
359 |
} |
5397 |
03 May 19 |
nicklas |
360 |
|
5397 |
03 May 19 |
nicklas |
// Toggle the selected status of a complete row |
5397 |
03 May 19 |
nicklas |
mips.toggleRow = function(event) |
5397 |
03 May 19 |
nicklas |
363 |
{ |
5397 |
03 May 19 |
nicklas |
var row = Data.int(event.currentTarget, 'row'); |
5397 |
03 May 19 |
nicklas |
Plate.toggleSelected(Plate.getRow(row)); |
5397 |
03 May 19 |
nicklas |
366 |
} |
5397 |
03 May 19 |
nicklas |
367 |
|
5397 |
03 May 19 |
nicklas |
// Toggle the selected status of a complete column |
5397 |
03 May 19 |
nicklas |
mips.toggleColumn = function(event) |
5397 |
03 May 19 |
nicklas |
370 |
{ |
5397 |
03 May 19 |
nicklas |
var column = Data.int(event.currentTarget, 'col'); |
5397 |
03 May 19 |
nicklas |
Plate.toggleSelected(Plate.getColumn(column)); |
5397 |
03 May 19 |
nicklas |
373 |
} |
5397 |
03 May 19 |
nicklas |
374 |
|
5444 |
23 May 19 |
nicklas |
// Toggle the selected status of a pool |
5444 |
23 May 19 |
nicklas |
mips.togglePool = function(event) |
5444 |
23 May 19 |
nicklas |
377 |
{ |
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)); |
5444 |
23 May 19 |
nicklas |
381 |
} |
5444 |
23 May 19 |
nicklas |
382 |
|
5397 |
03 May 19 |
nicklas |
// Highlight enable/disable all wells in a column |
5397 |
03 May 19 |
nicklas |
mips.highlightColumn = function(event) |
5397 |
03 May 19 |
nicklas |
385 |
{ |
5397 |
03 May 19 |
nicklas |
var column = Data.int(event.currentTarget, 'col'); |
5397 |
03 May 19 |
nicklas |
var on = event.type == 'mouseover'; |
5397 |
03 May 19 |
nicklas |
388 |
|
5397 |
03 May 19 |
nicklas |
Doc.addOrRemoveClass(event.currentTarget, 'highlight-column', on); |
5397 |
03 May 19 |
nicklas |
var wells = Plate.getColumn(column); |
5397 |
03 May 19 |
nicklas |
Plate.setHighlight(wells, 'highlight-column', on); |
5397 |
03 May 19 |
nicklas |
392 |
} |
5397 |
03 May 19 |
nicklas |
393 |
|
5397 |
03 May 19 |
nicklas |
// Highlight enable/disable all wells in a row |
5397 |
03 May 19 |
nicklas |
mips.highlightRow = function(event) |
5397 |
03 May 19 |
nicklas |
396 |
{ |
5397 |
03 May 19 |
nicklas |
var row = Data.int(event.currentTarget, 'row'); |
5397 |
03 May 19 |
nicklas |
var on = event.type == 'mouseover'; |
5397 |
03 May 19 |
nicklas |
399 |
|
5397 |
03 May 19 |
nicklas |
Doc.addOrRemoveClass(event.currentTarget, 'highlight-row', on); |
5397 |
03 May 19 |
nicklas |
var wells = Plate.getRow(row); |
5397 |
03 May 19 |
nicklas |
Plate.setHighlight(wells, 'highlight-row', on); |
5397 |
03 May 19 |
nicklas |
403 |
} |
5397 |
03 May 19 |
nicklas |
404 |
|
5444 |
23 May 19 |
nicklas |
// Highligt enable/disable all wells in a pool |
5444 |
23 May 19 |
nicklas |
mips.highlightPool = function(event) |
5444 |
23 May 19 |
nicklas |
407 |
{ |
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'); |
5444 |
23 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); |
5444 |
23 May 19 |
nicklas |
414 |
} |
5444 |
23 May 19 |
nicklas |
415 |
|
5397 |
03 May 19 |
nicklas |
return mips; |
5397 |
03 May 19 |
nicklas |
417 |
}(); |
5397 |
03 May 19 |
nicklas |
418 |
|
5397 |
03 May 19 |
nicklas |
Doc.onLoad(ImportPlates.initPage); |
5397 |
03 May 19 |
nicklas |
Doc.addElementInitializer(ImportPlates.initElements); |
5397 |
03 May 19 |
nicklas |
421 |
|
5444 |
23 May 19 |
nicklas |
var COLUMN_CLASSES = []; |
5397 |
03 May 19 |
nicklas |
var WellPainter = function() |
5397 |
03 May 19 |
nicklas |
424 |
{ |
5397 |
03 May 19 |
nicklas |
var painter = {}; |
5397 |
03 May 19 |
nicklas |
426 |
|
5397 |
03 May 19 |
nicklas |
// Add class indicators for replicates and QC assigned wells |
5397 |
03 May 19 |
nicklas |
painter.getClassNameForWell = function(well) |
5397 |
03 May 19 |
nicklas |
429 |
{ |
5397 |
03 May 19 |
nicklas |
var cls = ''; |
5397 |
03 May 19 |
nicklas |
if (well.extract) |
5397 |
03 May 19 |
nicklas |
432 |
{ |
5436 |
17 May 19 |
nicklas |
cls += ' primary'; |
5600 |
13 Sep 19 |
nicklas |
if (well.extract.MIPS_Panel) cls += ' ' + MipsColor.getColor(well.extract.MIPS_Panel); |
5397 |
03 May 19 |
nicklas |
435 |
} |
5444 |
23 May 19 |
nicklas |
if (COLUMN_CLASSES[well.column]) cls += ' ' + COLUMN_CLASSES[well.column]; |
5397 |
03 May 19 |
nicklas |
if (well.column == Plate.columns-1) cls += ' last-child'; |
5397 |
03 May 19 |
nicklas |
return cls; |
5397 |
03 May 19 |
nicklas |
439 |
} |
5397 |
03 May 19 |
nicklas |
440 |
|
5397 |
03 May 19 |
nicklas |
painter.getWellText = function(well) |
5397 |
03 May 19 |
nicklas |
442 |
{ |
5397 |
03 May 19 |
nicklas |
var text = ''; |
5397 |
03 May 19 |
nicklas |
if (well.extract) |
5397 |
03 May 19 |
nicklas |
445 |
{ |
5397 |
03 May 19 |
nicklas |
// The well contains DNA |
5397 |
03 May 19 |
nicklas |
var aliquot = well.extract; |
5481 |
11 Jun 19 |
nicklas |
text += '<div class="name">'+Reggie.softLineBreaks(Strings.encodeTags(aliquot.name || aliquot.prefix))+'</div>'; |
5397 |
03 May 19 |
nicklas |
449 |
|
5447 |
24 May 19 |
nicklas |
if (aliquot.MIPS_PoolVolume != null) |
5401 |
07 May 19 |
nicklas |
451 |
{ |
5461 |
03 Jun 19 |
nicklas |
text += '<div class="volume">'+Strings.encodeTags(aliquot.MIPS_PoolVolume)+'µl</div>'; |
5401 |
07 May 19 |
nicklas |
453 |
} |
5600 |
13 Sep 19 |
nicklas |
if (aliquot.MIPS_Panel != null) |
5402 |
07 May 19 |
nicklas |
455 |
{ |
5600 |
13 Sep 19 |
nicklas |
text += '<div class="mips-panel">'+Strings.encodeTags(aliquot.MIPS_Panel)+'</div>'; |
5402 |
07 May 19 |
nicklas |
457 |
} |
5447 |
24 May 19 |
nicklas |
458 |
|
5447 |
24 May 19 |
nicklas |
if (aliquot.MIPS_Form != null || aliquot.MIPS_NormalTumor != null) |
5402 |
07 May 19 |
nicklas |
460 |
{ |
5447 |
24 May 19 |
nicklas |
text += '<div class="mips-form">'; |
5447 |
24 May 19 |
nicklas |
if (aliquot.MIPS_NormalTumor != null) text += '<span>'+Strings.encodeTags(aliquot.MIPS_NormalTumor)+'</span>'; |
5447 |
24 May 19 |
nicklas |
if (aliquot.MIPS_Form != null) text += '<span>'+Strings.encodeTags(aliquot.MIPS_Form)+'</span>'; |
5447 |
24 May 19 |
nicklas |
text += '</div>'; |
5402 |
07 May 19 |
nicklas |
465 |
} |
5402 |
07 May 19 |
nicklas |
466 |
|
5397 |
03 May 19 |
nicklas |
var warningMsg = []; |
5397 |
03 May 19 |
nicklas |
if (aliquot.comment) |
5397 |
03 May 19 |
nicklas |
469 |
{ |
5397 |
03 May 19 |
nicklas |
text += '<div class="comment">'+Strings.encodeTags(aliquot.comment)+'</div>'; |
5397 |
03 May 19 |
nicklas |
471 |
} |
5397 |
03 May 19 |
nicklas |
if (warningMsg.length > 0) |
5397 |
03 May 19 |
nicklas |
473 |
{ |
5397 |
03 May 19 |
nicklas |
well.setWarning(warningMsg.join('; ')); |
5397 |
03 May 19 |
nicklas |
475 |
} |
5397 |
03 May 19 |
nicklas |
476 |
} |
5397 |
03 May 19 |
nicklas |
else |
5397 |
03 May 19 |
nicklas |
478 |
{ |
5397 |
03 May 19 |
nicklas |
text = 'empty'; |
5397 |
03 May 19 |
nicklas |
480 |
} |
5397 |
03 May 19 |
nicklas |
481 |
|
5397 |
03 May 19 |
nicklas |
return text; |
5397 |
03 May 19 |
nicklas |
483 |
} |
5397 |
03 May 19 |
nicklas |
484 |
|
5397 |
03 May 19 |
nicklas |
return painter; |
5397 |
03 May 19 |
nicklas |
486 |
}(); |