Class: BarcodeGenUPCA

BarcodeGenUPCA

new BarcodeGenUPCA(container, barcode_number, options)

Construct a new instance of a BarcodeGenUPCA to be displayed in the element specified by 'container' id. If a 'barcode_number' is provided then the actual barcode image will be rendered. The 'options' allow for the barcode to be customized. If no 'barcode_number' is provided then the image will not be rendered until one is assigned by calling set_barcode_number().
Parameters:
Name Type Argument Description
container string id of element to contain UPC image
barcode_number string <optional>
initial value
options Object <optional>
options hash to over-ride default values
Properties
Name Type Argument Default Description
display_outer_digits boolean <optional>
true determines whether the outer digits are displayed
Source:

Members

barcode_number :string

12 digit human-readable barcode
Type:
  • string
Source:

container :string

DOM ref of container to render barcode within (eg: '#my-container')
Type:
  • string
Source:

options

Configuration options
Properties:
Name Type Description
display_outer_digits boolean determines whether the outer digits are displayed
Source:

Methods

<static> get_check_digit(barcode_number) → {number}

Calculate and return the check-digit for the specified 11 digit 'barcode_number'. If 'barcode_number' is not numeric and exactly 11 digits long then null is returned indicating an error.
Parameters:
Name Type Description
barcode_number string 11 digit barcode number
Source:
Returns:
calculated check-digit - null if 'barcode_number' invalid
Type
number

<static> valid(barcode_number) → {boolean}

Validate that the specified 'barcode_number' is numeric and either 11 or 12 digits long. If 'barcode_number' is 12 digits long then the 12th digit is verified to be the valid check digit for the first 11 digits.
Parameters:
Name Type Description
barcode_number string 11 or 12 digit barcode number to be validated
Source:
Returns:
true if valid - else false
Type
boolean

render()

Render this instance's 'barcode_number' as an image into the 'container' element specified when constructed. Normally this is called internally when the barcode_number is changed by set_barcode_number() method. But, it may be useful when a page refresh is needed.
Source:

set_barcode_number(barcode_number)

Assign a value to be displayed in this barcode. If provided, the 12th digit is a check-digit which will be calculated from the 11 digit 'barcode_number'. The barcode image will be updated with this value. If the barcode has not been added to the DOM yet then it will be added to 'this.container'.
Parameters:
Name Type Description
barcode_number string 11 (or optionally 12) digit barcode
Source: