2675 |
17 Sep 14 |
nicklas |
var LibReg = function() |
2675 |
17 Sep 14 |
nicklas |
2 |
{ |
2675 |
17 Sep 14 |
nicklas |
var libreg = {}; |
3851 |
14 Apr 16 |
nicklas |
var debug = 0; |
2675 |
17 Sep 14 |
nicklas |
5 |
|
2675 |
17 Sep 14 |
nicklas |
var libCommentsIsValid = false; |
2675 |
17 Sep 14 |
nicklas |
7 |
|
2675 |
17 Sep 14 |
nicklas |
// Page initialization |
2675 |
17 Sep 14 |
nicklas |
libreg.initPage = function() |
2675 |
17 Sep 14 |
nicklas |
10 |
{ |
2675 |
17 Sep 14 |
nicklas |
// Step 1 |
2675 |
17 Sep 14 |
nicklas |
Events.addEventHandler('bioplate', 'change', libreg.bioPlateOnChange); |
2675 |
17 Sep 14 |
nicklas |
Events.addEventHandler('outcomeSuccess', 'click', libreg.outcomeOnChange); |
2675 |
17 Sep 14 |
nicklas |
Events.addEventHandler('outcomeFailed', 'click', libreg.outcomeOnChange); |
2675 |
17 Sep 14 |
nicklas |
Events.addEventHandler('step-1', 'wizard-validate', libreg.validateStep1); |
2675 |
17 Sep 14 |
nicklas |
16 |
|
2675 |
17 Sep 14 |
nicklas |
// Step 2 |
2675 |
17 Sep 14 |
nicklas |
Events.addEventHandler('step-2', 'wizard-initialize', libreg.initializeStep2); |
2675 |
17 Sep 14 |
nicklas |
Events.addEventHandler('step-2', 'wizard-validate', libreg.validateStep2); |
2675 |
17 Sep 14 |
nicklas |
Events.addEventHandler('amplificationDate', 'blur', Wizard.validateDate); |
2675 |
17 Sep 14 |
nicklas |
Events.addEventHandler('cleanupDate', 'blur', Wizard.validateDate); |
2675 |
17 Sep 14 |
nicklas |
Events.addEventHandler('libComments', 'blur', libreg.libCommentsOnChange); |
2675 |
17 Sep 14 |
nicklas |
Wizard.initFileSelectionField('qubitcsv'); |
2675 |
17 Sep 14 |
nicklas |
Wizard.initFileSelectionField('welltable'); |
2675 |
17 Sep 14 |
nicklas |
Wizard.initFileSelectionField('calipergxd'); |
2675 |
17 Sep 14 |
nicklas |
Wizard.initFileSelectionField('caliperpdf'); |
2675 |
17 Sep 14 |
nicklas |
Events.addEventHandler('welltable', 'change', libreg.prevalidateWellTable); |
2675 |
17 Sep 14 |
nicklas |
Events.addEventHandler('qubitcsv', 'change', libreg.prevalidateWellTable); |
3834 |
11 Apr 16 |
nicklas |
Events.addEventHandler('libSize', 'change', Wizard.validateNumber); |
3834 |
11 Apr 16 |
nicklas |
Events.addEventHandler('libSize', 'keypress', Events.numberOnly); |
2675 |
17 Sep 14 |
nicklas |
31 |
|
2675 |
17 Sep 14 |
nicklas |
if (debug) |
2675 |
17 Sep 14 |
nicklas |
33 |
{ |
2675 |
17 Sep 14 |
nicklas |
Buttons.addClickHandler('btnFakeQubit', libreg.generateFakeFile); |
2675 |
17 Sep 14 |
nicklas |
Buttons.addClickHandler('btnFakeWelltable', libreg.generateFakeFile); |
2675 |
17 Sep 14 |
nicklas |
36 |
} |
2675 |
17 Sep 14 |
nicklas |
37 |
|
2675 |
17 Sep 14 |
nicklas |
// Navigation |
2675 |
17 Sep 14 |
nicklas |
Buttons.addClickHandler('gocancel', Wizard.cancelWizard); |
2675 |
17 Sep 14 |
nicklas |
Buttons.addClickHandler('gorestart', Wizard.restartWizard); |
2675 |
17 Sep 14 |
nicklas |
Buttons.addClickHandler('gonext', Wizard.goNextOnClick); |
2675 |
17 Sep 14 |
nicklas |
Buttons.addClickHandler('goregister', Wizard.goRegister); |
2675 |
17 Sep 14 |
nicklas |
43 |
|
2675 |
17 Sep 14 |
nicklas |
// Final registration |
2675 |
17 Sep 14 |
nicklas |
Events.addEventHandler('wizard', 'wizard-submit', libreg.submit); |
2675 |
17 Sep 14 |
nicklas |
46 |
|
2675 |
17 Sep 14 |
nicklas |
var url = '../LibPrep.servlet?ID='+App.getSessionId(); |
2675 |
17 Sep 14 |
nicklas |
url += '&cmd=GetLibraryPlatesForLibPrep'; |
2675 |
17 Sep 14 |
nicklas |
Wizard.showLoadingAnimation('Loading Library plates...'); |
2675 |
17 Sep 14 |
nicklas |
Wizard.asyncJsonRequest(url, libreg.initializeStep1); |
2675 |
17 Sep 14 |
nicklas |
51 |
} |
2675 |
17 Sep 14 |
nicklas |
52 |
|
2675 |
17 Sep 14 |
nicklas |
53 |
|
2675 |
17 Sep 14 |
nicklas |
libreg.initializeStep1 = function(response) |
2675 |
17 Sep 14 |
nicklas |
55 |
{ |
2675 |
17 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2675 |
17 Sep 14 |
nicklas |
var bioplates = response.bioplates; |
2675 |
17 Sep 14 |
nicklas |
58 |
|
2675 |
17 Sep 14 |
nicklas |
var plates = frm.bioplate; |
2675 |
17 Sep 14 |
nicklas |
if (bioplates.length > 0) |
2675 |
17 Sep 14 |
nicklas |
61 |
{ |
2675 |
17 Sep 14 |
nicklas |
for (var i=0; i < bioplates.length; i++) |
2675 |
17 Sep 14 |
nicklas |
63 |
{ |
2675 |
17 Sep 14 |
nicklas |
var bioplate = bioplates[i]; |
3725 |
27 Jan 16 |
nicklas |
var name = bioplate.name; |
5883 |
26 Mar 20 |
nicklas |
var warning = bioplate.numFiles == 0 ? ' ( ! )' : ''; |
3725 |
27 Jan 16 |
nicklas |
var option = new Option(name + warning, bioplate.id); |
2675 |
17 Sep 14 |
nicklas |
option.bioplate = bioplate; |
2675 |
17 Sep 14 |
nicklas |
plates.options[plates.length] = option; |
2675 |
17 Sep 14 |
nicklas |
70 |
} |
2675 |
17 Sep 14 |
nicklas |
71 |
} |
2675 |
17 Sep 14 |
nicklas |
else |
2675 |
17 Sep 14 |
nicklas |
73 |
{ |
5883 |
26 Mar 20 |
nicklas |
Wizard.setFatalError('No Library bioplates available for processing.'); |
2675 |
17 Sep 14 |
nicklas |
return; |
2675 |
17 Sep 14 |
nicklas |
76 |
} |
2675 |
17 Sep 14 |
nicklas |
77 |
|
2675 |
17 Sep 14 |
nicklas |
libreg.bioPlateOnChange(); |
2675 |
17 Sep 14 |
nicklas |
libreg.outcomeOnChange(); |
2675 |
17 Sep 14 |
nicklas |
frm.bioplate.focus(); |
2675 |
17 Sep 14 |
nicklas |
81 |
|
2675 |
17 Sep 14 |
nicklas |
Doc.show('step-1'); |
2675 |
17 Sep 14 |
nicklas |
Doc.show('gonext'); |
2675 |
17 Sep 14 |
nicklas |
84 |
} |
2675 |
17 Sep 14 |
nicklas |
85 |
|
2675 |
17 Sep 14 |
nicklas |
libreg.bioPlateOnChange = function() |
2675 |
17 Sep 14 |
nicklas |
87 |
{ |
2675 |
17 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2675 |
17 Sep 14 |
nicklas |
var selectedPlate = frm.bioplate[frm.bioplate.selectedIndex].bioplate; |
5883 |
26 Mar 20 |
nicklas |
if (selectedPlate.numFiles == 0) |
2675 |
17 Sep 14 |
nicklas |
91 |
{ |
2675 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('bioplate', 'warning', 'No quality control PDF has been registered for this plate'); |
2675 |
17 Sep 14 |
nicklas |
93 |
} |
2675 |
17 Sep 14 |
nicklas |
else |
2675 |
17 Sep 14 |
nicklas |
95 |
{ |
2675 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('bioplate', 'valid'); |
2675 |
17 Sep 14 |
nicklas |
97 |
} |
2675 |
17 Sep 14 |
nicklas |
98 |
} |
2675 |
17 Sep 14 |
nicklas |
99 |
|
2675 |
17 Sep 14 |
nicklas |
libreg.outcomeOnChange = function() |
2675 |
17 Sep 14 |
nicklas |
101 |
{ |
2675 |
17 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2675 |
17 Sep 14 |
nicklas |
var failed = Doc.element('outcomeFailed').checked |
3834 |
11 Apr 16 |
nicklas |
Doc.element('useCaliper').disabled = failed; |
2675 |
17 Sep 14 |
nicklas |
if (failed) |
2675 |
17 Sep 14 |
nicklas |
106 |
{ |
2675 |
17 Sep 14 |
nicklas |
Doc.addClass(frm.libComments, 'required'); |
2675 |
17 Sep 14 |
nicklas |
108 |
} |
2675 |
17 Sep 14 |
nicklas |
else |
2675 |
17 Sep 14 |
nicklas |
110 |
{ |
2675 |
17 Sep 14 |
nicklas |
Doc.removeClass(frm.libComments, 'required'); |
2675 |
17 Sep 14 |
nicklas |
112 |
} |
2675 |
17 Sep 14 |
nicklas |
113 |
} |
2675 |
17 Sep 14 |
nicklas |
114 |
|
2675 |
17 Sep 14 |
nicklas |
115 |
|
2675 |
17 Sep 14 |
nicklas |
libreg.validateStep1 = function(event) |
2675 |
17 Sep 14 |
nicklas |
117 |
{} |
2675 |
17 Sep 14 |
nicklas |
118 |
|
2675 |
17 Sep 14 |
nicklas |
libreg.initializeStep2 = function() |
2675 |
17 Sep 14 |
nicklas |
120 |
{ |
2675 |
17 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2675 |
17 Sep 14 |
nicklas |
122 |
|
2675 |
17 Sep 14 |
nicklas |
var failed = Doc.element('outcomeFailed').checked; |
3834 |
11 Apr 16 |
nicklas |
var useCaliper = !failed && Doc.element('useCaliper').checked; |
2675 |
17 Sep 14 |
nicklas |
Wizard.setCurrentStep(2); |
2675 |
17 Sep 14 |
nicklas |
if (failed) |
2675 |
17 Sep 14 |
nicklas |
127 |
{ |
2675 |
17 Sep 14 |
nicklas |
Wizard.showGoNextConfirmation(true, 'Check to verify registration of failure.'); |
2675 |
17 Sep 14 |
nicklas |
libreg.libCommentsOnChange(); |
3834 |
11 Apr 16 |
nicklas |
Doc.hide('caliperFilesSection'); |
3834 |
11 Apr 16 |
nicklas |
Doc.hide('qubitFilesSection'); |
3834 |
11 Apr 16 |
nicklas |
Doc.hide('noCaliperFilesSection'); |
2675 |
17 Sep 14 |
nicklas |
133 |
} |
3834 |
11 Apr 16 |
nicklas |
else if (!useCaliper) |
3834 |
11 Apr 16 |
nicklas |
135 |
{ |
3834 |
11 Apr 16 |
nicklas |
Doc.hide('caliperFilesSection'); |
3834 |
11 Apr 16 |
nicklas |
137 |
} |
3834 |
11 Apr 16 |
nicklas |
else |
3834 |
11 Apr 16 |
nicklas |
139 |
{ |
3834 |
11 Apr 16 |
nicklas |
Doc.hide('noCaliperFilesSection'); |
3834 |
11 Apr 16 |
nicklas |
141 |
} |
3834 |
11 Apr 16 |
nicklas |
142 |
|
2675 |
17 Sep 14 |
nicklas |
Doc.show('gocancel'); |
2675 |
17 Sep 14 |
nicklas |
Doc.show('goregister'); |
2675 |
17 Sep 14 |
nicklas |
145 |
|
2675 |
17 Sep 14 |
nicklas |
var libInfo = libreg.getStoredInfo(frm.bioplate.value); |
2675 |
17 Sep 14 |
nicklas |
if (libInfo) |
2675 |
17 Sep 14 |
nicklas |
148 |
{ |
5883 |
26 Mar 20 |
nicklas |
if (libInfo.amplificationDate) |
2675 |
17 Sep 14 |
nicklas |
150 |
{ |
5883 |
26 Mar 20 |
nicklas |
frm.amplificationDate.value = libInfo.amplificationDate; |
5883 |
26 Mar 20 |
nicklas |
frm.amplificationOperator.value = libInfo.amplificationOperator; |
5883 |
26 Mar 20 |
nicklas |
frm.amplificationDate.focus(); |
2675 |
17 Sep 14 |
nicklas |
154 |
} |
5883 |
26 Mar 20 |
nicklas |
if (libInfo.cleanupDate) |
2675 |
17 Sep 14 |
nicklas |
156 |
{ |
5883 |
26 Mar 20 |
nicklas |
frm.cleanupDate.value = libInfo.cleanupDate; |
5883 |
26 Mar 20 |
nicklas |
frm.cleanupOperator.value = libInfo.cleanupOperator; |
5883 |
26 Mar 20 |
nicklas |
frm.cleanupDate.focus(); |
2675 |
17 Sep 14 |
nicklas |
160 |
} |
2675 |
17 Sep 14 |
nicklas |
if (!failed) |
2675 |
17 Sep 14 |
nicklas |
162 |
{ |
3834 |
11 Apr 16 |
nicklas |
if (useCaliper) |
2675 |
17 Sep 14 |
nicklas |
164 |
{ |
3834 |
11 Apr 16 |
nicklas |
if (libInfo.wellTable) |
3834 |
11 Apr 16 |
nicklas |
166 |
{ |
3834 |
11 Apr 16 |
nicklas |
frm.welltable.value = libInfo.wellTable; |
3834 |
11 Apr 16 |
nicklas |
Events.sendChangeEvent('welltable'); |
3834 |
11 Apr 16 |
nicklas |
169 |
} |
3834 |
11 Apr 16 |
nicklas |
if (libInfo.caliperGxd) |
3834 |
11 Apr 16 |
nicklas |
171 |
{ |
3834 |
11 Apr 16 |
nicklas |
frm.calipergxd.value = libInfo.caliperGxd; |
3834 |
11 Apr 16 |
nicklas |
Events.sendChangeEvent('calipergxd'); |
3834 |
11 Apr 16 |
nicklas |
174 |
} |
3834 |
11 Apr 16 |
nicklas |
if (libInfo.caliperPdf) |
3834 |
11 Apr 16 |
nicklas |
176 |
{ |
3834 |
11 Apr 16 |
nicklas |
frm.caliperpdf.value = libInfo.caliperPdf; |
3834 |
11 Apr 16 |
nicklas |
Events.sendChangeEvent('caliperpdf'); |
3834 |
11 Apr 16 |
nicklas |
179 |
} |
2675 |
17 Sep 14 |
nicklas |
180 |
} |
3834 |
11 Apr 16 |
nicklas |
else |
2675 |
17 Sep 14 |
nicklas |
182 |
{ |
3834 |
11 Apr 16 |
nicklas |
Events.sendChangeEvent('libSize'); |
2675 |
17 Sep 14 |
nicklas |
184 |
} |
2675 |
17 Sep 14 |
nicklas |
if (libInfo.qubitCsv) |
2675 |
17 Sep 14 |
nicklas |
186 |
{ |
2675 |
17 Sep 14 |
nicklas |
frm.qubitcsv.value = libInfo.qubitCsv; |
2675 |
17 Sep 14 |
nicklas |
Events.sendChangeEvent('qubitcsv'); |
2675 |
17 Sep 14 |
nicklas |
189 |
} |
2675 |
17 Sep 14 |
nicklas |
190 |
} |
2675 |
17 Sep 14 |
nicklas |
if (libInfo.libComments) |
2675 |
17 Sep 14 |
nicklas |
192 |
{ |
2675 |
17 Sep 14 |
nicklas |
frm.libComments.value = libInfo.libComments; |
2675 |
17 Sep 14 |
nicklas |
frm.libComments.focus(); |
2675 |
17 Sep 14 |
nicklas |
195 |
} |
2675 |
17 Sep 14 |
nicklas |
196 |
} |
2675 |
17 Sep 14 |
nicklas |
197 |
|
2675 |
17 Sep 14 |
nicklas |
var plateName = frm.bioplate[frm.bioplate.selectedIndex].bioplate.name; |
5300 |
14 Feb 19 |
nicklas |
Data.set('qubitcsv', 'name-filter', plateName + '%.csv|'+plateName+'%.xlsx'); |
2675 |
17 Sep 14 |
nicklas |
Data.set('welltable', 'name-filter', plateName + '%.csv'); |
2675 |
17 Sep 14 |
nicklas |
Data.set('calipergxd', 'name-filter', plateName + '%.gxd'); |
2675 |
17 Sep 14 |
nicklas |
Data.set('caliperpdf', 'name-filter', plateName + '%.pdf'); |
2675 |
17 Sep 14 |
nicklas |
203 |
|
5883 |
26 Mar 20 |
nicklas |
frm.amplificationDate.focus(); |
2675 |
17 Sep 14 |
nicklas |
205 |
|
2675 |
17 Sep 14 |
nicklas |
// Load Library protocols |
5883 |
26 Mar 20 |
nicklas |
Reggie.loadProtocols('LIBRARY_PROTOCOL', 'libProtocol', 'LIBPREP_TARGET', 'Manual'); |
2675 |
17 Sep 14 |
nicklas |
208 |
|
2675 |
17 Sep 14 |
nicklas |
if (debug && !failed) |
2675 |
17 Sep 14 |
nicklas |
210 |
{ |
2925 |
13 Nov 14 |
nicklas |
Wizard.showDebugTools(); |
2675 |
17 Sep 14 |
nicklas |
212 |
} |
2675 |
17 Sep 14 |
nicklas |
213 |
} |
2675 |
17 Sep 14 |
nicklas |
214 |
|
2675 |
17 Sep 14 |
nicklas |
libreg.prevalidateWellTable = function() |
2675 |
17 Sep 14 |
nicklas |
216 |
{ |
2675 |
17 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
3834 |
11 Apr 16 |
nicklas |
var useCaliper = frm.useCaliper.checked; |
3834 |
11 Apr 16 |
nicklas |
219 |
|
2675 |
17 Sep 14 |
nicklas |
var wellTable = frm.welltable.value; |
2675 |
17 Sep 14 |
nicklas |
var qubitCsv = frm.qubitcsv.value; |
2675 |
17 Sep 14 |
nicklas |
222 |
|
2675 |
17 Sep 14 |
nicklas |
if (wellTable) Wizard.setInputStatus('welltable'); |
2675 |
17 Sep 14 |
nicklas |
if (qubitCsv) Wizard.setInputStatus('qubitcsv'); |
2675 |
17 Sep 14 |
nicklas |
Data.set('welltable', 'valid', 0); |
2675 |
17 Sep 14 |
nicklas |
Data.set('qubitcsv', 'valid', 0); |
2675 |
17 Sep 14 |
nicklas |
227 |
|
3834 |
11 Apr 16 |
nicklas |
if (useCaliper && !wellTable || !qubitCsv) return; |
2675 |
17 Sep 14 |
nicklas |
229 |
|
2675 |
17 Sep 14 |
nicklas |
var url = '../LibPrep.servlet?ID='+App.getSessionId(); |
3834 |
11 Apr 16 |
nicklas |
url += '&cmd='+(useCaliper ? 'PreValidateCaliperWellTable' : 'PreValidateQubitCsv'); |
2675 |
17 Sep 14 |
nicklas |
url += '&bioplate='+frm.bioplate.value; |
3834 |
11 Apr 16 |
nicklas |
if (useCaliper) |
3834 |
11 Apr 16 |
nicklas |
234 |
{ |
3834 |
11 Apr 16 |
nicklas |
url += '&csv='+encodeURIComponent(wellTable); |
3834 |
11 Apr 16 |
nicklas |
236 |
} |
2675 |
17 Sep 14 |
nicklas |
url += '&qubit='+encodeURIComponent(qubitCsv); |
2675 |
17 Sep 14 |
nicklas |
238 |
|
3834 |
11 Apr 16 |
nicklas |
if (useCaliper) Wizard.setInputStatus('welltable', 'checking', 'Checking...'); |
2675 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('qubitcsv', 'checking', 'Checking...'); |
2675 |
17 Sep 14 |
nicklas |
Wizard.asyncJsonRequest(url, libreg.onWellTableValidated, 'POST'); |
2675 |
17 Sep 14 |
nicklas |
242 |
} |
2675 |
17 Sep 14 |
nicklas |
243 |
|
2675 |
17 Sep 14 |
nicklas |
libreg.onWellTableValidated = function(response) |
2675 |
17 Sep 14 |
nicklas |
245 |
{ |
2675 |
17 Sep 14 |
nicklas |
var qubit = response.qubit; |
2675 |
17 Sep 14 |
nicklas |
var welltable = response.welltable; |
2675 |
17 Sep 14 |
nicklas |
248 |
|
2675 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('welltable'); |
2675 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('qubitcsv'); |
2675 |
17 Sep 14 |
nicklas |
251 |
|
2675 |
17 Sep 14 |
nicklas |
Wizard.showFinalMessage(response.messages); |
2675 |
17 Sep 14 |
nicklas |
253 |
|
2675 |
17 Sep 14 |
nicklas |
if (qubit.valid) |
2675 |
17 Sep 14 |
nicklas |
255 |
{ |
2675 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('qubitcsv', qubit.warnings > 0 ? 'warning' : 'valid'); |
2675 |
17 Sep 14 |
nicklas |
Data.set('qubitcsv', 'valid', 1); |
2675 |
17 Sep 14 |
nicklas |
258 |
} |
2675 |
17 Sep 14 |
nicklas |
else |
2675 |
17 Sep 14 |
nicklas |
260 |
{ |
2675 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('qubitcsv', 'invalid'); |
2675 |
17 Sep 14 |
nicklas |
262 |
} |
2675 |
17 Sep 14 |
nicklas |
263 |
|
2675 |
17 Sep 14 |
nicklas |
if (welltable) |
2675 |
17 Sep 14 |
nicklas |
265 |
{ |
2675 |
17 Sep 14 |
nicklas |
if (welltable.valid) |
2675 |
17 Sep 14 |
nicklas |
267 |
{ |
2675 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('welltable', welltable.warnings > 0 ? 'warning' : 'valid'); |
2675 |
17 Sep 14 |
nicklas |
Data.set('welltable', 'valid', 1); |
2675 |
17 Sep 14 |
nicklas |
270 |
} |
2675 |
17 Sep 14 |
nicklas |
else |
2675 |
17 Sep 14 |
nicklas |
272 |
{ |
2675 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('welltable', 'invalid'); |
2675 |
17 Sep 14 |
nicklas |
274 |
} |
2675 |
17 Sep 14 |
nicklas |
275 |
} |
2675 |
17 Sep 14 |
nicklas |
276 |
} |
2675 |
17 Sep 14 |
nicklas |
277 |
|
2675 |
17 Sep 14 |
nicklas |
var fileField; |
2675 |
17 Sep 14 |
nicklas |
libreg.generateFakeFile = function(event) |
2675 |
17 Sep 14 |
nicklas |
280 |
{ |
2675 |
17 Sep 14 |
nicklas |
var target = event.currentTarget; |
2675 |
17 Sep 14 |
nicklas |
282 |
|
2675 |
17 Sep 14 |
nicklas |
if (location.protocol == 'https:') |
2675 |
17 Sep 14 |
nicklas |
284 |
{ |
2675 |
17 Sep 14 |
nicklas |
Forms.showNotification(target, "For security reasons, this function can't be used on HTTPS servers."); |
2675 |
17 Sep 14 |
nicklas |
return; |
2675 |
17 Sep 14 |
nicklas |
287 |
} |
2675 |
17 Sep 14 |
nicklas |
288 |
|
2675 |
17 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2675 |
17 Sep 14 |
nicklas |
fileField = Data.get(target, 'file-field'); |
2675 |
17 Sep 14 |
nicklas |
var path = Data.get(fileField, 'directory'); |
2675 |
17 Sep 14 |
nicklas |
292 |
|
2675 |
17 Sep 14 |
nicklas |
var url = '../LibPrep.servlet?ID='+App.getSessionId(); |
2675 |
17 Sep 14 |
nicklas |
url += '&cmd='+Data.get(target, 'cmd'); |
2675 |
17 Sep 14 |
nicklas |
url += '&bioplate='+frm.bioplate.value; |
2675 |
17 Sep 14 |
nicklas |
url += '&path='+encodeURIComponent(path); |
2675 |
17 Sep 14 |
nicklas |
297 |
|
2675 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus(fileField, 'checking', 'Generating fake file...'); |
2675 |
17 Sep 14 |
nicklas |
Wizard.asyncJsonRequest(url, libreg.fakeFileGenerated, 'POST'); |
2675 |
17 Sep 14 |
nicklas |
300 |
} |
2675 |
17 Sep 14 |
nicklas |
301 |
|
2675 |
17 Sep 14 |
nicklas |
libreg.fakeFileGenerated = function(response) |
2675 |
17 Sep 14 |
nicklas |
303 |
{ |
2675 |
17 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2675 |
17 Sep 14 |
nicklas |
var file = response.file; |
2675 |
17 Sep 14 |
nicklas |
frm[fileField].value = file.path; |
2675 |
17 Sep 14 |
nicklas |
Events.sendChangeEvent(fileField); |
2675 |
17 Sep 14 |
nicklas |
308 |
} |
2675 |
17 Sep 14 |
nicklas |
309 |
|
2675 |
17 Sep 14 |
nicklas |
libreg.libCommentsOnChange = function() |
2675 |
17 Sep 14 |
nicklas |
311 |
{ |
2675 |
17 Sep 14 |
nicklas |
var failed = Doc.element('outcomeFailed').checked; |
2675 |
17 Sep 14 |
nicklas |
if (!failed) return; |
2675 |
17 Sep 14 |
nicklas |
314 |
|
2675 |
17 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2675 |
17 Sep 14 |
nicklas |
libCommentsIsValid = false; |
2675 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('libComments'); |
2675 |
17 Sep 14 |
nicklas |
318 |
|
2675 |
17 Sep 14 |
nicklas |
var comments = frm.libComments.value; |
2675 |
17 Sep 14 |
nicklas |
if (comments == '') |
2675 |
17 Sep 14 |
nicklas |
321 |
{ |
2675 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('libComments', 'invalid', 'Missing'); |
2675 |
17 Sep 14 |
nicklas |
return; |
2675 |
17 Sep 14 |
nicklas |
324 |
} |
2675 |
17 Sep 14 |
nicklas |
325 |
|
2675 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('libComments', 'valid'); |
2675 |
17 Sep 14 |
nicklas |
libCommentsIsValid = true; |
2675 |
17 Sep 14 |
nicklas |
328 |
} |
2675 |
17 Sep 14 |
nicklas |
329 |
|
2675 |
17 Sep 14 |
nicklas |
libreg.validateStep2 = function(event) |
2675 |
17 Sep 14 |
nicklas |
331 |
{ |
2675 |
17 Sep 14 |
nicklas |
var valid = true; |
5883 |
26 Mar 20 |
nicklas |
valid &= Wizard.isValid('amplificationDate'); |
5883 |
26 Mar 20 |
nicklas |
valid &= Wizard.isValid('cleanupDate'); |
2675 |
17 Sep 14 |
nicklas |
335 |
|
2675 |
17 Sep 14 |
nicklas |
var failed = Doc.element('outcomeFailed').checked; |
3834 |
11 Apr 16 |
nicklas |
var useCaliper = Doc.element('useCaliper').checked; |
2675 |
17 Sep 14 |
nicklas |
if (failed) |
2675 |
17 Sep 14 |
nicklas |
339 |
{ |
2675 |
17 Sep 14 |
nicklas |
valid &= libCommentsIsValid; |
2675 |
17 Sep 14 |
nicklas |
341 |
} |
2675 |
17 Sep 14 |
nicklas |
else |
2675 |
17 Sep 14 |
nicklas |
343 |
{ |
2675 |
17 Sep 14 |
nicklas |
valid &= Wizard.isValid('qubitcsv'); |
3834 |
11 Apr 16 |
nicklas |
if (useCaliper) |
3834 |
11 Apr 16 |
nicklas |
346 |
{ |
3834 |
11 Apr 16 |
nicklas |
valid &= Wizard.isValid('welltable'); |
3834 |
11 Apr 16 |
nicklas |
348 |
} |
3834 |
11 Apr 16 |
nicklas |
else |
3834 |
11 Apr 16 |
nicklas |
350 |
{ |
3834 |
11 Apr 16 |
nicklas |
valid &= Wizard.isValid('libSize'); |
3834 |
11 Apr 16 |
nicklas |
352 |
} |
2675 |
17 Sep 14 |
nicklas |
353 |
} |
2675 |
17 Sep 14 |
nicklas |
354 |
|
2675 |
17 Sep 14 |
nicklas |
if (!valid) event.preventDefault(); |
2675 |
17 Sep 14 |
nicklas |
356 |
} |
2675 |
17 Sep 14 |
nicklas |
357 |
|
2675 |
17 Sep 14 |
nicklas |
358 |
|
2675 |
17 Sep 14 |
nicklas |
libreg.submit = function() |
2675 |
17 Sep 14 |
nicklas |
360 |
{ |
2675 |
17 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2675 |
17 Sep 14 |
nicklas |
362 |
|
2675 |
17 Sep 14 |
nicklas |
var submitInfo = {}; |
2675 |
17 Sep 14 |
nicklas |
submitInfo.bioplate = parseInt(frm.bioplate.value, 10); |
2675 |
17 Sep 14 |
nicklas |
365 |
|
2675 |
17 Sep 14 |
nicklas |
var failed = Doc.element('outcomeFailed').checked; |
3834 |
11 Apr 16 |
nicklas |
var useCaliper = Doc.element('useCaliper').checked; |
2675 |
17 Sep 14 |
nicklas |
submitInfo.failed = failed; |
2675 |
17 Sep 14 |
nicklas |
369 |
|
2675 |
17 Sep 14 |
nicklas |
if (!failed) |
2675 |
17 Sep 14 |
nicklas |
371 |
{ |
2675 |
17 Sep 14 |
nicklas |
libreg.saveToLocalStorage(frm.bioplate.value); |
3834 |
11 Apr 16 |
nicklas |
if (useCaliper) |
3834 |
11 Apr 16 |
nicklas |
374 |
{ |
3834 |
11 Apr 16 |
nicklas |
submitInfo.wellTableCsv = frm.welltable.value; |
3834 |
11 Apr 16 |
nicklas |
submitInfo.caliperGxd = frm.calipergxd.value; |
3834 |
11 Apr 16 |
nicklas |
submitInfo.caliperPdf = frm.caliperpdf.value; |
3834 |
11 Apr 16 |
nicklas |
378 |
} |
3834 |
11 Apr 16 |
nicklas |
else |
3834 |
11 Apr 16 |
nicklas |
380 |
{ |
3835 |
11 Apr 16 |
nicklas |
submitInfo.libSize = parseFloat(frm.libSize.value); |
3834 |
11 Apr 16 |
nicklas |
382 |
} |
2675 |
17 Sep 14 |
nicklas |
submitInfo.qubitCsv = frm.qubitcsv.value; |
2675 |
17 Sep 14 |
nicklas |
384 |
} |
5883 |
26 Mar 20 |
nicklas |
submitInfo.amplificationDate = frm.amplificationDate.value; |
5883 |
26 Mar 20 |
nicklas |
submitInfo.amplificationOperator = frm.amplificationOperator.value; |
5883 |
26 Mar 20 |
nicklas |
submitInfo.cleanupDate = frm.cleanupDate.value; |
5883 |
26 Mar 20 |
nicklas |
submitInfo.cleanupOperator = frm.cleanupOperator.value; |
2675 |
17 Sep 14 |
nicklas |
submitInfo.libProtocol = parseInt(frm.libProtocol.value, 10); |
2675 |
17 Sep 14 |
nicklas |
submitInfo.libComments = frm.libComments.value; |
2675 |
17 Sep 14 |
nicklas |
391 |
|
2675 |
17 Sep 14 |
nicklas |
var url = '../LibPrep.servlet?ID='+App.getSessionId(); |
2675 |
17 Sep 14 |
nicklas |
url += '&cmd=ImportLibPrepResults'; |
2675 |
17 Sep 14 |
nicklas |
Wizard.showLoadingAnimation('Performing registration...'); |
2675 |
17 Sep 14 |
nicklas |
Wizard.asyncJsonRequest(url, libreg.submissionResults, 'POST', JSON.stringify(submitInfo)); |
2675 |
17 Sep 14 |
nicklas |
396 |
} |
2675 |
17 Sep 14 |
nicklas |
397 |
|
2675 |
17 Sep 14 |
nicklas |
libreg.submissionResults = function(response) |
2675 |
17 Sep 14 |
nicklas |
399 |
{ |
2675 |
17 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2675 |
17 Sep 14 |
nicklas |
libreg.removeFromLocalStorage(frm.bioplate.value); |
2675 |
17 Sep 14 |
nicklas |
Wizard.showFinalMessage(response.messages); |
2675 |
17 Sep 14 |
nicklas |
Doc.show('gorestart'); |
2675 |
17 Sep 14 |
nicklas |
404 |
} |
2675 |
17 Sep 14 |
nicklas |
405 |
|
2675 |
17 Sep 14 |
nicklas |
406 |
/** |
2675 |
17 Sep 14 |
nicklas |
Save as much information as possible about the library registration. |
2675 |
17 Sep 14 |
nicklas |
The information is stored in the localStorage() |
2675 |
17 Sep 14 |
nicklas |
under the key 'reggie.libplate.<id>.info' where |
2675 |
17 Sep 14 |
nicklas |
<id> is the ID of the library plate. |
2675 |
17 Sep 14 |
nicklas |
411 |
*/ |
2675 |
17 Sep 14 |
nicklas |
libreg.saveToLocalStorage = function(libPlateId) |
2675 |
17 Sep 14 |
nicklas |
413 |
{ |
2675 |
17 Sep 14 |
nicklas |
if (!window.localStorage) return; |
2675 |
17 Sep 14 |
nicklas |
415 |
|
2675 |
17 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2675 |
17 Sep 14 |
nicklas |
var libInfo = {}; |
2675 |
17 Sep 14 |
nicklas |
libInfo.id = libPlateId; |
5883 |
26 Mar 20 |
nicklas |
libInfo.amplificationDate = frm.amplificationDate.value; |
5883 |
26 Mar 20 |
nicklas |
libInfo.amplificationOperator = frm.amplificationOperator.value; |
5883 |
26 Mar 20 |
nicklas |
libInfo.cleanupDate = frm.cleanupDate.value; |
5883 |
26 Mar 20 |
nicklas |
libInfo.cleanupOperator = frm.cleanupOperator.value; |
2675 |
17 Sep 14 |
nicklas |
libInfo.wellTable = frm.welltable.value; |
2675 |
17 Sep 14 |
nicklas |
libInfo.caliperGxd = frm.calipergxd.value; |
2675 |
17 Sep 14 |
nicklas |
libInfo.caliperPdf = frm.caliperpdf.value; |
2675 |
17 Sep 14 |
nicklas |
libInfo.qubitCsv = frm.qubitcsv.value; |
2675 |
17 Sep 14 |
nicklas |
libInfo.libProtocol = frm.libProtocol.value; |
2675 |
17 Sep 14 |
nicklas |
libInfo.libComments = frm.libComments.value; |
2675 |
17 Sep 14 |
nicklas |
429 |
|
2675 |
17 Sep 14 |
nicklas |
window.localStorage.setItem('reggie.libplate.' + libPlateId + '.info', JSON.stringify(libInfo)); |
2675 |
17 Sep 14 |
nicklas |
if (debug) |
2675 |
17 Sep 14 |
nicklas |
432 |
{ |
2675 |
17 Sep 14 |
nicklas |
App.debug(libPlateId + ': ' + window.localStorage.getItem('reggie.libplate.' + libPlateId + '.info')); |
2675 |
17 Sep 14 |
nicklas |
434 |
} |
2675 |
17 Sep 14 |
nicklas |
435 |
} |
2675 |
17 Sep 14 |
nicklas |
436 |
|
2675 |
17 Sep 14 |
nicklas |
437 |
|
2675 |
17 Sep 14 |
nicklas |
libreg.removeFromLocalStorage = function(libPlateId) |
2675 |
17 Sep 14 |
nicklas |
439 |
{ |
2675 |
17 Sep 14 |
nicklas |
if (!window.localStorage) return; |
2675 |
17 Sep 14 |
nicklas |
if (debug) App.debug('removeFromLocalStorage:' + libPlateId); |
2675 |
17 Sep 14 |
nicklas |
window.localStorage.removeItem('reggie.libplate.' + libPlateId + '.info'); |
2675 |
17 Sep 14 |
nicklas |
443 |
} |
2675 |
17 Sep 14 |
nicklas |
444 |
|
2675 |
17 Sep 14 |
nicklas |
libreg.getStoredInfo = function(libPlateId) |
2675 |
17 Sep 14 |
nicklas |
446 |
{ |
2675 |
17 Sep 14 |
nicklas |
if (!window.localStorage) return null; |
2675 |
17 Sep 14 |
nicklas |
var stored = null; |
2675 |
17 Sep 14 |
nicklas |
try |
2675 |
17 Sep 14 |
nicklas |
450 |
{ |
2675 |
17 Sep 14 |
nicklas |
var info = window.localStorage.getItem('reggie.libplate.' + libPlateId + '.info'); |
2675 |
17 Sep 14 |
nicklas |
if (debug) App.debug(libPlateId + ': ' + info); |
2675 |
17 Sep 14 |
nicklas |
stored = JSON.parse(info); |
2675 |
17 Sep 14 |
nicklas |
454 |
} |
2675 |
17 Sep 14 |
nicklas |
catch (e) |
2675 |
17 Sep 14 |
nicklas |
456 |
{ |
2675 |
17 Sep 14 |
nicklas |
App.debug('Could not load stored information for lib plate ' + libPlateId + ': ' + e); |
2675 |
17 Sep 14 |
nicklas |
458 |
} |
2675 |
17 Sep 14 |
nicklas |
return stored; |
2675 |
17 Sep 14 |
nicklas |
460 |
} |
2675 |
17 Sep 14 |
nicklas |
461 |
|
2675 |
17 Sep 14 |
nicklas |
462 |
|
2675 |
17 Sep 14 |
nicklas |
return libreg; |
2675 |
17 Sep 14 |
nicklas |
464 |
}(); |
2675 |
17 Sep 14 |
nicklas |
465 |
|
2675 |
17 Sep 14 |
nicklas |
Doc.onLoad(LibReg.initPage); |
2675 |
17 Sep 14 |
nicklas |
467 |
|