-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #182 from sanger/GPL-547-times-out-when-scanning
Gpl 547 times out when scanning
- Loading branch information
Showing
2 changed files
with
24 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,21 @@ | ||
%label{ :for => "source_plates" } Source plates | ||
%label{ :for => "source_plates" } Source plates (20 max.) | ||
= text_area_tag "source_plates", '', :rows => 5,:cols => 17 | ||
.live_results#barcodes_scanned 0 barcodes | ||
|
||
:javascript | ||
$('#source_plates').focus(); | ||
$('#source_plates').trigger('change'); | ||
$('#source_plates').focus(); | ||
$('#source_plates').trigger('change'); | ||
$('#source_plates').keyup(recalcNumBarcodes); | ||
|
||
function recalcNumBarcodes(){ | ||
const num_barcodes = find_number_barcodes($('#source_plates').val()); | ||
const colour = num_barcodes > 20 ? 'red' : 'black'; | ||
|
||
$('#barcodes_scanned').text(num_barcodes + ' barcodes').css('color', colour); | ||
} | ||
|
||
function find_number_barcodes(text){ | ||
const barcodes_list_no_blanks = text.split(/\s+/).filter(barcode => Boolean(barcode)); | ||
const barcodes_list_unique = [...new Set(barcodes_list_no_blanks)]; | ||
return barcodes_list_unique.length; | ||
} |