2667 |
15 Sep 14 |
nicklas |
var CDNAreg = function() |
2667 |
15 Sep 14 |
nicklas |
2 |
{ |
2667 |
15 Sep 14 |
nicklas |
var cdnareg = {}; |
2702 |
26 Sep 14 |
nicklas |
var debug = 0; |
2667 |
15 Sep 14 |
nicklas |
5 |
|
2667 |
15 Sep 14 |
nicklas |
var commentsIsValid = true; |
2667 |
15 Sep 14 |
nicklas |
7 |
|
2667 |
15 Sep 14 |
nicklas |
// Page initialization |
2667 |
15 Sep 14 |
nicklas |
cdnareg.initPage = function() |
2667 |
15 Sep 14 |
nicklas |
10 |
{ |
2667 |
15 Sep 14 |
nicklas |
// Step 1 |
2667 |
15 Sep 14 |
nicklas |
Events.addEventHandler('outcomeSuccess', 'click', cdnareg.outcomeOnChange); |
2667 |
15 Sep 14 |
nicklas |
Events.addEventHandler('outcomeFailed', 'click', cdnareg.outcomeOnChange); |
2667 |
15 Sep 14 |
nicklas |
Events.addEventHandler('step-1', 'wizard-validate', cdnareg.validateStep1); |
2667 |
15 Sep 14 |
nicklas |
15 |
|
2667 |
15 Sep 14 |
nicklas |
// Step 2 |
2667 |
15 Sep 14 |
nicklas |
Events.addEventHandler('step-2', 'wizard-initialize', cdnareg.initializeStep2); |
2667 |
15 Sep 14 |
nicklas |
Events.addEventHandler('step-2', 'wizard-validate', cdnareg.validateStep2); |
2667 |
15 Sep 14 |
nicklas |
Events.addEventHandler('synthesisDate', 'blur', Wizard.validateDate); |
2667 |
15 Sep 14 |
nicklas |
Events.addEventHandler('comments', 'blur', cdnareg.commentsOnChange); |
2667 |
15 Sep 14 |
nicklas |
21 |
|
2667 |
15 Sep 14 |
nicklas |
// Navigation |
2667 |
15 Sep 14 |
nicklas |
Buttons.addClickHandler('gocancel', Wizard.cancelWizard); |
2667 |
15 Sep 14 |
nicklas |
Buttons.addClickHandler('gorestart', Wizard.restartWizard); |
2667 |
15 Sep 14 |
nicklas |
Buttons.addClickHandler('gonext', Wizard.goNextOnClick); |
2667 |
15 Sep 14 |
nicklas |
Buttons.addClickHandler('goregister', Wizard.goRegister); |
2667 |
15 Sep 14 |
nicklas |
27 |
|
2667 |
15 Sep 14 |
nicklas |
// Final registration |
2667 |
15 Sep 14 |
nicklas |
Events.addEventHandler('wizard', 'wizard-submit', cdnareg.submit); |
2667 |
15 Sep 14 |
nicklas |
30 |
|
2667 |
15 Sep 14 |
nicklas |
var url = '../MRna.servlet?ID='+App.getSessionId(); |
2667 |
15 Sep 14 |
nicklas |
url += '&cmd=GetUnprocessedPlates&plateType=CDNA'; |
2667 |
15 Sep 14 |
nicklas |
Wizard.showLoadingAnimation('Loading cDNA plates...'); |
2667 |
15 Sep 14 |
nicklas |
Wizard.asyncJsonRequest(url, cdnareg.initializeStep1); |
2667 |
15 Sep 14 |
nicklas |
35 |
} |
2667 |
15 Sep 14 |
nicklas |
36 |
|
2667 |
15 Sep 14 |
nicklas |
37 |
|
2667 |
15 Sep 14 |
nicklas |
cdnareg.initializeStep1 = function(response) |
2667 |
15 Sep 14 |
nicklas |
39 |
{ |
2667 |
15 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2667 |
15 Sep 14 |
nicklas |
var bioplates = response.bioplates; |
2667 |
15 Sep 14 |
nicklas |
42 |
|
2667 |
15 Sep 14 |
nicklas |
var plates = frm.bioplate; |
2667 |
15 Sep 14 |
nicklas |
if (bioplates.length > 0) |
2667 |
15 Sep 14 |
nicklas |
45 |
{ |
2667 |
15 Sep 14 |
nicklas |
for (var i=0; i < bioplates.length; i++) |
2667 |
15 Sep 14 |
nicklas |
47 |
{ |
2667 |
15 Sep 14 |
nicklas |
var bioplate = bioplates[i]; |
2667 |
15 Sep 14 |
nicklas |
var option = new Option(bioplate.name, bioplate.id); |
2667 |
15 Sep 14 |
nicklas |
option.plate = bioplate; |
2667 |
15 Sep 14 |
nicklas |
plates.options[plates.length] = option; |
2667 |
15 Sep 14 |
nicklas |
52 |
} |
2667 |
15 Sep 14 |
nicklas |
bioplateIsValid = true; |
2667 |
15 Sep 14 |
nicklas |
Wizard.setInputStatus('bioplate', 'valid'); |
2667 |
15 Sep 14 |
nicklas |
cdnareg.outcomeOnChange(); |
2667 |
15 Sep 14 |
nicklas |
56 |
} |
2667 |
15 Sep 14 |
nicklas |
else |
2667 |
15 Sep 14 |
nicklas |
58 |
{ |
2667 |
15 Sep 14 |
nicklas |
Wizard.setFatalError('No cDNA bioplates available for processing.'); |
2667 |
15 Sep 14 |
nicklas |
return; |
2667 |
15 Sep 14 |
nicklas |
61 |
} |
2667 |
15 Sep 14 |
nicklas |
62 |
|
2667 |
15 Sep 14 |
nicklas |
Doc.show('step-1'); |
2667 |
15 Sep 14 |
nicklas |
Doc.show('gonext'); |
2667 |
15 Sep 14 |
nicklas |
frm.bioplate.focus(); |
2667 |
15 Sep 14 |
nicklas |
66 |
} |
2667 |
15 Sep 14 |
nicklas |
67 |
|
2667 |
15 Sep 14 |
nicklas |
cdnareg.outcomeOnChange = function() |
2667 |
15 Sep 14 |
nicklas |
69 |
{ |
2667 |
15 Sep 14 |
nicklas |
Doc.addOrRemoveClass('comments', 'required', Doc.element('outcomeFailed').checked); |
2667 |
15 Sep 14 |
nicklas |
cdnareg.commentsOnChange(); |
2667 |
15 Sep 14 |
nicklas |
72 |
} |
2667 |
15 Sep 14 |
nicklas |
73 |
|
2667 |
15 Sep 14 |
nicklas |
cdnareg.validateStep1 = function() |
2667 |
15 Sep 14 |
nicklas |
75 |
{} |
2667 |
15 Sep 14 |
nicklas |
76 |
|
2667 |
15 Sep 14 |
nicklas |
cdnareg.initializeStep2 = function() |
2667 |
15 Sep 14 |
nicklas |
78 |
{ |
2667 |
15 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2667 |
15 Sep 14 |
nicklas |
80 |
|
2667 |
15 Sep 14 |
nicklas |
Wizard.setCurrentStep(2); |
2667 |
15 Sep 14 |
nicklas |
if (Doc.element('outcomeFailed').checked) |
2667 |
15 Sep 14 |
nicklas |
83 |
{ |
2667 |
15 Sep 14 |
nicklas |
Wizard.showGoNextConfirmation(true, 'Check to verify registration of failure.'); |
2667 |
15 Sep 14 |
nicklas |
85 |
} |
2667 |
15 Sep 14 |
nicklas |
86 |
|
2667 |
15 Sep 14 |
nicklas |
Doc.show('gocancel'); |
2667 |
15 Sep 14 |
nicklas |
Doc.show('goregister'); |
2667 |
15 Sep 14 |
nicklas |
89 |
|
2667 |
15 Sep 14 |
nicklas |
90 |
|
2667 |
15 Sep 14 |
nicklas |
Reggie.loadProtocols('CDNA_PROTOCOL', 'cdnaProtocol'); |
2667 |
15 Sep 14 |
nicklas |
frm.synthesisDate.focus(); |
2667 |
15 Sep 14 |
nicklas |
93 |
} |
2667 |
15 Sep 14 |
nicklas |
94 |
|
2667 |
15 Sep 14 |
nicklas |
cdnareg.commentsOnChange = function() |
2667 |
15 Sep 14 |
nicklas |
96 |
{ |
2667 |
15 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2667 |
15 Sep 14 |
nicklas |
commentsIsValid = false; |
2667 |
15 Sep 14 |
nicklas |
Wizard.setInputStatus('comments'); |
2667 |
15 Sep 14 |
nicklas |
100 |
|
2667 |
15 Sep 14 |
nicklas |
var comments = frm.comments.value; |
2667 |
15 Sep 14 |
nicklas |
if (comments == '' && Doc.element('outcomeFailed').checked) |
2667 |
15 Sep 14 |
nicklas |
103 |
{ |
2667 |
15 Sep 14 |
nicklas |
Wizard.setInputStatus('comments', 'invalid', 'Missing'); |
2667 |
15 Sep 14 |
nicklas |
return; |
2667 |
15 Sep 14 |
nicklas |
106 |
} |
2667 |
15 Sep 14 |
nicklas |
107 |
|
2667 |
15 Sep 14 |
nicklas |
Wizard.setInputStatus('comments', 'valid'); |
2667 |
15 Sep 14 |
nicklas |
commentsIsValid = true; |
2667 |
15 Sep 14 |
nicklas |
110 |
} |
2667 |
15 Sep 14 |
nicklas |
111 |
|
2667 |
15 Sep 14 |
nicklas |
cdnareg.validateStep2 = function(event) |
2667 |
15 Sep 14 |
nicklas |
113 |
{ |
2667 |
15 Sep 14 |
nicklas |
var valid = true; |
2667 |
15 Sep 14 |
nicklas |
valid &= commentsIsValid; |
2667 |
15 Sep 14 |
nicklas |
valid &= Wizard.isValid('synthesisDate'); |
2667 |
15 Sep 14 |
nicklas |
if (!valid) event.preventDefault(); |
2667 |
15 Sep 14 |
nicklas |
118 |
} |
2667 |
15 Sep 14 |
nicklas |
119 |
|
2667 |
15 Sep 14 |
nicklas |
cdnareg.submit = function() |
2667 |
15 Sep 14 |
nicklas |
121 |
{ |
2667 |
15 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2667 |
15 Sep 14 |
nicklas |
123 |
|
2667 |
15 Sep 14 |
nicklas |
var submitInfo = {}; |
2667 |
15 Sep 14 |
nicklas |
submitInfo.bioplate = parseInt(frm.bioplate.value, 10); |
2667 |
15 Sep 14 |
nicklas |
submitInfo.failed = Doc.element('outcomeSuccess').checked ? false : true; |
2667 |
15 Sep 14 |
nicklas |
submitInfo.cdnaProtocol = parseInt(frm.cdnaProtocol.value, 10); |
2667 |
15 Sep 14 |
nicklas |
submitInfo.synthesisDate = frm.synthesisDate.value; |
2667 |
15 Sep 14 |
nicklas |
submitInfo.synthesisOperator = frm.synthesisOperator.value; |
2667 |
15 Sep 14 |
nicklas |
submitInfo.comments = frm.comments.value; |
2667 |
15 Sep 14 |
nicklas |
131 |
|
2667 |
15 Sep 14 |
nicklas |
var url = '../MRna.servlet?ID='+App.getSessionId(); |
2667 |
15 Sep 14 |
nicklas |
url += '&cmd=ImportCDnaResults'; |
2667 |
15 Sep 14 |
nicklas |
Wizard.showLoadingAnimation('Performing registration...'); |
2667 |
15 Sep 14 |
nicklas |
Wizard.asyncJsonRequest(url, cdnareg.submissionResults, 'POST', JSON.stringify(submitInfo)); |
2667 |
15 Sep 14 |
nicklas |
136 |
} |
2667 |
15 Sep 14 |
nicklas |
137 |
|
2667 |
15 Sep 14 |
nicklas |
cdnareg.submissionResults = function(response) |
2667 |
15 Sep 14 |
nicklas |
139 |
{ |
2667 |
15 Sep 14 |
nicklas |
Wizard.showFinalMessage(response.messages); |
2667 |
15 Sep 14 |
nicklas |
Doc.show('gorestart'); |
2667 |
15 Sep 14 |
nicklas |
142 |
} |
2667 |
15 Sep 14 |
nicklas |
143 |
|
2667 |
15 Sep 14 |
nicklas |
return cdnareg; |
2667 |
15 Sep 14 |
nicklas |
145 |
}(); |
2667 |
15 Sep 14 |
nicklas |
146 |
|
2667 |
15 Sep 14 |
nicklas |
Doc.onLoad(CDNAreg.initPage); |
2667 |
15 Sep 14 |
nicklas |
148 |
|