2922 |
12 Nov 14 |
nicklas |
var RnaQcExport = function() |
2922 |
12 Nov 14 |
nicklas |
2 |
{ |
2922 |
12 Nov 14 |
nicklas |
var rnaqc = {}; |
2922 |
12 Nov 14 |
nicklas |
4 |
|
2922 |
12 Nov 14 |
nicklas |
var selectedRnaQc; |
2922 |
12 Nov 14 |
nicklas |
var rinIsValid = []; |
2922 |
12 Nov 14 |
nicklas |
7 |
|
2922 |
12 Nov 14 |
nicklas |
// Page initialization |
2922 |
12 Nov 14 |
nicklas |
rnaqc.initPage = function() |
2922 |
12 Nov 14 |
nicklas |
10 |
{ |
2922 |
12 Nov 14 |
nicklas |
// Step 1 |
2922 |
12 Nov 14 |
nicklas |
Events.addEventHandler('step-1', 'wizard-validate', rnaqc.validateStep1); |
2922 |
12 Nov 14 |
nicklas |
Wizard.initFileSelectionField('pdf'); |
2922 |
12 Nov 14 |
nicklas |
Events.addEventHandler('qcRunDate', 'change', Wizard.validateDate); |
2922 |
12 Nov 14 |
nicklas |
15 |
|
2922 |
12 Nov 14 |
nicklas |
// Step 2 |
2922 |
12 Nov 14 |
nicklas |
Events.addEventHandler('step-2', 'wizard-initialize', rnaqc.initializeStep2); |
2922 |
12 Nov 14 |
nicklas |
Events.addEventHandler('step-2', 'wizard-validate', rnaqc.validateStep2); |
2922 |
12 Nov 14 |
nicklas |
19 |
|
2922 |
12 Nov 14 |
nicklas |
// Navigation |
2922 |
12 Nov 14 |
nicklas |
Buttons.addClickHandler('gocancel', Wizard.cancelWizard); |
2922 |
12 Nov 14 |
nicklas |
Buttons.addClickHandler('gorestart', Wizard.restartWizard); |
2922 |
12 Nov 14 |
nicklas |
Buttons.addClickHandler('gonext', Wizard.goNextOnClick); |
2922 |
12 Nov 14 |
nicklas |
Buttons.addClickHandler('goregister', Wizard.goRegister); |
2922 |
12 Nov 14 |
nicklas |
25 |
|
2922 |
12 Nov 14 |
nicklas |
// Final registration |
2922 |
12 Nov 14 |
nicklas |
Events.addEventHandler('wizard', 'wizard-submit', rnaqc.submit); |
2922 |
12 Nov 14 |
nicklas |
28 |
|
2922 |
12 Nov 14 |
nicklas |
var url = '../RnaQc.servlet?ID='+App.getSessionId(); |
2922 |
12 Nov 14 |
nicklas |
url += '&cmd=GetActiveRnaQcBioPlates&numFreeWells=0&bioPlateType=BA_RNAQC'; |
2922 |
12 Nov 14 |
nicklas |
Wizard.showLoadingAnimation('Loading RNAQC plates...'); |
2922 |
12 Nov 14 |
nicklas |
Wizard.asyncJsonRequest(url, rnaqc.qcPlatesLoaded); |
2922 |
12 Nov 14 |
nicklas |
33 |
} |
2922 |
12 Nov 14 |
nicklas |
34 |
|
2922 |
12 Nov 14 |
nicklas |
35 |
|
2922 |
12 Nov 14 |
nicklas |
rnaqc.qcPlatesLoaded = function(response) |
2922 |
12 Nov 14 |
nicklas |
37 |
{ |
2922 |
12 Nov 14 |
nicklas |
var frm = document.forms['reggie']; |
2922 |
12 Nov 14 |
nicklas |
var qcPlates = response.plates; |
2922 |
12 Nov 14 |
nicklas |
40 |
|
2922 |
12 Nov 14 |
nicklas |
for (var i = 0; i < qcPlates.length; i++) |
2922 |
12 Nov 14 |
nicklas |
42 |
{ |
2922 |
12 Nov 14 |
nicklas |
var plate = qcPlates[i]; |
2922 |
12 Nov 14 |
nicklas |
if (plate.usedWells > 0) |
2922 |
12 Nov 14 |
nicklas |
45 |
{ |
2922 |
12 Nov 14 |
nicklas |
var option = new Option(plate.name + ' -- ' + plate.usedWells + ' used wells', plate.id); |
2922 |
12 Nov 14 |
nicklas |
option.bioPlate = plate; |
2922 |
12 Nov 14 |
nicklas |
frm.bioPlates[frm.bioPlates.length] = option; |
2922 |
12 Nov 14 |
nicklas |
49 |
} |
2922 |
12 Nov 14 |
nicklas |
50 |
} |
2922 |
12 Nov 14 |
nicklas |
51 |
|
2922 |
12 Nov 14 |
nicklas |
if (frm.bioPlates.length == 0) |
2922 |
12 Nov 14 |
nicklas |
53 |
{ |
2922 |
12 Nov 14 |
nicklas |
Wizard.setFatalError('Could not find any bioplates to register.'); |
2922 |
12 Nov 14 |
nicklas |
return; |
2922 |
12 Nov 14 |
nicklas |
56 |
} |
2922 |
12 Nov 14 |
nicklas |
57 |
|
2922 |
12 Nov 14 |
nicklas |
Doc.show('step-1'); |
2922 |
12 Nov 14 |
nicklas |
Doc.show('gonext'); |
2922 |
12 Nov 14 |
nicklas |
Events.sendChangeEvent('qcRunDate'); |
2922 |
12 Nov 14 |
nicklas |
61 |
} |
2922 |
12 Nov 14 |
nicklas |
62 |
|
2922 |
12 Nov 14 |
nicklas |
rnaqc.validateStep1 = function(event) |
2922 |
12 Nov 14 |
nicklas |
64 |
{ |
2922 |
12 Nov 14 |
nicklas |
var valid = Wizard.isValid('qcRunDate'); |
2922 |
12 Nov 14 |
nicklas |
if (!valid) event.preventDefault(); |
2922 |
12 Nov 14 |
nicklas |
67 |
} |
2922 |
12 Nov 14 |
nicklas |
68 |
|
2922 |
12 Nov 14 |
nicklas |
rnaqc.initializeStep2 = function() |
2922 |
12 Nov 14 |
nicklas |
70 |
{ |
2922 |
12 Nov 14 |
nicklas |
var frm = document.forms['reggie']; |
2922 |
12 Nov 14 |
nicklas |
var url = '../RnaQc.servlet?ID='+App.getSessionId(); |
2922 |
12 Nov 14 |
nicklas |
url += '&cmd=GetRnaQcItemsOnBioPlate&bioPlateId='+frm.bioPlates.value; |
2922 |
12 Nov 14 |
nicklas |
Wizard.showLoadingAnimation('Loading RNAQC items...'); |
2922 |
12 Nov 14 |
nicklas |
Wizard.asyncJsonRequest(url, rnaqc.rnaQcItemsLoaded); |
2922 |
12 Nov 14 |
nicklas |
76 |
} |
2922 |
12 Nov 14 |
nicklas |
77 |
|
2922 |
12 Nov 14 |
nicklas |
rnaqc.rnaQcItemsLoaded = function(response) |
2922 |
12 Nov 14 |
nicklas |
79 |
{ |
2922 |
12 Nov 14 |
nicklas |
var frm = document.forms['reggie']; |
2922 |
12 Nov 14 |
nicklas |
selectedRnaQc = response.rnaqc; |
2922 |
12 Nov 14 |
nicklas |
var selectedBioPlate = frm.bioPlates[frm.bioPlates.selectedIndex].bioPlate; |
2922 |
12 Nov 14 |
nicklas |
83 |
|
2922 |
12 Nov 14 |
nicklas |
var html = '<table id="rnaQcTable" class="step-form">'; |
2922 |
12 Nov 14 |
nicklas |
// First header row |
2922 |
12 Nov 14 |
nicklas |
html += '<tr>'; |
2922 |
12 Nov 14 |
nicklas |
html += '<th>RNA QC</th>'; |
2922 |
12 Nov 14 |
nicklas |
html += '<th class="dottedleft">' + Strings.encodeTags(selectedBioPlate.name) + '</th>'; |
2922 |
12 Nov 14 |
nicklas |
html += '<th class="dottedleft">RIN¹</th>'; |
2922 |
12 Nov 14 |
nicklas |
html += '<th></th>'; |
2922 |
12 Nov 14 |
nicklas |
html += '<th class="dottedleft comments">Comments</th>'; |
2922 |
12 Nov 14 |
nicklas |
html += '</tr>'; |
2922 |
12 Nov 14 |
nicklas |
93 |
|
2922 |
12 Nov 14 |
nicklas |
94 |
|
2922 |
12 Nov 14 |
nicklas |
for (var rnaNo=0; rnaNo < selectedRnaQc.length; rnaNo++) |
2922 |
12 Nov 14 |
nicklas |
96 |
{ |
2922 |
12 Nov 14 |
nicklas |
var rna = selectedRnaQc[rnaNo]; |
3742 |
12 Feb 16 |
nicklas |
var isYellow = rna.specimen && rna.specimen.YellowLabel != null; |
3742 |
12 Feb 16 |
nicklas |
var img = isYellow ? '<img src="../images/yellow-label.png">' : ''; |
3742 |
12 Feb 16 |
nicklas |
100 |
|
3742 |
12 Feb 16 |
nicklas |
html += '<tr class="highlight'+(isYellow ? ' yellow-specimen' : '')+'">'; |
3742 |
12 Feb 16 |
nicklas |
html += '<td class="prompt if-yellow">'+img+Strings.encodeTags(rna.name)+'</td>'; |
3154 |
27 Feb 15 |
nicklas |
html += '<td class="dottedleft">'+(rna.bioWell.column+1)+'</td>'; |
2922 |
12 Nov 14 |
nicklas |
html += '<td class="dottedleft"><input class="required" type="text" name="rin.'+rnaNo+'" id="rin.'+rnaNo+'" style="width: 6em;" maxlength="6"></td>'; |
2922 |
12 Nov 14 |
nicklas |
html += '<td class="status" id="rin.'+rnaNo+'.status"></td>'; |
2922 |
12 Nov 14 |
nicklas |
html += '<td class="dottedleft comments"><input type="text" name="comment.'+rnaNo+'"></td>'; |
2922 |
12 Nov 14 |
nicklas |
html += '</tr>' |
2922 |
12 Nov 14 |
nicklas |
108 |
} |
2922 |
12 Nov 14 |
nicklas |
109 |
|
3154 |
27 Feb 15 |
nicklas |
html += '<tr style="border-top-width: 1px;">'; |
2922 |
12 Nov 14 |
nicklas |
html += '<td colspan="5" class="help" style="text-align: left;">¹RIN: a number between 0 and 10 or -100 if no value could be measured.</td>'; |
2922 |
12 Nov 14 |
nicklas |
html += '</tr>' |
2922 |
12 Nov 14 |
nicklas |
html += '</table>'; |
2922 |
12 Nov 14 |
nicklas |
114 |
|
2922 |
12 Nov 14 |
nicklas |
Doc.element('rnaQc').innerHTML = html; |
2922 |
12 Nov 14 |
nicklas |
116 |
|
2922 |
12 Nov 14 |
nicklas |
Wizard.setCurrentStep(2); |
2922 |
12 Nov 14 |
nicklas |
Doc.show('goregister'); |
2922 |
12 Nov 14 |
nicklas |
Doc.show('gocancel'); |
2922 |
12 Nov 14 |
nicklas |
120 |
|
2922 |
12 Nov 14 |
nicklas |
Wizard.keepSessionAlive(); |
2922 |
12 Nov 14 |
nicklas |
122 |
|
2922 |
12 Nov 14 |
nicklas |
for (var rnaNo=0; rnaNo < selectedRnaQc.length; rnaNo++) |
2922 |
12 Nov 14 |
nicklas |
124 |
{ |
2922 |
12 Nov 14 |
nicklas |
Events.addEventHandler('rin.'+rnaNo, 'keypress', Wizard.focusOnEnter, { 'next-focus': 'rin.'+(rnaNo+1) }); |
2922 |
12 Nov 14 |
nicklas |
Events.addEventHandler('rin.'+rnaNo, 'keypress', Events.numberOnly); |
2922 |
12 Nov 14 |
nicklas |
Events.addEventHandler('rin.'+rnaNo, 'change', rnaqc.rinOnChange, { 'index': rnaNo }); |
2922 |
12 Nov 14 |
nicklas |
rinIsValid[rnaNo] = false; |
2922 |
12 Nov 14 |
nicklas |
129 |
} |
2922 |
12 Nov 14 |
nicklas |
130 |
|
2922 |
12 Nov 14 |
nicklas |
frm['rin.0'].focus(); |
2922 |
12 Nov 14 |
nicklas |
132 |
} |
2922 |
12 Nov 14 |
nicklas |
133 |
|
2922 |
12 Nov 14 |
nicklas |
rnaqc.rinOnChange = function(event) |
2922 |
12 Nov 14 |
nicklas |
135 |
{ |
2922 |
12 Nov 14 |
nicklas |
var index = Data.int(event.currentTarget, 'index'); |
2922 |
12 Nov 14 |
nicklas |
var rin = parseFloat(event.currentTarget.value); |
2922 |
12 Nov 14 |
nicklas |
138 |
|
2922 |
12 Nov 14 |
nicklas |
if ((rin >= 0 && rin <= 10) || rin == -100) |
2922 |
12 Nov 14 |
nicklas |
140 |
{ |
2922 |
12 Nov 14 |
nicklas |
rinIsValid[index] = true; |
2922 |
12 Nov 14 |
nicklas |
Wizard.setInputStatus('rin.'+index, 'valid'); |
2922 |
12 Nov 14 |
nicklas |
143 |
} |
2922 |
12 Nov 14 |
nicklas |
else |
2922 |
12 Nov 14 |
nicklas |
145 |
{ |
2922 |
12 Nov 14 |
nicklas |
rinIsValid[index] = false; |
2922 |
12 Nov 14 |
nicklas |
Wizard.setInputStatus('rin.'+index, 'invalid', 'RIN must be a number between 0 and 10 (or -100)'); |
2922 |
12 Nov 14 |
nicklas |
148 |
} |
2922 |
12 Nov 14 |
nicklas |
149 |
} |
2922 |
12 Nov 14 |
nicklas |
150 |
|
2922 |
12 Nov 14 |
nicklas |
rnaqc.validateStep2 = function(event) |
2922 |
12 Nov 14 |
nicklas |
152 |
{ |
2922 |
12 Nov 14 |
nicklas |
var valid = true; |
2922 |
12 Nov 14 |
nicklas |
for (var rnaNo = 0; rnaNo < rinIsValid.length; rnaNo++) |
2922 |
12 Nov 14 |
nicklas |
155 |
{ |
2922 |
12 Nov 14 |
nicklas |
if (!rinIsValid[rnaNo]) |
2922 |
12 Nov 14 |
nicklas |
157 |
{ |
2922 |
12 Nov 14 |
nicklas |
Wizard.setInputStatus('rin.'+rnaNo, 'invalid', 'RIN must be a number between 0 and 10 (or -100)'); |
2922 |
12 Nov 14 |
nicklas |
valid = false; |
2922 |
12 Nov 14 |
nicklas |
160 |
} |
2922 |
12 Nov 14 |
nicklas |
161 |
} |
2922 |
12 Nov 14 |
nicklas |
if (!valid) event.preventDefault(); |
2922 |
12 Nov 14 |
nicklas |
163 |
} |
2922 |
12 Nov 14 |
nicklas |
164 |
|
2922 |
12 Nov 14 |
nicklas |
rnaqc.submit = function() |
2922 |
12 Nov 14 |
nicklas |
166 |
{ |
2922 |
12 Nov 14 |
nicklas |
var frm = document.forms['reggie']; |
2922 |
12 Nov 14 |
nicklas |
var submitInfo = {}; |
2922 |
12 Nov 14 |
nicklas |
169 |
|
2922 |
12 Nov 14 |
nicklas |
submitInfo.pdf = frm.pdf.value; |
2922 |
12 Nov 14 |
nicklas |
submitInfo.bioPlate = parseInt(frm.bioPlates.value); |
2922 |
12 Nov 14 |
nicklas |
submitInfo.QCRunDate = frm.qcRunDate.value; |
2922 |
12 Nov 14 |
nicklas |
submitInfo.QCOperator = frm.qcOperator.value; |
2922 |
12 Nov 14 |
nicklas |
submitInfo.comments = frm.comments.value; |
2922 |
12 Nov 14 |
nicklas |
175 |
|
2922 |
12 Nov 14 |
nicklas |
var all = []; |
2922 |
12 Nov 14 |
nicklas |
submitInfo.rnaqc = all; |
2922 |
12 Nov 14 |
nicklas |
178 |
|
2922 |
12 Nov 14 |
nicklas |
for (var rnaNo = 0; rnaNo < selectedRnaQc.length; rnaNo++) |
2922 |
12 Nov 14 |
nicklas |
180 |
{ |
2922 |
12 Nov 14 |
nicklas |
var rna = selectedRnaQc[rnaNo]; |
2922 |
12 Nov 14 |
nicklas |
var tmp = {}; |
2922 |
12 Nov 14 |
nicklas |
183 |
|
2922 |
12 Nov 14 |
nicklas |
tmp.id = rna.id; |
2922 |
12 Nov 14 |
nicklas |
tmp.rin = parseFloat(frm['rin.'+rnaNo].value); |
2922 |
12 Nov 14 |
nicklas |
tmp.comment = frm['comment.'+rnaNo].value; |
2922 |
12 Nov 14 |
nicklas |
187 |
|
2922 |
12 Nov 14 |
nicklas |
all[all.length] = tmp; |
2922 |
12 Nov 14 |
nicklas |
189 |
} |
2922 |
12 Nov 14 |
nicklas |
190 |
|
2922 |
12 Nov 14 |
nicklas |
var url = '../RnaQc.servlet?ID='+App.getSessionId(); |
2922 |
12 Nov 14 |
nicklas |
url += '&cmd=RegisterRinValues'; |
2922 |
12 Nov 14 |
nicklas |
Wizard.showLoadingAnimation('Performing registration...'); |
2922 |
12 Nov 14 |
nicklas |
Wizard.asyncJsonRequest(url, rnaqc.submissionResults, 'POST', JSON.stringify(submitInfo)); |
2922 |
12 Nov 14 |
nicklas |
195 |
} |
2922 |
12 Nov 14 |
nicklas |
196 |
|
2922 |
12 Nov 14 |
nicklas |
rnaqc.submissionResults = function(response) |
2922 |
12 Nov 14 |
nicklas |
198 |
{ |
2922 |
12 Nov 14 |
nicklas |
Wizard.showFinalMessage(response.messages); |
2922 |
12 Nov 14 |
nicklas |
Doc.show('gorestart'); |
2922 |
12 Nov 14 |
nicklas |
201 |
} |
2922 |
12 Nov 14 |
nicklas |
return rnaqc; |
2922 |
12 Nov 14 |
nicklas |
203 |
}(); |
2922 |
12 Nov 14 |
nicklas |
204 |
|
2922 |
12 Nov 14 |
nicklas |
Doc.onLoad(RnaQcExport.initPage); |
2922 |
12 Nov 14 |
nicklas |
206 |
|