JsBarcode icon indicating copy to clipboard operation
JsBarcode copied to clipboard

Can't seem to get 128-JS to work on local filesystem

Open CausticLasagne opened this issue 2 months ago • 0 comments

Hi. I am trying to make a barcode generator for my work. I've followed your instructions and it works perfectly. However, when I download the script from the CDN at https://cdn.jsdelivr.net/npm/[email protected]/dist/barcodes/JsBarcode.code128.min.js and then try to use it locally from the filesystem on my page it prints an error:

Uncaught SyntaxError: Invalid regular expression: /^[_These characters could not be pasted_]*/: Range out of order in character class (at JsBarcode.code128.min.js:834:28)
    at new RegExp (<anonymous>)
    at a (JsBarcode.code128.min.js:834:28)
    at e.default (JsBarcode.code128.min.js:846:21)
    at new e (JsBarcode.code128.min.js:803:150)
    at o (JsBarcode.code128.min.js:494:17)
    at JsBarcode.code128.min.js:545:25
    at t.value (JsBarcode.code128.min.js:380:35)
    at x.<computed>.x.<computed>.x.<computed> (JsBarcode.code128.min.js:540:36)
    at E (JsBarcode.code128.min.js:532:222)
    at Go (Main.html:21:2)

I have a sinking feeling it is related to the file's encoding. I've tried different encoding to no avail. If it is related to the file's encoding, could I please request a version of the file or instructions on how to change the characters in the array to standard characters? I only need 0-9, A-Z, a-z. The main keyboard symbols are a bonus but not needed.

I've just designed a simple page that loads whatever text is in a textbox at the click of a button and then displays it as a barcode.

<!DOCTYPE html>
<html>
<script src="JsBarcode.code128.min.js"></script>
<head>

</head>
<body>


<div style="position:absolute; top:20%; left:40%">
<img id="barcd11"/> </br></br></br>
<input type="text" id="testInp1"  value="Nothing Selected"/>
<input type="button" id="btnGo" onclick="Go()"/>
</div>

<script>
//JsBarcode("#barcd11", document.getElementById("testInp1").value);

function Go()
{
	JsBarcode("#barcd11", document.getElementById("testInp1").value);
}

</script>

</body>
</html>

CausticLasagne avatar Apr 17 '24 06:04 CausticLasagne