2664 |
15 Sep 14 |
nicklas |
var RNAreg = function() |
2664 |
15 Sep 14 |
nicklas |
2 |
{ |
2664 |
15 Sep 14 |
nicklas |
var rnareg = {}; |
2702 |
26 Sep 14 |
nicklas |
var debug = 0; |
2664 |
15 Sep 14 |
nicklas |
5 |
|
2664 |
15 Sep 14 |
nicklas |
// Page initialization |
2664 |
15 Sep 14 |
nicklas |
rnareg.initPage = function() |
2664 |
15 Sep 14 |
nicklas |
8 |
{ |
2664 |
15 Sep 14 |
nicklas |
// Step 1 |
3040 |
15 Dec 14 |
nicklas |
Events.addEventHandler('bioplate', 'change', rnareg.bioPlateOnChange); |
2664 |
15 Sep 14 |
nicklas |
Events.addEventHandler('step-1', 'wizard-validate', rnareg.validateStep1); |
2664 |
15 Sep 14 |
nicklas |
12 |
|
2664 |
15 Sep 14 |
nicklas |
// Step 2 |
2664 |
15 Sep 14 |
nicklas |
Events.addEventHandler('step-2', 'wizard-initialize', rnareg.initializeStep2); |
2664 |
15 Sep 14 |
nicklas |
Events.addEventHandler('step-2', 'wizard-validate', rnareg.validateStep2); |
2664 |
15 Sep 14 |
nicklas |
Events.addEventHandler('dilutionDate', 'blur', Wizard.validateDate); |
2664 |
15 Sep 14 |
nicklas |
17 |
|
2664 |
15 Sep 14 |
nicklas |
// Navigation |
2664 |
15 Sep 14 |
nicklas |
Buttons.addClickHandler('gocancel', Wizard.cancelWizard); |
2664 |
15 Sep 14 |
nicklas |
Buttons.addClickHandler('gorestart', Wizard.restartWizard); |
2664 |
15 Sep 14 |
nicklas |
Buttons.addClickHandler('gonext', Wizard.goNextOnClick); |
2664 |
15 Sep 14 |
nicklas |
Buttons.addClickHandler('goregister', Wizard.goRegister); |
2664 |
15 Sep 14 |
nicklas |
23 |
|
2664 |
15 Sep 14 |
nicklas |
// Final registration |
2664 |
15 Sep 14 |
nicklas |
Events.addEventHandler('wizard', 'wizard-submit', rnareg.submit); |
2664 |
15 Sep 14 |
nicklas |
26 |
|
2664 |
15 Sep 14 |
nicklas |
var url = '../MRna.servlet?ID='+App.getSessionId(); |
2664 |
15 Sep 14 |
nicklas |
url += '&cmd=GetUnprocessedPlates&plateType=MRNA&onlyUndiluted=1'; |
2664 |
15 Sep 14 |
nicklas |
Wizard.showLoadingAnimation('Loading mRNA plates...'); |
2664 |
15 Sep 14 |
nicklas |
Wizard.asyncJsonRequest(url, rnareg.initializeStep1); |
2664 |
15 Sep 14 |
nicklas |
31 |
} |
2664 |
15 Sep 14 |
nicklas |
32 |
|
2664 |
15 Sep 14 |
nicklas |
33 |
|
2664 |
15 Sep 14 |
nicklas |
rnareg.initializeStep1 = function(response) |
2664 |
15 Sep 14 |
nicklas |
35 |
{ |
2664 |
15 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2664 |
15 Sep 14 |
nicklas |
var bioplates = response.bioplates; |
2664 |
15 Sep 14 |
nicklas |
38 |
|
2664 |
15 Sep 14 |
nicklas |
var plates = frm.bioplate; |
2664 |
15 Sep 14 |
nicklas |
if (bioplates.length > 0) |
2664 |
15 Sep 14 |
nicklas |
41 |
{ |
2664 |
15 Sep 14 |
nicklas |
for (var i=0; i < bioplates.length; i++) |
2664 |
15 Sep 14 |
nicklas |
43 |
{ |
2664 |
15 Sep 14 |
nicklas |
var bioplate = bioplates[i]; |
2664 |
15 Sep 14 |
nicklas |
var option = new Option(bioplate.name, bioplate.id); |
2664 |
15 Sep 14 |
nicklas |
option.plate = bioplate; |
2664 |
15 Sep 14 |
nicklas |
plates.options[plates.length] = option; |
2664 |
15 Sep 14 |
nicklas |
48 |
} |
2664 |
15 Sep 14 |
nicklas |
bioplateIsValid = true; |
2664 |
15 Sep 14 |
nicklas |
Wizard.setInputStatus('bioplate', 'valid'); |
2664 |
15 Sep 14 |
nicklas |
rnareg.bioPlateOnChange(); |
2664 |
15 Sep 14 |
nicklas |
52 |
} |
2664 |
15 Sep 14 |
nicklas |
else |
2664 |
15 Sep 14 |
nicklas |
54 |
{ |
2664 |
15 Sep 14 |
nicklas |
Wizard.setFatalError('No mRNA bioplates available for processing.'); |
2664 |
15 Sep 14 |
nicklas |
return; |
2664 |
15 Sep 14 |
nicklas |
57 |
} |
2664 |
15 Sep 14 |
nicklas |
58 |
|
2664 |
15 Sep 14 |
nicklas |
Doc.show('step-1'); |
2664 |
15 Sep 14 |
nicklas |
Doc.show('gonext'); |
2664 |
15 Sep 14 |
nicklas |
frm.bioplate.focus(); |
2664 |
15 Sep 14 |
nicklas |
62 |
|
2664 |
15 Sep 14 |
nicklas |
63 |
} |
2664 |
15 Sep 14 |
nicklas |
64 |
|
2664 |
15 Sep 14 |
nicklas |
rnareg.bioPlateOnChange = function() |
2664 |
15 Sep 14 |
nicklas |
66 |
{ |
2664 |
15 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
3040 |
15 Dec 14 |
nicklas |
var bioplate = frm.bioplate[frm.bioplate.selectedIndex].plate; |
3040 |
15 Dec 14 |
nicklas |
Doc.element('comments-info').innerHTML = Strings.encodeTags(bioplate.comments); |
2664 |
15 Sep 14 |
nicklas |
70 |
} |
2664 |
15 Sep 14 |
nicklas |
71 |
|
2664 |
15 Sep 14 |
nicklas |
72 |
|
2664 |
15 Sep 14 |
nicklas |
rnareg.validateStep1 = function() |
2664 |
15 Sep 14 |
nicklas |
74 |
{} |
2664 |
15 Sep 14 |
nicklas |
75 |
|
2664 |
15 Sep 14 |
nicklas |
rnareg.initializeStep2 = function() |
2664 |
15 Sep 14 |
nicklas |
77 |
{ |
2664 |
15 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
3040 |
15 Dec 14 |
nicklas |
frm.comments.value = frm.bioplate[frm.bioplate.selectedIndex].plate.comments; |
2664 |
15 Sep 14 |
nicklas |
Wizard.setCurrentStep(2); |
2664 |
15 Sep 14 |
nicklas |
Doc.show('goregister'); |
2664 |
15 Sep 14 |
nicklas |
Doc.show('gocancel'); |
2664 |
15 Sep 14 |
nicklas |
frm.dilutionDate.focus(); |
2664 |
15 Sep 14 |
nicklas |
84 |
} |
2664 |
15 Sep 14 |
nicklas |
85 |
|
2664 |
15 Sep 14 |
nicklas |
rnareg.validateStep2 = function(event) |
2664 |
15 Sep 14 |
nicklas |
87 |
{ |
2664 |
15 Sep 14 |
nicklas |
if (!Wizard.isValid('dilutionDate')) |
2664 |
15 Sep 14 |
nicklas |
89 |
{ |
2664 |
15 Sep 14 |
nicklas |
event.preventDefault(); |
2664 |
15 Sep 14 |
nicklas |
91 |
} |
2664 |
15 Sep 14 |
nicklas |
92 |
} |
2664 |
15 Sep 14 |
nicklas |
93 |
|
2664 |
15 Sep 14 |
nicklas |
rnareg.submit = function() |
2664 |
15 Sep 14 |
nicklas |
95 |
{ |
2664 |
15 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2664 |
15 Sep 14 |
nicklas |
97 |
|
2664 |
15 Sep 14 |
nicklas |
var submitInfo = {}; |
2664 |
15 Sep 14 |
nicklas |
submitInfo.bioplate = parseInt(frm.bioplate.value, 10); |
2664 |
15 Sep 14 |
nicklas |
submitInfo.dilutionDate = frm.dilutionDate.value; |
2664 |
15 Sep 14 |
nicklas |
submitInfo.dilutionOperator = frm.dilutionOperator.value; |
2664 |
15 Sep 14 |
nicklas |
submitInfo.comments = frm.comments.value; |
2664 |
15 Sep 14 |
nicklas |
103 |
|
2664 |
15 Sep 14 |
nicklas |
var url = '../MRna.servlet?ID='+App.getSessionId(); |
2664 |
15 Sep 14 |
nicklas |
url += '&cmd=RegisterRNADilution'; |
2664 |
15 Sep 14 |
nicklas |
Wizard.showLoadingAnimation('Performing registration...'); |
2664 |
15 Sep 14 |
nicklas |
Wizard.asyncJsonRequest(url, rnareg.submissionResults, 'POST', JSON.stringify(submitInfo)); |
2664 |
15 Sep 14 |
nicklas |
108 |
} |
2664 |
15 Sep 14 |
nicklas |
109 |
|
2664 |
15 Sep 14 |
nicklas |
rnareg.submissionResults = function(response) |
2664 |
15 Sep 14 |
nicklas |
111 |
{ |
2664 |
15 Sep 14 |
nicklas |
Wizard.showFinalMessage(response.messages); |
2664 |
15 Sep 14 |
nicklas |
Doc.show('gorestart'); |
2664 |
15 Sep 14 |
nicklas |
114 |
} |
2664 |
15 Sep 14 |
nicklas |
115 |
|
2664 |
15 Sep 14 |
nicklas |
return rnareg; |
2664 |
15 Sep 14 |
nicklas |
117 |
}(); |
2664 |
15 Sep 14 |
nicklas |
118 |
|
2664 |
15 Sep 14 |
nicklas |
Doc.onLoad(RNAreg.initPage); |
2664 |
15 Sep 14 |
nicklas |
120 |
|