mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-21 14:10:59 +01:00
16 lines
24 KiB
JavaScript
16 lines
24 KiB
JavaScript
|
/*!
|
||
|
* BarCode Coder Library (BCC Library)
|
||
|
* BCCL Version 2.0
|
||
|
*
|
||
|
* Porting : jQuery barcode plugin
|
||
|
* Version : 2.0.3
|
||
|
*
|
||
|
* Date : 2013-01-06
|
||
|
* Author : DEMONTE Jean-Baptiste <jbdemonte@gmail.com>
|
||
|
* HOUREZ Jonathan
|
||
|
*
|
||
|
* Web site: http://barcode-coder.com/
|
||
|
* dual licence : http://www.cecill.info/licences/Licence_CeCILL_V2-fr.html
|
||
|
* http://www.gnu.org/licenses/gpl.html
|
||
|
*/
|
||
|
(function(b){var a={settings:{barWidth:1,barHeight:50,moduleSize:5,showHRI:true,addQuietZone:true,marginHRI:5,bgColor:"#FFFFFF",color:"#000000",fontSize:10,output:"css",posX:0,posY:0},intval:function(d){var c=typeof(d);if(c=="string"){d=d.replace(/[^0-9-.]/g,"");d=parseInt(d*1,10);return isNaN(d)||!isFinite(d)?0:d}return c=="number"&&isFinite(d)?Math.floor(d):0},i25:{encoding:["NNWWN","WNNNW","NWNNW","WWNNN","NNWNW","WNWNN","NWWNN","NNNWW","WNNWN","NWNWN"],compute:function(g,j,f){if(!j){if(g.length%2!=0){g="0"+g}}else{if((f=="int25")&&(g.length%2==0)){g="0"+g}var h=true,c,e=0;for(var d=g.length-1;d>-1;d--){c=a.intval(g.charAt(d));if(isNaN(c)){return("")}e+=h?3*c:c;h=!h}g+=((10-e%10)%10).toString()}return(g)},getDigit:function(k,l,h){k=this.compute(k,l,h);if(k==""){return("")}result="";var f,d;if(h=="int25"){result+="1010";var g,e;for(f=0;f<k.length/2;f++){g=k.charAt(2*f);e=k.charAt(2*f+1);for(d=0;d<5;d++){result+="1";if(this.encoding[g].charAt(d)=="W"){result+="1"}result+="0";if(this.encoding[e].charAt(d)=="W"){result+="0"}}}result+="1101"}else{if(h=="std25"){result+="11011010";var m;for(f=0;f<k.length;f++){m=k.charAt(f);for(d=0;d<5;d++){result+="1";if(this.encoding[m].charAt(d)=="W"){result+="11"}result+="0"}}result+="11010110"}}return(result)}},ean:{encoding:[["0001101","0100111","1110010"],["0011001","0110011","1100110"],["0010011","0011011","1101100"],["0111101","0100001","1000010"],["0100011","0011101","1011100"],["0110001","0111001","1001110"],["0101111","0000101","1010000"],["0111011","0010001","1000100"],["0110111","0001001","1001000"],["0001011","0010111","1110100"]],first:["000000","001011","001101","001110","010011","011001","011100","010101","010110","011010"],getDigit:function(j,h){var e=h=="ean8"?7:12;j=j.substring(0,e);if(j.length!=e){return("")}var k;for(var g=0;g<j.length;g++){k=j.charAt(g);if((k<"0")||(k>"9")){return("")}}j=this.compute(j,h);var d="101";if(h=="ean8"){for(var g=0;g<4;g++){d+=this.encoding[a.intval(j.charAt(g))][0]}d+="01010";for(var g=4;g<8;g++){d+=this.encoding[a.intval(j.charAt(g))][2]}}else{var f=this.first[a.intval(j.charAt(0))];for(var g=1;g<7;g++){d+=this.encoding[a.intval(j.charAt(g))][a.intval(f.charAt(g-1))]}d+="01010";for(var g=7;g<13;g++){d+=this.encoding[a.intval(j.charAt(g))][2]}}d+="101";return(d)},compute:function(f,e){var c=e=="ean13"?12:7;f=f.substring(0,c);var d=0,g=true;for(i=f.length-1;i>-1;i--){d+=(g?3:1)*a.intval(f.charAt(i));g=!g}return(f+((10-d%10)%10).toString())}},upc:{getDigit:function(c){if(c.length<12){c="0"+c}return a.ean.getDigit(c,"ean13")},compute:function(c){if(c.length<12){c="0"+c}return a.ean.compute(c,"ean13").substr(1)}},msi:{encoding:["100100100100","100100100110","100100110100","100100110110","100110100100","100110100110","100110110100","100110110110","110100100100","110100100110"],compute:function(c,d){if(typeof(d)=="object"){if(d.crc1=="mod10"){c=this.computeMod10(c)}else{if(d.crc1=="mod11"){c=this.computeMod11(c)}}if(d.crc2=="mod10"){c=this.computeMod10(c)}else{if(d.crc2=="mod11"){c=this.computeMod11(c)}}}else{if(typeof(d)=="boolean"){if(d){c=this.computeMod10(c)}}}return(c)},computeMod10:function(h){var e,c=h.length%2;var g=0,f=0;for(e=0;e<h.length;e++){if(c){g=10*g+a.intval(h.charAt(e))}else{f+=a.intval(h.charAt(e))}c=!c}var d=(2*g).toString();for(e=0;e<d.length;e++){f+=a.intval(d.charAt(e))}return(h+((10-f%10)%10).toString())},computeMod11:function(e){var d=0,f=2;for(var c=e.length-1;c>=0;c--){d+=f*a.intval(e.charAt(c));f=f==7?2:f+1}return(e+((11-d%11)%11).toString())},getDigit:function(f,g){var e="0123456789";var d=0;var c="";f=this.compute(f,false);c="110";for(i=0;i<f.length;i++){d=e.indexOf(f.charAt(i));if(d<0){return("")}c+=this.encoding[d]}c+="1001";return(c)}},code11:{encoding:["101011","1101011","1001011","1100101","1011011","1101101","1001101","1010011","1101001","110101","101101"],getDigit:function(e){var p="0123456789-";var j,m,q="",f="0";q="1011001"+f;for(j=0;j<e.length;j++){m=p.indexOf(e.charAt(j));if(m<0){return("")}q+=this.encoding[m]+f}var o=0,h=0,l=1,d=0;for(j=e.length-1;j>=0;j--){o=o==10?1:o+1;l=l==10?1:l+1;m=p.indexOf(e.cha
|