2795 |
13 Oct 14 |
nicklas |
var Barcode = function() |
2795 |
13 Oct 14 |
nicklas |
2 |
{ |
2795 |
13 Oct 14 |
nicklas |
var barcode = {}; |
2853 |
23 Oct 14 |
nicklas |
var debug = 0; |
2795 |
13 Oct 14 |
nicklas |
5 |
|
2795 |
13 Oct 14 |
nicklas |
var barcodesByName = []; |
2795 |
13 Oct 14 |
nicklas |
7 |
|
2795 |
13 Oct 14 |
nicklas |
// Page initialization |
2795 |
13 Oct 14 |
nicklas |
barcode.initPage = function() |
2795 |
13 Oct 14 |
nicklas |
10 |
{ |
2795 |
13 Oct 14 |
nicklas |
// Step 1 |
2795 |
13 Oct 14 |
nicklas |
Events.addEventHandler('step-1', 'wizard-validate', barcode.validateStep1); |
2795 |
13 Oct 14 |
nicklas |
Events.addEventHandler('bioplate', 'change', barcode.bioPlateOnChange); |
2795 |
13 Oct 14 |
nicklas |
14 |
|
2795 |
13 Oct 14 |
nicklas |
// Step 2 |
2795 |
13 Oct 14 |
nicklas |
Events.addEventHandler('step-2', 'wizard-initialize', barcode.initializeStep2); |
2795 |
13 Oct 14 |
nicklas |
Events.addEventHandler('step-2', 'wizard-validate', barcode.validateStep2); |
2795 |
13 Oct 14 |
nicklas |
Events.addEventHandler('pool_schema', 'change', barcode.poolSchemaOnChange); |
2795 |
13 Oct 14 |
nicklas |
Events.addEventHandler('barcode_variant', 'change', barcode.barcodeVariantOnChange); |
2795 |
13 Oct 14 |
nicklas |
var wells = document.getElementsByClassName('well'); |
2795 |
13 Oct 14 |
nicklas |
for (var wellNo = 0; wellNo < wells.length; wellNo++) |
2795 |
13 Oct 14 |
nicklas |
22 |
{ |
2795 |
13 Oct 14 |
nicklas |
Events.addEventHandler(wells[wellNo], 'click', barcode.selectBarcode); |
2795 |
13 Oct 14 |
nicklas |
24 |
} |
2795 |
13 Oct 14 |
nicklas |
Events.addEventHandler('select-barcode', 'click', barcode.barcodeSelected); |
2795 |
13 Oct 14 |
nicklas |
Events.addEventHandler('wizard', 'click', barcode.hideBarcodeSelection); |
2795 |
13 Oct 14 |
nicklas |
27 |
|
2795 |
13 Oct 14 |
nicklas |
// Navigation |
2795 |
13 Oct 14 |
nicklas |
Buttons.addClickHandler('gocancel', Wizard.cancelWizard); |
2795 |
13 Oct 14 |
nicklas |
Buttons.addClickHandler('gorestart', Wizard.restartWizard); |
2795 |
13 Oct 14 |
nicklas |
Buttons.addClickHandler('gonext', Wizard.goNextOnClick); |
2795 |
13 Oct 14 |
nicklas |
Buttons.addClickHandler('goregister', Wizard.goRegister); |
2795 |
13 Oct 14 |
nicklas |
33 |
|
2795 |
13 Oct 14 |
nicklas |
// Final registration |
2795 |
13 Oct 14 |
nicklas |
Events.addEventHandler('wizard', 'wizard-submit', barcode.submit); |
2795 |
13 Oct 14 |
nicklas |
36 |
|
2795 |
13 Oct 14 |
nicklas |
var url = '../LibPrep.servlet?ID='+App.getSessionId(); |
2795 |
13 Oct 14 |
nicklas |
url += '&cmd=GetCDNAPlatesForBarcoding'; |
2795 |
13 Oct 14 |
nicklas |
Wizard.showLoadingAnimation('Loading cDNA plates...'); |
2795 |
13 Oct 14 |
nicklas |
Wizard.asyncJsonRequest(url, barcode.initializeStep1); |
2795 |
13 Oct 14 |
nicklas |
41 |
|
2795 |
13 Oct 14 |
nicklas |
var url = '../LibPrep.servlet?ID='+App.getSessionId(); |
5866 |
13 Mar 20 |
nicklas |
url += '&cmd=GetAllBarcodeInfo&pipeline=RNA_SEQ&barcodeSet=TRUSEQ_SINGLE'; |
2795 |
13 Oct 14 |
nicklas |
Wizard.asyncJsonRequest(url, barcode.barcodesLoaded); |
2795 |
13 Oct 14 |
nicklas |
45 |
} |
2795 |
13 Oct 14 |
nicklas |
46 |
|
2795 |
13 Oct 14 |
nicklas |
47 |
|
2795 |
13 Oct 14 |
nicklas |
barcode.initializeStep1 = function(response) |
2795 |
13 Oct 14 |
nicklas |
49 |
{ |
2795 |
13 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2795 |
13 Oct 14 |
nicklas |
51 |
|
2795 |
13 Oct 14 |
nicklas |
var bioplates = response.bioplates; |
2795 |
13 Oct 14 |
nicklas |
var plates = frm.bioplate; |
2795 |
13 Oct 14 |
nicklas |
if (bioplates.length > 0) |
2795 |
13 Oct 14 |
nicklas |
55 |
{ |
2795 |
13 Oct 14 |
nicklas |
for (var i=0; i < bioplates.length; i++) |
2795 |
13 Oct 14 |
nicklas |
57 |
{ |
2795 |
13 Oct 14 |
nicklas |
var bioplate = bioplates[i]; |
2795 |
13 Oct 14 |
nicklas |
var option = new Option(bioplate.name, bioplate.id); |
2795 |
13 Oct 14 |
nicklas |
option.bioplate = bioplate; |
2795 |
13 Oct 14 |
nicklas |
plates.options[plates.length] = option; |
2795 |
13 Oct 14 |
nicklas |
62 |
} |
2795 |
13 Oct 14 |
nicklas |
63 |
} |
2795 |
13 Oct 14 |
nicklas |
else |
2795 |
13 Oct 14 |
nicklas |
65 |
{ |
2795 |
13 Oct 14 |
nicklas |
Wizard.setFatalError('No cDNA bioplates available for processing.'); |
2795 |
13 Oct 14 |
nicklas |
return; |
2795 |
13 Oct 14 |
nicklas |
68 |
} |
2795 |
13 Oct 14 |
nicklas |
69 |
|
2795 |
13 Oct 14 |
nicklas |
bioplateIsValid = true; |
2795 |
13 Oct 14 |
nicklas |
Wizard.setInputStatus('bioplate', 'valid'); |
2795 |
13 Oct 14 |
nicklas |
Events.sendChangeEvent('bioplate'); |
2795 |
13 Oct 14 |
nicklas |
73 |
|
2795 |
13 Oct 14 |
nicklas |
Doc.show('step-1'); |
2795 |
13 Oct 14 |
nicklas |
Doc.show('gonext'); |
2795 |
13 Oct 14 |
nicklas |
76 |
} |
2795 |
13 Oct 14 |
nicklas |
77 |
|
2795 |
13 Oct 14 |
nicklas |
barcode.bioPlateOnChange = function() |
2795 |
13 Oct 14 |
nicklas |
79 |
{ |
2795 |
13 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2795 |
13 Oct 14 |
nicklas |
var bioplate = frm.bioplate[frm.bioplate.selectedIndex].bioplate; |
2795 |
13 Oct 14 |
nicklas |
Doc.element('cdnaComments').innerHTML = Strings.encodeTags(bioplate.comments); |
2795 |
13 Oct 14 |
nicklas |
83 |
} |
2795 |
13 Oct 14 |
nicklas |
84 |
|
2795 |
13 Oct 14 |
nicklas |
barcode.barcodesLoaded = function(response) |
2795 |
13 Oct 14 |
nicklas |
86 |
{ |
2795 |
13 Oct 14 |
nicklas |
var barcodes = response.barcodes |
2795 |
13 Oct 14 |
nicklas |
var selectBarcodeHtml = ''; |
2795 |
13 Oct 14 |
nicklas |
89 |
|
2795 |
13 Oct 14 |
nicklas |
for (var i = 0; i < barcodes.length; i++) |
2795 |
13 Oct 14 |
nicklas |
91 |
{ |
2795 |
13 Oct 14 |
nicklas |
if (i % 8 == 0 && i > 0) |
2795 |
13 Oct 14 |
nicklas |
93 |
{ |
2795 |
13 Oct 14 |
nicklas |
selectBarcodeHtml += '<div class="menuseparator"></div>'; |
2795 |
13 Oct 14 |
nicklas |
95 |
} |
2795 |
13 Oct 14 |
nicklas |
var barcode = barcodes[i]; |
2795 |
13 Oct 14 |
nicklas |
barcodesByName[barcode.name] = barcode; |
3026 |
11 Dec 14 |
nicklas |
selectBarcodeHtml += '<div class="menuitem interactable enabled" id="bc-'+barcode.id+'" data-barcode-name="'+Strings.encodeTags(barcode.name)+'">'; |
2795 |
13 Oct 14 |
nicklas |
selectBarcodeHtml += Strings.encodeTags(barcode.name)+'</div>'; |
2795 |
13 Oct 14 |
nicklas |
100 |
} |
2795 |
13 Oct 14 |
nicklas |
Doc.element('select-barcode-all').innerHTML = selectBarcodeHtml; |
2795 |
13 Oct 14 |
nicklas |
102 |
} |
2795 |
13 Oct 14 |
nicklas |
103 |
|
2795 |
13 Oct 14 |
nicklas |
barcode.validateStep1 = function(event) |
2795 |
13 Oct 14 |
nicklas |
105 |
{} |
2795 |
13 Oct 14 |
nicklas |
106 |
|
2795 |
13 Oct 14 |
nicklas |
barcode.initializeStep2 = function() |
2795 |
13 Oct 14 |
nicklas |
108 |
{ |
2795 |
13 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2795 |
13 Oct 14 |
nicklas |
110 |
|
2795 |
13 Oct 14 |
nicklas |
var url = '../LibPrep.servlet?ID='+App.getSessionId(); |
2795 |
13 Oct 14 |
nicklas |
url += '&cmd=GetCDnaInfoForPlate&bioplate='+frm.bioplate.value; |
2795 |
13 Oct 14 |
nicklas |
Wizard.showLoadingAnimation('Loading cDNA bioplate information...'); |
2795 |
13 Oct 14 |
nicklas |
Wizard.asyncJsonRequest(url, barcode.cdnaInfoLoaded); |
2795 |
13 Oct 14 |
nicklas |
115 |
} |
2795 |
13 Oct 14 |
nicklas |
116 |
|
2795 |
13 Oct 14 |
nicklas |
barcode.cdnaInfoLoaded = function(response) |
2795 |
13 Oct 14 |
nicklas |
118 |
{ |
2795 |
13 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2795 |
13 Oct 14 |
nicklas |
var cdnaPlate = frm.bioplate[frm.bioplate.selectedIndex].bioplate; |
2795 |
13 Oct 14 |
nicklas |
121 |
|
2795 |
13 Oct 14 |
nicklas |
var schema = PoolSchema.getById(cdnaPlate.poolSchema); |
3289 |
30 Apr 15 |
nicklas |
PoolSchema.initList(frm.pool_schema, schema.id, 'manual'); |
2795 |
13 Oct 14 |
nicklas |
PoolSchema.initVariantList(frm.barcode_variant, schema, cdnaPlate.barcodeVariant); |
2795 |
13 Oct 14 |
nicklas |
125 |
|
2795 |
13 Oct 14 |
nicklas |
var list = response.cdna; |
2795 |
13 Oct 14 |
nicklas |
// Pre-process the return cDNA items |
2795 |
13 Oct 14 |
nicklas |
for (var i = 0; i < list.length; i++) |
2795 |
13 Oct 14 |
nicklas |
129 |
{ |
2795 |
13 Oct 14 |
nicklas |
barcode.checkAndPreProcessCDna(list[i]); |
2795 |
13 Oct 14 |
nicklas |
131 |
} |
2795 |
13 Oct 14 |
nicklas |
132 |
|
2795 |
13 Oct 14 |
nicklas |
barcode.viewAsPlate(list, schema); |
2795 |
13 Oct 14 |
nicklas |
Wizard.keepSessionAlive(); |
2795 |
13 Oct 14 |
nicklas |
135 |
|
2795 |
13 Oct 14 |
nicklas |
Wizard.setCurrentStep(2); |
2795 |
13 Oct 14 |
nicklas |
Doc.show('goregister'); |
2795 |
13 Oct 14 |
nicklas |
Doc.show('gocancel'); |
2795 |
13 Oct 14 |
nicklas |
139 |
} |
2795 |
13 Oct 14 |
nicklas |
140 |
|
2795 |
13 Oct 14 |
nicklas |
141 |
|
2795 |
13 Oct 14 |
nicklas |
barcode.checkAndPreProcessCDna = function(cdna) |
2795 |
13 Oct 14 |
nicklas |
143 |
{ |
2795 |
13 Oct 14 |
nicklas |
// Set the 'stratagene'/'external' flag |
2795 |
13 Oct 14 |
nicklas |
cdna.stratagene = Reggie.isStratagene(cdna.name); |
2795 |
13 Oct 14 |
nicklas |
cdna.external = Reggie.isExternal(cdna.name); |
3760 |
19 Feb 16 |
nicklas |
cdna.isYellow = cdna.specimen && cdna.specimen.YellowLabel != null; |
2795 |
13 Oct 14 |
nicklas |
148 |
} |
2795 |
13 Oct 14 |
nicklas |
149 |
|
2795 |
13 Oct 14 |
nicklas |
barcode.viewAsPlate = function(list, schema) |
2795 |
13 Oct 14 |
nicklas |
151 |
{ |
2795 |
13 Oct 14 |
nicklas |
Plate.init(8, 12, schema, WellPainter); |
2795 |
13 Oct 14 |
nicklas |
153 |
|
2795 |
13 Oct 14 |
nicklas |
for (var i = 0; i < list.length; i++) |
2795 |
13 Oct 14 |
nicklas |
155 |
{ |
2795 |
13 Oct 14 |
nicklas |
var cdna = list[i]; |
2795 |
13 Oct 14 |
nicklas |
var well = cdna.bioWell; |
2795 |
13 Oct 14 |
nicklas |
Plate.getWell(well.row, well.column).setExtract(cdna); |
2795 |
13 Oct 14 |
nicklas |
159 |
} |
2795 |
13 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2795 |
13 Oct 14 |
nicklas |
161 |
|
2795 |
13 Oct 14 |
nicklas |
var barcodeVariant = PoolSchema.getBarcodeVariantByName(schema, frm.barcode_variant.value); |
2795 |
13 Oct 14 |
nicklas |
barcode.assignSchemaDefinedBarcodeVariant(schema, barcodeVariant); |
2795 |
13 Oct 14 |
nicklas |
164 |
|
2795 |
13 Oct 14 |
nicklas |
WellPainter.barcodeVariant = barcodeVariant; |
2795 |
13 Oct 14 |
nicklas |
Plate.paint(Plate.getWells()); |
2795 |
13 Oct 14 |
nicklas |
PoolSchema.buildPoolTableRow(schema, 12, false); |
2795 |
13 Oct 14 |
nicklas |
168 |
} |
2795 |
13 Oct 14 |
nicklas |
169 |
|
2795 |
13 Oct 14 |
nicklas |
barcode.assignSchemaDefinedBarcodeVariant = function(schema, barcodeVariant) |
2795 |
13 Oct 14 |
nicklas |
171 |
{ |
2795 |
13 Oct 14 |
nicklas |
var wells = Plate.getWells(); |
2795 |
13 Oct 14 |
nicklas |
for (var i = 0; i < wells.length; i++) |
2795 |
13 Oct 14 |
nicklas |
174 |
{ |
2795 |
13 Oct 14 |
nicklas |
var well = wells[i]; |
2795 |
13 Oct 14 |
nicklas |
var cdna = well.extract; |
2795 |
13 Oct 14 |
nicklas |
if (cdna) |
2795 |
13 Oct 14 |
nicklas |
178 |
{ |
2795 |
13 Oct 14 |
nicklas |
var indexSet = barcodeVariant ? barcodeVariant.indexSets[well.column] : null; |
2795 |
13 Oct 14 |
nicklas |
var barcode = null; |
2795 |
13 Oct 14 |
nicklas |
if (indexSet) |
2795 |
13 Oct 14 |
nicklas |
182 |
{ |
2795 |
13 Oct 14 |
nicklas |
var barcodeName = indexSet.barcodes[well.row]; |
2795 |
13 Oct 14 |
nicklas |
barcode = barcodesByName[barcodeName]; |
2795 |
13 Oct 14 |
nicklas |
185 |
} |
2795 |
13 Oct 14 |
nicklas |
cdna.barcode = barcode; |
2795 |
13 Oct 14 |
nicklas |
cdna.defaultBarcode = barcode; |
2795 |
13 Oct 14 |
nicklas |
well.duplicate = false; |
2795 |
13 Oct 14 |
nicklas |
189 |
} |
2795 |
13 Oct 14 |
nicklas |
190 |
} |
2795 |
13 Oct 14 |
nicklas |
191 |
} |
2795 |
13 Oct 14 |
nicklas |
192 |
|
2795 |
13 Oct 14 |
nicklas |
barcode.poolSchemaOnChange = function() |
2795 |
13 Oct 14 |
nicklas |
194 |
{ |
2795 |
13 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
3289 |
30 Apr 15 |
nicklas |
var schema = PoolSchema.getById(frm.pool_schema.value); |
2795 |
13 Oct 14 |
nicklas |
Plate.setPoolSchema(schema); |
2795 |
13 Oct 14 |
nicklas |
PoolSchema.initVariantList(frm.barcode_variant, schema); |
2795 |
13 Oct 14 |
nicklas |
199 |
|
2795 |
13 Oct 14 |
nicklas |
var barcodeVariant = PoolSchema.getBarcodeVariantByName(schema, frm.barcode_variant.value); |
2795 |
13 Oct 14 |
nicklas |
barcode.assignSchemaDefinedBarcodeVariant(schema, barcodeVariant); |
2795 |
13 Oct 14 |
nicklas |
202 |
|
2795 |
13 Oct 14 |
nicklas |
WellPainter.barcodeVariant = barcodeVariant; |
2795 |
13 Oct 14 |
nicklas |
Plate.paint(Plate.getWells()); |
2795 |
13 Oct 14 |
nicklas |
PoolSchema.buildPoolTableRow(schema, 12, false); |
2795 |
13 Oct 14 |
nicklas |
206 |
} |
2795 |
13 Oct 14 |
nicklas |
207 |
|
2795 |
13 Oct 14 |
nicklas |
barcode.barcodeVariantOnChange = function() |
2795 |
13 Oct 14 |
nicklas |
209 |
{ |
2795 |
13 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
3289 |
30 Apr 15 |
nicklas |
var schema = PoolSchema.getById(frm.pool_schema.value); |
2795 |
13 Oct 14 |
nicklas |
var barcodeVariant = PoolSchema.getBarcodeVariantByName(schema, frm.barcode_variant.value); |
2795 |
13 Oct 14 |
nicklas |
213 |
|
2795 |
13 Oct 14 |
nicklas |
barcode.assignSchemaDefinedBarcodeVariant(schema, barcodeVariant); |
2795 |
13 Oct 14 |
nicklas |
215 |
|
2795 |
13 Oct 14 |
nicklas |
WellPainter.barcodeVariant = barcodeVariant; |
2795 |
13 Oct 14 |
nicklas |
Plate.paint(Plate.getWells()); |
2795 |
13 Oct 14 |
nicklas |
218 |
} |
2795 |
13 Oct 14 |
nicklas |
219 |
|
2795 |
13 Oct 14 |
nicklas |
var currentWell; |
2795 |
13 Oct 14 |
nicklas |
var lastSelectedBarcode; |
2795 |
13 Oct 14 |
nicklas |
barcode.selectBarcode = function(event) |
2795 |
13 Oct 14 |
nicklas |
223 |
{ |
2795 |
13 Oct 14 |
nicklas |
var row = Data.int(event.currentTarget, 'row'); |
2795 |
13 Oct 14 |
nicklas |
var column = Data.int(event.currentTarget, 'col'); |
2795 |
13 Oct 14 |
nicklas |
226 |
|
2795 |
13 Oct 14 |
nicklas |
// Locate the barcode selection div so that the current |
2795 |
13 Oct 14 |
nicklas |
// barcode is positioned next to the current mouse position |
2795 |
13 Oct 14 |
nicklas |
// Initially set it to the right of the mouse so that the |
2795 |
13 Oct 14 |
nicklas |
// center is vertically aligned |
2795 |
13 Oct 14 |
nicklas |
231 |
|
2795 |
13 Oct 14 |
nicklas |
currentWell = Plate.getWell(row, column); |
2795 |
13 Oct 14 |
nicklas |
var cdna = currentWell.extract; |
2795 |
13 Oct 14 |
nicklas |
var scroll = 0; |
2795 |
13 Oct 14 |
nicklas |
if (cdna) |
2795 |
13 Oct 14 |
nicklas |
236 |
{ |
2795 |
13 Oct 14 |
nicklas |
// Reset 'current' selection |
2795 |
13 Oct 14 |
nicklas |
var menu = Doc.element('select-barcode'); |
2795 |
13 Oct 14 |
nicklas |
var selectAll = Doc.element('select-barcode-all'); |
2795 |
13 Oct 14 |
nicklas |
for (var i = 0; i < selectAll.childNodes.length; i++) |
2795 |
13 Oct 14 |
nicklas |
241 |
{ |
2795 |
13 Oct 14 |
nicklas |
Doc.removeClass(selectAll.childNodes[i], 'current'); |
2795 |
13 Oct 14 |
nicklas |
243 |
} |
2795 |
13 Oct 14 |
nicklas |
menu.style.display = 'block'; |
2795 |
13 Oct 14 |
nicklas |
245 |
|
2795 |
13 Oct 14 |
nicklas |
var x = event.clientX+1; |
2795 |
13 Oct 14 |
nicklas |
var halfHeight = Math.floor(selectAll.offsetHeight/2) |
2795 |
13 Oct 14 |
nicklas |
var y = event.clientY-halfHeight; |
2795 |
13 Oct 14 |
nicklas |
var scroll = 0; |
2795 |
13 Oct 14 |
nicklas |
var barcodeDiv; |
2795 |
13 Oct 14 |
nicklas |
251 |
|
2795 |
13 Oct 14 |
nicklas |
var useBarcode = cdna.barcode || lastSelectedBarcode; |
2795 |
13 Oct 14 |
nicklas |
if (useBarcode) |
2795 |
13 Oct 14 |
nicklas |
254 |
{ |
2795 |
13 Oct 14 |
nicklas |
var barcodeDiv = Doc.element('bc-'+useBarcode.id); |
2795 |
13 Oct 14 |
nicklas |
if (!cdna.barcode && barcodeDiv.nextSibling) barcodeDiv = barcodeDiv.nextSibling; |
2795 |
13 Oct 14 |
nicklas |
// Try to scroll the current barcode so that it's baseline is at the center of the div |
2795 |
13 Oct 14 |
nicklas |
scroll = barcodeDiv.offsetTop + barcodeDiv.offsetHeight - halfHeight; |
2795 |
13 Oct 14 |
nicklas |
if (scroll < 0) |
2795 |
13 Oct 14 |
nicklas |
260 |
{ |
2795 |
13 Oct 14 |
nicklas |
// We get a negative scroll for the first few elements, shift the |
2795 |
13 Oct 14 |
nicklas |
// entire selection div down instead |
2795 |
13 Oct 14 |
nicklas |
y -= scroll; |
2795 |
13 Oct 14 |
nicklas |
scroll = 0; |
2795 |
13 Oct 14 |
nicklas |
265 |
} |
2795 |
13 Oct 14 |
nicklas |
else if (scroll > selectAll.scrollHeight - selectAll.offsetHeight) |
2795 |
13 Oct 14 |
nicklas |
267 |
{ |
2795 |
13 Oct 14 |
nicklas |
// We get a too large scroll value for the last few elements, shift |
2795 |
13 Oct 14 |
nicklas |
// the entire selection div up instead |
2795 |
13 Oct 14 |
nicklas |
y -= scroll - (selectAll.scrollHeight - selectAll.offsetHeight); |
2795 |
13 Oct 14 |
nicklas |
scroll = selectAll.scrollHeight - selectAll.offsetHeight; |
2795 |
13 Oct 14 |
nicklas |
272 |
} |
2795 |
13 Oct 14 |
nicklas |
if (cdna.barcode) |
2795 |
13 Oct 14 |
nicklas |
274 |
{ |
2795 |
13 Oct 14 |
nicklas |
Doc.addClass(barcodeDiv, 'current'); |
2795 |
13 Oct 14 |
nicklas |
276 |
} |
2795 |
13 Oct 14 |
nicklas |
277 |
} |
2795 |
13 Oct 14 |
nicklas |
278 |
|
2795 |
13 Oct 14 |
nicklas |
// Default barcode |
2795 |
13 Oct 14 |
nicklas |
if (cdna.defaultBarcode && cdna.defaultBarcode != cdna.barcode) |
2795 |
13 Oct 14 |
nicklas |
281 |
{ |
2795 |
13 Oct 14 |
nicklas |
var selectDefault = Doc.element('select-barcode-default'); |
2795 |
13 Oct 14 |
nicklas |
Data.set(selectDefault, 'barcode-name', cdna.defaultBarcode.name); |
2795 |
13 Oct 14 |
nicklas |
selectDefault.innerHTML = 'Default: ' + Strings.encodeTags(cdna.defaultBarcode.name); |
2795 |
13 Oct 14 |
nicklas |
Doc.show('select-barcode-default'); |
2795 |
13 Oct 14 |
nicklas |
Doc.show('select-barcode-default-separator'); |
2795 |
13 Oct 14 |
nicklas |
287 |
} |
2795 |
13 Oct 14 |
nicklas |
else |
2795 |
13 Oct 14 |
nicklas |
289 |
{ |
2795 |
13 Oct 14 |
nicklas |
Doc.hide('select-barcode-default'); |
2795 |
13 Oct 14 |
nicklas |
Doc.hide('select-barcode-default-separator'); |
2795 |
13 Oct 14 |
nicklas |
292 |
} |
2795 |
13 Oct 14 |
nicklas |
293 |
|
2795 |
13 Oct 14 |
nicklas |
// Position the selection div |
2795 |
13 Oct 14 |
nicklas |
selectAll.scrollTop = scroll; |
2795 |
13 Oct 14 |
nicklas |
menu.style.left = (x)+'px'; |
2795 |
13 Oct 14 |
nicklas |
menu.style.top = (y)+'px'; |
2795 |
13 Oct 14 |
nicklas |
event.stopPropagation(); |
2795 |
13 Oct 14 |
nicklas |
299 |
} |
2795 |
13 Oct 14 |
nicklas |
300 |
} |
2795 |
13 Oct 14 |
nicklas |
301 |
|
2795 |
13 Oct 14 |
nicklas |
barcode.barcodeSelected = function(event) |
2795 |
13 Oct 14 |
nicklas |
303 |
{ |
2795 |
13 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
3289 |
30 Apr 15 |
nicklas |
var schema = PoolSchema.getById(frm.pool_schema.value); |
2795 |
13 Oct 14 |
nicklas |
var target = event.target; |
2795 |
13 Oct 14 |
nicklas |
if (currentWell && currentWell.extract) |
2795 |
13 Oct 14 |
nicklas |
308 |
{ |
2795 |
13 Oct 14 |
nicklas |
lastSelectedBarcode = barcodesByName[Data.get(target, 'barcode-name')]; |
2795 |
13 Oct 14 |
nicklas |
currentWell.extract.barcode = lastSelectedBarcode; |
2795 |
13 Oct 14 |
nicklas |
var poolNum = schema.getPoolNumForColumn(currentWell.column); |
2795 |
13 Oct 14 |
nicklas |
if (poolNum >= 0) |
2795 |
13 Oct 14 |
nicklas |
313 |
{ |
2795 |
13 Oct 14 |
nicklas |
barcode.checkDuplicateBarcode(poolNum); |
2795 |
13 Oct 14 |
nicklas |
Plate.paint(schema.getWellsInPool(Plate, poolNum)); |
2795 |
13 Oct 14 |
nicklas |
316 |
} |
2795 |
13 Oct 14 |
nicklas |
else |
2795 |
13 Oct 14 |
nicklas |
318 |
{ |
2795 |
13 Oct 14 |
nicklas |
Plate.paint([currentWell]); |
2795 |
13 Oct 14 |
nicklas |
320 |
} |
2795 |
13 Oct 14 |
nicklas |
321 |
} |
2795 |
13 Oct 14 |
nicklas |
322 |
} |
2795 |
13 Oct 14 |
nicklas |
323 |
|
2795 |
13 Oct 14 |
nicklas |
barcode.hideBarcodeSelection = function() |
2795 |
13 Oct 14 |
nicklas |
325 |
{ |
2795 |
13 Oct 14 |
nicklas |
Doc.hide('select-barcode'); |
2795 |
13 Oct 14 |
nicklas |
327 |
} |
2795 |
13 Oct 14 |
nicklas |
328 |
|
2795 |
13 Oct 14 |
nicklas |
barcode.checkDuplicateBarcode = function(poolNum) |
2795 |
13 Oct 14 |
nicklas |
330 |
{ |
2795 |
13 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
3289 |
30 Apr 15 |
nicklas |
var schema = PoolSchema.getById(frm.pool_schema.value); |
2795 |
13 Oct 14 |
nicklas |
333 |
|
2795 |
13 Oct 14 |
nicklas |
var wells = schema.getWellsInPool(Plate, poolNum); |
2795 |
13 Oct 14 |
nicklas |
var wellByBarcodeName = []; |
2795 |
13 Oct 14 |
nicklas |
for (var i = 0; i < wells.length; i++) |
2795 |
13 Oct 14 |
nicklas |
337 |
{ |
2795 |
13 Oct 14 |
nicklas |
var well = wells[i]; |
2795 |
13 Oct 14 |
nicklas |
var cdna = well.extract; |
2795 |
13 Oct 14 |
nicklas |
if (cdna && cdna.barcode) |
2795 |
13 Oct 14 |
nicklas |
341 |
{ |
2795 |
13 Oct 14 |
nicklas |
if (wellByBarcodeName[cdna.barcode.name]) |
2795 |
13 Oct 14 |
nicklas |
343 |
{ |
2795 |
13 Oct 14 |
nicklas |
well.duplicate = true; |
2795 |
13 Oct 14 |
nicklas |
wellByBarcodeName[cdna.barcode.name].duplicate = true; |
2795 |
13 Oct 14 |
nicklas |
346 |
} |
2795 |
13 Oct 14 |
nicklas |
else |
2795 |
13 Oct 14 |
nicklas |
348 |
{ |
2795 |
13 Oct 14 |
nicklas |
wellByBarcodeName[cdna.barcode.name] = well; |
2795 |
13 Oct 14 |
nicklas |
well.duplicate = false; |
2795 |
13 Oct 14 |
nicklas |
351 |
} |
2795 |
13 Oct 14 |
nicklas |
352 |
} |
2795 |
13 Oct 14 |
nicklas |
353 |
} |
2795 |
13 Oct 14 |
nicklas |
354 |
} |
2795 |
13 Oct 14 |
nicklas |
355 |
|
2795 |
13 Oct 14 |
nicklas |
barcode.validateStep2 = function(event) |
2795 |
13 Oct 14 |
nicklas |
357 |
{ |
2795 |
13 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2795 |
13 Oct 14 |
nicklas |
359 |
|
2795 |
13 Oct 14 |
nicklas |
var wells = Plate.getWells(); |
2795 |
13 Oct 14 |
nicklas |
var numErrors = 0; |
2795 |
13 Oct 14 |
nicklas |
var numWarnings = 0; |
2795 |
13 Oct 14 |
nicklas |
var numCdna = 0; |
2795 |
13 Oct 14 |
nicklas |
for (var i = 0; i < wells.length; i++) |
2795 |
13 Oct 14 |
nicklas |
365 |
{ |
2795 |
13 Oct 14 |
nicklas |
var well = wells[i]; |
2795 |
13 Oct 14 |
nicklas |
if (well.hasWarning()) |
2795 |
13 Oct 14 |
nicklas |
368 |
{ |
2795 |
13 Oct 14 |
nicklas |
numWarnings++; |
2795 |
13 Oct 14 |
nicklas |
370 |
} |
2795 |
13 Oct 14 |
nicklas |
if (well.hasError()) |
2795 |
13 Oct 14 |
nicklas |
372 |
{ |
2795 |
13 Oct 14 |
nicklas |
numErrors++; |
2795 |
13 Oct 14 |
nicklas |
374 |
} |
2795 |
13 Oct 14 |
nicklas |
else if (well.extract && well.extract.id) |
2795 |
13 Oct 14 |
nicklas |
376 |
{ |
2795 |
13 Oct 14 |
nicklas |
numCdna++; |
2795 |
13 Oct 14 |
nicklas |
378 |
} |
2795 |
13 Oct 14 |
nicklas |
379 |
} |
2795 |
13 Oct 14 |
nicklas |
380 |
|
2795 |
13 Oct 14 |
nicklas |
if (numErrors > 0) |
2795 |
13 Oct 14 |
nicklas |
382 |
{ |
2795 |
13 Oct 14 |
nicklas |
event.preventDefault(); |
2795 |
13 Oct 14 |
nicklas |
return; |
2795 |
13 Oct 14 |
nicklas |
385 |
} |
2795 |
13 Oct 14 |
nicklas |
else if (numCdna == 0) |
2795 |
13 Oct 14 |
nicklas |
387 |
{ |
2795 |
13 Oct 14 |
nicklas |
alert('There is no cDNA in any wells'); |
2795 |
13 Oct 14 |
nicklas |
event.preventDefault(); |
2795 |
13 Oct 14 |
nicklas |
return; |
2795 |
13 Oct 14 |
nicklas |
391 |
} |
2795 |
13 Oct 14 |
nicklas |
else if (numWarnings > 0) |
2795 |
13 Oct 14 |
nicklas |
393 |
{ |
2795 |
13 Oct 14 |
nicklas |
if (!frm.verifyGoNext || !frm.verifyGoNext.checked) |
2795 |
13 Oct 14 |
nicklas |
395 |
{ |
2795 |
13 Oct 14 |
nicklas |
Wizard.showGoNextConfirmation(true, 'There are ' + numWarnings + ' wells with a warning. Continue anyway?'); |
2795 |
13 Oct 14 |
nicklas |
event.preventDefault(); |
2795 |
13 Oct 14 |
nicklas |
398 |
} |
2795 |
13 Oct 14 |
nicklas |
399 |
} |
2795 |
13 Oct 14 |
nicklas |
400 |
} |
2795 |
13 Oct 14 |
nicklas |
401 |
|
2795 |
13 Oct 14 |
nicklas |
barcode.submit = function() |
2795 |
13 Oct 14 |
nicklas |
403 |
{ |
2795 |
13 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2795 |
13 Oct 14 |
nicklas |
405 |
|
2795 |
13 Oct 14 |
nicklas |
var submitInfo = {}; |
2795 |
13 Oct 14 |
nicklas |
var plateInfo = {}; |
2795 |
13 Oct 14 |
nicklas |
408 |
|
2795 |
13 Oct 14 |
nicklas |
submitInfo.bioplate = plateInfo; |
2795 |
13 Oct 14 |
nicklas |
plateInfo.id = parseInt(frm.bioplate.value); |
2795 |
13 Oct 14 |
nicklas |
plateInfo.poolSchema = frm.pool_schema.value; |
2795 |
13 Oct 14 |
nicklas |
plateInfo.barcodeVariant = frm.barcode_variant.value; |
2795 |
13 Oct 14 |
nicklas |
plateInfo.comments = frm.comments.value; |
2795 |
13 Oct 14 |
nicklas |
plateInfo.wells = []; |
2795 |
13 Oct 14 |
nicklas |
415 |
|
2795 |
13 Oct 14 |
nicklas |
var wells = Plate.getWells(); |
2795 |
13 Oct 14 |
nicklas |
for (var i = 0; i < wells.length; i++) |
2795 |
13 Oct 14 |
nicklas |
418 |
{ |
2795 |
13 Oct 14 |
nicklas |
var well = wells[i]; |
2795 |
13 Oct 14 |
nicklas |
if (well.extract && well.extract.id) |
2795 |
13 Oct 14 |
nicklas |
421 |
{ |
2795 |
13 Oct 14 |
nicklas |
var tmp = {}; |
2795 |
13 Oct 14 |
nicklas |
tmp.row = well.row; |
2795 |
13 Oct 14 |
nicklas |
tmp.column = well.column; |
2795 |
13 Oct 14 |
nicklas |
tmp.cdna = {}; |
2795 |
13 Oct 14 |
nicklas |
tmp.cdna.id = well.extract.id; |
2795 |
13 Oct 14 |
nicklas |
tmp.cdna.barcode = {}; |
2795 |
13 Oct 14 |
nicklas |
tmp.cdna.barcode.id = well.extract.barcode.id; |
2795 |
13 Oct 14 |
nicklas |
plateInfo.wells[plateInfo.wells.length] = tmp; |
2795 |
13 Oct 14 |
nicklas |
430 |
} |
2795 |
13 Oct 14 |
nicklas |
431 |
} |
2795 |
13 Oct 14 |
nicklas |
432 |
|
2795 |
13 Oct 14 |
nicklas |
var url = '../LibPrep.servlet?ID='+App.getSessionId(); |
2795 |
13 Oct 14 |
nicklas |
url += '&cmd=CreateBarcodedLibraries'; |
2795 |
13 Oct 14 |
nicklas |
Wizard.showLoadingAnimation('Performing registration...'); |
2795 |
13 Oct 14 |
nicklas |
Wizard.asyncJsonRequest(url, barcode.submissionResults, 'POST', JSON.stringify(submitInfo)); |
2795 |
13 Oct 14 |
nicklas |
437 |
} |
2795 |
13 Oct 14 |
nicklas |
438 |
|
2795 |
13 Oct 14 |
nicklas |
barcode.submissionResults = function(response) |
2795 |
13 Oct 14 |
nicklas |
440 |
{ |
2795 |
13 Oct 14 |
nicklas |
Wizard.showFinalMessage(response.messages); |
2795 |
13 Oct 14 |
nicklas |
Doc.show('gorestart'); |
2795 |
13 Oct 14 |
nicklas |
443 |
} |
2795 |
13 Oct 14 |
nicklas |
444 |
|
2795 |
13 Oct 14 |
nicklas |
return barcode; |
2795 |
13 Oct 14 |
nicklas |
446 |
}(); |
2795 |
13 Oct 14 |
nicklas |
447 |
|
2795 |
13 Oct 14 |
nicklas |
Doc.onLoad(Barcode.initPage); |
2795 |
13 Oct 14 |
nicklas |
449 |
|
2795 |
13 Oct 14 |
nicklas |
var WellPainter = function() |
2795 |
13 Oct 14 |
nicklas |
451 |
{ |
2795 |
13 Oct 14 |
nicklas |
var painter = {}; |
2795 |
13 Oct 14 |
nicklas |
453 |
|
2795 |
13 Oct 14 |
nicklas |
painter.getClassNameForWell = function(well, schema) |
2795 |
13 Oct 14 |
nicklas |
455 |
{ |
2795 |
13 Oct 14 |
nicklas |
var cls = ''; |
2795 |
13 Oct 14 |
nicklas |
var indexSet = painter.barcodeVariant ? painter.barcodeVariant.indexSets[well.column] : null; |
2795 |
13 Oct 14 |
nicklas |
if (indexSet) |
2795 |
13 Oct 14 |
nicklas |
459 |
{ |
2795 |
13 Oct 14 |
nicklas |
cls += indexSet.color; |
2795 |
13 Oct 14 |
nicklas |
461 |
} |
2795 |
13 Oct 14 |
nicklas |
var cdna = well.extract; |
2795 |
13 Oct 14 |
nicklas |
if (cdna && cdna.barcode) |
2795 |
13 Oct 14 |
nicklas |
464 |
{ |
2795 |
13 Oct 14 |
nicklas |
if (cdna.defaultBarcode && cdna.barcode != cdna.defaultBarcode) |
2795 |
13 Oct 14 |
nicklas |
466 |
{ |
2795 |
13 Oct 14 |
nicklas |
cls += ' bg-modified'; |
2795 |
13 Oct 14 |
nicklas |
468 |
} |
3760 |
19 Feb 16 |
nicklas |
if (cdna.isYellow) |
3760 |
19 Feb 16 |
nicklas |
470 |
{ |
3760 |
19 Feb 16 |
nicklas |
cls += ' yellow-specimen'; |
3760 |
19 Feb 16 |
nicklas |
472 |
} |
2795 |
13 Oct 14 |
nicklas |
473 |
} |
2795 |
13 Oct 14 |
nicklas |
if (well.duplicate) |
2795 |
13 Oct 14 |
nicklas |
475 |
{ |
2795 |
13 Oct 14 |
nicklas |
cls += ' duplicate'; |
2795 |
13 Oct 14 |
nicklas |
477 |
} |
2795 |
13 Oct 14 |
nicklas |
return cls; |
2795 |
13 Oct 14 |
nicklas |
479 |
} |
2795 |
13 Oct 14 |
nicklas |
480 |
|
2795 |
13 Oct 14 |
nicklas |
painter.getWellText = function(well, schema) |
2795 |
13 Oct 14 |
nicklas |
482 |
{ |
2795 |
13 Oct 14 |
nicklas |
var text = ''; |
2795 |
13 Oct 14 |
nicklas |
var cdna = well.extract; |
2795 |
13 Oct 14 |
nicklas |
if (cdna) |
2795 |
13 Oct 14 |
nicklas |
486 |
{ |
2795 |
13 Oct 14 |
nicklas |
var name = cdna.name; |
2795 |
13 Oct 14 |
nicklas |
var i = name.indexOf('.m'); |
3760 |
19 Feb 16 |
nicklas |
text += '<div class="name if-yellow">'+name.substring(0, i)+'.<br> '+name.substring(i)+'</div>'; |
2795 |
13 Oct 14 |
nicklas |
if (cdna.barcode) |
2795 |
13 Oct 14 |
nicklas |
491 |
{ |
2795 |
13 Oct 14 |
nicklas |
text += '<div class="barcode">'+cdna.barcode.name+'</div>'; |
2795 |
13 Oct 14 |
nicklas |
if (cdna.defaultBarcode && cdna.barcode != cdna.defaultBarcode) |
2795 |
13 Oct 14 |
nicklas |
494 |
{ |
2795 |
13 Oct 14 |
nicklas |
text += '<div class="warn-msg">Modified barcode</div>'; |
2795 |
13 Oct 14 |
nicklas |
496 |
} |
2795 |
13 Oct 14 |
nicklas |
497 |
} |
2795 |
13 Oct 14 |
nicklas |
else |
2795 |
13 Oct 14 |
nicklas |
499 |
{ |
2795 |
13 Oct 14 |
nicklas |
well.setError('No barcode'); |
2795 |
13 Oct 14 |
nicklas |
501 |
} |
2795 |
13 Oct 14 |
nicklas |
502 |
} |
2795 |
13 Oct 14 |
nicklas |
if (well.duplicate) |
2795 |
13 Oct 14 |
nicklas |
504 |
{ |
2795 |
13 Oct 14 |
nicklas |
well.setError('Duplicate barcode'); |
2795 |
13 Oct 14 |
nicklas |
506 |
} |
2795 |
13 Oct 14 |
nicklas |
return text; |
2795 |
13 Oct 14 |
nicklas |
508 |
} |
2795 |
13 Oct 14 |
nicklas |
509 |
|
2795 |
13 Oct 14 |
nicklas |
return painter; |
2795 |
13 Oct 14 |
nicklas |
511 |
}(); |
2795 |
13 Oct 14 |
nicklas |
512 |
|
2795 |
13 Oct 14 |
nicklas |
513 |
|