From e94b002ef3c37312f81aa6939d50c346331c0e39 Mon Sep 17 00:00:00 2001 From: Johan Lindell Date: Tue, 22 Mar 2016 22:39:54 +0100 Subject: [PATCH] Release v2.4.5 --- JsBarcode.all.min.js | 3 ++- bower.json | 2 +- package.json | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/JsBarcode.all.min.js b/JsBarcode.all.min.js index ea92abf8..69897c2b 100644 --- a/JsBarcode.all.min.js +++ b/JsBarcode.all.min.js @@ -1 +1,2 @@ -function CODE128(t,e){function r(){return!(-1===this.string.search(/^[!-~ ]+$/))}function n(t,e,r,n){var i=e(t,r);return s(r)+i.result+s(i.checksum)+g}function i(t,e){for(var r="",n=0,i=0,o=t.length;o>i;i++)r+=u(t[i]),n+=a(t[i])*(i+1);return{result:r,checksum:(n+e)%103}}function o(t,e){for(var r="",n=0,i=1,o=0,a=t.length;a>o;o+=2)r+=s(parseInt(t.substr(o,2))),n+=parseInt(t.substr(o,2))*i,i++;return{result:r,checksum:(n+e)%103}}function s(t){return h(t)}function a(t){return t.charCodeAt(0)-32}function u(t){return h(a(t))}e=e||"B",this.string=t+"",this.valid=r,this.getText=function(){return this.string},this.encoded=function(){return f["code128"+e](t)};var c=[740,644,638,176,164,100,224,220,124,608,604,572,436,244,230,484,260,254,650,628,614,764,652,902,868,836,830,892,844,842,752,734,590,304,112,94,416,128,122,672,576,570,464,422,134,496,478,142,910,678,582,768,762,774,880,862,814,896,890,818,914,602,930,328,292,200,158,68,62,424,412,232,218,76,74,554,616,978,556,146,340,212,182,508,268,266,956,940,938,758,782,974,400,310,118,512,506,960,954,502,518,886,966,668,680,692],h=function(t){return c[t]?(c[t]+1e3).toString(2):""},g="1100011101011",f={code128B:function(t){return n(t,i,104)},code128C:function(t){return t=t.replace(/ /g,""),n(t,o,105)}}}function CODE128B(t){return new CODE128(t,"B")}function CODE128C(t){return new CODE128(t,"C")}function CODE39(t){this.string=t.toUpperCase();var e={0:"101000111011101",1:"111010001010111",2:"101110001010111",3:"111011100010101",4:"101000111010111",5:"111010001110101",6:"101110001110101",7:"101000101110111",8:"111010001011101",9:"101110001011101",A:"111010100010111",B:"101110100010111",C:"111011101000101",D:"101011100010111",E:"111010111000101",F:"101110111000101",G:"101010001110111",H:"111010100011101",I:"101110100011101",J:"101011100011101",K:"111010101000111",L:"101110101000111",M:"111011101010001",N:"101011101000111",O:"111010111010001",P:"101110111010001",Q:"101010111000111",R:"111010101110001",S:"101110101110001",T:"101011101110001",U:"111000101010111",V:"100011101010111",W:"111000111010101",X:"100010111010111",Y:"111000101110101",Z:"100011101110101","-":"100010101110111",".":"111000101011101"," ":"100011101011101",$:"100010001000101","/":"100010001010001","+":"100010100010001","%":"101000100010001","*":"1000101110111010"};this.getText=function(){return this.string},this.encoded=function(){var t="";t+=e["*"];for(var r=0;rr;r+=2)e+=parseInt(t[r]);for(var r=1;12>r;r+=2)e+=3*parseInt(t[r]);return(10-e%10)%10}function n(t){return-1!=t.search(i)?t[12]==r(t):!1}this.EANnumber=t+"";var i=/^[0-9]{13}$/,o=/^[0-9]{12}$/;-1!=this.EANnumber.search(o)&&(this.EANnumber+=r(this.EANnumber)),this.getText=function(){return this.EANnumber},this.valid=function(){return n(this.EANnumber)},this.encoded=function(){return e(this.EANnumber)}}function EAN8(t){function e(t){return-1!=t.search(i)?t[7]==r(t):!1}function r(t){for(var e=0,r=0;7>r;r+=2)e+=3*parseInt(t[r]);for(var r=1;7>r;r+=2)e+=parseInt(t[r]);return(10-e%10)%10}function n(t){var e=new EANencoder,r="",n=t.substr(0,4),i=t.substr(4,4);return r+=e.startBin,r+=e.encode(n,"LLLL"),r+=e.middleBin,r+=e.encode(i,"RRRR"),r+=e.endBin}this.EAN8number=t+"";var i=/^[0-9]{8}$/,o=/^[0-9]{7}$/;-1!=this.EAN8number.search(o)&&(this.EAN8number+=r(this.EAN8number)),this.getText=function(){return this.EAN8number},this.valid=function(){return e(this.EAN8number)},this.encoded=function(){return n(this.EAN8number)}}function UPC(t){this.ean=new EAN("0"+t),this.getText=function(){return this.ean.getText().substring(1)},this.valid=function(){return this.ean.valid()},this.encoded=function(){return this.ean.encoded()}}function EANencoder(){this.startBin="101",this.endBin="101",this.middleBin="01010";var t={0:"0001101",1:"0011001",2:"0010011",3:"0111101",4:"0100011",5:"0110001",6:"0101111",7:"0111011",8:"0110111",9:"0001011"},e={0:"0100111",1:"0110011",2:"0011011",3:"0100001",4:"0011101",5:"0111001",6:"0000101",7:"0010001",8:"0001001",9:"0010111"},r={0:"1110010",1:"1100110",2:"1101100",3:"1000010",4:"1011100",5:"1001110",6:"1010000",7:"1000100",8:"1001000",9:"1110100"},n={0:"LLLLLL",1:"LLGLGG",2:"LLGGLG",3:"LLGGGL",4:"LGLLGG",5:"LGGLLG",6:"LGGGLL",7:"LGLGLG",8:"LGLGGL",9:"LGGLGL"};this.getEANstructure=function(t){return n[t[0]]},this.encode=function(n,i){for(var o="",s=0;so;o++)e+="1"==r[o]?"111":"1",e+="1"==i[o]?"000":"0";return e}function r(t){return-1!==t.search(s)}this.ITFNumber=t+"",this.getText=function(){return this.ITFNumber},this.valid=function(){return r(this.ITFNumber)},this.encoded=function(){var t="";t+=i;for(var r=0;ri;i++)e+="1"==r[i]?"111":"1",e+="1"==n[i]?"000":"0";return e}function checksum(t){for(var e=0,r=0;13>r;r++)e+=parseInt(t[r])*(3-r%2*2);return 10-e%10}function valid(t){return-1==t.search(regexp)?!1:14==t.length?t[13]==checksum(t):!0}function MSI(t){this.string=""+t}function MSI10(t){this.string=""+t,this.string+=mod10(this.string)}function MSI11(t){this.string=""+t,this.string+=mod11(this.string)}function MSI1010(t){this.string=""+t,this.string+=mod10(this.string),this.string+=mod10(this.string)}function MSI1110(t){this.string=""+t,this.string+=mod11(this.string),this.string+=mod10(this.string)}function mod10(t){for(var e=0,r=0;rr;r++)t="0"+t;return t}function pharmacode(t){function e(t,n){if(0==t.length)return"";var i,o=!1,s=r(t);return 0==s?(i=n?"001":"00111",o=n):(i="001".repeat(s-(n?1:0)),i+="00111"),e(t.substr(0,t.length-s-1),o)+i}this.number=parseInt(t),this.getText=function(){return this.number+""},this.encoded=function(){return e(this.number.toString(2),!0).substr(2)},this.valid=function(){return this.number>=3&&this.number<=131070};var r=function(t){for(var e=t.length-1,r=0;"0"==t[e]||0>e;)r++,e--;return r};String.prototype.repeat=function(t){return new Array(t+1).join(this)}}!function(){var t=function(r,n,i){if("string"==typeof r)r=document.querySelector(r),t(r,n,i);else if("undefined"!=typeof HTMLCanvasElement&&r instanceof HTMLImageElement)canvas=document.createElement("canvas"),e(canvas,n,i),r.setAttribute("src",canvas.toDataURL());else{if(!r.getContext)throw new Error("Not supported type to draw on.");e(r,n,i)}},e=function(e,r,n){if(n=a(t.defaults,n),n.marginTop=n.marginTop|n.margin,n.marginBottom=n.marginBottom|n.margin,n.marginRight=n.marginRight|n.margin,n.marginLeft=n.marginLeft|n.margin,!e.getContext)throw new Error("The browser does not support canvas.");if("auto"==n.format)var i=new(t.autoSelectEncoder(r))(r);else var i=new(t.getModule(n.format))(r);if(i.valid()){var o=t.getCache(n.format,r);if(o)var s=o;else{var s=i.encoded();t.cache(n.format,r,s)}var u=e.getContext("2d"),c=n.fontOptions+" "+n.fontSize+"px "+n.font;u.font=c;var h=s.length*n.width,g=u.measureText(i.getText()).width;if(n.displayValue&&g>h){if("center"==n.textAlign)var f=Math.floor((g-h)/2);else if("left"==n.textAlign)var f=0;else if("right"==n.textAlign)var f=Math.floor(g-h);h=g}var f=f||0;e.width=h+n.marginLeft+n.marginRight,e.height=n.height+(n.displayValue?n.fontSize:0)+n.textMargin+n.marginTop+n.marginBottom,u.clearRect(0,0,e.width,e.height),n.background&&(u.fillStyle=n.background,u.fillRect(0,0,e.width,e.height)),u.fillStyle=n.lineColor;for(var d=0;d0?(l=n.marginLeft,u.textAlign="left"):"right"==n.textAlign?(l=e.width-n.marginRight,u.textAlign="right"):(l=e.width/2,u.textAlign="center"),u.fillText(i.getText(),l,m)}n.valid(!0)}else if(n.valid(!1),n.valid==t.defaults.valid)throw new Error("The data is not valid for the type of barcode.")};if(t._modules=[],t.register=function(e,r,n){var i=0;if("undefined"==typeof n)i=t._modules.length-1;else for(var o=0;oe;e+=2)t+=calculatePair(this.string.substr(e,2));return t+=endBin};var digitStructure={0:"00110",1:"10001",2:"01001",3:"11000",4:"00101",5:"10100",6:"01100",7:"00011",8:"10010",9:"01010"},startBin="1010",endBin="11101",regexp=/^[0-9]{13,14}$/,register=function(t){t.register(ITF14,/^ITF.?14$/i,5)};try{register(JsBarcode)}catch(e){}try{module.exports.register=register}catch(e){}var prototype={};prototype.getText=function(){return this.string},prototype.encoded=function(){for(var t="110",e=0;ei;i++)r+=u(t[i]),n+=a(t[i])*(i+1);return{result:r,checksum:(n+e)%103}}function o(t,e){for(var r="",n=0,i=1,o=0,a=t.length;a>o;o+=2)r+=s(parseInt(t.substr(o,2))),n+=parseInt(t.substr(o,2))*i,i++;return{result:r,checksum:(n+e)%103}}function s(t){return h(t)}function a(t){return t.charCodeAt(0)-32}function u(t){return h(a(t))}e=e||"B",this.string=t+"",this.valid=r,this.getText=function(){return this.string},this.encoded=function(){return f["code128"+e](t)};var c=[740,644,638,176,164,100,224,220,124,608,604,572,436,244,230,484,260,254,650,628,614,764,652,902,868,836,830,892,844,842,752,734,590,304,112,94,416,128,122,672,576,570,464,422,134,496,478,142,910,678,582,768,762,774,880,862,814,896,890,818,914,602,930,328,292,200,158,68,62,424,412,232,218,76,74,554,616,978,556,146,340,212,182,508,268,266,956,940,938,758,782,974,400,310,118,512,506,960,954,502,518,886,966,668,680,692],h=function(t){return c[t]?(c[t]+1e3).toString(2):""},g="1100011101011",f={code128B:function(t){return n(t,i,104)},code128C:function(t){return t=t.replace(/ /g,""),n(t,o,105)}}}function CODE128B(t){return new CODE128(t,"B")}function CODE128C(t){return new CODE128(t,"C")}function CODE39(t){this.string=t.toUpperCase();var e={0:20957,1:29783,2:23639,3:30485,4:20951,5:29813,6:23669,7:20855,8:29789,9:23645,A:29975,B:23831,C:30533,D:22295,E:30149,F:24005,G:21623,H:29981,I:23837,J:22301,K:30023,L:23879,M:30545,N:22343,O:30161,P:24017,Q:21959,R:30065,S:23921,T:22385,U:29015,V:18263,W:29141,X:17879,Y:29045,Z:18293,"-":17783,".":29021," ":18269,$:17477,"/":17489,"+":17681,"%":20753,"*":35770};this.getText=function(){return this.string},this.encoded=function(){var t="";t+=e["*"].toString(2);for(var r=0;rr;r+=2)e+=parseInt(t[r]);for(var r=1;12>r;r+=2)e+=3*parseInt(t[r]);return(10-e%10)%10}function n(t){return-1!=t.search(i)?t[12]==r(t):!1}this.EANnumber=t+"";var i=/^[0-9]{13}$/,o=/^[0-9]{12}$/;-1!=this.EANnumber.search(o)&&(this.EANnumber+=r(this.EANnumber)),this.getText=function(){return this.EANnumber},this.valid=function(){return n(this.EANnumber)},this.encoded=function(){return e(this.EANnumber)}}function EAN8(t){function e(t){return-1!=t.search(i)?t[7]==r(t):!1}function r(t){for(var e=0,r=0;7>r;r+=2)e+=3*parseInt(t[r]);for(var r=1;7>r;r+=2)e+=parseInt(t[r]);return(10-e%10)%10}function n(t){var e=new EANencoder,r="",n=t.substr(0,4),i=t.substr(4,4);return r+=e.startBin,r+=e.encode(n,"LLLL"),r+=e.middleBin,r+=e.encode(i,"RRRR"),r+=e.endBin}this.EAN8number=t+"";var i=/^[0-9]{8}$/,o=/^[0-9]{7}$/;-1!=this.EAN8number.search(o)&&(this.EAN8number+=r(this.EAN8number)),this.getText=function(){return this.EAN8number},this.valid=function(){return e(this.EAN8number)},this.encoded=function(){return n(this.EAN8number)}}function UPC(t){this.ean=new EAN("0"+t),this.getText=function(){return this.ean.getText().substring(1)},this.valid=function(){return this.ean.valid()},this.encoded=function(){return this.ean.encoded()}}function EANencoder(){this.startBin="101",this.endBin="101",this.middleBin="01010";var t={0:"0001101",1:"0011001",2:"0010011",3:"0111101",4:"0100011",5:"0110001",6:"0101111",7:"0111011",8:"0110111",9:"0001011"},e={0:"0100111",1:"0110011",2:"0011011",3:"0100001",4:"0011101",5:"0111001",6:"0000101",7:"0010001",8:"0001001",9:"0010111"},r={0:"1110010",1:"1100110",2:"1101100",3:"1000010",4:"1011100",5:"1001110",6:"1010000",7:"1000100",8:"1001000",9:"1110100"},n={0:"LLLLLL",1:"LLGLGG",2:"LLGGLG",3:"LLGGGL",4:"LGLLGG",5:"LGGLLG",6:"LGGGLL",7:"LGLGLG",8:"LGLGGL",9:"LGGLGL"};this.getEANstructure=function(t){return n[t[0]]},this.encode=function(n,i){for(var o="",s=0;so;o++)e+="1"==r[o]?"111":"1",e+="1"==i[o]?"000":"0";return e}function r(t){return-1!==t.search(s)}this.ITFNumber=t+"",this.getText=function(){return this.ITFNumber},this.valid=function(){return r(this.ITFNumber)},this.encoded=function(){var t="";t+=i;for(var r=0;ri;i++)e+="1"==r[i]?"111":"1",e+="1"==n[i]?"000":"0";return e}function checksum(t){for(var e=0,r=0;13>r;r++)e+=parseInt(t[r])*(3-r%2*2);return 10-e%10}function valid(t){return-1==t.search(regexp)?!1:14==t.length?t[13]==checksum(t):!0}function MSI(t){this.string=""+t}function MSI10(t){this.string=""+t,this.string+=mod10(this.string)}function MSI11(t){this.string=""+t,this.string+=mod11(this.string)}function MSI1010(t){this.string=""+t,this.string+=mod10(this.string),this.string+=mod10(this.string)}function MSI1110(t){this.string=""+t,this.string+=mod11(this.string),this.string+=mod10(this.string)}function mod10(t){for(var e=0,r=0;rr;r++)t="0"+t;return t}function pharmacode(t){function e(t,n){if(0==t.length)return"";var i,o=!1,s=r(t);return 0==s?(i=n?"001":"00111",o=n):(i="001".repeat(s-(n?1:0)),i+="00111"),e(t.substr(0,t.length-s-1),o)+i}this.number=parseInt(t),this.getText=function(){return this.number+""},this.encoded=function(){return e(this.number.toString(2),!0).substr(2)},this.valid=function(){return this.number>=3&&this.number<=131070};var r=function(t){for(var e=t.length-1,r=0;"0"==t[e]||0>e;)r++,e--;return r};String.prototype.repeat=function(t){return new Array(t+1).join(this)}}!function(){var t=function(r,n,i){if("string"==typeof r)r=document.querySelector(r),t(r,n,i);else if("undefined"!=typeof HTMLCanvasElement&&r instanceof HTMLImageElement)canvas=document.createElement("canvas"),e(canvas,n,i),r.setAttribute("src",canvas.toDataURL());else{if(!r.getContext)throw new Error("Not supported type to draw on.");e(r,n,i)}},e=function(e,r,n){if(n=a(t.defaults,n),n.marginTop=n.marginTop|n.margin,n.marginBottom=n.marginBottom|n.margin,n.marginRight=n.marginRight|n.margin,n.marginLeft=n.marginLeft|n.margin,!e.getContext)throw new Error("The browser does not support canvas.");if("auto"==n.format)var i=new(t.autoSelectEncoder(r))(r);else var i=new(t.getModule(n.format))(r);if(i.valid()){var o=t.getCache(n.format,r);if(o)var s=o;else{var s=i.encoded();t.cache(n.format,r,s)}var u=e.getContext("2d"),c=n.fontOptions+" "+n.fontSize+"px "+n.font;u.font=c;var h=s.length*n.width,g=u.measureText(i.getText()).width;if(n.displayValue&&g>h){if("center"==n.textAlign)var f=Math.floor((g-h)/2);else if("left"==n.textAlign)var f=0;else if("right"==n.textAlign)var f=Math.floor(g-h);h=g}var f=f||0;e.width=h+n.marginLeft+n.marginRight,e.height=n.height+(n.displayValue?n.fontSize:0)+n.textMargin+n.marginTop+n.marginBottom,u.clearRect(0,0,e.width,e.height),n.background&&(u.fillStyle=n.background,u.fillRect(0,0,e.width,e.height)),u.fillStyle=n.lineColor;for(var d=0;d0?(l=n.marginLeft,u.textAlign="left"):"right"==n.textAlign?(l=e.width-n.marginRight,u.textAlign="right"):(l=e.width/2,u.textAlign="center"),u.fillText(i.getText(),l,m)}n.valid(!0)}else if(n.valid(!1),n.valid==t.defaults.valid)throw new Error("The data is not valid for the type of barcode.")};if(t._modules=[],t.register=function(e,r,n){var i=0;if("undefined"==typeof n)i=t._modules.length-1;else for(var o=0;oe;e+=2)t+=calculatePair(this.string.substr(e,2));return t+=endBin};var digitStructure={0:"00110",1:"10001",2:"01001",3:"11000",4:"00101",5:"10100",6:"01100",7:"00011",8:"10010",9:"01010"},startBin="1010",endBin="11101",regexp=/^[0-9]{13,14}$/,register=function(t){t.register(ITF14,/^ITF.?14$/i,5)};try{register(JsBarcode)}catch(e){}try{module.exports.register=register}catch(e){}var prototype={};prototype.getText=function(){return this.string},prototype.encoded=function(){for(var t="110",e=0;e" diff --git a/package.json b/package.json index e772991d..c5e44025 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jsbarcode", - "version": "2.4.4", + "version": "2.4.5", "description": "JsBarcode is a simple way to create different types of 1d barcodes.", "main": "JsBarcode.js", "directories": {