Skip to content

A JavaScript library the interprets a string typically from a barcode scan

License

Notifications You must be signed in to change notification settings

mgh128/interpretGS1scan

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Interpret GS1 scan

Interpret GS1 scan is a JavaScript library that interprets the string of data in various GS1 formats, as found in barcodes of different types.

You might want to head over to the demo.

QR code for https://gs1.github.io/interpretGS1scan/camera.html

This demo does not work in all browsers. It seems to work well with:

  • Samsung Internet on Android
  • Chrome on Android

It is usable but without the beep or choice of camera when used with Safari on iOS

It does not work with Chrome on iOS

It does not work with Firefox on Windows

We'll do what we can to improve this but a lot of it is down to the underlying libraries.

The Interpret GS1 Scan library

Interpret GS1 scan depends on the GS1 Digital Link toolkit.

If there are no errors, the interpretScan() function returns an object as follows

  • AIbrackets: The equivalent GS1 element string in human-readable AI syntax
  • AIfnc1: The equivalent GS1 element string in AI syntax with FNC1 (as used in barcodes)
  • dl: The equivalent GS1 Digital Link URL (on id.gs1.org)
  • ol: An ordered array of objects parsed/interpreted from the input string:
    • ai: the GS1 Application Identifier
    • label: what that AI is used for
    • value: the value

The order for the ol list matches that found in a GS1 Digital Link URI

  1. primary identifier
  2. any applicable qualifiers
  3. any data attributes
  4. any non-GS1 AIs and their values

Simply pass the string to be interpreted to the interpretScan() function.

It can handle any of the 3 formats:

  • Human readable AI syntax (i.e. with brackets)
  • Pure AI syntax (i.e. with the FNC1 character)
  • GS1 Digital Link URI

If the input string cannot be interpreted, i.e. it's not a valid GS1 string, then the returned object has a value for errmsg which is the system error message.

About

A JavaScript library the interprets a string typically from a barcode scan

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 88.1%
  • JavaScript 11.9%