5439 |
20 May 19 |
nicklas |
var FlowCell = function() |
5439 |
20 May 19 |
nicklas |
2 |
{ |
5439 |
20 May 19 |
nicklas |
var flowcell = {}; |
5439 |
20 May 19 |
nicklas |
var debug = 0; |
5439 |
20 May 19 |
nicklas |
var subtypePooledLibrary = null; |
5439 |
20 May 19 |
nicklas |
var annotationTypePipeline = null; |
5439 |
20 May 19 |
nicklas |
7 |
|
5439 |
20 May 19 |
nicklas |
var flowCells = []; |
5439 |
20 May 19 |
nicklas |
var selectedPools = []; |
5439 |
20 May 19 |
nicklas |
var newPools; |
5439 |
20 May 19 |
nicklas |
11 |
|
5453 |
28 May 19 |
nicklas |
var PRESETS = { |
5453 |
28 May 19 |
nicklas |
HiSeq2: { name: 'HiSeq2', flowCellType: 'HiSeq', lanes: 2, maxPools: 1, reads: [105, 8, 8, 104] }, |
5453 |
28 May 19 |
nicklas |
HiSeq8: { name: 'HiSeq8', flowCellType: 'HiSeq', lanes: 8, maxPools: 8, reads: [105, 8, 8, 104] }, |
5453 |
28 May 19 |
nicklas |
NextSeq: { name: 'NextSeq', flowCellType: 'NextSeq', lanes: 4, maxPools: 1, reads: [151, 8, 8, 151] } |
5453 |
28 May 19 |
nicklas |
16 |
}; |
5439 |
20 May 19 |
nicklas |
17 |
|
5439 |
20 May 19 |
nicklas |
var poolsAreValid = false; |
5439 |
20 May 19 |
nicklas |
var readIsValid = []; |
5439 |
20 May 19 |
nicklas |
var currentFcNo; |
5439 |
20 May 19 |
nicklas |
var currentLaneNo; |
5439 |
20 May 19 |
nicklas |
22 |
|
5439 |
20 May 19 |
nicklas |
// Page initialization |
5439 |
20 May 19 |
nicklas |
flowcell.initPage = function() |
5439 |
20 May 19 |
nicklas |
25 |
{ |
5439 |
20 May 19 |
nicklas |
// Step 1 |
5439 |
20 May 19 |
nicklas |
Events.addEventHandler('step-1', 'wizard-validate', flowcell.validateStep1); |
5439 |
20 May 19 |
nicklas |
Events.addEventHandler('preset', 'change', flowcell.presetOnChange); |
5439 |
20 May 19 |
nicklas |
Events.addEventHandler('pools', 'change', flowcell.poolsOnChange); |
5439 |
20 May 19 |
nicklas |
Events.addEventHandler('pools', 'base-selected', flowcell.setPoolCallback); |
5439 |
20 May 19 |
nicklas |
Buttons.addClickHandler('btnSelectPools', flowcell.selectPools); |
5439 |
20 May 19 |
nicklas |
32 |
|
5439 |
20 May 19 |
nicklas |
// Step 2 |
5439 |
20 May 19 |
nicklas |
Events.addEventHandler('step-2', 'wizard-initialize', flowcell.initializeStep2); |
5439 |
20 May 19 |
nicklas |
Events.addEventHandler('step-2', 'wizard-validate', flowcell.validateStep2); |
5439 |
20 May 19 |
nicklas |
Events.addEventHandler('read1', 'change', flowcell.readOnChange); |
5453 |
28 May 19 |
nicklas |
Events.addEventHandler('indexRead1', 'change', flowcell.readOnChange); |
5453 |
28 May 19 |
nicklas |
Events.addEventHandler('indexRead2', 'change', flowcell.readOnChange); |
5439 |
20 May 19 |
nicklas |
Events.addEventHandler('read2', 'change', flowcell.readOnChange); |
5439 |
20 May 19 |
nicklas |
Events.addEventHandler('read1', 'keypress', Events.integerOnly); |
5453 |
28 May 19 |
nicklas |
Events.addEventHandler('indexRead1', 'keypress', Events.integerOnly); |
5453 |
28 May 19 |
nicklas |
Events.addEventHandler('indexRead2', 'keypress', Events.integerOnly); |
5439 |
20 May 19 |
nicklas |
Events.addEventHandler('read2', 'keypress', Events.integerOnly); |
5439 |
20 May 19 |
nicklas |
Events.addEventHandler('select-pool', 'click', flowcell.onPoolSelected); |
5439 |
20 May 19 |
nicklas |
Events.addEventHandler('wizard', 'click', flowcell.hidePoolSelection); |
5439 |
20 May 19 |
nicklas |
46 |
|
5439 |
20 May 19 |
nicklas |
// Navigation |
5439 |
20 May 19 |
nicklas |
Buttons.addClickHandler('gocancel', Wizard.cancelWizard); |
5439 |
20 May 19 |
nicklas |
Buttons.addClickHandler('gorestart', Wizard.restartWizard); |
5439 |
20 May 19 |
nicklas |
Buttons.addClickHandler('gonext', Wizard.goNextOnClick); |
5439 |
20 May 19 |
nicklas |
Buttons.addClickHandler('goregister', Wizard.goRegister); |
5439 |
20 May 19 |
nicklas |
52 |
|
5439 |
20 May 19 |
nicklas |
// Final registration |
5439 |
20 May 19 |
nicklas |
Events.addEventHandler('wizard', 'wizard-submit', flowcell.submit); |
5439 |
20 May 19 |
nicklas |
55 |
|
5439 |
20 May 19 |
nicklas |
var url = '../Mips.servlet?ID='+App.getSessionId(); |
5439 |
20 May 19 |
nicklas |
url += '&cmd=GetUnusedPools'; |
5439 |
20 May 19 |
nicklas |
Wizard.showLoadingAnimation('Loading pools...'); |
5439 |
20 May 19 |
nicklas |
Wizard.asyncJsonRequest(url, flowcell.initializeStep1); |
5439 |
20 May 19 |
nicklas |
60 |
} |
5439 |
20 May 19 |
nicklas |
61 |
|
5439 |
20 May 19 |
nicklas |
62 |
|
5439 |
20 May 19 |
nicklas |
flowcell.initializeStep1 = function(response) |
5439 |
20 May 19 |
nicklas |
64 |
{ |
5439 |
20 May 19 |
nicklas |
flowcell.poolInfoLoaded(response); |
5439 |
20 May 19 |
nicklas |
flowcell.presetOnChange(); |
5439 |
20 May 19 |
nicklas |
Doc.show('step-1'); |
5439 |
20 May 19 |
nicklas |
Doc.show('gonext'); |
5439 |
20 May 19 |
nicklas |
69 |
} |
5439 |
20 May 19 |
nicklas |
70 |
|
5439 |
20 May 19 |
nicklas |
flowcell.poolInfoLoaded = function(response) |
5439 |
20 May 19 |
nicklas |
72 |
{ |
5439 |
20 May 19 |
nicklas |
var frm = document.forms['reggie']; |
5439 |
20 May 19 |
nicklas |
var pools = response.pools; |
5439 |
20 May 19 |
nicklas |
75 |
|
5439 |
20 May 19 |
nicklas |
var poolsList = frm.pools; |
5439 |
20 May 19 |
nicklas |
if (pools.length > 0) |
5439 |
20 May 19 |
nicklas |
78 |
{ |
5439 |
20 May 19 |
nicklas |
for (var poolNo=0; poolNo < pools.length; poolNo++) |
5439 |
20 May 19 |
nicklas |
80 |
{ |
5439 |
20 May 19 |
nicklas |
var pool = pools[poolNo]; |
5439 |
20 May 19 |
nicklas |
var name = pool.name + ' - '; |
5439 |
20 May 19 |
nicklas |
83 |
|
5439 |
20 May 19 |
nicklas |
var numPlates = pool.libPlates.length; |
5439 |
20 May 19 |
nicklas |
var title = ''; |
5439 |
20 May 19 |
nicklas |
86 |
|
5439 |
20 May 19 |
nicklas |
if (numPlates <= 2) |
5439 |
20 May 19 |
nicklas |
88 |
{ |
5439 |
20 May 19 |
nicklas |
for (var plateNo=0; plateNo < numPlates; plateNo++) |
5439 |
20 May 19 |
nicklas |
90 |
{ |
5439 |
20 May 19 |
nicklas |
var libPlate = pool.libPlates[plateNo]; |
5439 |
20 May 19 |
nicklas |
if (plateNo > 0) name += ', '; |
5439 |
20 May 19 |
nicklas |
name += libPlate.name; |
5439 |
20 May 19 |
nicklas |
94 |
} |
5439 |
20 May 19 |
nicklas |
95 |
} |
5439 |
20 May 19 |
nicklas |
else |
5439 |
20 May 19 |
nicklas |
97 |
{ |
5439 |
20 May 19 |
nicklas |
name += pool.libPlates[0].name + ' + ' + (numPlates-1) + ' more...'; |
5439 |
20 May 19 |
nicklas |
for (var plateNo=0; plateNo < numPlates; plateNo++) |
5439 |
20 May 19 |
nicklas |
100 |
{ |
5439 |
20 May 19 |
nicklas |
var libPlate = pool.libPlates[plateNo]; |
5439 |
20 May 19 |
nicklas |
if (plateNo > 0) title += ', '; |
5439 |
20 May 19 |
nicklas |
title += libPlate.name; |
5439 |
20 May 19 |
nicklas |
104 |
} |
5439 |
20 May 19 |
nicklas |
105 |
} |
5439 |
20 May 19 |
nicklas |
106 |
|
5439 |
20 May 19 |
nicklas |
var option = new Option(name, pool.id, false, poolNo < 1); |
5439 |
20 May 19 |
nicklas |
option.title = title; |
5439 |
20 May 19 |
nicklas |
option.pool = pool; |
5439 |
20 May 19 |
nicklas |
110 |
|
5439 |
20 May 19 |
nicklas |
poolsList[poolsList.length] = option; |
5439 |
20 May 19 |
nicklas |
112 |
} |
5439 |
20 May 19 |
nicklas |
113 |
} |
5439 |
20 May 19 |
nicklas |
114 |
} |
5439 |
20 May 19 |
nicklas |
115 |
|
5439 |
20 May 19 |
nicklas |
flowcell.presetOnChange = function() |
5439 |
20 May 19 |
nicklas |
117 |
{ |
5439 |
20 May 19 |
nicklas |
var frm = document.forms['reggie']; |
5453 |
28 May 19 |
nicklas |
var preset = PRESETS[frm.preset.value]; |
5439 |
20 May 19 |
nicklas |
120 |
|
5453 |
28 May 19 |
nicklas |
if (preset) |
5439 |
20 May 19 |
nicklas |
122 |
{ |
5453 |
28 May 19 |
nicklas |
frm.num_lanes[0].disabled = true; |
5439 |
20 May 19 |
nicklas |
frm.num_lanes[1].disabled = true; |
5453 |
28 May 19 |
nicklas |
frm.num_lanes[2].disabled = true; |
5453 |
28 May 19 |
nicklas |
var lanes = Doc.element('num_lanes_'+preset.lanes); |
5453 |
28 May 19 |
nicklas |
lanes.disabled = false; |
5453 |
28 May 19 |
nicklas |
lanes.checked = true; |
5453 |
28 May 19 |
nicklas |
129 |
|
5453 |
28 May 19 |
nicklas |
frm.read1.value = preset.reads[0]; |
5453 |
28 May 19 |
nicklas |
frm.indexRead1.value = preset.reads[1]; |
5453 |
28 May 19 |
nicklas |
frm.indexRead2.value = preset.reads[2]; |
5453 |
28 May 19 |
nicklas |
frm.read2.value = preset.reads[3]; |
5439 |
20 May 19 |
nicklas |
134 |
} |
5439 |
20 May 19 |
nicklas |
else |
5439 |
20 May 19 |
nicklas |
136 |
{ |
5439 |
20 May 19 |
nicklas |
frm.num_lanes[0].disabled = false; |
5439 |
20 May 19 |
nicklas |
frm.num_lanes[1].disabled = false; |
5439 |
20 May 19 |
nicklas |
frm.num_lanes[2].disabled = false; |
5439 |
20 May 19 |
nicklas |
140 |
} |
5439 |
20 May 19 |
nicklas |
flowcell.poolsOnChange(); |
5439 |
20 May 19 |
nicklas |
142 |
} |
5439 |
20 May 19 |
nicklas |
143 |
|
5439 |
20 May 19 |
nicklas |
flowcell.poolsOnChange = function() |
5439 |
20 May 19 |
nicklas |
145 |
{ |
5439 |
20 May 19 |
nicklas |
poolsAreValid = false; |
5439 |
20 May 19 |
nicklas |
147 |
|
5439 |
20 May 19 |
nicklas |
var frm = document.forms['reggie']; |
5439 |
20 May 19 |
nicklas |
var poolsList = frm.pools; |
5439 |
20 May 19 |
nicklas |
150 |
|
5439 |
20 May 19 |
nicklas |
var numSelected = 0; |
5439 |
20 May 19 |
nicklas |
var invalidPipeline = null; |
5439 |
20 May 19 |
nicklas |
for (var i = 0; i < poolsList.length; i++) |
5439 |
20 May 19 |
nicklas |
154 |
{ |
5439 |
20 May 19 |
nicklas |
if (poolsList[i].selected) |
5439 |
20 May 19 |
nicklas |
156 |
{ |
5439 |
20 May 19 |
nicklas |
var pool = poolsList[i].pool; |
5439 |
20 May 19 |
nicklas |
if (pool.pipeline && pool.pipeline != 'MIPs') |
5439 |
20 May 19 |
nicklas |
159 |
{ |
5439 |
20 May 19 |
nicklas |
invalidPipeline = 'Pool ' + Strings.encodeTags(pool.name+' ('+pool.pipeline)+') is not intended for MIPs pipeline.'; |
5439 |
20 May 19 |
nicklas |
161 |
} |
5439 |
20 May 19 |
nicklas |
numSelected++; |
5439 |
20 May 19 |
nicklas |
163 |
} |
5439 |
20 May 19 |
nicklas |
164 |
} |
5439 |
20 May 19 |
nicklas |
165 |
|
5439 |
20 May 19 |
nicklas |
Doc.element('numSelected').innerHTML = numSelected + ' selected'; |
5439 |
20 May 19 |
nicklas |
167 |
|
5439 |
20 May 19 |
nicklas |
if (invalidPipeline) |
5439 |
20 May 19 |
nicklas |
169 |
{ |
5439 |
20 May 19 |
nicklas |
Wizard.setInputStatus('pools', 'invalid', invalidPipeline); |
5439 |
20 May 19 |
nicklas |
return; |
5439 |
20 May 19 |
nicklas |
172 |
} |
5439 |
20 May 19 |
nicklas |
if (numSelected == 0) |
5439 |
20 May 19 |
nicklas |
174 |
{ |
5439 |
20 May 19 |
nicklas |
Wizard.setInputStatus('pools', 'invalid', 'Must select at least 1 pool.'); |
5439 |
20 May 19 |
nicklas |
return; |
5439 |
20 May 19 |
nicklas |
177 |
} |
5453 |
28 May 19 |
nicklas |
178 |
|
5453 |
28 May 19 |
nicklas |
var preset = PRESETS[frm.preset.value]; |
5453 |
28 May 19 |
nicklas |
if (preset && numSelected > preset.maxPools) |
5439 |
20 May 19 |
nicklas |
181 |
{ |
5453 |
28 May 19 |
nicklas |
Wizard.setInputStatus('pools', 'invalid', 'Can only use '+preset.maxPools + ' pool(s) with the ' + preset.name); |
5453 |
28 May 19 |
nicklas |
return; |
5439 |
20 May 19 |
nicklas |
184 |
} |
5439 |
20 May 19 |
nicklas |
185 |
|
5439 |
20 May 19 |
nicklas |
poolsAreValid = true; |
5439 |
20 May 19 |
nicklas |
Wizard.setInputStatus('pools', 'valid'); |
5439 |
20 May 19 |
nicklas |
188 |
} |
5439 |
20 May 19 |
nicklas |
189 |
|
5439 |
20 May 19 |
nicklas |
190 |
|
5439 |
20 May 19 |
nicklas |
flowcell.selectPools = function() |
5439 |
20 May 19 |
nicklas |
192 |
{ |
5439 |
20 May 19 |
nicklas |
var frm = document.forms['reggie']; |
5439 |
20 May 19 |
nicklas |
if (frm.pools.disabled) return; |
5439 |
20 May 19 |
nicklas |
195 |
|
5439 |
20 May 19 |
nicklas |
if (subtypePooledLibrary == null) |
5439 |
20 May 19 |
nicklas |
197 |
{ |
5439 |
20 May 19 |
nicklas |
subtypePooledLibrary = Reggie.getSubtypeInfo('POOLED_LIBRARY'); |
5439 |
20 May 19 |
nicklas |
199 |
} |
5439 |
20 May 19 |
nicklas |
if (annotationTypePipeline == null) |
5439 |
20 May 19 |
nicklas |
201 |
{ |
5439 |
20 May 19 |
nicklas |
annotationTypePipeline = Reggie.getAnnotationTypeInfo('PIPELINE'); |
5439 |
20 May 19 |
nicklas |
203 |
} |
5439 |
20 May 19 |
nicklas |
204 |
|
5439 |
20 May 19 |
nicklas |
newPools = []; |
5439 |
20 May 19 |
nicklas |
var url = '&resetTemporary=1'; |
5439 |
20 May 19 |
nicklas |
url += '&tmpfilter:INT:itemSubtype='+subtypePooledLibrary.id; |
5439 |
20 May 19 |
nicklas |
url += '&tmpfilter:DATE:creationEvent.eventDate='+encodeURIComponent('<>'); |
5439 |
20 May 19 |
nicklas |
url += '&tmpfilter:STRING:'+encodeURIComponent('#')+annotationTypePipeline.id+'=MIPs'; |
5439 |
20 May 19 |
nicklas |
Dialogs.selectItem('EXTRACT', 'pools', 1, url); |
5439 |
20 May 19 |
nicklas |
211 |
} |
5439 |
20 May 19 |
nicklas |
212 |
|
5439 |
20 May 19 |
nicklas |
flowcell.setPoolCallback = function(event) |
5439 |
20 May 19 |
nicklas |
214 |
{ |
5439 |
20 May 19 |
nicklas |
var frm = document.forms['reggie']; |
5439 |
20 May 19 |
nicklas |
var name = event.detail.name; |
5439 |
20 May 19 |
nicklas |
var id = event.detail.id; |
5439 |
20 May 19 |
nicklas |
218 |
|
5439 |
20 May 19 |
nicklas |
var poolsList = frm.pools; |
5439 |
20 May 19 |
nicklas |
var isNew = true; |
5439 |
20 May 19 |
nicklas |
for (var i = 0; i < poolsList.length; i++) |
5439 |
20 May 19 |
nicklas |
222 |
{ |
5439 |
20 May 19 |
nicklas |
if (poolsList[i].value == id) |
5439 |
20 May 19 |
nicklas |
224 |
{ |
5439 |
20 May 19 |
nicklas |
poolsList[i].selected = true; |
5439 |
20 May 19 |
nicklas |
isNew = false; |
5439 |
20 May 19 |
nicklas |
227 |
} |
5439 |
20 May 19 |
nicklas |
228 |
} |
5439 |
20 May 19 |
nicklas |
229 |
|
5439 |
20 May 19 |
nicklas |
if (isNew) |
5439 |
20 May 19 |
nicklas |
231 |
{ |
5439 |
20 May 19 |
nicklas |
newPools[newPools.length] = id; |
5439 |
20 May 19 |
nicklas |
233 |
} |
5439 |
20 May 19 |
nicklas |
234 |
|
5439 |
20 May 19 |
nicklas |
if (event.detail.remaining == 0 && newPools.length > 0) |
5439 |
20 May 19 |
nicklas |
236 |
{ |
5439 |
20 May 19 |
nicklas |
// Get more information about the selected library |
5439 |
20 May 19 |
nicklas |
var url = '../Mips.servlet?ID='+App.getSessionId(); |
5439 |
20 May 19 |
nicklas |
url += '&cmd=GetPoolInfo&pools=' + newPools.join(','); |
5439 |
20 May 19 |
nicklas |
Wizard.asyncJsonRequest(url, flowcell.manualPoolInfoLoaded); |
5439 |
20 May 19 |
nicklas |
241 |
} |
5439 |
20 May 19 |
nicklas |
242 |
} |
5439 |
20 May 19 |
nicklas |
243 |
|
5439 |
20 May 19 |
nicklas |
flowcell.manualPoolInfoLoaded = function(response) |
5439 |
20 May 19 |
nicklas |
245 |
{ |
5439 |
20 May 19 |
nicklas |
flowcell.poolInfoLoaded(response); |
5439 |
20 May 19 |
nicklas |
flowcell.poolsOnChange(); |
5439 |
20 May 19 |
nicklas |
248 |
} |
5439 |
20 May 19 |
nicklas |
249 |
|
5439 |
20 May 19 |
nicklas |
flowcell.validateStep1 = function(event) |
5439 |
20 May 19 |
nicklas |
251 |
{ |
5439 |
20 May 19 |
nicklas |
if (!poolsAreValid) event.preventDefault(); |
5439 |
20 May 19 |
nicklas |
253 |
} |
5439 |
20 May 19 |
nicklas |
254 |
|
5439 |
20 May 19 |
nicklas |
255 |
|
5439 |
20 May 19 |
nicklas |
flowcell.initializeStep2 = function() |
5439 |
20 May 19 |
nicklas |
257 |
{ |
5439 |
20 May 19 |
nicklas |
var frm = document.forms['reggie']; |
5439 |
20 May 19 |
nicklas |
259 |
|
5439 |
20 May 19 |
nicklas |
var numFlowCells = Forms.getCheckedRadio(frm.num_flowcells).value; |
5439 |
20 May 19 |
nicklas |
var url = '../Mips.servlet?ID='+App.getSessionId(); |
5439 |
20 May 19 |
nicklas |
url += '&cmd=GetNextAutoGeneratedFlowCellNames&numNames='+numFlowCells; |
5439 |
20 May 19 |
nicklas |
Wizard.showLoadingAnimation('Loading flow cell information...'); |
5439 |
20 May 19 |
nicklas |
Wizard.asyncJsonRequest(url, flowcell.flowCellsLoaded); |
5439 |
20 May 19 |
nicklas |
265 |
} |
5439 |
20 May 19 |
nicklas |
266 |
|
5439 |
20 May 19 |
nicklas |
flowcell.flowCellsLoaded = function(response) |
5439 |
20 May 19 |
nicklas |
268 |
{ |
5439 |
20 May 19 |
nicklas |
var frm = document.forms['reggie']; |
5439 |
20 May 19 |
nicklas |
270 |
|
5439 |
20 May 19 |
nicklas |
var names = response.names; |
5439 |
20 May 19 |
nicklas |
var numFlowCells = names.length; |
5439 |
20 May 19 |
nicklas |
var numLanes = Forms.getCheckedRadio(frm.num_lanes).value; |
5439 |
20 May 19 |
nicklas |
274 |
|
5439 |
20 May 19 |
nicklas |
// Initialize flowCell->lane->pool array |
5439 |
20 May 19 |
nicklas |
for (var fcNo = 0; fcNo < numFlowCells; fcNo++) |
5439 |
20 May 19 |
nicklas |
277 |
{ |
5439 |
20 May 19 |
nicklas |
var fc = {}; |
5439 |
20 May 19 |
nicklas |
fc.name = names[fcNo]; |
5439 |
20 May 19 |
nicklas |
fc.lanes = []; |
5439 |
20 May 19 |
nicklas |
for (var laneNo = 0; laneNo < numLanes; laneNo++) |
5439 |
20 May 19 |
nicklas |
282 |
{ |
5439 |
20 May 19 |
nicklas |
fc.lanes[laneNo] = {}; |
5439 |
20 May 19 |
nicklas |
284 |
} |
5439 |
20 May 19 |
nicklas |
285 |
|
5439 |
20 May 19 |
nicklas |
flowCells[fcNo] = fc; |
5439 |
20 May 19 |
nicklas |
Doc.element('fc.'+fcNo).innerHTML = Strings.encodeTags(fc.name); |
5439 |
20 May 19 |
nicklas |
Doc.element('comments.'+fcNo+'.name').innerHTML = Strings.encodeTags(fc.name); |
5439 |
20 May 19 |
nicklas |
289 |
} |
5439 |
20 May 19 |
nicklas |
290 |
|
5439 |
20 May 19 |
nicklas |
// Hide unused flow cell |
5439 |
20 May 19 |
nicklas |
if (numFlowCells == 1) |
5439 |
20 May 19 |
nicklas |
293 |
{ |
5439 |
20 May 19 |
nicklas |
Doc.addClass(plate, 'hide-fc-1'); |
5439 |
20 May 19 |
nicklas |
Doc.hide('comments.1'); |
5439 |
20 May 19 |
nicklas |
296 |
} |
5439 |
20 May 19 |
nicklas |
297 |
|
5439 |
20 May 19 |
nicklas |
// Hide unused lanes |
5439 |
20 May 19 |
nicklas |
for (var i = numLanes; i < 8; i++) |
5439 |
20 May 19 |
nicklas |
300 |
{ |
5439 |
20 May 19 |
nicklas |
Doc.hide('lane.'+i); |
5439 |
20 May 19 |
nicklas |
302 |
} |
5439 |
20 May 19 |
nicklas |
303 |
|
5439 |
20 May 19 |
nicklas |
// Generate popup menu for pool selection |
5439 |
20 May 19 |
nicklas |
var selectPoolHtml = ''; |
5439 |
20 May 19 |
nicklas |
for (var i = 0; i < frm.pools.length; i++) |
5439 |
20 May 19 |
nicklas |
307 |
{ |
5439 |
20 May 19 |
nicklas |
if (frm.pools[i].selected) |
5439 |
20 May 19 |
nicklas |
309 |
{ |
5439 |
20 May 19 |
nicklas |
var pool = frm.pools[i].pool; |
5439 |
20 May 19 |
nicklas |
var index = selectedPools.length; |
5439 |
20 May 19 |
nicklas |
selectedPools[index] = pool; |
5439 |
20 May 19 |
nicklas |
313 |
|
5439 |
20 May 19 |
nicklas |
selectPoolHtml += '<div class="menuitem enabled interactable" id="pool-'+pool.id+'" data-index="'+index+'">'; |
5439 |
20 May 19 |
nicklas |
selectPoolHtml += Strings.encodeTags(pool.name)+'</div>'; |
5439 |
20 May 19 |
nicklas |
316 |
} |
5439 |
20 May 19 |
nicklas |
317 |
} |
5439 |
20 May 19 |
nicklas |
// Add separator |
5439 |
20 May 19 |
nicklas |
selectPoolHtml += '<div class="menuseparator"></div>'; |
5439 |
20 May 19 |
nicklas |
// Add option for empty lane |
5439 |
20 May 19 |
nicklas |
selectPoolHtml += '<div class="menuitem enabled interactable" id="pool-none"><i>empty</i>'+'</div>'; |
5439 |
20 May 19 |
nicklas |
Doc.element('select-pool-all').innerHTML = selectPoolHtml; |
5439 |
20 May 19 |
nicklas |
323 |
|
5439 |
20 May 19 |
nicklas |
// A single pool on all lanes |
5439 |
20 May 19 |
nicklas |
if (selectedPools.length == 1) |
5439 |
20 May 19 |
nicklas |
326 |
{ |
5439 |
20 May 19 |
nicklas |
var pool = selectedPools[0]; |
5439 |
20 May 19 |
nicklas |
for (var fcNo = 0; fcNo < numFlowCells; fcNo++) |
5439 |
20 May 19 |
nicklas |
329 |
{ |
5439 |
20 May 19 |
nicklas |
for (var laneNo = 0; laneNo < numLanes; laneNo++) |
5439 |
20 May 19 |
nicklas |
331 |
{ |
5439 |
20 May 19 |
nicklas |
flowCells[fcNo].lanes[laneNo] = {'pool': pool, 'defaultPool': pool}; |
5439 |
20 May 19 |
nicklas |
333 |
} |
5439 |
20 May 19 |
nicklas |
334 |
} |
5439 |
20 May 19 |
nicklas |
335 |
} |
5439 |
20 May 19 |
nicklas |
336 |
|
5439 |
20 May 19 |
nicklas |
flowcell.updateFlowCellsMatrix(true); |
5439 |
20 May 19 |
nicklas |
338 |
|
5439 |
20 May 19 |
nicklas |
Doc.show('gocancel'); |
5439 |
20 May 19 |
nicklas |
Doc.show('goregister'); |
5439 |
20 May 19 |
nicklas |
Wizard.setCurrentStep(2); |
5439 |
20 May 19 |
nicklas |
342 |
|
5439 |
20 May 19 |
nicklas |
Events.sendChangeEvent('read1'); |
5453 |
28 May 19 |
nicklas |
Events.sendChangeEvent('indexRead1'); |
5453 |
28 May 19 |
nicklas |
Events.sendChangeEvent('indexRead2'); |
5439 |
20 May 19 |
nicklas |
Events.sendChangeEvent('read2'); |
5439 |
20 May 19 |
nicklas |
frm.read1.focus(); |
5439 |
20 May 19 |
nicklas |
348 |
} |
5439 |
20 May 19 |
nicklas |
349 |
|
5439 |
20 May 19 |
nicklas |
flowcell.readOnChange = function(event) |
5439 |
20 May 19 |
nicklas |
351 |
{ |
5439 |
20 May 19 |
nicklas |
var target = event.currentTarget; |
5439 |
20 May 19 |
nicklas |
353 |
|
5439 |
20 May 19 |
nicklas |
Wizard.setInputStatus(target.id); |
5439 |
20 May 19 |
nicklas |
355 |
|
5439 |
20 May 19 |
nicklas |
var defaultValue = Data.int(target, 'default-value'); |
5439 |
20 May 19 |
nicklas |
var value = target.value; |
5439 |
20 May 19 |
nicklas |
if (!defaultValue) Data.set(target, 'default-value', value); // Initalize the default value |
5439 |
20 May 19 |
nicklas |
359 |
|
5439 |
20 May 19 |
nicklas |
if (value == '') |
5439 |
20 May 19 |
nicklas |
361 |
{ |
5439 |
20 May 19 |
nicklas |
readIsValid[target.id] = false; |
5439 |
20 May 19 |
nicklas |
Wizard.setInputStatus(target.id, 'invalid', 'Missing'); |
5439 |
20 May 19 |
nicklas |
return; |
5439 |
20 May 19 |
nicklas |
365 |
} |
5439 |
20 May 19 |
nicklas |
366 |
|
5439 |
20 May 19 |
nicklas |
if (!Numbers.isInteger(value)) |
5439 |
20 May 19 |
nicklas |
368 |
{ |
5439 |
20 May 19 |
nicklas |
readIsValid[target.id] = false; |
5439 |
20 May 19 |
nicklas |
Wizard.setInputStatus(target.id, 'invalid', 'Not a number'); |
5439 |
20 May 19 |
nicklas |
return; |
5439 |
20 May 19 |
nicklas |
372 |
} |
5439 |
20 May 19 |
nicklas |
373 |
|
5439 |
20 May 19 |
nicklas |
readIsValid[target.id] = true; |
5439 |
20 May 19 |
nicklas |
if (defaultValue && parseInt(value) != defaultValue) |
5439 |
20 May 19 |
nicklas |
376 |
{ |
5439 |
20 May 19 |
nicklas |
Wizard.setInputStatus(target.id, 'warning', 'Default: ' + defaultValue); |
5439 |
20 May 19 |
nicklas |
378 |
} |
5439 |
20 May 19 |
nicklas |
else |
5439 |
20 May 19 |
nicklas |
380 |
{ |
5439 |
20 May 19 |
nicklas |
Wizard.setInputStatus(target.id, 'valid'); |
5439 |
20 May 19 |
nicklas |
382 |
} |
5439 |
20 May 19 |
nicklas |
383 |
} |
5439 |
20 May 19 |
nicklas |
384 |
|
5439 |
20 May 19 |
nicklas |
flowcell.updateFlowCellsMatrix = function(attachEventHandlers) |
5439 |
20 May 19 |
nicklas |
386 |
{ |
5439 |
20 May 19 |
nicklas |
Wizard.setInputStatus('flowCells'); |
5439 |
20 May 19 |
nicklas |
flowCellsAreValid = false; |
5439 |
20 May 19 |
nicklas |
389 |
|
5439 |
20 May 19 |
nicklas |
var frm = document.forms['reggie']; |
5439 |
20 May 19 |
nicklas |
var numFlowCells = Forms.getCheckedRadio(frm.num_flowcells).value; |
5439 |
20 May 19 |
nicklas |
var numLanes = Forms.getCheckedRadio(frm.num_lanes).value; |
5439 |
20 May 19 |
nicklas |
var numEmptyLanes = 0; |
5439 |
20 May 19 |
nicklas |
394 |
|
5439 |
20 May 19 |
nicklas |
for (var fcNo = 0; fcNo < flowCells.length; fcNo++) |
5439 |
20 May 19 |
nicklas |
396 |
{ |
5439 |
20 May 19 |
nicklas |
for (var laneNo = 0; laneNo < flowCells[fcNo].lanes.length; laneNo++) |
5439 |
20 May 19 |
nicklas |
398 |
{ |
5439 |
20 May 19 |
nicklas |
var lane = flowCells[fcNo].lanes[laneNo]; |
5439 |
20 May 19 |
nicklas |
var pool = lane.pool; |
5439 |
20 May 19 |
nicklas |
401 |
|
5439 |
20 May 19 |
nicklas |
var name = pool ? Strings.encodeTags(pool.name) : ''; |
5439 |
20 May 19 |
nicklas |
if (pool && lane.defaultPool && pool != lane.defaultPool) |
5439 |
20 May 19 |
nicklas |
404 |
{ |
5439 |
20 May 19 |
nicklas |
name = '<span class="nondefault">' + name + '</name>'; |
5439 |
20 May 19 |
nicklas |
406 |
} |
5439 |
20 May 19 |
nicklas |
407 |
|
5439 |
20 May 19 |
nicklas |
Doc.element('lane.'+laneNo+'.'+fcNo).innerHTML = name; |
5439 |
20 May 19 |
nicklas |
if (attachEventHandlers) |
5439 |
20 May 19 |
nicklas |
410 |
{ |
5439 |
20 May 19 |
nicklas |
Events.addEventHandler('lane.'+laneNo+'.'+fcNo, 'click', flowcell.selectPool); |
5439 |
20 May 19 |
nicklas |
412 |
} |
5439 |
20 May 19 |
nicklas |
if (!pool) numEmptyLanes++; |
5439 |
20 May 19 |
nicklas |
414 |
} |
5439 |
20 May 19 |
nicklas |
415 |
} |
5439 |
20 May 19 |
nicklas |
416 |
|
5439 |
20 May 19 |
nicklas |
if (numEmptyLanes >= numFlowCells*numLanes) |
5439 |
20 May 19 |
nicklas |
418 |
{ |
5439 |
20 May 19 |
nicklas |
Wizard.setInputStatus('flowCells', 'invalid', 'All lanes empty'); |
5439 |
20 May 19 |
nicklas |
return; |
5439 |
20 May 19 |
nicklas |
421 |
} |
5439 |
20 May 19 |
nicklas |
422 |
|
5439 |
20 May 19 |
nicklas |
flowCellsAreValid = true; |
5439 |
20 May 19 |
nicklas |
if (numEmptyLanes > 0) |
5439 |
20 May 19 |
nicklas |
425 |
{ |
5439 |
20 May 19 |
nicklas |
Wizard.setInputStatus('flowCells', 'warning', numEmptyLanes + ' empty lanes'); |
5439 |
20 May 19 |
nicklas |
427 |
} |
5439 |
20 May 19 |
nicklas |
else |
5439 |
20 May 19 |
nicklas |
429 |
{ |
5439 |
20 May 19 |
nicklas |
Wizard.setInputStatus('flowCells', 'valid'); |
5439 |
20 May 19 |
nicklas |
431 |
} |
5439 |
20 May 19 |
nicklas |
432 |
} |
5439 |
20 May 19 |
nicklas |
433 |
|
5439 |
20 May 19 |
nicklas |
434 |
|
5439 |
20 May 19 |
nicklas |
flowcell.selectPool = function(event) |
5439 |
20 May 19 |
nicklas |
436 |
{ |
5439 |
20 May 19 |
nicklas |
var frm = document.forms['reggie']; |
5453 |
28 May 19 |
nicklas |
var preset = PRESETS[frm.preset.value]; |
5453 |
28 May 19 |
nicklas |
if (preset && preset.maxPools == 1) return; |
5439 |
20 May 19 |
nicklas |
440 |
|
5439 |
20 May 19 |
nicklas |
var target = event.currentTarget; |
5439 |
20 May 19 |
nicklas |
currentFcNo = Data.int(target, 'fc-no'); |
5439 |
20 May 19 |
nicklas |
currentLaneNo = Data.int(target, 'lane-no'); |
5439 |
20 May 19 |
nicklas |
444 |
|
5439 |
20 May 19 |
nicklas |
// Reset 'current' selection |
5439 |
20 May 19 |
nicklas |
var menu = Doc.element('select-pool'); |
5439 |
20 May 19 |
nicklas |
var selectAll = Doc.element('select-pool-all'); |
5439 |
20 May 19 |
nicklas |
for (var i = 0; i < selectAll.childNodes.length; i++) |
5439 |
20 May 19 |
nicklas |
449 |
{ |
5439 |
20 May 19 |
nicklas |
Doc.removeClass(selectAll.childNodes[i], 'current'); |
5439 |
20 May 19 |
nicklas |
Doc.removeClass(selectAll.childNodes[i], 'default'); |
5439 |
20 May 19 |
nicklas |
452 |
} |
5439 |
20 May 19 |
nicklas |
menu.style.display = 'block'; |
5439 |
20 May 19 |
nicklas |
454 |
|
5439 |
20 May 19 |
nicklas |
var currentPool = flowCells[currentFcNo].lanes[currentLaneNo].pool; |
5439 |
20 May 19 |
nicklas |
var defaultPool = flowCells[currentFcNo].lanes[currentLaneNo].defaultPool; |
5439 |
20 May 19 |
nicklas |
if (currentPool) |
5439 |
20 May 19 |
nicklas |
458 |
{ |
5439 |
20 May 19 |
nicklas |
Doc.addClass('pool-'+currentPool.id, 'current'); |
5439 |
20 May 19 |
nicklas |
460 |
} |
5439 |
20 May 19 |
nicklas |
if (defaultPool && defaultPool != currentPool) |
5439 |
20 May 19 |
nicklas |
462 |
{ |
5439 |
20 May 19 |
nicklas |
Doc.addClass('pool-'+defaultPool.id, 'default'); |
5439 |
20 May 19 |
nicklas |
464 |
} |
5439 |
20 May 19 |
nicklas |
465 |
|
5439 |
20 May 19 |
nicklas |
var x = event.clientX; |
5439 |
20 May 19 |
nicklas |
var halfHeight = Math.floor(selectAll.offsetHeight/2) |
5439 |
20 May 19 |
nicklas |
var y = event.clientY+2; //-halfHeight; |
5439 |
20 May 19 |
nicklas |
469 |
|
5439 |
20 May 19 |
nicklas |
var scroll = 0; |
5439 |
20 May 19 |
nicklas |
471 |
|
5439 |
20 May 19 |
nicklas |
// Position the selection div |
5439 |
20 May 19 |
nicklas |
selectAll.scrollTop = scroll; |
5439 |
20 May 19 |
nicklas |
menu.style.left = (x)+'px'; |
5439 |
20 May 19 |
nicklas |
menu.style.top = (y)+'px'; |
5439 |
20 May 19 |
nicklas |
event.stopPropagation(); |
5439 |
20 May 19 |
nicklas |
477 |
} |
5439 |
20 May 19 |
nicklas |
478 |
|
5439 |
20 May 19 |
nicklas |
flowcell.onPoolSelected = function(event) |
5439 |
20 May 19 |
nicklas |
480 |
{ |
5439 |
20 May 19 |
nicklas |
var optionId = event.target.id; |
5439 |
20 May 19 |
nicklas |
var pool = null; |
5439 |
20 May 19 |
nicklas |
var index = Data.int(event.target, 'index', -1); |
5439 |
20 May 19 |
nicklas |
if (index >= 0) |
5439 |
20 May 19 |
nicklas |
485 |
{ |
5439 |
20 May 19 |
nicklas |
pool = selectedPools[index]; |
5439 |
20 May 19 |
nicklas |
487 |
} |
5439 |
20 May 19 |
nicklas |
flowCells[currentFcNo].lanes[currentLaneNo].pool = pool; |
5439 |
20 May 19 |
nicklas |
flowcell.updateFlowCellsMatrix(); |
5439 |
20 May 19 |
nicklas |
490 |
} |
5439 |
20 May 19 |
nicklas |
491 |
|
5439 |
20 May 19 |
nicklas |
flowcell.hidePoolSelection = function() |
5439 |
20 May 19 |
nicklas |
493 |
{ |
5439 |
20 May 19 |
nicklas |
Doc.hide('select-pool'); |
5439 |
20 May 19 |
nicklas |
495 |
} |
5439 |
20 May 19 |
nicklas |
496 |
|
5439 |
20 May 19 |
nicklas |
flowcell.validateStep2 = function(event) |
5439 |
20 May 19 |
nicklas |
498 |
{ |
5439 |
20 May 19 |
nicklas |
var valid = flowCellsAreValid; |
5439 |
20 May 19 |
nicklas |
valid &= readIsValid['read1']; |
5453 |
28 May 19 |
nicklas |
valid &= readIsValid['indexRead1']; |
5453 |
28 May 19 |
nicklas |
valid &= readIsValid['indexRead2']; |
5439 |
20 May 19 |
nicklas |
valid &= readIsValid['read2']; |
5439 |
20 May 19 |
nicklas |
504 |
|
5439 |
20 May 19 |
nicklas |
if (!valid) |
5439 |
20 May 19 |
nicklas |
506 |
{ |
5439 |
20 May 19 |
nicklas |
event.preventDefault(); |
5439 |
20 May 19 |
nicklas |
508 |
} |
5439 |
20 May 19 |
nicklas |
509 |
} |
5439 |
20 May 19 |
nicklas |
510 |
|
5439 |
20 May 19 |
nicklas |
flowcell.submit = function() |
5439 |
20 May 19 |
nicklas |
512 |
{ |
5439 |
20 May 19 |
nicklas |
var frm = document.forms['reggie']; |
5453 |
28 May 19 |
nicklas |
var preset = PRESETS[frm.preset.value]; |
5439 |
20 May 19 |
nicklas |
515 |
|
5439 |
20 May 19 |
nicklas |
var submitInfo = {}; |
5453 |
28 May 19 |
nicklas |
submitInfo.flowCellType = preset ? preset.flowCellType : null; |
5439 |
20 May 19 |
nicklas |
submitInfo.read1 = parseInt(frm.read1.value); |
5453 |
28 May 19 |
nicklas |
submitInfo.indexRead1 = parseInt(frm.indexRead1.value); |
5453 |
28 May 19 |
nicklas |
submitInfo.indexRead2 = parseInt(frm.indexRead2.value); |
5439 |
20 May 19 |
nicklas |
submitInfo.read2 = parseInt(frm.read2.value); |
5439 |
20 May 19 |
nicklas |
submitInfo.flowCells = flowCells; |
5439 |
20 May 19 |
nicklas |
523 |
|
5439 |
20 May 19 |
nicklas |
for (var fcNo = 0; fcNo < flowCells.length; fcNo++) |
5439 |
20 May 19 |
nicklas |
525 |
{ |
5439 |
20 May 19 |
nicklas |
var flowCell = flowCells[fcNo]; |
5439 |
20 May 19 |
nicklas |
flowCell.comment = frm['comments.'+fcNo].value; |
5439 |
20 May 19 |
nicklas |
for (var laneNo = 0; laneNo < flowCell.lanes.length; laneNo++) |
5439 |
20 May 19 |
nicklas |
529 |
{ |
5439 |
20 May 19 |
nicklas |
var lane = flowCell.lanes[laneNo]; |
5439 |
20 May 19 |
nicklas |
lane.defaultPool = null; // Do not need to submit this information |
5439 |
20 May 19 |
nicklas |
var pool = lane.pool; |
5439 |
20 May 19 |
nicklas |
if (pool != null) |
5439 |
20 May 19 |
nicklas |
534 |
{ |
5439 |
20 May 19 |
nicklas |
pool.count = pool.count ? pool.count+1 : 1; |
5439 |
20 May 19 |
nicklas |
536 |
} |
5439 |
20 May 19 |
nicklas |
537 |
} |
5439 |
20 May 19 |
nicklas |
538 |
} |
5439 |
20 May 19 |
nicklas |
539 |
|
5439 |
20 May 19 |
nicklas |
var url = '../Mips.servlet?ID='+App.getSessionId(); |
5439 |
20 May 19 |
nicklas |
url += '&cmd=CreateFlowCells'; |
5439 |
20 May 19 |
nicklas |
Wizard.showLoadingAnimation('Performing registration...'); |
5439 |
20 May 19 |
nicklas |
Wizard.asyncJsonRequest(url, flowcell.submissionResults, 'POST', JSON.stringify(submitInfo)); |
5439 |
20 May 19 |
nicklas |
544 |
} |
5439 |
20 May 19 |
nicklas |
545 |
|
5439 |
20 May 19 |
nicklas |
flowcell.submissionResults = function(response) |
5439 |
20 May 19 |
nicklas |
547 |
{ |
5439 |
20 May 19 |
nicklas |
Wizard.showFinalMessage(response.messages); |
5439 |
20 May 19 |
nicklas |
Doc.show('gorestart'); |
5439 |
20 May 19 |
nicklas |
550 |
} |
5439 |
20 May 19 |
nicklas |
551 |
|
5439 |
20 May 19 |
nicklas |
return flowcell; |
5439 |
20 May 19 |
nicklas |
553 |
}(); |
5439 |
20 May 19 |
nicklas |
554 |
|
5439 |
20 May 19 |
nicklas |
Doc.onLoad(FlowCell.initPage); |
5439 |
20 May 19 |
nicklas |
556 |
|