2666 |
15 Sep 14 |
nicklas |
var MRNAreg = function() |
2666 |
15 Sep 14 |
nicklas |
2 |
{ |
2666 |
15 Sep 14 |
nicklas |
var mrnareg = {}; |
2702 |
26 Sep 14 |
nicklas |
var debug = 0; |
2666 |
15 Sep 14 |
nicklas |
5 |
|
2666 |
15 Sep 14 |
nicklas |
var commentsIsValid = false; |
2666 |
15 Sep 14 |
nicklas |
7 |
|
2666 |
15 Sep 14 |
nicklas |
// Page initialization |
2666 |
15 Sep 14 |
nicklas |
mrnareg.initPage = function() |
2666 |
15 Sep 14 |
nicklas |
10 |
{ |
2666 |
15 Sep 14 |
nicklas |
// Step 1 |
3282 |
29 Apr 15 |
nicklas |
Events.addEventHandler('bioplate', 'change', mrnareg.bioPlateOnChange); |
2666 |
15 Sep 14 |
nicklas |
Events.addEventHandler('step-1', 'wizard-validate', mrnareg.validateStep1); |
2666 |
15 Sep 14 |
nicklas |
14 |
|
2666 |
15 Sep 14 |
nicklas |
// Step 2 |
2666 |
15 Sep 14 |
nicklas |
Events.addEventHandler('step-2', 'wizard-initialize', mrnareg.initializeStep2); |
2666 |
15 Sep 14 |
nicklas |
Events.addEventHandler('step-2', 'wizard-validate', mrnareg.validateStep2); |
2666 |
15 Sep 14 |
nicklas |
Events.addEventHandler('purificationDate', 'blur', Wizard.validateDate); |
2666 |
15 Sep 14 |
nicklas |
Events.addEventHandler('fragmentationDate', 'blur', Wizard.validateDate); |
2666 |
15 Sep 14 |
nicklas |
Events.addEventHandler('cleanupDate', 'blur', Wizard.validateDate); |
2666 |
15 Sep 14 |
nicklas |
Events.addEventHandler('comments', 'blur', mrnareg.commentsOnChange); |
2666 |
15 Sep 14 |
nicklas |
Wizard.initFileSelectionField('pdf'); |
2666 |
15 Sep 14 |
nicklas |
23 |
|
2666 |
15 Sep 14 |
nicklas |
// Navigation |
2666 |
15 Sep 14 |
nicklas |
Buttons.addClickHandler('gocancel', Wizard.cancelWizard); |
2666 |
15 Sep 14 |
nicklas |
Buttons.addClickHandler('gorestart', Wizard.restartWizard); |
2666 |
15 Sep 14 |
nicklas |
Buttons.addClickHandler('gonext', Wizard.goNextOnClick); |
2666 |
15 Sep 14 |
nicklas |
Buttons.addClickHandler('goregister', Wizard.goRegister); |
2666 |
15 Sep 14 |
nicklas |
29 |
|
2666 |
15 Sep 14 |
nicklas |
// Final registration |
2666 |
15 Sep 14 |
nicklas |
Events.addEventHandler('wizard', 'wizard-submit', mrnareg.submit); |
2666 |
15 Sep 14 |
nicklas |
32 |
|
2666 |
15 Sep 14 |
nicklas |
var url = '../MRna.servlet?ID='+App.getSessionId(); |
2666 |
15 Sep 14 |
nicklas |
url += '&cmd=GetUnprocessedPlates&plateType=MRNA&onlyDiluted=1'; |
2666 |
15 Sep 14 |
nicklas |
Wizard.showLoadingAnimation('Loading mRNA plates...'); |
2666 |
15 Sep 14 |
nicklas |
Wizard.asyncJsonRequest(url, mrnareg.initializeStep1); |
2666 |
15 Sep 14 |
nicklas |
37 |
} |
2666 |
15 Sep 14 |
nicklas |
38 |
|
2666 |
15 Sep 14 |
nicklas |
39 |
|
2666 |
15 Sep 14 |
nicklas |
mrnareg.initializeStep1 = function(response) |
2666 |
15 Sep 14 |
nicklas |
41 |
{ |
2666 |
15 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2666 |
15 Sep 14 |
nicklas |
var bioplates = response.bioplates; |
2666 |
15 Sep 14 |
nicklas |
44 |
|
2666 |
15 Sep 14 |
nicklas |
var plates = frm.bioplate; |
2666 |
15 Sep 14 |
nicklas |
if (bioplates.length > 0) |
2666 |
15 Sep 14 |
nicklas |
47 |
{ |
2666 |
15 Sep 14 |
nicklas |
for (var i=0; i < bioplates.length; i++) |
2666 |
15 Sep 14 |
nicklas |
49 |
{ |
2666 |
15 Sep 14 |
nicklas |
var bioplate = bioplates[i]; |
2906 |
07 Nov 14 |
nicklas |
var name = bioplate.name; |
2906 |
07 Nov 14 |
nicklas |
if (bioplate.AutoProcessing == 'PreNormalizeRNA') |
2906 |
07 Nov 14 |
nicklas |
53 |
{ |
2906 |
07 Nov 14 |
nicklas |
name += ' (pre-normalized)'; |
2906 |
07 Nov 14 |
nicklas |
55 |
} |
2906 |
07 Nov 14 |
nicklas |
else if (bioplate.DilutionDate) |
2906 |
07 Nov 14 |
nicklas |
57 |
{ |
2906 |
07 Nov 14 |
nicklas |
name += ' (diluted ' + Reggie.reformatDate(bioplate.DilutionDate) + ')'; |
2906 |
07 Nov 14 |
nicklas |
59 |
} |
2906 |
07 Nov 14 |
nicklas |
60 |
|
2906 |
07 Nov 14 |
nicklas |
var option = new Option(name, bioplate.id); |
2666 |
15 Sep 14 |
nicklas |
option.plate = bioplate; |
2666 |
15 Sep 14 |
nicklas |
plates.options[plates.length] = option; |
2666 |
15 Sep 14 |
nicklas |
64 |
} |
2666 |
15 Sep 14 |
nicklas |
bioplateIsValid = true; |
2666 |
15 Sep 14 |
nicklas |
Wizard.setInputStatus('bioplate', 'valid'); |
2666 |
15 Sep 14 |
nicklas |
mrnareg.bioPlateOnChange(); |
2666 |
15 Sep 14 |
nicklas |
68 |
} |
2666 |
15 Sep 14 |
nicklas |
else |
2666 |
15 Sep 14 |
nicklas |
70 |
{ |
2666 |
15 Sep 14 |
nicklas |
Wizard.setFatalError('No mRNA bioplates available for processing.'); |
2666 |
15 Sep 14 |
nicklas |
return; |
2666 |
15 Sep 14 |
nicklas |
73 |
} |
2666 |
15 Sep 14 |
nicklas |
74 |
|
2666 |
15 Sep 14 |
nicklas |
Doc.show('step-1'); |
2666 |
15 Sep 14 |
nicklas |
Doc.show('gonext'); |
2666 |
15 Sep 14 |
nicklas |
frm.bioplate.focus(); |
2666 |
15 Sep 14 |
nicklas |
78 |
|
2666 |
15 Sep 14 |
nicklas |
79 |
} |
2666 |
15 Sep 14 |
nicklas |
80 |
|
2666 |
15 Sep 14 |
nicklas |
mrnareg.bioPlateOnChange = function() |
2666 |
15 Sep 14 |
nicklas |
82 |
{ |
2666 |
15 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
3282 |
29 Apr 15 |
nicklas |
var bioplate = frm.bioplate[frm.bioplate.selectedIndex].plate; |
3282 |
29 Apr 15 |
nicklas |
Doc.element('comments-info').innerHTML = Strings.encodeTags(bioplate.comments); |
2666 |
15 Sep 14 |
nicklas |
86 |
} |
2666 |
15 Sep 14 |
nicklas |
87 |
|
2666 |
15 Sep 14 |
nicklas |
mrnareg.validateStep1 = function() |
2666 |
15 Sep 14 |
nicklas |
89 |
{} |
2666 |
15 Sep 14 |
nicklas |
90 |
|
2666 |
15 Sep 14 |
nicklas |
mrnareg.initializeStep2 = function() |
2666 |
15 Sep 14 |
nicklas |
92 |
{ |
2666 |
15 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
3282 |
29 Apr 15 |
nicklas |
frm.comments.value = frm.bioplate[frm.bioplate.selectedIndex].plate.comments; |
3282 |
29 Apr 15 |
nicklas |
Doc.addOrRemoveClass('comments', 'required', Doc.element('outcomeFailed').checked); |
3282 |
29 Apr 15 |
nicklas |
mrnareg.commentsOnChange(); |
3282 |
29 Apr 15 |
nicklas |
97 |
|
2666 |
15 Sep 14 |
nicklas |
Wizard.setCurrentStep(2); |
2666 |
15 Sep 14 |
nicklas |
if (Doc.element('outcomeFailed').checked) |
2666 |
15 Sep 14 |
nicklas |
100 |
{ |
2666 |
15 Sep 14 |
nicklas |
Wizard.showGoNextConfirmation(true, 'Check to verify registration of failure.'); |
2666 |
15 Sep 14 |
nicklas |
102 |
} |
2666 |
15 Sep 14 |
nicklas |
Doc.show('gocancel'); |
2666 |
15 Sep 14 |
nicklas |
Doc.show('goregister'); |
2666 |
15 Sep 14 |
nicklas |
105 |
|
2666 |
15 Sep 14 |
nicklas |
Events.sendChangeEvent('pdf'); |
2666 |
15 Sep 14 |
nicklas |
107 |
|
2666 |
15 Sep 14 |
nicklas |
Reggie.loadProtocols('MRNA_PROTOCOL', 'mrnaProtocol'); |
2666 |
15 Sep 14 |
nicklas |
frm.purificationDate.focus(); |
2666 |
15 Sep 14 |
nicklas |
110 |
} |
2666 |
15 Sep 14 |
nicklas |
111 |
|
2666 |
15 Sep 14 |
nicklas |
mrnareg.commentsOnChange = function() |
2666 |
15 Sep 14 |
nicklas |
113 |
{ |
2666 |
15 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2666 |
15 Sep 14 |
nicklas |
commentsIsValid = false; |
2666 |
15 Sep 14 |
nicklas |
Wizard.setInputStatus('comments'); |
2666 |
15 Sep 14 |
nicklas |
117 |
|
2666 |
15 Sep 14 |
nicklas |
var comments = frm.comments.value; |
2666 |
15 Sep 14 |
nicklas |
if (comments == '' && Doc.element('outcomeFailed').checked) |
2666 |
15 Sep 14 |
nicklas |
120 |
{ |
2666 |
15 Sep 14 |
nicklas |
Wizard.setInputStatus('comments', 'invalid', 'Missing'); |
2666 |
15 Sep 14 |
nicklas |
return; |
2666 |
15 Sep 14 |
nicklas |
123 |
} |
2666 |
15 Sep 14 |
nicklas |
124 |
|
2666 |
15 Sep 14 |
nicklas |
Wizard.setInputStatus('comments', 'valid'); |
2666 |
15 Sep 14 |
nicklas |
commentsIsValid = true; |
2666 |
15 Sep 14 |
nicklas |
127 |
} |
2666 |
15 Sep 14 |
nicklas |
128 |
|
2666 |
15 Sep 14 |
nicklas |
mrnareg.validateStep2 = function(event) |
2666 |
15 Sep 14 |
nicklas |
130 |
{ |
2666 |
15 Sep 14 |
nicklas |
var valid = true; |
2666 |
15 Sep 14 |
nicklas |
132 |
|
2666 |
15 Sep 14 |
nicklas |
valid &= Wizard.isValid('pdf'); |
2666 |
15 Sep 14 |
nicklas |
valid &= commentsIsValid; |
2666 |
15 Sep 14 |
nicklas |
valid &= Wizard.isValid('purificationDate'); |
2666 |
15 Sep 14 |
nicklas |
valid &= Wizard.isValid('fragmentationDate'); |
2666 |
15 Sep 14 |
nicklas |
valid &= Wizard.isValid('cleanupDate'); |
2666 |
15 Sep 14 |
nicklas |
138 |
|
2666 |
15 Sep 14 |
nicklas |
if (!valid) event.preventDefault(); |
2666 |
15 Sep 14 |
nicklas |
140 |
} |
2666 |
15 Sep 14 |
nicklas |
141 |
|
2666 |
15 Sep 14 |
nicklas |
mrnareg.submit = function() |
2666 |
15 Sep 14 |
nicklas |
143 |
{ |
2666 |
15 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2666 |
15 Sep 14 |
nicklas |
145 |
|
2666 |
15 Sep 14 |
nicklas |
var submitInfo = {}; |
2666 |
15 Sep 14 |
nicklas |
submitInfo.bioplate = parseInt(frm.bioplate.value, 10); |
2666 |
15 Sep 14 |
nicklas |
submitInfo.mrnaProtocol = parseInt(frm.mrnaProtocol.value, 10); |
2666 |
15 Sep 14 |
nicklas |
submitInfo.failed = Doc.element('outcomeSuccess').checked ? false : true; |
2666 |
15 Sep 14 |
nicklas |
submitInfo.pdf = frm.pdf.value; |
2666 |
15 Sep 14 |
nicklas |
submitInfo.purificationDate = frm.purificationDate.value; |
2666 |
15 Sep 14 |
nicklas |
submitInfo.purificationOperator = frm.purificationOperator.value; |
2666 |
15 Sep 14 |
nicklas |
submitInfo.fragmentationDate = frm.fragmentationDate.value; |
2666 |
15 Sep 14 |
nicklas |
submitInfo.fragmentationOperator = frm.fragmentationOperator.value; |
2666 |
15 Sep 14 |
nicklas |
submitInfo.cleanupDate = frm.cleanupDate.value; |
2666 |
15 Sep 14 |
nicklas |
submitInfo.cleanupOperator = frm.cleanupOperator.value; |
2666 |
15 Sep 14 |
nicklas |
submitInfo.comments = frm.comments.value; |
2666 |
15 Sep 14 |
nicklas |
158 |
|
2666 |
15 Sep 14 |
nicklas |
var url = '../MRna.servlet?ID='+App.getSessionId(); |
2666 |
15 Sep 14 |
nicklas |
url += '&cmd=ImportMRnaQCResults'; |
2666 |
15 Sep 14 |
nicklas |
Wizard.showLoadingAnimation('Performing registration...'); |
2666 |
15 Sep 14 |
nicklas |
Wizard.asyncJsonRequest(url, mrnareg.submissionResults, 'POST', JSON.stringify(submitInfo)); |
2666 |
15 Sep 14 |
nicklas |
163 |
} |
2666 |
15 Sep 14 |
nicklas |
164 |
|
2666 |
15 Sep 14 |
nicklas |
mrnareg.submissionResults = function(response) |
2666 |
15 Sep 14 |
nicklas |
166 |
{ |
2666 |
15 Sep 14 |
nicklas |
Wizard.showFinalMessage(response.messages); |
2666 |
15 Sep 14 |
nicklas |
Doc.show('gorestart'); |
2666 |
15 Sep 14 |
nicklas |
169 |
} |
2666 |
15 Sep 14 |
nicklas |
170 |
|
2666 |
15 Sep 14 |
nicklas |
return mrnareg; |
2666 |
15 Sep 14 |
nicklas |
172 |
}(); |
2666 |
15 Sep 14 |
nicklas |
173 |
|
2666 |
15 Sep 14 |
nicklas |
Doc.onLoad(MRNAreg.initPage); |
2666 |
15 Sep 14 |
nicklas |
175 |
|