From 62966084ffdde9b1d72163b58ae4d3c4a08327e6 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Tue, 25 Aug 2015 15:30:30 +0000 Subject: [PATCH] Add barcode plugin --- phpgwapi/js/jquery/barcode/changelog.txt | 30 + phpgwapi/js/jquery/barcode/jquery-barcode.js | 1298 +++++++++++++++++ .../js/jquery/barcode/jquery-barcode.min.js | 16 + phpgwapi/js/jquery/barcode/readme.md | 35 + 4 files changed, 1379 insertions(+) create mode 100644 phpgwapi/js/jquery/barcode/changelog.txt create mode 100644 phpgwapi/js/jquery/barcode/jquery-barcode.js create mode 100644 phpgwapi/js/jquery/barcode/jquery-barcode.min.js create mode 100644 phpgwapi/js/jquery/barcode/readme.md diff --git a/phpgwapi/js/jquery/barcode/changelog.txt b/phpgwapi/js/jquery/barcode/changelog.txt new file mode 100644 index 0000000000..419ab5135c --- /dev/null +++ b/phpgwapi/js/jquery/barcode/changelog.txt @@ -0,0 +1,30 @@ +2.0.3 - 2013-01-06 + remove useless code from datamatrix + add upc support (Niels Leenheer) + +2.0.2 - 2011-03-01 + integration to jquery updated + table B of code 128 fixed (\\ instead of \) thanks to jmcarson + +2.0.1 - 2010/09/05 + CSS fixed to print easily - Thanks to Léo West for this fix + datamatrix added - Jonathan Hourez join developper team + canvas renderer added + code cleaned + fontSize become an integer + +1.3.3 - 2009/10/17 + no wait document is ready to add plugin + +1.3.2 - 2009/10/03 + manage int and string formated values for barcode width/height + +1.3 - 2009/09/26 + bmp and svg image renderer added + +1.2 - 2009/09/10 + parseInt replaced by intval (nb: parseInt("09") => 0) + code128 fixed (C Table analyse) - Thanks to Vadim for the bug report + +1.1 - 2009/05/26 + std25 fixed \ No newline at end of file diff --git a/phpgwapi/js/jquery/barcode/jquery-barcode.js b/phpgwapi/js/jquery/barcode/jquery-barcode.js new file mode 100644 index 0000000000..fcb45e3eca --- /dev/null +++ b/phpgwapi/js/jquery/barcode/jquery-barcode.js @@ -0,0 +1,1298 @@ +/*! + * 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 + * 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 ($) { + + var barcode = { + 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(val){ + var type = typeof( val ); + if (type == 'string'){ + val = val.replace(/[^0-9-.]/g, ""); + val = parseInt(val * 1, 10); + return isNaN(val) || !isFinite(val) ? 0 : val; + } + return type == 'number' && isFinite(val) ? Math.floor(val) : 0; + }, + i25: { // std25 int25 + encoding: ["NNWWN", "WNNNW", "NWNNW", "WWNNN", "NNWNW", "WNWNN", "NWWNN", "NNNWW", "WNNWN","NWNWN"], + compute: function(code, crc, type){ + if (! crc) { + if (code.length % 2 != 0) code = '0' + code; + } else { + if ( (type == "int25") && (code.length % 2 == 0) ) code = '0' + code; + var odd = true, v, sum = 0; + for(var i=code.length-1; i>-1; i--){ + v = barcode.intval(code.charAt(i)); + if (isNaN(v)) return(""); + sum += odd ? 3 * v : v; + odd = ! odd; + } + code += ((10 - sum % 10) % 10).toString(); + } + return(code); + }, + getDigit: function(code, crc, type){ + code = this.compute(code, crc, type); + if (code == "") return(""); + result = ""; + + var i, j; + if (type == "int25") { + // Interleaved 2 of 5 + + // start + result += "1010"; + + // digits + CRC + var c1, c2; + for(i=0; i '9') ) return(""); + } + // get checksum + code = this.compute(code, type); + + // process analyse + var result = "101"; // start + + if (type == "ean8"){ + + // process left part + for(var i=0; i<4; i++){ + result += this.encoding[barcode.intval(code.charAt(i))][0]; + } + + // center guard bars + result += "01010"; + + // process right part + for(var i=4; i<8; i++){ + result += this.encoding[barcode.intval(code.charAt(i))][2]; + } + + } else { // ean13 + // extract first digit and get sequence + var seq = this.first[ barcode.intval(code.charAt(0)) ]; + + // process left part + for(var i=1; i<7; i++){ + result += this.encoding[barcode.intval(code.charAt(i))][ barcode.intval(seq.charAt(i-1)) ]; + } + + // center guard bars + result += "01010"; + + // process right part + for(var i=7; i<13; i++){ + result += this.encoding[barcode.intval(code.charAt(i))][ 2 ]; + } + } // ean13 + + result += "101"; // stop + return(result); + }, + compute: function (code, type){ + var len = type == "ean13" ? 12 : 7; + code = code.substring(0, len); + var sum = 0, odd = true; + for(i=code.length-1; i>-1; i--){ + sum += (odd ? 3 : 1) * barcode.intval(code.charAt(i)); + odd = ! odd; + } + return(code + ((10 - sum % 10) % 10).toString()); + } + }, + upc: { + getDigit: function(code){ + if (code.length < 12) { + code = '0' + code; + } + return barcode.ean.getDigit(code, 'ean13'); + }, + compute: function (code){ + if (code.length < 12) { + code = '0' + code; + } + return barcode.ean.compute(code, 'ean13').substr(1); + } + }, + msi: { + encoding:["100100100100", "100100100110", "100100110100", "100100110110", + "100110100100", "100110100110", "100110110100", "100110110110", + "110100100100", "110100100110"], + compute: function(code, crc){ + if (typeof(crc) == "object"){ + if (crc.crc1 == "mod10"){ + code = this.computeMod10(code); + } else if (crc.crc1 == "mod11"){ + code = this.computeMod11(code); + } + if (crc.crc2 == "mod10"){ + code = this.computeMod10(code); + } else if (crc.crc2 == "mod11"){ + code = this.computeMod11(code); + } + } else if (typeof(crc) == "boolean"){ + if (crc) code = this.computeMod10(code); + } + return(code); + }, + computeMod10:function(code){ + var i, + toPart1 = code.length % 2; + var n1 = 0, sum = 0; + for(i=0; i=0; i--){ + sum += weight * barcode.intval(code.charAt(i)); + weight = weight == 7 ? 2 : weight + 1; + } + return(code + ((11 - sum % 11) % 11).toString()); + }, + getDigit: function(code, crc){ + var table = "0123456789"; + var index = 0; + var result = ""; + + code = this.compute(code, false); + + // start + result = "110"; + + // digits + for(i=0; i=0; i--){ + weightC = weightC == 10 ? 1 : weightC + 1; + weightK = weightK == 10 ? 1 : weightK + 1; + + index = table.indexOf( code.charAt(i) ); + + weightSumC += weightC * index; + weightSumK += weightK * index; + } + + var c = weightSumC % 11; + weightSumK += c; + var k = weightSumK % 11; + + result += this.encoding[c] + intercharacter; + + if (code.length >= 10){ + result += this.encoding[k] + intercharacter; + } + + // stop + result += "1011001"; + + return(result); + } + }, + code39: { + encoding:["101001101101", "110100101011", "101100101011", "110110010101", + "101001101011", "110100110101", "101100110101", "101001011011", + "110100101101", "101100101101", "110101001011", "101101001011", + "110110100101", "101011001011", "110101100101", "101101100101", + "101010011011", "110101001101", "101101001101", "101011001101", + "110101010011", "101101010011", "110110101001", "101011010011", + "110101101001", "101101101001", "101010110011", "110101011001", + "101101011001", "101011011001", "110010101011", "100110101011", + "110011010101", "100101101011", "110010110101", "100110110101", + "100101011011", "110010101101", "100110101101", "100100100101", + "100100101001", "100101001001", "101001001001", "100101101101"], + getDigit: function(code){ + var table = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%*"; + var i, index, result="", intercharacter='0'; + + if (code.indexOf('*') >= 0) return(""); + + // Add Start and Stop charactere : * + code = ("*" + code + "*").toUpperCase(); + + for(i=0; i 0) result += intercharacter; + result += this.encoding[ index ]; + } + return(result); + } + }, + code93:{ + encoding:["100010100", "101001000", "101000100", "101000010", + "100101000", "100100100", "100100010", "101010000", + "100010010", "100001010", "110101000", "110100100", + "110100010", "110010100", "110010010", "110001010", + "101101000", "101100100", "101100010", "100110100", + "100011010", "101011000", "101001100", "101000110", + "100101100", "100010110", "110110100", "110110010", + "110101100", "110100110", "110010110", "110011010", + "101101100", "101100110", "100110110", "100111010", + "100101110", "111010100", "111010010", "111001010", + "101101110", "101110110", "110101110", "100100110", + "111011010", "111010110", "100110010", "101011110"], + getDigit: function(code, crc){ + var table = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%____*", // _ => ($), (%), (/) et (+) + c, result = ""; + + if (code.indexOf('*') >= 0) return(""); + + code = code.toUpperCase(); + + // start : * + result += this.encoding[47]; + + // digits + for(i=0; i=0; i--){ + weightC = weightC == 20 ? 1 : weightC + 1; + weightK = weightK == 15 ? 1 : weightK + 1; + + index = table.indexOf( code.charAt(i) ); + + weightSumC += weightC * index; + weightSumK += weightK * index; + } + + var c = weightSumC % 47; + weightSumK += c; + var k = weightSumK % 47; + + result += this.encoding[c]; + result += this.encoding[k]; + } + + // stop : * + result += this.encoding[47]; + + // Terminaison bar + result += '1'; + return(result); + } + }, + code128: { + encoding:["11011001100", "11001101100", "11001100110", "10010011000", + "10010001100", "10001001100", "10011001000", "10011000100", + "10001100100", "11001001000", "11001000100", "11000100100", + "10110011100", "10011011100", "10011001110", "10111001100", + "10011101100", "10011100110", "11001110010", "11001011100", + "11001001110", "11011100100", "11001110100", "11101101110", + "11101001100", "11100101100", "11100100110", "11101100100", + "11100110100", "11100110010", "11011011000", "11011000110", + "11000110110", "10100011000", "10001011000", "10001000110", + "10110001000", "10001101000", "10001100010", "11010001000", + "11000101000", "11000100010", "10110111000", "10110001110", + "10001101110", "10111011000", "10111000110", "10001110110", + "11101110110", "11010001110", "11000101110", "11011101000", + "11011100010", "11011101110", "11101011000", "11101000110", + "11100010110", "11101101000", "11101100010", "11100011010", + "11101111010", "11001000010", "11110001010", "10100110000", + "10100001100", "10010110000", "10010000110", "10000101100", + "10000100110", "10110010000", "10110000100", "10011010000", + "10011000010", "10000110100", "10000110010", "11000010010", + "11001010000", "11110111010", "11000010100", "10001111010", + "10100111100", "10010111100", "10010011110", "10111100100", + "10011110100", "10011110010", "11110100100", "11110010100", + "11110010010", "11011011110", "11011110110", "11110110110", + "10101111000", "10100011110", "10001011110", "10111101000", + "10111100010", "11110101000", "11110100010", "10111011110", + "10111101110", "11101011110", "11110101110", "11010000100", + "11010010000", "11010011100", "11000111010"], + getDigit: function(code){ + var tableB = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"; + var result = ""; + var sum = 0; + var isum = 0; + var i = 0; + var j = 0; + var value = 0; + + // check each characters + for(i=0; i 1; + var c = ''; + for(i=0; i<3 && i= '0' && c <= '9'; + } + + sum = tableCActivated ? 105 : 104; + + // start : [105] : C table or [104] : B table + result = this.encoding[ sum ]; + + i = 0; + while( i < code.length ){ + if (! tableCActivated){ + j = 0; + // check next character to activate C table if interresting + while ( (i + j < code.length) && (code.charAt(i+j) >= '0') && (code.charAt(i+j) <= '9') ) j++; + + // 6 min everywhere or 4 mini at the end + tableCActivated = (j > 5) || ((i + j - 1 == code.length) && (j > 3)); + + if ( tableCActivated ){ + result += this.encoding[ 99 ]; // C table + sum += ++isum * 99; + } + // 2 min for table C so need table B + } else if ( (i == code.length) || (code.charAt(i) < '0') || (code.charAt(i) > '9') || (code.charAt(i+1) < '0') || (code.charAt(i+1) > '9') ) { + tableCActivated = false; + result += this.encoding[ 100 ]; // B table + sum += ++isum * 100; + } + + if ( tableCActivated ) { + value = barcode.intval(code.charAt(i) + code.charAt(i+1)); // Add two characters (numeric) + i += 2; + } else { + value = tableB.indexOf( code.charAt(i) ); // Add one character + i += 1; + } + result += this.encoding[ value ]; + sum += ++isum * value; + } + + // Add CRC + result += this.encoding[ sum % 103 ]; + + // Stop + result += this.encoding[106]; + + // Termination bar + result += "11"; + + return(result); + } + }, + codabar: { + encoding:["101010011", "101011001", "101001011", "110010101", + "101101001", "110101001", "100101011", "100101101", + "100110101", "110100101", "101001101", "101100101", + "1101011011", "1101101011", "1101101101", "1011011011", + "1011001001", "1010010011", "1001001011", "1010011001"], + getDigit: function(code){ + var table = "0123456789-$:/.+"; + var i, index, result="", intercharacter = '0'; + + // add start : A->D : arbitrary choose A + result += this.encoding[16] + intercharacter; + + for(i=0; iD : arbitrary choose A + result += this.encoding[16]; + return(result); + } + }, + datamatrix: { + lengthRows: [ 10, 12, 14, 16, 18, 20, 22, 24, 26, // 24 squares et 6 rectangular + 32, 36, 40, 44, 48, 52, 64, 72, 80, 88, 96, 104, 120, 132, 144, + 8, 8, 12, 12, 16, 16], + lengthCols: [ 10, 12, 14, 16, 18, 20, 22, 24, 26, // Number of columns for the entire datamatrix + 32, 36, 40, 44, 48, 52, 64, 72, 80, 88, 96, 104, 120, 132, 144, + 18, 32, 26, 36, 36, 48], + dataCWCount: [ 3, 5, 8, 12, 18, 22, 30, 36, // Number of data codewords for the datamatrix + 44, 62, 86, 114, 144, 174, 204, 280, 368, 456, 576, 696, 816, 1050, + 1304, 1558, 5, 10, 16, 22, 32, 49], + solomonCWCount: [ 5, 7, 10, 12, 14, 18, 20, 24, 28, // Number of Reed-Solomon codewords for the datamatrix + 36, 42, 48, 56, 68, 84, 112, 144, 192, 224, 272, 336, 408, 496, 620, + 7, 11, 14, 18, 24, 28], + dataRegionRows: [ 8, 10, 12, 14, 16, 18, 20, 22, // Number of rows per region + 24, 14, 16, 18, 20, 22, 24, 14, 16, 18, 20, 22, 24, 18, 20, 22, + 6, 6, 10, 10, 14, 14], + dataRegionCols: [ 8, 10, 12, 14, 16, 18, 20, 22, // Number of columns per region + 24, 14, 16, 18, 20, 22, 24, 14, 16, 18, 20, 22, 24, 18, 20, 22, + 16, 14, 24, 16, 16, 22], + regionRows: [ 1, 1, 1, 1, 1, 1, 1, 1, // Number of regions per row + 1, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 6, 6, 6, + 1, 1, 1, 1, 1, 1], + regionCols: [ 1, 1, 1, 1, 1, 1, 1, 1, // Number of regions per column + 1, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 6, 6, 6, + 1, 2, 1, 2, 2, 2], + interleavedBlocks:[ 1, 1, 1, 1, 1, 1, 1, 1, // Number of blocks + 1, 1, 1, 1, 1, 1, 2, 2, 4, 4, 4, 4, 6, 6, 8, 8, + 1, 1, 1, 1, 1, 1], + logTab: [ -255, 255, 1, 240, 2, 225, 241, 53, 3, // Table of log for the Galois field + 38, 226, 133, 242, 43, 54, 210, 4, 195, 39, 114, 227, 106, 134, 28, + 243, 140, 44, 23, 55, 118, 211, 234, 5, 219, 196, 96, 40, 222, 115, + 103, 228, 78, 107, 125, 135, 8, 29, 162, 244, 186, 141, 180, 45, 99, + 24, 49, 56, 13, 119, 153, 212, 199, 235, 91, 6, 76, 220, 217, 197, + 11, 97, 184, 41, 36, 223, 253, 116, 138, 104, 193, 229, 86, 79, 171, + 108, 165, 126, 145, 136, 34, 9, 74, 30, 32, 163, 84, 245, 173, 187, + 204, 142, 81, 181, 190, 46, 88, 100, 159, 25, 231, 50, 207, 57, 147, + 14, 67, 120, 128, 154, 248, 213, 167, 200, 63, 236, 110, 92, 176, 7, + 161, 77, 124, 221, 102, 218, 95, 198, 90, 12, 152, 98, 48, 185, 179, + 42, 209, 37, 132, 224, 52, 254, 239, 117, 233, 139, 22, 105, 27, 194, + 113, 230, 206, 87, 158, 80, 189, 172, 203, 109, 175, 166, 62, 127, + 247, 146, 66, 137, 192, 35, 252, 10, 183, 75, 216, 31, 83, 33, 73, + 164, 144, 85, 170, 246, 65, 174, 61, 188, 202, 205, 157, 143, 169, 82, + 72, 182, 215, 191, 251, 47, 178, 89, 151, 101, 94, 160, 123, 26, 112, + 232, 21, 51, 238, 208, 131, 58, 69, 148, 18, 15, 16, 68, 17, 121, 149, + 129, 19, 155, 59, 249, 70, 214, 250, 168, 71, 201, 156, 64, 60, 237, + 130, 111, 20, 93, 122, 177, 150], + aLogTab: [ 1, 2, 4, 8, 16, 32, 64, 128, 45, 90, // Table of aLog for the Galois field + 180, 69, 138, 57, 114, 228, 229, 231, 227, 235, 251, 219, 155, 27, 54, + 108, 216, 157, 23, 46, 92, 184, 93, 186, 89, 178, 73, 146, 9, 18, 36, + 72, 144, 13, 26, 52, 104, 208, 141, 55, 110, 220, 149, 7, 14, 28, 56, + 112, 224, 237, 247, 195, 171, 123, 246, 193, 175, 115, 230, 225, 239, + 243, 203, 187, 91, 182, 65, 130, 41, 82, 164, 101, 202, 185, 95, 190, + 81, 162, 105, 210, 137, 63, 126, 252, 213, 135, 35, 70, 140, 53, 106, + 212, 133, 39, 78, 156, 21, 42, 84, 168, 125, 250, 217, 159, 19, 38, 76, + 152, 29, 58, 116, 232, 253, 215, 131, 43, 86, 172, 117, 234, 249, 223, + 147, 11, 22, 44, 88, 176, 77, 154, 25, 50, 100, 200, 189, 87, 174, 113, + 226, 233, 255, 211, 139, 59, 118, 236, 245, 199, 163, 107, 214, 129, + 47, 94, 188, 85, 170, 121, 242, 201, 191, 83, 166, 97, 194, 169, 127, + 254, 209, 143, 51, 102, 204, 181, 71, 142, 49, 98, 196, 165, 103, 206, + 177, 79, 158, 17, 34, 68, 136, 61, 122, 244, 197, 167, 99, 198, 161, + 111, 222, 145, 15, 30, 60, 120, 240, 205, 183, 67, 134, 33, 66, 132, + 37, 74, 148, 5, 10, 20, 40, 80, 160, 109, 218, 153, 31, 62, 124, 248, + 221, 151, 3, 6, 12, 24, 48, 96, 192, 173, 119, 238, 241, 207, 179, 75, + 150, 1], + champGaloisMult: function(a, b){ // MULTIPLICATION IN GALOIS FIELD GF(2^8) + if(!a || !b) return 0; + return this.aLogTab[(this.logTab[a] + this.logTab[b]) % 255]; + }, + champGaloisDoub: function(a, b){ // THE OPERATION a * 2^b IN GALOIS FIELD GF(2^8) + if (!a) return 0; + if (!b) return a; + return this.aLogTab[(this.logTab[a] + b) % 255]; + }, + champGaloisSum: function(a, b){ // SUM IN GALOIS FIELD GF(2^8) + return a ^ b; + }, + selectIndex: function(dataCodeWordsCount, rectangular){ // CHOOSE THE GOOD INDEX FOR TABLES + if ((dataCodeWordsCount<1 || dataCodeWordsCount>1558) && !rectangular) return -1; + if ((dataCodeWordsCount<1 || dataCodeWordsCount>49) && rectangular) return -1; + + var n = 0; + if ( rectangular ) n = 24; + + while (this.dataCWCount[n] < dataCodeWordsCount) n++; + return n; + }, + encodeDataCodeWordsASCII: function(text) { + var dataCodeWords = new Array(); + var n = 0, i, c; + for (i=0; i 127) { + dataCodeWords[n] = 235; + c = c - 127; + n++; + } else if ((c>=48 && c<=57) && (i+1=48 && text.charCodeAt(i+1)<=57)) { + c = ((c - 48) * 10) + ((text.charCodeAt(i+1))-48); + c += 130; + i++; + } else c++; + dataCodeWords[n] = c; + n++; + } + return dataCodeWords; + }, + addPadCW: function(tab, from, to){ + if (from >= to) return ; + tab[from] = 129; + var r, i; + for (i=from+1; i= 0; j--) { + g[j] = this.champGaloisDoub(g[j], i); + if(j > 0) g[j] = this.champGaloisSum(g[j], g[j-1]); + } + } + return g; + }, + addReedSolomonCW: function(nSolomonCW, coeffTab, nDataCW, dataTab, blocks){ // Add the Reed Solomon codewords + var temp = 0; + var errorBlocks = nSolomonCW / blocks; + var correctionCW = new Array(); + + var i,j,k; + for(k = 0; k < blocks; k++) { + for (i=0; i=0; j--){ + if ( !temp ) { + correctionCW[j] = 0; + } else { + correctionCW[j] = this.champGaloisMult(temp, coeffTab[j]); + } + if (j>0) correctionCW[j] = this.champGaloisSum(correctionCW[j-1], correctionCW[j]); + } + } + // Renversement des blocs calcules + j = nDataCW + k; + for (i=errorBlocks-1; i>=0; i--){ + dataTab[j] = correctionCW[i]; + j=j+blocks; + } + } + return dataTab; + }, + getBits: function(entier){ // Transform integer to tab of bits + var bits = new Array(); + for (var i=0; i<8; i++){ + bits[i] = entier & (128 >> i) ? 1 : 0; + } + return bits; + }, + next: function(etape, totalRows, totalCols, codeWordsBits, datamatrix, assigned){ // Place codewords into the matrix + var chr = 0; // Place of the 8st bit from the first character to [4][0] + var row = 4; + var col = 0; + + do { + // Check for a special case of corner + if((row == totalRows) && (col == 0)){ + this.patternShapeSpecial1(datamatrix, assigned, codeWordsBits[chr], totalRows, totalCols); + chr++; + } else if((etape<3) && (row == totalRows-2) && (col == 0) && (totalCols%4 != 0)){ + this.patternShapeSpecial2(datamatrix, assigned, codeWordsBits[chr], totalRows, totalCols); + chr++; + } else if((row == totalRows-2) && (col == 0) && (totalCols%8 == 4)){ + this.patternShapeSpecial3(datamatrix, assigned, codeWordsBits[chr], totalRows, totalCols); + chr++; + } + else if((row == totalRows+4) && (col == 2) && (totalCols%8 == 0)){ + this.patternShapeSpecial4(datamatrix, assigned, codeWordsBits[chr], totalRows, totalCols); + chr++; + } + + // Go up and right in the datamatrix + do { + if((row < totalRows) && (col >= 0) && (assigned[row][col]!=1)) { + this.patternShapeStandard(datamatrix, assigned, codeWordsBits[chr], row, col, totalRows, totalCols); + chr++; + } + row -= 2; + col += 2; + } while ((row >= 0) && (col < totalCols)); + row += 1; + col += 3; + + // Go down and left in the datamatrix + do { + if((row >= 0) && (col < totalCols) && (assigned[row][col]!=1)){ + this.patternShapeStandard(datamatrix, assigned, codeWordsBits[chr], row, col, totalRows, totalCols); + chr++; + } + row += 2; + col -= 2; + } while ((row < totalRows) && (col >=0)); + row += 3; + col += 1; + } while ((row < totalRows) || (col < totalCols)); + }, + patternShapeStandard: function(datamatrix, assigned, bits, row, col, totalRows, totalCols){ // Place bits in the matrix (standard or special case) + this.placeBitInDatamatrix(datamatrix, assigned, bits[0], row-2, col-2, totalRows, totalCols); + this.placeBitInDatamatrix(datamatrix, assigned, bits[1], row-2, col-1, totalRows, totalCols); + this.placeBitInDatamatrix(datamatrix, assigned, bits[2], row-1, col-2, totalRows, totalCols); + this.placeBitInDatamatrix(datamatrix, assigned, bits[3], row-1, col-1, totalRows, totalCols); + this.placeBitInDatamatrix(datamatrix, assigned, bits[4], row-1, col, totalRows, totalCols); + this.placeBitInDatamatrix(datamatrix, assigned, bits[5], row, col-2, totalRows, totalCols); + this.placeBitInDatamatrix(datamatrix, assigned, bits[6], row, col-1, totalRows, totalCols); + this.placeBitInDatamatrix(datamatrix, assigned, bits[7], row, col, totalRows, totalCols); + }, + patternShapeSpecial1: function(datamatrix, assigned, bits, totalRows, totalCols ){ + this.placeBitInDatamatrix(datamatrix, assigned, bits[0], totalRows-1, 0, totalRows, totalCols); + this.placeBitInDatamatrix(datamatrix, assigned, bits[1], totalRows-1, 1, totalRows, totalCols); + this.placeBitInDatamatrix(datamatrix, assigned, bits[2], totalRows-1, 2, totalRows, totalCols); + this.placeBitInDatamatrix(datamatrix, assigned, bits[3], 0, totalCols-2, totalRows, totalCols); + this.placeBitInDatamatrix(datamatrix, assigned, bits[4], 0, totalCols-1, totalRows, totalCols); + this.placeBitInDatamatrix(datamatrix, assigned, bits[5], 1, totalCols-1, totalRows, totalCols); + this.placeBitInDatamatrix(datamatrix, assigned, bits[6], 2, totalCols-1, totalRows, totalCols); + this.placeBitInDatamatrix(datamatrix, assigned, bits[7], 3, totalCols-1, totalRows, totalCols); + }, + patternShapeSpecial2: function(datamatrix, assigned, bits, totalRows, totalCols ){ + this.placeBitInDatamatrix(datamatrix, assigned, bits[0], totalRows-3, 0, totalRows, totalCols); + this.placeBitInDatamatrix(datamatrix, assigned, bits[1], totalRows-2, 0, totalRows, totalCols); + this.placeBitInDatamatrix(datamatrix, assigned, bits[2], totalRows-1, 0, totalRows, totalCols); + this.placeBitInDatamatrix(datamatrix, assigned, bits[3], 0, totalCols-4, totalRows, totalCols); + this.placeBitInDatamatrix(datamatrix, assigned, bits[4], 0, totalCols-3, totalRows, totalCols); + this.placeBitInDatamatrix(datamatrix, assigned, bits[5], 0, totalCols-2, totalRows, totalCols); + this.placeBitInDatamatrix(datamatrix, assigned, bits[6], 0, totalCols-1, totalRows, totalCols); + this.placeBitInDatamatrix(datamatrix, assigned, bits[7], 1, totalCols-1, totalRows, totalCols); + }, + patternShapeSpecial3: function(datamatrix, assigned, bits, totalRows, totalCols ){ + this.placeBitInDatamatrix(datamatrix, assigned, bits[0], totalRows-3, 0, totalRows, totalCols); + this.placeBitInDatamatrix(datamatrix, assigned, bits[1], totalRows-2, 0, totalRows, totalCols); + this.placeBitInDatamatrix(datamatrix, assigned, bits[2], totalRows-1, 0, totalRows, totalCols); + this.placeBitInDatamatrix(datamatrix, assigned, bits[3], 0, totalCols-2, totalRows, totalCols); + this.placeBitInDatamatrix(datamatrix, assigned, bits[4], 0, totalCols-1, totalRows, totalCols); + this.placeBitInDatamatrix(datamatrix, assigned, bits[5], 1, totalCols-1, totalRows, totalCols); + this.placeBitInDatamatrix(datamatrix, assigned, bits[6], 2, totalCols-1, totalRows, totalCols); + this.placeBitInDatamatrix(datamatrix, assigned, bits[7], 3, totalCols-1, totalRows, totalCols); + }, + patternShapeSpecial4: function(datamatrix, assigned, bits, totalRows, totalCols ){ + this.placeBitInDatamatrix(datamatrix, assigned, bits[0], totalRows-1, 0, totalRows, totalCols); + this.placeBitInDatamatrix(datamatrix, assigned, bits[1], totalRows-1, totalCols-1, totalRows, totalCols); + this.placeBitInDatamatrix(datamatrix, assigned, bits[2], 0, totalCols-3, totalRows, totalCols); + this.placeBitInDatamatrix(datamatrix, assigned, bits[3], 0, totalCols-2, totalRows, totalCols); + this.placeBitInDatamatrix(datamatrix, assigned, bits[4], 0, totalCols-1, totalRows, totalCols); + this.placeBitInDatamatrix(datamatrix, assigned, bits[5], 1, totalCols-3, totalRows, totalCols); + this.placeBitInDatamatrix(datamatrix, assigned, bits[6], 1, totalCols-2, totalRows, totalCols); + this.placeBitInDatamatrix(datamatrix, assigned, bits[7], 1, totalCols-1, totalRows, totalCols); + }, + placeBitInDatamatrix: function(datamatrix, assigned, bit, row, col, totalRows, totalCols){ // Put a bit into the matrix + if (row < 0) { + row += totalRows; + col += 4 - ((totalRows+4)%8); + } + if (col < 0) { + col += totalCols; + row += 4 - ((totalCols+4)%8); + } + if (assigned[row][col] != 1) { + datamatrix[row][col] = bit; + assigned[row][col] = 1; + } + }, + addFinderPattern: function(datamatrix, rowsRegion, colsRegion, rowsRegionCW, colsRegionCW){ // Add the finder pattern + var totalRowsCW = (rowsRegionCW+2) * rowsRegion; + var totalColsCW = (colsRegionCW+2) * colsRegion; + + var datamatrixTemp = new Array(); + datamatrixTemp[0] = new Array(); + for (var j=0; j> 8; + } + return le; + }, + // return a byte string from rgb values + cRgb: function(r,g,b){ + return String.fromCharCode(b) + String.fromCharCode(g) + String.fromCharCode(r); + }, + // return a byte string from a hex string color + cHexColor: function(hex){ + var v = parseInt('0x' + hex.substr(1)); + var b = v & 0xFF; + v = v >> 8; + var g = v & 0xFF; + var r = v >> 8; + return(this.cRgb(r,g,b)); + } + }, + hexToRGB: function(hex){ + var v = parseInt('0x' + hex.substr(1)); + var b = v & 0xFF; + v = v >> 8; + var g = v & 0xFF; + var r = v >> 8; + return({r:r,g:g,b:b}); + }, + // test if a string is a hexa string color (like #FF0000) + isHexColor: function (value){ + var r = new RegExp("#[0-91-F]", "gi"); + return value.match(r); + }, + // encode data in base64 + base64Encode: function(value) { + var r = '', c1, c2, c3, b1, b2, b3, b4; + var k = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; + var i = 0; + while (i < value.length) { + c1 = value.charCodeAt(i++); + c2 = value.charCodeAt(i++); + c3 = value.charCodeAt(i++); + b1 = c1 >> 2; + b2 = ((c1 & 3) << 4) | (c2 >> 4); + b3 = ((c2 & 15) << 2) | (c3 >> 6); + b4 = c3 & 63; + if (isNaN(c2)) b3 = b4 = 64; + else if (isNaN(c3)) b4 = 64; + r += k.charAt(b1) + k.charAt(b2) + k.charAt(b3) + k.charAt(b4); + } + return r; + }, + // convert a bit string to an array of array of bit char + bitStringTo2DArray: function( digit ){ + var d = []; d[0] = []; + for(var i=0; i=0; y--){ + var line = ''; + for (var x=0; x"; + var bar1 = "
"; + + var len, current; + for(var y=0; y 0){ + content += (current == '0' ? bar0 : bar1).replace("&W", len * mw); + } + } + if (settings.showHRI){ + content += "
"+hri+"
"; + } + this.resize($container, mw * columns).html(content); + }, + // css 1D barcode renderer + digitToCss: function($container, settings, digit, hri){ + var w = barcode.intval(settings.barWidth); + var h = barcode.intval(settings.barHeight); + this.digitToCssRenderer($container, settings, this.bitStringTo2DArray(digit), hri, w, h); + }, + // css 2D barcode renderer + digitToCss2D: function($container, settings, digit, hri){ + var s = barcode.intval(settings.moduleSize); + this.digitToCssRenderer($container, settings, digit, hri, s, s); + }, + // svg barcode renderer + digitToSvgRenderer: function($container, settings, digit, hri, mw, mh){ + var lines = digit.length; + var columns = digit[0].length; + + var width = mw * columns; + var height = mh * lines; + if (settings.showHRI){ + var fontSize = barcode.intval(settings.fontSize); + height += barcode.intval(settings.marginHRI) + fontSize; + } + + // svg header + var svg = ''; + + // background + svg += ''; + + var bar1 = ''; + + var len, current; + for(var y=0; y 0) && (current == '1') ){ + svg += bar1.replace("&W", len * mw).replace("&X", (columns - len) * mw).replace("&Y", y * mh); + } + } + + if (settings.showHRI){ + svg += ''; + svg += '' + hri + ''; + svg += ''; + } + // svg footer + svg += ''; + + // create a dom object, flush container and add object to the container + var object = document.createElement('object'); + object.setAttribute('type', 'image/svg+xml'); + object.setAttribute('data', 'data:image/svg+xml,'+ svg); + this.resize($container, width).append(object); + }, + // svg 1D barcode renderer + digitToSvg: function($container, settings, digit, hri){ + var w = barcode.intval(settings.barWidth); + var h = barcode.intval(settings.barHeight); + this.digitToSvgRenderer($container, settings, this.bitStringTo2DArray(digit), hri, w, h); + }, + // svg 2D barcode renderer + digitToSvg2D: function($container, settings, digit, hri){ + var s = barcode.intval(settings.moduleSize); + this.digitToSvgRenderer($container, settings, digit, hri, s, s); + }, + + // canvas barcode renderer + digitToCanvasRenderer : function($container, settings, digit, hri, xi, yi, mw, mh){ + var canvas = $container.get(0); + if ( !canvas || !canvas.getContext ) return; // not compatible + + var lines = digit.length; + var columns = digit[0].length; + + var ctx = canvas.getContext('2d'); + ctx.lineWidth = 1; + ctx.lineCap = 'butt'; + ctx.fillStyle = settings.bgColor; + ctx.fillRect (xi, yi, columns * mw, lines * mh); + + ctx.fillStyle = settings.color; + + for(var y=0; y 0) && (current == '1') ){ + ctx.fillRect (xi + (columns - len) * mw, yi + y * mh, mw * len, mh); + } + } + if (settings.showHRI){ + var dim = ctx.measureText(hri); + ctx.fillText(hri, xi + Math.floor((columns * mw - dim.width)/2), yi + lines * mh + settings.fontSize + settings.marginHRI); + } + }, + // canvas 1D barcode renderer + digitToCanvas: function($container, settings, digit, hri){ + var w = barcode.intval(settings.barWidth); + var h = barcode.intval(settings.barHeight); + var x = barcode.intval(settings.posX); + var y = barcode.intval(settings.posY); + this.digitToCanvasRenderer($container, settings, this.bitStringTo2DArray(digit), hri, x, y, w, h); + }, + // canvas 2D barcode renderer + digitToCanvas2D: function($container, settings, digit, hri){ + var s = barcode.intval(settings.moduleSize); + var x = barcode.intval(settings.posX); + var y = barcode.intval(settings.posY); + this.digitToCanvasRenderer($container, settings, digit, hri, x, y, s, s); + } + }; + + $.fn.extend({ + barcode: function(datas, type, settings) { + var digit = "", + hri = "", + code = "", + crc = true, + rect = false, + b2d = false; + + if (typeof(datas) == "string"){ + code = datas; + } else if (typeof(datas) == "object"){ + code = typeof(datas.code) == "string" ? datas.code : ""; + crc = typeof(datas.crc) != "undefined" ? datas.crc : true; + rect = typeof(datas.rect) != "undefined" ? datas.rect : false; + } + if (code == "") return(false); + + if (typeof(settings) == "undefined") settings = []; + for(var name in barcode.settings){ + if (settings[name] == undefined) settings[name] = barcode.settings[name]; + } + + switch(type){ + case "std25": + case "int25": + digit = barcode.i25.getDigit(code, crc, type); + hri = barcode.i25.compute(code, crc, type); + break; + case "ean8": + case "ean13": + digit = barcode.ean.getDigit(code, type); + hri = barcode.ean.compute(code, type); + break; + case "upc": + digit = barcode.upc.getDigit(code); + hri = barcode.upc.compute(code); + break; + case "code11": + digit = barcode.code11.getDigit(code); + hri = code; + break; + case "code39": + digit = barcode.code39.getDigit(code); + hri = code; + break; + case "code93": + digit = barcode.code93.getDigit(code, crc); + hri = code; + break; + case "code128": + digit = barcode.code128.getDigit(code); + hri = code; + break; + case "codabar": + digit = barcode.codabar.getDigit(code); + hri = code; + break; + case "msi": + digit = barcode.msi.getDigit(code, crc); + hri = barcode.msi.compute(code, crc); + break; + case "datamatrix": + digit = barcode.datamatrix.getDigit(code, rect); + hri = code; + b2d = true; + break; + } + if (digit.length == 0) return($(this)); + + // Quiet Zone + if ( !b2d && settings.addQuietZone) digit = "0000000000" + digit + "0000000000"; + + var $this = $(this); + var fname = 'digitTo' + settings.output.charAt(0).toUpperCase() + settings.output.substr(1) + (b2d ? '2D' : ''); + if (typeof(barcode[fname]) == 'function') { + barcode[fname]($this, settings, digit, hri); + } + + return($this); + } + }); + +}(jQuery)); \ No newline at end of file diff --git a/phpgwapi/js/jquery/barcode/jquery-barcode.min.js b/phpgwapi/js/jquery/barcode/jquery-barcode.min.js new file mode 100644 index 0000000000..e8773830bc --- /dev/null +++ b/phpgwapi/js/jquery/barcode/jquery-barcode.min.js @@ -0,0 +1,16 @@ +/*! + * 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 + * 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"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=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=0;j--){o=o==10?1:o+1;l=l==10?1:l+1;m=p.indexOf(e.charAt(j));h+=o*m;d+=l*m}var n=h%11;d+=n;var g=d%11;q+=this.encoding[n]+f;if(e.length>=10){q+=this.encoding[g]+f}q+="1011001";return(q)}},code39:{encoding:["101001101101","110100101011","101100101011","110110010101","101001101011","110100110101","101100110101","101001011011","110100101101","101100101101","110101001011","101101001011","110110100101","101011001011","110101100101","101101100101","101010011011","110101001101","101101001101","101011001101","110101010011","101101010011","110110101001","101011010011","110101101001","101101101001","101010110011","110101011001","101101011001","101011011001","110010101011","100110101011","110011010101","100101101011","110010110101","100110110101","100101011011","110010101101","100110101101","100100100101","100100101001","100101001001","101001001001","100101101101"],getDigit:function(h){var g="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%*";var f,e,d="",c="0";if(h.indexOf("*")>=0){return("")}h=("*"+h+"*").toUpperCase();for(f=0;f0){d+=c}d+=this.encoding[e]}return(d)}},code93:{encoding:["100010100","101001000","101000100","101000010","100101000","100100100","100100010","101010000","100010010","100001010","110101000","110100100","110100010","110010100","110010010","110001010","101101000","101100100","101100010","100110100","100011010","101011000","101001100","101000110","100101100","100010110","110110100","110110010","110101100","110100110","110010110","110011010","101101100","101100110","100110110","100111010","100101110","111010100","111010010","111001010","101101110","101110110","110101110","100100110","111011010","111010110","100110010","101011110"],getDigit:function(e,j){var n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%____*",l,o="";if(e.indexOf("*")>=0){return("")}e=e.toUpperCase();o+=this.encoding[47];for(i=0;i=0;i--){m=m==20?1:m+1;h=h==15?1:h+1;index=n.indexOf(e.charAt(i));g+=m*index;d+=h*index}var l=g%47;d+=l;var f=d%47;o+=this.encoding[l];o+=this.encoding[f]}o+=this.encoding[47];o+="1";return(o)}},code128:{encoding:["11011001100","11001101100","11001100110","10010011000","10010001100","10001001100","10011001000","10011000100","10001100100","11001001000","11001000100","11000100100","10110011100","10011011100","10011001110","10111001100","10011101100","10011100110","11001110010","11001011100","11001001110","11011100100","11001110100","11101101110","11101001100","11100101100","11100100110","11101100100","11100110100","11100110010","11011011000","11011000110","11000110110","10100011000","10001011000","10001000110","10110001000","10001101000","10001100010","11010001000","11000101000","11000100010","10110111000","10110001110","10001101110","10111011000","10111000110","10001110110","11101110110","11010001110","11000101110","11011101000","11011100010","11011101110","11101011000","11101000110","11100010110","11101101000","11101100010","11100011010","11101111010","11001000010","11110001010","10100110000","10100001100","10010110000","10010000110","10000101100","10000100110","10110010000","10110000100","10011010000","10011000010","10000110100","10000110010","11000010010","11001010000","11110111010","11000010100","10001111010","10100111100","10010111100","10010011110","10111100100","10011110100","10011110010","11110100100","11110010100","11110010010","11011011110","11011110110","11110110110","10101111000","10100011110","10001011110","10111101000","10111100010","11110101000","11110100010","10111011110","10111101110","11101011110","11110101110","11010000100","11010010000","11010011100","11000111010"],getDigit:function(e){var d=" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";var o="";var l=0;var f=0;var k=0;var h=0;var n=0;for(k=0;k1;var m="";for(k=0;k<3&&k="0"&&m<="9"}l=g?105:104;o=this.encoding[l];k=0;while(k="0")&&(e.charAt(k+h)<="9")){h++}g=(h>5)||((k+h-1==e.length)&&(h>3));if(g){o+=this.encoding[99];l+=++f*99}}else{if((k==e.length)||(e.charAt(k)<"0")||(e.charAt(k)>"9")||(e.charAt(k+1)<"0")||(e.charAt(k+1)>"9")){g=false;o+=this.encoding[100];l+=++f*100}}if(g){n=a.intval(e.charAt(k)+e.charAt(k+1));k+=2}else{n=d.indexOf(e.charAt(k));k+=1}o+=this.encoding[n];l+=++f*n}o+=this.encoding[l%103];o+=this.encoding[106];o+="11";return(o)}},codabar:{encoding:["101010011","101011001","101001011","110010101","101101001","110101001","100101011","100101101","100110101","110100101","101001101","101100101","1101011011","1101101011","1101101101","1011011011","1011001001","1010010011","1001001011","1010011001"],getDigit:function(h){var g="0123456789-$:/.+";var f,e,d="",c="0";d+=this.encoding[16]+c;for(f=0;f1558)&&!c){return -1}if((d<1||d>49)&&c){return -1}var e=0;if(c){e=24}while(this.dataCWCount[e]127){e[h]=235;g=g-127;h++}else{if((g>=48&&g<=57)&&(d+1=48&&f.charCodeAt(d+1)<=57)){g=((g-48)*10)+((f.charCodeAt(d+1))-48);g+=130;d++}else{g++}}e[h]=g;h++}return e},addPadCW:function(d,g,f){if(g>=f){return}d[g]=129;var e,c;for(c=g+1;c=0;d--){f[d]=this.champGaloisDoub(f[d],e);if(d>0){f[d]=this.champGaloisSum(f[d],f[d-1])}}}return f},addReedSolomonCW:function(e,d,n,m,c){var p=0;var o=e/c;var l=new Array();var h,g,f;for(f=0;f=0;g--){if(!p){l[g]=0}else{l[g]=this.champGaloisMult(p,d[g])}if(g>0){l[g]=this.champGaloisSum(l[g-1],l[g])}}}g=n+f;for(h=o-1;h>=0;h--){m[g]=l[h];g=g+c}}return m},getBits:function(c){var e=new Array();for(var d=0;d<8;d++){e[d]=c&(128>>d)?1:0}return e},next:function(h,j,f,k,e,g){var d=0;var l=4;var c=0;do{if((l==j)&&(c==0)){this.patternShapeSpecial1(e,g,k[d],j,f);d++}else{if((h<3)&&(l==j-2)&&(c==0)&&(f%4!=0)){this.patternShapeSpecial2(e,g,k[d],j,f);d++}else{if((l==j-2)&&(c==0)&&(f%8==4)){this.patternShapeSpecial3(e,g,k[d],j,f);d++}else{if((l==j+4)&&(c==2)&&(f%8==0)){this.patternShapeSpecial4(e,g,k[d],j,f);d++}}}}do{if((l=0)&&(g[l][c]!=1)){this.patternShapeStandard(e,g,k[d],l,c,j,f);d++}l-=2;c+=2}while((l>=0)&&(c=0)&&(c=0));l+=3;c+=1}while((l>8}return d},cRgb:function(e,d,c){return String.fromCharCode(c)+String.fromCharCode(d)+String.fromCharCode(e)},cHexColor:function(h){var d=parseInt("0x"+h.substr(1));var c=d&255;d=d>>8;var f=d&255;var e=d>>8;return(this.cRgb(e,f,c))}},hexToRGB:function(h){var d=parseInt("0x"+h.substr(1));var c=d&255;d=d>>8;var f=d&255;var e=d>>8;return({r:e,g:f,b:c})},isHexColor:function(d){var c=new RegExp("#[0-91-F]","gi");return d.match(c)},base64Encode:function(o){var c="",h,f,e,n,m,l,j;var d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var g=0;while(g>2;m=((h&3)<<4)|(f>>4);l=((f&15)<<2)|(e>>6);j=e&63;if(isNaN(f)){l=j=64}else{if(isNaN(e)){j=64}}c+=d.charAt(n)+d.charAt(m)+d.charAt(l)+d.charAt(j)}return c},bitStringTo2DArray:function(f){var e=[];e[0]=[];for(var c=0;c=0;h--){var l="";for(var j=0;j';var l='
';var f,h;for(var k=0;k0){j+=(h=="0"?o:l).replace("&W",f*p)}}if(c.showHRI){j+='
'+e+"
"}this.resize(q,p*d).html(j)},digitToCss:function(g,f,j,d){var c=a.intval(f.barWidth);var e=a.intval(f.barHeight);this.digitToCssRenderer(g,f,this.bitStringTo2DArray(j),d,c,e)},digitToCss2D:function(f,e,g,c){var d=a.intval(e.moduleSize);this.digitToCssRenderer(f,e,g,c,d,d)},digitToSvgRenderer:function(q,s,m,f,k,t){var d=m.length;var e=m[0].length;var p=k*e;var l=t*d;if(s.showHRI){var g=a.intval(s.fontSize);l+=a.intval(s.marginHRI)+g}var n='';n+='';var c='';var r,o;for(var h=0;h0)&&(o=="1")){n+=c.replace("&W",r*k).replace("&X",(e-r)*k).replace("&Y",h*t)}}if(s.showHRI){n+='';n+=''+f+"";n+=""}n+="";var u=document.createElement("object");u.setAttribute("type","image/svg+xml");u.setAttribute("data","data:image/svg+xml,"+n);this.resize(q,p).append(u)},digitToSvg:function(g,f,j,d){var c=a.intval(f.barWidth);var e=a.intval(f.barHeight);this.digitToSvgRenderer(g,f,this.bitStringTo2DArray(j),d,c,e)},digitToSvg2D:function(f,e,g,c){var d=a.intval(e.moduleSize);this.digitToSvgRenderer(f,e,g,c,d,d)},digitToCanvasRenderer:function(s,e,o,g,m,f,q,k){var c=s.get(0);if(!c||!c.getContext){return}var t=o.length;var d=o[0].length;var r=c.getContext("2d");r.lineWidth=1;r.lineCap="butt";r.fillStyle=e.bgColor;r.fillRect(m,f,d*q,t*k);r.fillStyle=e.color;for(var n=0;n0)&&(l=="1")){r.fillRect(m+(d-j)*q,f+n*k,q*j,k)}}if(e.showHRI){var h=r.measureText(g);r.fillText(g,m+Math.floor((d*q-h.width)/2),f+t*k+e.fontSize+e.marginHRI)}},digitToCanvas:function(j,g,l,e){var d=a.intval(g.barWidth);var f=a.intval(g.barHeight);var c=a.intval(g.posX);var k=a.intval(g.posY);this.digitToCanvasRenderer(j,g,this.bitStringTo2DArray(l),e,c,k,d,f)},digitToCanvas2D:function(g,f,j,d){var e=a.intval(f.moduleSize);var c=a.intval(f.posX);var h=a.intval(f.posY);this.digitToCanvasRenderer(g,f,j,d,c,h,e,e)}};b.fn.extend({barcode:function(h,m,f){var n="",g="",d="",k=true,o=false,j=false;if(typeof(h)=="string"){d=h}else{if(typeof(h)=="object"){d=typeof(h.code)=="string"?h.code:"";k=typeof(h.crc)!="undefined"?h.crc:true;o=typeof(h.rect)!="undefined"?h.rect:false}}if(d==""){return(false)}if(typeof(f)=="undefined"){f=[]}for(var c in a.settings){if(f[c]==undefined){f[c]=a.settings[c]}}switch(m){case"std25":case"int25":n=a.i25.getDigit(d,k,m);g=a.i25.compute(d,k,m);break;case"ean8":case"ean13":n=a.ean.getDigit(d,m);g=a.ean.compute(d,m);break;case"upc":n=a.upc.getDigit(d);g=a.upc.compute(d);break;case"code11":n=a.code11.getDigit(d);g=d;break;case"code39":n=a.code39.getDigit(d);g=d;break;case"code93":n=a.code93.getDigit(d,k);g=d;break;case"code128":n=a.code128.getDigit(d);g=d;break;case"codabar":n=a.codabar.getDigit(d);g=d;break;case"msi":n=a.msi.getDigit(d,k);g=a.msi.compute(d,k);break;case"datamatrix":n=a.datamatrix.getDigit(d,o);g=d;j=true;break}if(n.length==0){return(b(this))}if(!j&&f.addQuietZone){n="0000000000"+n+"0000000000"}var l=b(this);var e="digitTo"+f.output.charAt(0).toUpperCase()+f.output.substr(1)+(j?"2D":"");if(typeof(a[e])=="function"){a[e](l,f,n,g)}return(l)}})}(jQuery)); \ No newline at end of file diff --git a/phpgwapi/js/jquery/barcode/readme.md b/phpgwapi/js/jquery/barcode/readme.md new file mode 100644 index 0000000000..bd122c4a40 --- /dev/null +++ b/phpgwapi/js/jquery/barcode/readme.md @@ -0,0 +1,35 @@ +jquery-barcode +============== + +Presentation +------------ + +This plugin allows you to display barcodes on your website using jQuery. + +Licence +------- +[GPL v3](http://www.gnu.org/licenses/gpl.html) +[CeCILL](http://www.cecill.info/licences/Licence_CeCILL_V2-fr.html) + +Features +-------- + +### Symbologies + - standard 2 of 5 (std25) + - interleaved 2 of 5 (int25) + - ean 8 (ean8) + - ean 13 (ean13) + - upc (upc) + - code 11 (code11) + - code 39 (code39) + - code 93 (code93) + - code 128 (code128) + - codabar (codabar) + - msi (msi) + - datamatrix (datamatrix) + +### Output : + - CSS (compatible with any browser) + - SVG inline (not compatible with IE) + - BMP inline (not compatible with IE) + - CANVAS html 5 (not compatible with IE) \ No newline at end of file