From 22df08c29f6e4566d418e2a80a8279303406a733 Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Fri, 29 Jun 2018 00:58:19 +0200 Subject: build: switch to meson buildsystem We build the project with 'meson' now instead of using custom configure script + GNU Makefiles. To build the project, go to the project root directory and use the following commands: Building: meson build cd build ninja Update Language Files: ninja shopsystem-pot ninja shopsystem-update-po Install: DESTDIR=./tmp ninja install --- data/templates/js/code39.js | 148 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 data/templates/js/code39.js (limited to 'data/templates/js/code39.js') diff --git a/data/templates/js/code39.js b/data/templates/js/code39.js new file mode 100644 index 0000000..6028854 --- /dev/null +++ b/data/templates/js/code39.js @@ -0,0 +1,148 @@ +var encodings = { + '0':'bwbWBwBwb', + '1':'BwbWbwbwB', + '2':'bwBWbwbwB', + '3':'BwBWbwbwb', + '4':'bwbWBwbwB', + '5':'BwbWBwbwb', + '6':'bwBWBwbwb', + '7':'bwbWbwBwB', + '8':'BwbWbwBwb', + '9':'bwBWbwBwb', + 'A':'BwbwbWbwB', + 'B':'bwBwbWbwB', + 'C':'BwBwbWbwb', + 'D':'bwbwBWbwB', + 'E':'BwbwBWbwb', + 'F':'bwBwBWbwb', + 'G':'bwbwbWBwB', + 'H':'BwbwbWBwb', + 'I':'bwBwbWBwb', + 'J':'bwbwBWBwb', + 'K':'BwbwbwbWB', + 'L':'bwBwbwbWB', + 'M':'BwBwbwbWb', + 'N':'bwbwBwbWB', + 'O':'BwbwBwbWb', + 'P':'bwBwBwbWb', + 'Q':'bwbwbwBWB', + 'R':'BwbwbwBWb', + 'S':'bwBwbwBWb', + 'T':'bwbwBwBWb', + 'U':'BWbwbwbwB', + 'V':'bWBwbwbwB', + 'W':'BWBwbwbwb', + 'X':'bWbwBwbwB', + 'Y':'BWbwBwbwb', + 'Z':'bWBwBwbwb', + '-':'bWbwbwBwB', + '.':'BWbwbwBwb', + ' ':'bWBwbwBwb', + '$':'bWbWbWbwb', + '/':'bWbWbwbWb', + '+':'bWbwbWbWb', + '%':'bwbWbWbWb', + '*':'bWbwBwBwb' +} + +var height = 100; +var paintText = true; +var canvas; +var ctx; + +var code39_init = function() { + canvas = $('#barcode')[0]; + ctx = canvas.getContext("2d"); +} + +var code39_checksum = function(barcode) { + var charset = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%"; + var subtotal = 0; + var c; + + for (c in barcode) { + subtotal += charset.indexOf(barcode[c]); + } + + return charset[subtotal%43]; +} + +var code39_draw = function(text, add_checksum) { + var showtext = text; + + if(add_checksum) { + text += code39_checksum(text); + showtext += " "; + } + + text = "*" + text + "*"; + showtext = " " + showtext + " "; + + var txtLength = text.length; + var totalWidth = txtLength*15 +txtLength - 1; + cwidth = totalWidth+30; + + ctx.clearRect(0,0,canvas.width,canvas.height); + + canvas.style.height = canvas.height = height; + canvas.style.width = canvas.width = cwidth ; + ctx.fillStyle = "rgb(255,255,255)"; + ctx.fillRect(0,0,canvas.width,canvas.height); + + var i,j; + + /* Rounding to prevent antialising */ + var currentx = Math.round(cwidth/2-totalWidth/2), currenty = 20; + + /* wides are 3x width of narrow */ + var widewidth = 3; + + var barheight = 80; + + if(paintText) { + barheight -= 20; + } + + for(i=0;i