Skip to content

Instantly share code, notes, and snippets.

@thole
Last active November 17, 2020 15:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thole/2d24f0c12a5703a66140af4af71e563c to your computer and use it in GitHub Desktop.
Save thole/2d24f0c12a5703a66140af4af71e563c to your computer and use it in GitHub Desktop.
barcode
<body>
<style>
body {
background-color: #f6f1d5;
}
</style>
<svg id="barcode"></svg>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jsbarcode/3.5.5/JsBarcode.all.min.js"></script>
<script>
function format(num, length) {
var r = "" + num;
while (r.length < length) {
r = "0" + r;
}
return r;
}
function update(){
var n = format(i,12);
JsBarcode("#barcode", n, {
format: "EAN13",
background: "#f6f1d5",
lineColor: "#191588"
});
i++;
i = i % 1000000000000;
}
var i = 0;
setInterval(update, 50);
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment