From 6fb5b55863fa0b27d4e6bcf3963410ab16878b19 Mon Sep 17 00:00:00 2001 From: Denys Vitali Date: Sun, 14 Nov 2021 23:56:31 +0100 Subject: [PATCH 01/33] wip: support more QR code versions --- finder-example.html | 61 ++++++++++++++ index2.html | 61 ++++++++++++++ js/main.js | 11 ++- js/qr.js | 197 ++++++++++++++++++++++++++++++++++++++++++++ js/table.js | 20 ++++- 5 files changed, 345 insertions(+), 5 deletions(-) create mode 100644 finder-example.html create mode 100644 index2.html create mode 100644 js/qr.js diff --git a/finder-example.html b/finder-example.html new file mode 100644 index 0000000..e53731a --- /dev/null +++ b/finder-example.html @@ -0,0 +1,61 @@ + + + + QR Code Finder Example + + + + + + + + + + diff --git a/index2.html b/index2.html new file mode 100644 index 0000000..d7676cf --- /dev/null +++ b/index2.html @@ -0,0 +1,61 @@ + + + + QR Code Display + + + + + + + + + + diff --git a/js/main.js b/js/main.js index 412d66b..2de983e 100644 --- a/js/main.js +++ b/js/main.js @@ -6,7 +6,7 @@ **************************************** */ -var APP_VERSION = '0.3.3'; +var APP_VERSION = '0.4.0'; var qr_version = 1; //Current QR version (1-9) var qr_pixel_size = 10; //Current view size of QR code (pixel per module) @@ -33,6 +33,9 @@ var is_data_module = []; //Store data that separate between data module a var history_array = []; //Store history information and its qr_array data var active_history = -1; //Current active history +const maxSupportedSize = 100; +const maxVersion = 50; + /*** * * generate QR table based on qr_array @@ -571,7 +574,7 @@ function importFromImage(src, cb){ var qrArray = qRCodeMatrix.bits.bits; var size = qRCodeMatrix.bits.width; - if(size > 53){ + if(size > maxSupportedSize){ alert("QR version is unsupported"); return; } @@ -1462,7 +1465,7 @@ $(document).ready(function(){ $("#btn-version-plus").click(function(){ if(changed_state){ if(confirm("Are you sure want to proceed?\nYour unsaved progress will be lost!")){ - if(qr_version != 9){ + if(qr_version != maxVersion){ qr_version += 1; qr_size = 17+(qr_version*4); $("#qr-version").val(qr_size+"x"+qr_size+" (ver. "+qr_version+")"); @@ -1470,7 +1473,7 @@ $(document).ready(function(){ } } } else { - if(qr_version != 9){ + if(qr_version != maxVersion){ qr_version += 1; qr_size = 17+(qr_version*4); $("#qr-version").val(qr_size+"x"+qr_size+" (ver. "+qr_version+")"); diff --git a/js/qr.js b/js/qr.js new file mode 100644 index 0000000..e658ee6 --- /dev/null +++ b/js/qr.js @@ -0,0 +1,197 @@ +const WHITE_COLOR = 0; +const BLACK_COLOR = 1; +const RED_COLOR = 3; +const GREY_COLOR = -1; + +/* + A finder is defined by 3 squares: + - A black 7x7 square + - A white 5x5 square + - A black 3x3 square + + Padding is denoted by a 9x9 square surrounding the element + and being cropped on its corners. + + x and y denote the (x,y) coordinate of the 7x7 square, taken + at the top left corner +*/ + +function draw_square(t, x, y, size, color){ + for(let i=x; i= t.length || i < 0){ + continue + } + if(j >= t.length || j < 0) { + continue + } + t[i][j] = color; + } + } +} + +function generate_finder_separator(t, x, y) { + return draw_square(t, x - 1, y - 1, 9, WHITE_COLOR); +} + +function generate_finder(t, x, y){ + generate_finder_separator(t, x, y); + draw_square(t, x, y, 7, BLACK_COLOR); + draw_square(t, x + 1, y + 1, 5, WHITE_COLOR); + draw_square(t, x + 2, y + 2, 3, BLACK_COLOR); +} + +/* + The timing patterns is a pattern of black / white squares (1x1) that + begin with a black one and move either horizontally or vertically, + connecting the finders separators. +*/ +function generate_timing_pattern_v(t, xStart, yStart, yEnd){ + // Start with black + let current = BLACK_COLOR; + for(let j=yStart; j<=yEnd; j++){ + t[xStart][j] = current; + current = (current == BLACK_COLOR ? WHITE_COLOR : BLACK_COLOR) + } +} + +function generate_timing_pattern_h(t, xStart, yStart, xEnd){ + // Start with black + let current = BLACK_COLOR; + for(let i=xStart; i<=xEnd; i++){ + t[i][yStart] = current; + current = (current == BLACK_COLOR ? WHITE_COLOR : BLACK_COLOR) + } +} + + +let versions = []; +for(let i=0;i<40;i++){ + versions.push( + [21 + i*4, 21 + i*4] + ) +} + +let alignment_lookup = [ + [], + [6, 18], + [6, 22], + [6, 26], + [6, 30], + [6, 34], + [6, 22, 38], + [6, 24, 42], + [6, 26, 46], + [6, 28, 50], + [6, 30, 54], + [6, 32, 58], + [6, 34, 62], + [6, 26, 46, 66], + [6, 26, 48, 70], + [6, 26, 50, 74], + [6, 30, 54, 78], + [6, 30, 56, 82], + [6, 30, 58, 86], + [6, 34, 62, 90], + [6, 28, 50, 72, 94], + [6, 26, 50, 74, 98], + [6, 30, 54, 78, 102], + [6, 28, 54, 80, 106], + [6, 32, 58, 84, 110], + [6, 30, 58, 86, 114], + [6, 34, 62, 90, 118], + [6, 26, 50, 74, 98, 122], + [6, 30, 54, 78, 102, 126], + [6, 26, 52, 78, 104, 130], + [6, 30, 56, 82, 108, 134], + [6, 34, 60, 86, 112, 138], + [6, 30, 58, 86, 114, 142], + [6, 34, 62, 90, 118, 146], + [6, 30, 54, 78, 102, 126, 150], + [6, 24, 50, 76, 102, 128, 154], + [6, 28, 54, 80, 106, 132, 158], + [6, 32, 58, 84, 110, 136, 162], + [6, 26, 54, 82, 110, 138, 166], + [6, 30, 58, 86, 114, 142, 170] +]; + +/* + Alignment patterns are boxes sized 5x5 that are + formed as follows: + + - Outer 5x5 black square + - Inner 3x3 white square + - Inner-most 1x1 black square + + The coordinates from alignment_lookup refer to the center + of the alignment pattern (the 1x1 square). +*/ + +function add_alignment_patterns(t, index){ + let alignment = alignment_lookup[index]; + if(alignment.length == 0){ + return; + } + + let alignment_locs = []; + + for(let i=0; i t.length - 8 && t_y < 8) { + continue + } + + if(l_x < 8 && t_y < 8) { + continue; + } + + if(l_x < 8 && b_y > t.length - 8){ + continue + } + + draw_square(t, x-2, y-2, 5, BLACK_COLOR); + draw_square(t, x-1, y-1, 3, WHITE_COLOR); + draw_square(t, x, y, 1, BLACK_COLOR); + + + } + console.log(alignment_locs); +} + +function generate_qr(version){ + console.log(`Generating ${version}`) + let t = []; + let sizes = versions[version-1]; + let x_max = sizes[0]; + let y_max = sizes[1]; + + for(let i = 0; i Date: Sun, 2 Jan 2022 14:10:13 +0100 Subject: [PATCH 02/33] Update qr.js add version info , add dark module --- js/qr.js | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 79 insertions(+), 5 deletions(-) diff --git a/js/qr.js b/js/qr.js index e658ee6..e3c9a2b 100644 --- a/js/qr.js +++ b/js/qr.js @@ -65,9 +65,9 @@ function generate_timing_pattern_h(t, xStart, yStart, xEnd){ } -let versions = []; +let versions_size = []; for(let i=0;i<40;i++){ - versions.push( + versions_size.push( [21 + i*4, 21 + i*4] ) } @@ -115,6 +115,7 @@ let alignment_lookup = [ [6, 30, 58, 86, 114, 142, 170] ]; + /* Alignment patterns are boxes sized 5x5 that are formed as follows: @@ -168,10 +169,79 @@ function add_alignment_patterns(t, index){ console.log(alignment_locs); } +// from table.js version_information_table ( left most bit is still position 17 ) +var version_information_table_bit = [ + [0,0,0,1,1,1,1,1,0,0,1,0,0,1,0,1,0,0], //7 + [0,0,1,0,0,0,0,1,0,1,1,0,1,1,1,1,0,0], //8 + [0,0,1,0,0,1,1,0,1,0,1,0,0,1,1,0,0,1], //9 + [0,0,1,0,1,0,0,1,0,0,1,1,0,1,0,0,1,1], //10 + [0,0,1,0,1,1,1,0,1,1,1,1,1,1,0,1,1,0], //11 + [0,0,1,1,0,0,0,1,1,1,0,1,1,0,0,0,1,0], //12 + [0,0,1,1,0,1,1,0,0,0,0,1,0,0,0,1,1,1], //13 + [0,0,1,1,1,0,0,1,1,0,0,0,0,0,1,1,0,1], //14 + [0,0,1,1,1,1,1,0,0,1,0,0,1,0,1,0,0,0], //15 + [0,1,0,0,0,0,1,0,1,1,0,1,1,1,1,0,0,0], //16 + [0,1,0,0,0,1,0,1,0,0,0,1,0,1,1,1,0,1], //17 + [0,1,0,0,1,0,1,0,1,0,0,0,0,1,0,1,1,1], //18 + [0,1,0,0,1,1,0,1,0,1,0,0,1,1,0,0,1,0], //19 + [0,1,0,1,0,0,1,0,0,1,1,0,1,0,0,1,1,0], //20 + [0,1,0,1,0,1,0,1,1,0,1,0,0,0,0,0,1,1], //21 + [0,1,0,1,1,0,1,0,0,0,1,1,0,0,1,0,0,1], //22 + [0,1,0,1,1,1,0,1,1,1,1,1,1,0,1,1,0,0], //23 + [0,1,1,0,0,0,1,1,1,0,1,1,0,0,0,1,0,0], //24 + [0,1,1,0,0,1,0,0,0,1,1,1,1,0,0,0,0,1], //25 + [0,1,1,0,1,0,1,1,1,1,1,0,1,0,1,0,1,1], //26 + [0,1,1,0,1,1,0,0,0,0,1,0,0,0,1,1,1,0], //27 + [0,1,1,1,0,0,1,1,0,0,0,0,0,1,1,0,1,0], //28 + [0,1,1,1,0,1,0,0,1,1,0,0,1,1,1,1,1,1], //29 + [0,1,1,1,1,0,1,1,0,1,0,1,1,1,0,1,0,1], //30 + [0,1,1,1,1,1,0,0,1,0,0,1,0,1,0,0,0,0], //31 + [1,0,0,0,0,0,1,0,0,1,1,1,0,1,0,1,0,1], //32 + [1,0,0,0,0,1,0,1,1,0,1,1,1,1,0,0,0,0], //33 + [1,0,0,0,1,0,1,0,0,0,1,0,1,1,1,0,1,0], //34 + [1,0,0,0,1,1,0,1,1,1,1,0,0,1,1,1,1,1], //35 + [1,0,0,1,0,0,1,0,1,1,0,0,0,0,1,0,1,1], //36 + [1,0,0,1,0,1,0,1,0,0,0,0,1,0,1,1,1,0], //37 + [1,0,0,1,1,0,1,0,1,0,0,1,1,0,0,1,0,0], //38 + [1,0,0,1,1,1,0,1,0,1,0,1,0,0,0,0,0,1], //39 + [1,0,1,0,0,0,1,1,0,0,0,1,1,0,1,0,0,1] //40 +]; + +function add_version_info(t, version){ + + if (version >= 7) { + for (step=0 ; step < 3 ; step++ ) + { + x=0; + for(let i = 17 - step; i>=0 ; i -= 3){ + // Bottom Left + draw_square(t, 4*version + 6 + step, x ,1, version_information_table_bit[version - 7][i]); + // Top Right + draw_square(t, x, 4*version + 6 + step ,1, version_information_table_bit[version - 7][i]); + + x++; + + } + } + } + return t; +} + +// https://www.thonky.com/qr-code-tutorial/format-version-information +function add_dark_module(t, version){ + + //dark module is always (8, 4*version + 9) + draw_square(t, 4*version + 9, 8 ,1, BLACK_COLOR); + + return t; +} + + + function generate_qr(version){ console.log(`Generating ${version}`) let t = []; - let sizes = versions[version-1]; + let sizes = versions_size[version-1]; let x_max = sizes[0]; let y_max = sizes[1]; @@ -193,5 +263,9 @@ function generate_qr(version){ add_alignment_patterns(t, version-1); - return t; -} \ No newline at end of file + + add_dark_module(t,version); + add_version_info(t,version); + + return t; +} From 77ee8f0901b264e7c99b27e515f7cb3658f1a5df Mon Sep 17 00:00:00 2001 From: wphiphi <96982181+wphiphi@users.noreply.github.com> Date: Sun, 2 Jan 2022 14:21:54 +0100 Subject: [PATCH 03/33] Update main.js switch qr_template array to denisvitalys generate_qr() (qr.js) resize to acceptable QR size pixel width ( main + padding windows) --- js/main.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/js/main.js b/js/main.js index 2de983e..a047a87 100644 --- a/js/main.js +++ b/js/main.js @@ -33,8 +33,8 @@ var is_data_module = []; //Store data that separate between data module a var history_array = []; //Store history information and its qr_array data var active_history = -1; //Current active history -const maxSupportedSize = 100; -const maxVersion = 50; +const maxSupportedSize = 177; // max is 177 for v40 +const maxVersion = 40; // max is not 50, but image load does not support v40 anyway and maybe less /*** * @@ -42,7 +42,15 @@ const maxVersion = 50; * ***/ function generateTable(version){ - qr_array = JSON.parse(JSON.stringify(qr_templates[version-1])); + qr_array = JSON.parse(JSON.stringify(generate_qr(version))); + if (version > 9 && version <= 20){ + qr_pixel_size = 5; + } else if (version > 20 && version <=35){ + qr_pixel_size = 2; + } else if (version > 35 ){ + qr_pixel_size = 1; + } + changed_state = false; var element = ""; @@ -909,6 +917,8 @@ function recoverPadding(){ } elem += ""; $("#qr-dummy").append(elem); + resize(qr_pixel_size); + } for(var i=0; i < result.after.length; i++){ @@ -2288,4 +2298,4 @@ $(document).ready(function(){ return "Do you really want to close? Your unsaved progress will be lost!"; }; -}) \ No newline at end of file +}) From 20d1e552c67de9614130d4da9c959fc1562c0d3f Mon Sep 17 00:00:00 2001 From: wphiphi <96982181+wphiphi@users.noreply.github.com> Date: Sun, 2 Jan 2022 14:28:13 +0100 Subject: [PATCH 04/33] Update table.js complete all tables info for up to version 40 of QR version size --- js/table.js | 679 +++++++++++++++++----------------------------------- 1 file changed, 222 insertions(+), 457 deletions(-) diff --git a/js/table.js b/js/table.js index 8eab4e6..af70202 100644 --- a/js/table.js +++ b/js/table.js @@ -48,33 +48,46 @@ var function_pattern_with_format_info = { var alignment_pattern_array = [ - [], - [6, 18], - [6, 22], - [6, 26], - [6, 30], - [6, 34], - [6, 22, 38], - [6, 24, 42], - [6, 26, 46], - [6, 28, 50], - [6, 30, 54], - [6, 32, 58], - [6, 34, 62], - [6, 26, 46, 66], - [6, 26, 36, 66], - [6, 26, 48, 70], - [6, 26, 50, 74], - [6, 30, 54, 78], - [6, 30, 56, 82], - [6, 30, 58, 86], - [6, 34, 62, 90], - [6, 28, 50, 72, 94], - [6, 26, 50, 74, 98], - [6, 30, 54, 78, 102], - [6, 28, 54, 80, 106], - [6, 32, 58, 84, 110], - [6, 30, 58, 86, 114] + [], //1 + [6, 18], //2 + [6, 22], //3 + [6, 26], //4 + [6, 30], //5 + [6, 34], //6 + [6, 22, 38], //7 + [6, 24, 42], //8 + [6, 26, 46], //9 + [6, 28, 50], //10 + [6, 30, 54], //11 + [6, 32, 58], //12 + [6, 34, 62], //13 + [6, 26, 46, 66], //14 + [6, 26, 48, 70], //15 + [6, 26, 50, 74], //16 + [6, 30, 54, 78], //17 + [6, 30, 56, 82], //18 + [6, 30, 58, 86], //19 + [6, 34, 62, 90], //20 + [6, 28, 50, 72, 94], //21 + [6, 26, 50, 74, 98], //22 + [6, 30, 54, 78, 102], //23 + [6, 28, 54, 80, 106], //24 + [6, 32, 58, 84, 110], //25 + [6, 30, 58, 86, 114], //26 + [6, 34, 62, 90, 118], //27 + [6, 26, 50, 74, 98, 122], //28 + [6, 30, 54, 78, 102, 126], //29 + [6, 26, 52, 78, 104, 130], //30 + [6, 30, 56, 82, 108, 134], //31 + [6, 34, 60, 86, 112, 138], //32 + [6, 30, 58, 86, 114, 142], //33 + [6, 34, 62, 90, 118, 146], //34 + [6, 30, 54, 78, 102, 126, 150], //35 + [6, 24, 50, 76, 102, 128, 154], //36 + [6, 28, 54, 80, 106, 132, 158], //37 + [6, 32, 58, 84, 110, 136, 162], //38 + [6, 26, 54, 82, 110, 138, 166], //39 + [6, 30, 58, 86, 114, 142, 170] //40 ]; var format_information_bits_raw = { @@ -247,37 +260,192 @@ var format_information_unmask = [ '111111111111111' ]; + +/* https://www.thonky.com/qr-code-tutorial/format-version-tables */ //Version information table for QR version 7 and higher var version_information_table = [ - 000111110010010100, - 001000010110111100, - 001001101010011001 -] + 000111110010010100, //7 + 001000010110111100, //8 + 001001101010011001, //9 + 001010010011010011, //10 + 001011101111110110, //11 + 001100011101100010, //12 + 001101100001000111, //13 + 001110011000001101, //14 + 001111100100101000, //15 + 010000101101111000, //16 + 010001010001011101, //17 + 010010101000010111, //18 + 010011010100110010, //19 + 010100100110100110, //20 + 010101011010000011, //21 + 010110100011001001, //22 + 010111011111101100, //23 + 011000111011000100, //24 + 011001000111100001, //25 + 011010111110101011, //26 + 011011000010001110, //27 + 011100110000011010, //28 + 011101001100111111, //29 + 011110110101110101, //30 + 011111001001010000, //31 + 100000100111010101, //32 + 100001011011110000, //33 + 100010100010111010, //34 + 100011011110011111, //35 + 100100101100001011, //36 + 100101010000101110, //37 + 100110101001100100, //38 + 100111010101000001, //39 + 101000110001101001 //40 +]; + + + +/* https://www.thonky.com/qr-code-tutorial/format-version-information */ +// L = 1 +// M = 0 +// Q = 3 +// H = 2 + + +/* M L H Q https://www.thonky.com/qr-code-tutorial/error-correction-table adding code block 1 and 2 */ var data_code_num_table = [ - [ 16, 19, 9, 13], - [ 28, 34, 16, 22], - [ 44, 55, 26, 34], - [ 64, 80, 36, 48], - [ 86, 108, 46, 62], - [ 108, 136, 60, 76], - [ 124, 156, 66, 88], - [ 154, 194, 86, 110], - [ 182, 232, 100, 132] + [ 16, 19, 9, 13], //1 + [ 28, 34, 16, 22], //2 + [ 44, 55, 26, 34], //3 + [ 64, 80, 36, 48], //4 + [ 86, 108, 46, 62], //5 + [ 108, 136, 60, 76], //6 + [ 124, 156, 66, 88], //7 + [ 154, 194, 86, 110], //8 + [ 182, 232, 100, 132], //9 + [ 216, 274, 122, 154], //10 + [ 254, 324, 140, 180], //11 + [ 290, 370, 158, 206], //12 + [ 334, 428, 180, 244], //13 + [ 365, 461, 197, 261], //14 + [ 415, 523, 223, 295], //15 + [ 453, 589, 253, 325], //16 + [ 507, 647, 283, 367], //17 + [ 563, 721, 313, 397], //18 + [ 627, 795, 341, 445], //19 + [ 669, 861, 385, 485], //20 + [ 714, 932, 406, 512], //21 + [ 782, 1006, 442, 568], //22 + [ 860, 1094, 464, 614], //23 + [ 914, 1174, 514, 664], //24 + [1000, 1276, 538, 718], //25 + [1062, 1370, 596, 754], //26 + [1128, 1468, 628, 808], //27 + [1193, 1531, 661, 871], //28 + [1267, 1631, 701, 911], //29 + [1373, 1735, 745, 985], //30 + [1455, 1843, 793, 1033], //31 + [1541, 1955, 845, 1115], //32 + [1631, 2071, 901, 1171], //33 + [1725, 2191, 961, 1231], //34 + [1812, 2306, 986, 1286], //35 + [1914, 2434, 1054, 1354], //36 + [1992, 2566, 1096, 1426], //37 + [2102, 2702, 1142, 1502], //38 + [2216, 2812, 1222, 1582], //39 + [2334, 2956, 1276, 1666] //40 + ]; +/* M L H Q https://www.thonky.com/qr-code-tutorial/error-correction-table adding code block 1 and 2 */ var RS_block_num_table = [ - [1, 1, 1, 1], - [1, 1, 1, 1], - [1, 1, 2, 2], - [2, 1, 4, 2], - [2, 1, 4, 4], - [4, 2, 4, 4], - [4, 2, 5, 6], - [4, 2, 6, 6], - [5, 2, 8, 8] + [1, 1, 1, 1], //1 + [1, 1, 1, 1], //2 + [1, 1, 2, 2], //3 + [2, 1, 4, 2], //4 + [2, 1, 4, 4], //5 + [4, 2, 4, 4], //6 + [4, 2, 5, 6], //7 + [4, 2, 6, 6], //8 + [5, 2, 8, 8], //9 + [5, 4, 8, 8], //10 + [5, 4, 11,8], //11 + [8, 4, 11,10], //12 + [9, 4, 16,12], //13 + [9, 4, 16,16], //14 + [10,6, 18,12], //15 + [10,6, 16,17], //16 + [11,6, 19,16], //17 + [13, 6, 21, 18], //18 + [14, 7, 25, 21], //19 + [16, 8, 25, 20], //20 + [17, 8, 25, 23], //21 + [17, 9, 34, 23], //22 + [18, 9, 30, 25], //23 + [20, 10, 32, 27], //24 + [21, 12, 35, 29], //25 + [23, 12, 37, 34], //26 + [25, 12, 40, 34], //27 + [26, 13, 42, 35], //28 + [28, 14, 45, 38], //29 + [29, 15, 48, 40], //30 + [31, 16, 51, 43], //31 + [33, 17, 54, 45], //32 + [35, 18, 57, 48], //33 + [37, 19, 60, 51], //34 + [38, 19, 63, 53], //35 + [40, 20, 66, 56], //36 + [43, 21, 70, 59], //37 + [45, 22, 74, 62], //38 + [47, 24, 77, 65], //39 + [49, 25, 81, 68] //40 ]; +/* M L H Q https://www.thonky.com/qr-code-tutorial/error-correction-table adding code block 1 and 2 */ +var error_correction_code_table = [ + [10, 7,17,13], //1 + [16,10,28,22], //2 + [26,15,22,18], //3 + [18,20,16,26], //4 + [24,26,22,18], //5 + [16,18,28,24], //6 + [18,20,26,18], //7 + [22,24,26,22], //8 + [22,30,24,20], //9 + [26,18,28,24], //10 + [30,20,24,28], //11 + [22,24,28,26], //12 + [22,26,22,24], //13 + [24,30,24,20], //14 + [24,22,24,30], //15 + [28,24,30,24], //16 + [28,28,28,28], //17 + [26,30,28,28], //18 + [26,28,26,26], //19 + [26,28,28,30], //20 + [26,28,30,28], //21 + [28,28,24,30], //22 + [28,30,30,30], //23 + [28,30,30,30], //24 + [28,26,30,30], //25 + [28,28,30,28], //26 + [28,30,30,30], //27 + [28,30,30,30], //28 + [28,30,30,30], //29 + [28,30,30,30], //30 + [28,30,30,30], //31 + [28,30,30,30], //32 + [28,30,30,30], //33 + [28,30,30,30], //34 + [28,30,30,30], //35 + [28,30,30,30], //36 + [28,30,30,30], //37 + [28,30,30,30], //38 + [28,30,30,30], //39 + [28,30,30,30] //40 + +]; + + + var alphanumeric_table = [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", @@ -289,414 +457,11 @@ var alphanumeric_table = [ ".", "/", ":" ]; -var error_correction_code_table = [ - [10,7,17,13], - [16,10,28,22], - [26,15,22,18], - [18,20,16,26], - [24,26,22,18], - [16,18,28,24], - [18,20,26,18], - [22,24,26,22], - [22,30,24,20] -]; +/* + https://www.thonky.com/qr-code-tutorial/structure-final-message + up to QR version 40 -var remainder_bits_table = [0,7,7,7,7,7,0,0,0]; + 1 2 3 4 5 6 7 8 910111213141516171819202122232425262728293031323334353637383940 */ +var remainder_bits_table = [0,7,7,7,7,7,0,0,0,0,0,0,0,3,3,3,3,3,3,3,4,4,4,4,4,4,4,3,3,3,3,3,3,3,0,0,0,0,0,0]; -/************************************************************ - Pre-defined QR matri-1 template for faster computing - - 0 : white - 1 : black - -1 : grey (data modules) - -*************************************************************/ -var qr_templates = [ - [ - /**************** - VERSION 1 - ****************/ - [1,1,1,1,1,1,1,0,0,-1,-1,-1,-1,0,1,1,1,1,1,1,1], - [1,0,0,0,0,0,1,0,0,-1,-1,-1,-1,0,1,0,0,0,0,0,1], - [1,0,1,1,1,0,1,0,0,-1,-1,-1,-1,0,1,0,1,1,1,0,1], - [1,0,1,1,1,0,1,0,0,-1,-1,-1,-1,0,1,0,1,1,1,0,1], - [1,0,1,1,1,0,1,0,0,-1,-1,-1,-1,0,1,0,1,1,1,0,1], - [1,0,0,0,0,0,1,0,0,-1,-1,-1,-1,0,1,0,0,0,0,0,1], - [1,1,1,1,1,1,1,0,1,0,1,0,1,0,1,1,1,1,1,1,1], - [0,0,0,0,0,0,0,0,0,-1,-1,-1,-1,0,0,0,0,0,0,0,0], - [0,0,0,0,0,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1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1], - [1,0,0,0,0,0,1,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1], - [1,1,1,1,1,1,1,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1] - ] -]; \ No newline at end of file From a8167f9bc5336c9d25ecb1a9e38d5407acb61d51 Mon Sep 17 00:00:00 2001 From: wphiphi <96982181+wphiphi@users.noreply.github.com> Date: Sun, 2 Jan 2022 14:34:13 +0100 Subject: [PATCH 05/33] add load denyvitali qr.js --- index.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index bd4e16c..bd3f893 100644 --- a/index.html +++ b/index.html @@ -553,6 +553,7 @@ + @@ -599,4 +600,4 @@ - \ No newline at end of file + From d53a0786eaf628c7611575622f806d58bb6cc16c Mon Sep 17 00:00:00 2001 From: wphiphi <96982181+wphiphi@users.noreply.github.com> Date: Sun, 2 Jan 2022 14:41:01 +0100 Subject: [PATCH 06/33] update to suppport up to version 40 --- js/sqrd.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/js/sqrd.js b/js/sqrd.js index 7325466..e80b8b9 100644 --- a/js/sqrd.js +++ b/js/sqrd.js @@ -870,6 +870,12 @@ function QRDecode(data){ if(mode == 0b0001){ var length_indicator = 10; + if ( version > 9 && version <= 26 ){ + length_indicator = 12; + } else if ( version > 26 ){ + length_indicator = 14; + } + var num = ""; length = parseInt(data_bits.substring(0, length_indicator), 2); temp_data += "["+data_bits.substring(0, length_indicator)+"] ["; @@ -908,6 +914,12 @@ function QRDecode(data){ } else if(mode == 0b0010){ var length_indicator = 9; + if ( version > 9 && version <= 26 ){ + length_indicator = 11; + } else if ( version > 26 ){ + length_indicator = 13; + } + var current_data = ""; length = parseInt(data_bits.substring(0, length_indicator), 2); temp_data += "["+data_bits.substring(0, length_indicator)+"] ["; @@ -950,6 +962,10 @@ function QRDecode(data){ } else if(mode == 0b0100){ var length_indicator = 8; + if ( version > 9 ){ + length_indicator = 16; + } + var current_data = ""; length = parseInt(data_bits.substring(0, length_indicator), 2); temp_data += "["+data_bits.substring(0, length_indicator)+"] ["; @@ -1232,4 +1248,4 @@ function readDataBits(data_bits){ } return data.join(""); -} \ No newline at end of file +} From 419f7cb342f42136becc7755c33f61985ce1f844 Mon Sep 17 00:00:00 2001 From: wphiphi <96982181+wphiphi@users.noreply.github.com> Date: Sun, 2 Jan 2022 15:28:37 +0100 Subject: [PATCH 07/33] Update main.js --- js/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/main.js b/js/main.js index a047a87..4892164 100644 --- a/js/main.js +++ b/js/main.js @@ -34,7 +34,7 @@ var history_array = []; //Store history information and its qr_array dat var active_history = -1; //Current active history const maxSupportedSize = 177; // max is 177 for v40 -const maxVersion = 40; // max is not 50, but image load does not support v40 anyway and maybe less +const maxVersion = 40; // max is not 50 /*** * From 42cfcdcb49453edc30356e999f8fa79a613d4927 Mon Sep 17 00:00:00 2001 From: wphiphi <96982181+wphiphi@users.noreply.github.com> Date: Sun, 2 Jan 2022 15:36:22 +0100 Subject: [PATCH 08/33] fix styling --- js/qr.js | 46 +++++++++++++++++++--------------------------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/js/qr.js b/js/qr.js index e3c9a2b..24d9b63 100644 --- a/js/qr.js +++ b/js/qr.js @@ -208,32 +208,26 @@ var version_information_table_bit = [ ]; function add_version_info(t, version){ - - if (version >= 7) { - for (step=0 ; step < 3 ; step++ ) - { - x=0; - for(let i = 17 - step; i>=0 ; i -= 3){ - // Bottom Left - draw_square(t, 4*version + 6 + step, x ,1, version_information_table_bit[version - 7][i]); - // Top Right - draw_square(t, x, 4*version + 6 + step ,1, version_information_table_bit[version - 7][i]); - - x++; - - } - } - } - return t; + if (version >= 7) { + for (step=0 ; step < 3 ; step++ ){ + x=0; + for(let i = 17 - step; i>=0 ; i -= 3){ + // Bottom Left + draw_square(t, 4*version + 6 + step, x ,1, version_information_table_bit[version - 7][i]); + // Top Right + draw_square(t, x, 4*version + 6 + step ,1, version_information_table_bit[version - 7][i]); + x++; + } + } + } + return t; } // https://www.thonky.com/qr-code-tutorial/format-version-information function add_dark_module(t, version){ - - //dark module is always (8, 4*version + 9) - draw_square(t, 4*version + 9, 8 ,1, BLACK_COLOR); - - return t; + //dark module is always (8, 4*version + 9) + draw_square(t, 4*version + 9, 8 ,1, BLACK_COLOR); + return t; } @@ -262,10 +256,8 @@ function generate_qr(version){ generate_timing_pattern_h(t, 8, 6, x_max-9); add_alignment_patterns(t, version-1); + add_dark_module(t,version); + add_version_info(t,version); - - add_dark_module(t,version); - add_version_info(t,version); - - return t; + return t; } From 8766a6b880adcce849aac7364d12ddef3b9cb2d0 Mon Sep 17 00:00:00 2001 From: wphiphi <96982181+wphiphi@users.noreply.github.com> Date: Sun, 2 Jan 2022 16:34:14 +0100 Subject: [PATCH 09/33] add quiet zone to canvas image ( decode section ) normal decode will work for v40 --- js/main.js | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/js/main.js b/js/main.js index 4892164..f9d3847 100644 --- a/js/main.js +++ b/js/main.js @@ -300,17 +300,30 @@ function getInfoBits(){ ***/ function generateResult(){ - var c = document.getElementById("qr-result"); - var size = 17+(qr_version*4); - c.width = qr_pixel_size*size; + var c = document.getElementById("qr-result"); + var size = 17+(qr_version*4); + var ctx = c.getContext("2d"); + + c.width = qr_pixel_size*size; c.height = qr_pixel_size*size; - var ctx = c.getContext("2d"); - ctx.fillStyle = "#000"; - for(var i=0; i < qr_array.length; i++){ - for(var j=0; j < qr_array[i].length; j++){ - var x = qr_pixel_size*j; - var y = qr_pixel_size*i; + // add quiet zone border and white fill + c.width += (qr_pixel_size*4) * 2; + c.height += (qr_pixel_size*4) * 2; + ctx.fillStyle = "#fff"; + ctx.fillRect(0,0,c.width,c.height); + + ctx.fillStyle = "#000"; + + for(var i=0; i < qr_array.length; i++){ + for(var j=0; j < qr_array[i].length; j++){ + var x = qr_pixel_size*j; + var y = qr_pixel_size*i; + + //shift due to quiet zone + x += qr_pixel_size*4; + y += qr_pixel_size*4; + if(qr_array[i][j] == 1){ ctx.fillStyle = "#000"; ctx.fillRect(x,y,qr_pixel_size,qr_pixel_size); From f3918f18bf2cc3298f8d71ccc9276ea674243061 Mon Sep 17 00:00:00 2001 From: wphiphi <96982181+wphiphi@users.noreply.github.com> Date: Sun, 2 Jan 2022 20:44:07 +0100 Subject: [PATCH 10/33] decode mode min 2px + toogle back restore px size decode mode need 2px width module for correct decoding , also it now support switching up or lower and reverting to original encode pixel module settings before decode mode being used --- js/main.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/js/main.js b/js/main.js index f9d3847..4b9d63d 100644 --- a/js/main.js +++ b/js/main.js @@ -10,6 +10,8 @@ var APP_VERSION = '0.4.0'; var qr_version = 1; //Current QR version (1-9) var qr_pixel_size = 10; //Current view size of QR code (pixel per module) +var qr_pixel_size_togglesave = 10; //Last toggle view size of QR code (pixel per module) + var qr_size = 17+(qr_version*4); //Current size of QR code var qr_array = []; //Main array to store QR data @@ -380,6 +382,12 @@ function toggleResult(){ $(".mode-indicator button").removeClass("active"); $("#mobile-decode-mode").addClass("active"); + //resize for decode ( minimum 2px module width needed for standard device decoding ) + qr_pixel_size_togglesave = qr_pixel_size; + if (qr_pixel_size == 1 ) { + $("#btn-size-plus").trigger("click"); + } + generateResult(); $("#btn-switch-mode").addClass("active"); $("#div-tool-work, #box-history").hide(); @@ -400,6 +408,18 @@ function toggleResult(){ $(".mode-indicator button").removeClass("active"); $("#mobile-editor-mode").addClass("active"); + //restore to previous encode mode pixel size + if (qr_pixel_size - qr_pixel_size_togglesave >= 0){ + for (i = qr_pixel_size - qr_pixel_size_togglesave ; i > 0 ; i-- ){ + $("#btn-size-min").trigger("click"); + } + } + else { + for (i = qr_pixel_size_togglesave - qr_pixel_size ; i > 0 ; i-- ){ + $("#btn-size-plus").trigger("click"); + } + } + $("#qr-result").hide(); $(".qr-tab").show(); $("#btn-switch-mode").removeClass("active"); From b396c5e61181c2977fa9c7a66c2d749613af66bf Mon Sep 17 00:00:00 2001 From: wphiphi <96982181+wphiphi@users.noreply.github.com> Date: Sun, 2 Jan 2022 21:01:28 +0100 Subject: [PATCH 11/33] decode mode result textarea size * QR version --- js/main.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/js/main.js b/js/main.js index 4b9d63d..df36f93 100644 --- a/js/main.js +++ b/js/main.js @@ -1595,6 +1595,8 @@ $(document).ready(function(){ decodeFromBase64(image, function(decodedData){ if(decodedData != "error decoding QR Code"){ $("#decode-message").val(decodedData); + //resize for text based on QR version + $("#decode-message").css("height", (17+4*qr_version)*3+"px"); } }); } From dba1483176d9e681b20c499c9f67e493d3fc3126 Mon Sep 17 00:00:00 2001 From: wphiphi <96982181+wphiphi@users.noreply.github.com> Date: Mon, 3 Jan 2022 00:37:34 +0100 Subject: [PATCH 12/33] fix RS decoder & recoverPadding decoder QR higher version bit parsing fix (num, alphanum, byte) --- js/sqrd.js | 51 ++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 9 deletions(-) diff --git a/js/sqrd.js b/js/sqrd.js index e80b8b9..d4bd650 100644 --- a/js/sqrd.js +++ b/js/sqrd.js @@ -429,10 +429,17 @@ function recoverPaddingBits(data_array){ var encoding_mode = data_bits.substring(0,4); if(encoding_mode == "0001"){ - if(data_bits.substring(4,14).search(/\?/g) != -1) + var length_indicator = 10; + if ( version > 9 && version <= 26 ){ + length_indicator = 12; + } else if ( version > 26 ){ + length_indicator = 14; + } + + if(data_bits.substring(4,4+length_indicator).search(/\?/g) != -1) return "ERROR: Unknown Character Count Indicator"; - var character_count = parseInt(data_bits.substring(4,14), 2); + var character_count = parseInt(data_bits.substring(4,4+length_indicator), 2); if(character_count % 3 == 0){ var offset = (character_count/3)*10; } else if(character_count % 3 == 1) { @@ -442,28 +449,38 @@ function recoverPaddingBits(data_array){ var offset = ((character_count-1)/3)*10; offset += 4; } - offset += 14; + offset += 4+length_indicator; } else if(encoding_mode == "0010"){ - if(data_bits.substring(4,13).search(/\?/g) != -1) + var length_indicator = 9; + if ( version > 9 && version <= 26 ){ + length_indicator = 11; + } else if ( version > 26 ){ + length_indicator = 13; + } + if(data_bits.substring(4,4+length_indicator).search(/\?/g) != -1) return "ERROR: Unknown Character Count Indicator"; - var character_count = parseInt(data_bits.substring(4,13), 2); + var character_count = parseInt(data_bits.substring(4,4+length_indicator), 2); if(character_count % 2 == 0){ var offset = (character_count/2)*11; } else { var offset = ((character_count-1)/2)*11; offset += 6; } - offset += 13; + offset += 4+length_indicator; } else if(encoding_mode == "0100"){ - if(data_bits.substring(4,12).search(/\?/g) != -1) + var length_indicator = 8; + if ( version > 9 ){ + length_indicator = 16; + } + if(data_bits.substring(4,4+length_indicator).search(/\?/g) != -1) return "ERROR: Unknown Character Count Indicator"; - var character_count = parseInt(data_bits.substring(4,12), 2); + var character_count = parseInt(data_bits.substring(4,4+length_indicator), 2); var offset = character_count*8; - offset += 12; + offset += 4+length_indicator; } else if(encoding_mode == "1000"){ if(data_bits.substring(4,12).search(/\?/g) != -1) @@ -1133,6 +1150,12 @@ function readDataBits(data_bits){ if(mode == 0b0001){ var length_indicator = 10; + if ( qr_version > 9 && qr_version <= 26 ){ + length_indicator = 12; + } else if ( qr_version > 26 ){ + length_indicator = 14; + } + var num = ""; length = parseInt(data_bits.substring(0, length_indicator), 2); temp_data += "["+data_bits.substring(0, length_indicator)+"] ["; @@ -1168,6 +1191,12 @@ function readDataBits(data_bits){ } else if(mode == 0b0010){ var length_indicator = 9; + if ( qr_version > 9 && qr_version <= 26 ){ + length_indicator = 11; + } else if ( qr_version > 26 ){ + length_indicator = 13; + } + var current_data = ""; length = parseInt(data_bits.substring(0, length_indicator), 2); temp_data += "["+data_bits.substring(0, length_indicator)+"] ["; @@ -1206,6 +1235,10 @@ function readDataBits(data_bits){ } else if(mode == 0b0100){ var length_indicator = 8; + if ( qr_version > 9 ){ + length_indicator = 16; + } + var current_data = ""; length = parseInt(data_bits.substring(0, length_indicator), 2); temp_data += "["+data_bits.substring(0, length_indicator)+"] ["; From e14f03123725e3844e36c3860e726fb97f095076 Mon Sep 17 00:00:00 2001 From: wphiphi <96982181+wphiphi@users.noreply.github.com> Date: Mon, 3 Jan 2022 01:01:04 +0100 Subject: [PATCH 13/33] highlight masking in menu if applied --- js/main.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/js/main.js b/js/main.js index df36f93..9e7562e 100644 --- a/js/main.js +++ b/js/main.js @@ -26,6 +26,7 @@ var show_grey = true; //Show grey modules in Decode mode var extract_info_mode = false; //Is Extract QR Information active? var brute_force_mode = false; //Is Brute-force Format Info active? var analysis_mode = false; //Is Data Analysis tool active? +var masking_mode = false; //Is Masking active? var qr_temp_array = []; //Temporary variable to handle qr_array duplicates var qr_data_block = []; //Array to store data block in "Data Analysis tool" @@ -1745,6 +1746,14 @@ $(document).ready(function(){ $("#data-masking-slider div.active").removeClass("active"); $("#data-masking-slider div[data="+current_mask+"]").addClass("active"); + if($(this).hasClass("active")){ + masking_mode = false; + $(this).removeClass("active"); + } else { + masking_mode = true; + $(this).addClass("active"); + } + $("#div-data-masking").show(); $("#div-tools").hide(); }) From a86429b67379d4d012fd6bcbe11b5c04e8d4b770 Mon Sep 17 00:00:00 2001 From: wphiphi <96982181+wphiphi@users.noreply.github.com> Date: Mon, 3 Jan 2022 01:22:00 +0100 Subject: [PATCH 14/33] Delete finder-example.html --- finder-example.html | 61 --------------------------------------------- 1 file changed, 61 deletions(-) delete mode 100644 finder-example.html diff --git a/finder-example.html b/finder-example.html deleted file mode 100644 index e53731a..0000000 --- a/finder-example.html +++ /dev/null @@ -1,61 +0,0 @@ - - - - QR Code Finder Example - - - - - - - - - - From 18f0d9444327f646c32eca0ecaa24763bf00f566 Mon Sep 17 00:00:00 2001 From: wphiphi <96982181+wphiphi@users.noreply.github.com> Date: Mon, 3 Jan 2022 01:23:16 +0100 Subject: [PATCH 15/33] Delete index2.html --- index2.html | 61 ----------------------------------------------------- 1 file changed, 61 deletions(-) delete mode 100644 index2.html diff --git a/index2.html b/index2.html deleted file mode 100644 index d7676cf..0000000 --- a/index2.html +++ /dev/null @@ -1,61 +0,0 @@ - - - - QR Code Display - - - - - - - - - - From 65d210f345c2df8294a5c069ba883b92e971ca87 Mon Sep 17 00:00:00 2001 From: wphiphi <96982181+wphiphi@users.noreply.github.com> Date: Mon, 3 Jan 2022 01:44:09 +0100 Subject: [PATCH 16/33] change version_information_table to string quoted all 0 & 1 --- js/table.js | 69 ++++++++++++++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 35 deletions(-) diff --git a/js/table.js b/js/table.js index af70202..8a7f8ee 100644 --- a/js/table.js +++ b/js/table.js @@ -264,44 +264,43 @@ var format_information_unmask = [ /* https://www.thonky.com/qr-code-tutorial/format-version-tables */ //Version information table for QR version 7 and higher var version_information_table = [ - 000111110010010100, //7 - 001000010110111100, //8 - 001001101010011001, //9 - 001010010011010011, //10 - 001011101111110110, //11 - 001100011101100010, //12 - 001101100001000111, //13 - 001110011000001101, //14 - 001111100100101000, //15 - 010000101101111000, //16 - 010001010001011101, //17 - 010010101000010111, //18 - 010011010100110010, //19 - 010100100110100110, //20 - 010101011010000011, //21 - 010110100011001001, //22 - 010111011111101100, //23 - 011000111011000100, //24 - 011001000111100001, //25 - 011010111110101011, //26 - 011011000010001110, //27 - 011100110000011010, //28 - 011101001100111111, //29 - 011110110101110101, //30 - 011111001001010000, //31 - 100000100111010101, //32 - 100001011011110000, //33 - 100010100010111010, //34 - 100011011110011111, //35 - 100100101100001011, //36 - 100101010000101110, //37 - 100110101001100100, //38 - 100111010101000001, //39 - 101000110001101001 //40 + "000111110010010100", //7 + "001000010110111100", //8 + "001001101010011001", //9 + "001010010011010011", //10 + "001011101111110110", //11 + "001100011101100010", //12 + "001101100001000111", //13 + "001110011000001101", //14 + "001111100100101000", //15 + "010000101101111000", //16 + "010001010001011101", //17 + "010010101000010111", //18 + "010011010100110010", //19 + "010100100110100110", //20 + "010101011010000011", //21 + "010110100011001001", //22 + "010111011111101100", //23 + "011000111011000100", //24 + "011001000111100001", //25 + "011010111110101011", //26 + "011011000010001110", //27 + "011100110000011010", //28 + "011101001100111111", //29 + "011110110101110101", //30 + "011111001001010000", //31 + "100000100111010101", //32 + "100001011011110000", //33 + "100010100010111010", //34 + "100011011110011111", //35 + "100100101100001011", //36 + "100101010000101110", //37 + "100110101001100100", //38 + "100111010101000001", //39 + "101000110001101001" //40 ]; - /* https://www.thonky.com/qr-code-tutorial/format-version-information */ // L = 1 // M = 0 From 6f5439d7a71e64317702a72262c66716d5d841eb Mon Sep 17 00:00:00 2001 From: wphiphi <96982181+wphiphi@users.noreply.github.com> Date: Tue, 4 Jan 2022 13:30:47 +0100 Subject: [PATCH 17/33] add textarea for text export --- index.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index bd3f893..828fe68 100644 --- a/index.html +++ b/index.html @@ -176,7 +176,11 @@
- +
+ +

+ +

From 3181e2bc6f67c951046e1aa9b276c989a5bb1a62 Mon Sep 17 00:00:00 2001 From: wphiphi <96982181+wphiphi@users.noreply.github.com> Date: Tue, 4 Jan 2022 13:37:50 +0100 Subject: [PATCH 18/33] add textarea text dump in decode mode --- js/main.js | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/js/main.js b/js/main.js index 9e7562e..0d9c65d 100644 --- a/js/main.js +++ b/js/main.js @@ -296,6 +296,24 @@ function getInfoBits(){ return result; } +/*** +* +* Create text format compatible with Strong Decoder based on qr_array values +* from https://github.com/saitouena/qrazybox/commit/b64a0580be81e0d091c544abae3fff5e246dc09c +***/ +function dump_qr_array() { + let sz = qr_array.length; + dump_qr = ""; + for(let i=0;i x===1 ? 'X' : '_').join(''); + console.log(line); + dump_qr += line + "\n" + } + + return dump_qr; + +} + /*** * * generate QR code made from canvas based on qr_array values @@ -303,7 +321,7 @@ function getInfoBits(){ ***/ function generateResult(){ - var c = document.getElementById("qr-result"); + var c = document.getElementById("qr-result-canvas"); var size = 17+(qr_version*4); var ctx = c.getContext("2d"); @@ -345,7 +363,13 @@ function generateResult(){ } } } - + + $("#qr-result-dump").attr('rows', qr_version*4 +17 ); + $("#qr-result-dump").attr('cols', qr_version*4 +17 ); + $("#qr-result-dump").css( 'font-family', 'Courier New'); + $("#qr-result-dump").css("font-size", "7px"); + $("#qr-result-dump").val( dump_qr_array() ); + $("#qr-result").show(); $("#qr-table").hide(); $("#qr-overlay").hide(); @@ -857,7 +881,7 @@ function bruteForceFormatInfo(){ qr_format_array = format_information_bits[i][j].split("").reverse(); saveInfoTable(qr_size); generateResult(); - var image = document.getElementById("qr-result").toDataURL(); + var image = document.getElementById("qr-result-canvas").toDataURL(); if(i == 3 && j == 7){ decodeFromBase64(image, function(data){ brute_result.push(data); @@ -1590,7 +1614,7 @@ $(document).ready(function(){ $("#div-brute-force-loader").show(); bruteForceFormatInfo(); } else { - var image = document.getElementById("qr-result").toDataURL(); + var image = document.getElementById("qr-result-canvas").toDataURL(); $("#decode-message").val(""); $("#div-decode").show(); decodeFromBase64(image, function(decodedData){ From aeccf3f471ab5e8f1939dcd530dbd9f2f6a5b240 Mon Sep 17 00:00:00 2001 From: wphiphi <96982181+wphiphi@users.noreply.github.com> Date: Tue, 4 Jan 2022 13:57:41 +0100 Subject: [PATCH 19/33] refoctoring - reuse table.js infomration arrays --- js/qr.js | 92 ++++---------------------------------------------------- 1 file changed, 6 insertions(+), 86 deletions(-) diff --git a/js/qr.js b/js/qr.js index 24d9b63..657084e 100644 --- a/js/qr.js +++ b/js/qr.js @@ -72,50 +72,6 @@ for(let i=0;i<40;i++){ ) } -let alignment_lookup = [ - [], - [6, 18], - [6, 22], - [6, 26], - [6, 30], - [6, 34], - [6, 22, 38], - [6, 24, 42], - [6, 26, 46], - [6, 28, 50], - [6, 30, 54], - [6, 32, 58], - [6, 34, 62], - [6, 26, 46, 66], - [6, 26, 48, 70], - [6, 26, 50, 74], - [6, 30, 54, 78], - [6, 30, 56, 82], - [6, 30, 58, 86], - [6, 34, 62, 90], - [6, 28, 50, 72, 94], - [6, 26, 50, 74, 98], - [6, 30, 54, 78, 102], - [6, 28, 54, 80, 106], - [6, 32, 58, 84, 110], - [6, 30, 58, 86, 114], - [6, 34, 62, 90, 118], - [6, 26, 50, 74, 98, 122], - [6, 30, 54, 78, 102, 126], - [6, 26, 52, 78, 104, 130], - [6, 30, 56, 82, 108, 134], - [6, 34, 60, 86, 112, 138], - [6, 30, 58, 86, 114, 142], - [6, 34, 62, 90, 118, 146], - [6, 30, 54, 78, 102, 126, 150], - [6, 24, 50, 76, 102, 128, 154], - [6, 28, 54, 80, 106, 132, 158], - [6, 32, 58, 84, 110, 136, 162], - [6, 26, 54, 82, 110, 138, 166], - [6, 30, 58, 86, 114, 142, 170] -]; - - /* Alignment patterns are boxes sized 5x5 that are formed as follows: @@ -124,12 +80,12 @@ let alignment_lookup = [ - Inner 3x3 white square - Inner-most 1x1 black square - The coordinates from alignment_lookup refer to the center + The coordinates from alignment_pattern_array (file: table.js) refer to the center of the alignment pattern (the 1x1 square). */ function add_alignment_patterns(t, index){ - let alignment = alignment_lookup[index]; + let alignment = alignment_pattern_array[index]; if(alignment.length == 0){ return; } @@ -169,53 +125,17 @@ function add_alignment_patterns(t, index){ console.log(alignment_locs); } -// from table.js version_information_table ( left most bit is still position 17 ) -var version_information_table_bit = [ - [0,0,0,1,1,1,1,1,0,0,1,0,0,1,0,1,0,0], //7 - [0,0,1,0,0,0,0,1,0,1,1,0,1,1,1,1,0,0], //8 - [0,0,1,0,0,1,1,0,1,0,1,0,0,1,1,0,0,1], //9 - [0,0,1,0,1,0,0,1,0,0,1,1,0,1,0,0,1,1], //10 - [0,0,1,0,1,1,1,0,1,1,1,1,1,1,0,1,1,0], //11 - [0,0,1,1,0,0,0,1,1,1,0,1,1,0,0,0,1,0], //12 - [0,0,1,1,0,1,1,0,0,0,0,1,0,0,0,1,1,1], //13 - [0,0,1,1,1,0,0,1,1,0,0,0,0,0,1,1,0,1], //14 - [0,0,1,1,1,1,1,0,0,1,0,0,1,0,1,0,0,0], //15 - [0,1,0,0,0,0,1,0,1,1,0,1,1,1,1,0,0,0], //16 - [0,1,0,0,0,1,0,1,0,0,0,1,0,1,1,1,0,1], //17 - [0,1,0,0,1,0,1,0,1,0,0,0,0,1,0,1,1,1], //18 - [0,1,0,0,1,1,0,1,0,1,0,0,1,1,0,0,1,0], //19 - [0,1,0,1,0,0,1,0,0,1,1,0,1,0,0,1,1,0], //20 - [0,1,0,1,0,1,0,1,1,0,1,0,0,0,0,0,1,1], //21 - [0,1,0,1,1,0,1,0,0,0,1,1,0,0,1,0,0,1], //22 - [0,1,0,1,1,1,0,1,1,1,1,1,1,0,1,1,0,0], //23 - [0,1,1,0,0,0,1,1,1,0,1,1,0,0,0,1,0,0], //24 - [0,1,1,0,0,1,0,0,0,1,1,1,1,0,0,0,0,1], //25 - [0,1,1,0,1,0,1,1,1,1,1,0,1,0,1,0,1,1], //26 - [0,1,1,0,1,1,0,0,0,0,1,0,0,0,1,1,1,0], //27 - [0,1,1,1,0,0,1,1,0,0,0,0,0,1,1,0,1,0], //28 - [0,1,1,1,0,1,0,0,1,1,0,0,1,1,1,1,1,1], //29 - [0,1,1,1,1,0,1,1,0,1,0,1,1,1,0,1,0,1], //30 - [0,1,1,1,1,1,0,0,1,0,0,1,0,1,0,0,0,0], //31 - [1,0,0,0,0,0,1,0,0,1,1,1,0,1,0,1,0,1], //32 - [1,0,0,0,0,1,0,1,1,0,1,1,1,1,0,0,0,0], //33 - [1,0,0,0,1,0,1,0,0,0,1,0,1,1,1,0,1,0], //34 - [1,0,0,0,1,1,0,1,1,1,1,0,0,1,1,1,1,1], //35 - [1,0,0,1,0,0,1,0,1,1,0,0,0,0,1,0,1,1], //36 - [1,0,0,1,0,1,0,1,0,0,0,0,1,0,1,1,1,0], //37 - [1,0,0,1,1,0,1,0,1,0,0,1,1,0,0,1,0,0], //38 - [1,0,0,1,1,1,0,1,0,1,0,1,0,0,0,0,0,1], //39 - [1,0,1,0,0,0,1,1,0,0,0,1,1,0,1,0,0,1] //40 -]; - +// use table.js Array version_information_table ( left most bit is still position 17 ) function add_version_info(t, version){ if (version >= 7) { for (step=0 ; step < 3 ; step++ ){ x=0; for(let i = 17 - step; i>=0 ; i -= 3){ // Bottom Left - draw_square(t, 4*version + 6 + step, x ,1, version_information_table_bit[version - 7][i]); + draw_square(t, 4*version + 6 + step, x ,1, version_information_table[version - 7].toString().split("")[i]); // Top Right - draw_square(t, x, 4*version + 6 + step ,1, version_information_table_bit[version - 7][i]); + draw_square(t, x, 4*version + 6 + step ,1, version_information_table[version - 7].toString().split("")[i]); + x++; } } From 39088a3d91028aeef0ce0d3f476fedf93f5e582c Mon Sep 17 00:00:00 2001 From: wphiphi <96982181+wphiphi@users.noreply.github.com> Date: Tue, 4 Jan 2022 14:12:21 +0100 Subject: [PATCH 20/33] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7619568..523cdee 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,8 @@ Main Features - Decode and read unscannable QR Code - Save and load existing work for later use - Import/export QR Code from/to Image file -- Currently support up to QR Code Version 9 (53x53) +- Export QR code to Text file +- Currently support up to QR Code Version 40 (177x177) - Support both Error and Erasure Correction using universal Reed-Solomon decoder - Extract valuable information although from badly damaged QR Code - Simulate data unmasking for manual data analysis From bfe213af7ae3b34d2fb29b9b6eb5c106bac2fc57 Mon Sep 17 00:00:00 2001 From: wphiphi <96982181+wphiphi@users.noreply.github.com> Date: Tue, 4 Jan 2022 15:34:18 +0100 Subject: [PATCH 21/33] dump to text support for show_Grey button --- js/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/main.js b/js/main.js index 0d9c65d..b6fde59 100644 --- a/js/main.js +++ b/js/main.js @@ -305,7 +305,7 @@ function dump_qr_array() { let sz = qr_array.length; dump_qr = ""; for(let i=0;i x===1 ? 'X' : '_').join(''); + let line = qr_array[i].map(x => ( x===1 ? '#' : ( x===0 ? '_' : ( show_grey ? '?' : '_' ) ) ) ).join(''); console.log(line); dump_qr += line + "\n" } From 3231700a78d820556b6eb7b2d74bc3d77be610a7 Mon Sep 17 00:00:00 2001 From: wphiphi <96982181+wphiphi@users.noreply.github.com> Date: Tue, 4 Jan 2022 15:36:17 +0100 Subject: [PATCH 22/33] fix : version bit : was char instead of bool --- js/qr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/qr.js b/js/qr.js index 657084e..b2bcb7c 100644 --- a/js/qr.js +++ b/js/qr.js @@ -132,9 +132,9 @@ function add_version_info(t, version){ x=0; for(let i = 17 - step; i>=0 ; i -= 3){ // Bottom Left - draw_square(t, 4*version + 6 + step, x ,1, version_information_table[version - 7].toString().split("")[i]); + draw_square(t, 4*version + 6 + step, x ,1, BLACK_COLOR * parseInt(version_information_table[version - 7].toString().split("")[i])); // Top Right - draw_square(t, x, 4*version + 6 + step ,1, version_information_table[version - 7].toString().split("")[i]); + draw_square(t, x, 4*version + 6 + step ,1, BLACK_COLOR * parseInt(version_information_table[version - 7].toString().split("")[i])); x++; } From 9013a40a80e8cb8da0bcd7c63db8c078e1c9bff2 Mon Sep 17 00:00:00 2001 From: wphiphi <96982181+wphiphi@users.noreply.github.com> Date: Tue, 4 Jan 2022 17:44:44 +0100 Subject: [PATCH 23/33] support for Text file loading in index.html --- index.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/index.html b/index.html index 828fe68..8a17529 100644 --- a/index.html +++ b/index.html @@ -210,10 +210,13 @@
+
+ +
From ee0174594ceda0d1e6a79ef087749d9dbf5cff66 Mon Sep 17 00:00:00 2001 From: wphiphi <96982181+wphiphi@users.noreply.github.com> Date: Tue, 4 Jan 2022 17:51:27 +0100 Subject: [PATCH 24/33] Import from Text ( format used in waidotto ) --- js/main.js | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/js/main.js b/js/main.js index b6fde59..a707e60 100644 --- a/js/main.js +++ b/js/main.js @@ -296,6 +296,50 @@ function getInfoBits(){ return result; } +/*** +* +* Load Waidotto QR text format +* https://github.com/waidotto/strong-qr-decoder +***/ +function loadtxt2qrarray(lines) { + let sz = lines.length; + + var is_data_module = getDataModule(lines); //getDataModule use lines.lenght only :D + + for(let i=0;i Date: Tue, 4 Jan 2022 23:08:17 +0100 Subject: [PATCH 25/33] fix Txt file loading --- js/main.js | 72 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 34 deletions(-) diff --git a/js/main.js b/js/main.js index a707e60..2a19e8f 100644 --- a/js/main.js +++ b/js/main.js @@ -301,51 +301,54 @@ function getInfoBits(){ * Load Waidotto QR text format * https://github.com/waidotto/strong-qr-decoder ***/ -function loadtxt2qrarray(lines) { +function loadTxt2Array(lines) { let sz = lines.length; - var is_data_module = getDataModule(lines); //getDataModule use lines.lenght only :D + var data = []; - for(let i=0;i Date: Tue, 4 Jan 2022 23:10:37 +0100 Subject: [PATCH 26/33] Announce that text file import or export works --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 523cdee..4560771 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,7 @@ Main Features - Reconstruct QR Code by drawing pixel by pixel - Decode and read unscannable QR Code - Save and load existing work for later use -- Import/export QR Code from/to Image file -- Export QR code to Text file +- Import/export QR Code from/to Image file or Text file - Currently support up to QR Code Version 40 (177x177) - Support both Error and Erasure Correction using universal Reed-Solomon decoder - Extract valuable information although from badly damaged QR Code From 03aaa3b877c4ff77c43c7c4c3457fd52f8c79750 Mon Sep 17 00:00:00 2001 From: wphiphi <96982181+wphiphi@users.noreply.github.com> Date: Thu, 6 Jan 2022 01:43:52 +0100 Subject: [PATCH 27/33] make padding bits recovery overlay reusable as patching overlay --- index.html | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/index.html b/index.html index 8a17529..f19b7b4 100644 --- a/index.html +++ b/index.html @@ -512,40 +512,40 @@
- -
+ +
-

Padding Bits Recovery

+

-
+
Error :
-
+
Bits before recovery :
- +
Bits after recovery :
- +
-
+
Warning :
Note : Recovered modules are marked with green color
- - + +
- +
From 4351fb5701e5f8d26860f02ff9d72225a7880daf Mon Sep 17 00:00:00 2001 From: wphiphi <96982181+wphiphi@users.noreply.github.com> Date: Thu, 6 Jan 2022 02:00:24 +0100 Subject: [PATCH 28/33] rename display for padding recovery to patching recovery --- js/main.js | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/js/main.js b/js/main.js index 2a19e8f..19693a4 100644 --- a/js/main.js +++ b/js/main.js @@ -985,19 +985,17 @@ function showMaskPatternArea(){ resize(qr_pixel_size); } -function recoverPadding(){ - var data_array = JSON.stringify(qr_array); - var result = recoverPaddingBits(JSON.parse(data_array)); - var warning = false; +function patchingRecovery(result){ + var warning = 0; $("#qr-dummy").html(""); - $("#div-pad-rec-warning, #div-pad-rec-error").hide(); - $("#div-pad-rec-data, #btn-pad-rec-apply").show() + $("#div-patch-rec-warning, #div-patch-rec-error").hide(); + $("#div-patch-rec-data, #btn-patch-rec-apply").show() if(typeof result == "string"){ - $("#div-pad-rec-error").show(); - $("#div-pad-rec-error textarea").val(result); - $("#div-pad-rec-warning, #div-pad-rec-data, #btn-pad-rec-apply").hide(); + $("#div-patch-rec-error").show(); + $("#div-patch-rec-error textarea").val(result); + $("#div-patch-rec-warning, #div-patch-rec-data, #btn-patch-rec-apply").hide(); return; } @@ -1029,23 +1027,23 @@ function recoverPadding(){ for(var i=0; i < result.after.length; i++){ if(result.before.charAt(i) != "?"){ if(result.after.charAt(i) != result.before.charAt(i)){ - warning = true; - break; + warning++; } } } if(warning){ - $("#div-pad-rec-warning").show(); - $("#div-pad-rec-warning textarea").val("There's one or more modules conflict with the already known module of original QR code. Correction may fail.") + $("#div-patch-rec-warning").show(); + $("#div-patch-rec-warning textarea").val("There's are " + warning +" modules conflict with the already known module of original QR code. Correction may fail.") } - $("#pad-rec-before").val(result.before); - $("#pad-rec-after").val(result.after); + $("#patch-rec-before").val(result.before); + $("#patch-rec-after").val(result.after); qr_temp_array = Array.prototype.slice.call(result.result_array); } + /*** * * Perform Reed-Solomon decode @@ -1900,21 +1898,23 @@ $(document).ready(function(){ ****************************/ $("#tools-pad-recovery").click(function(){ - recoverPadding(); - $("#div-padding-recovery").show(); + patchingRecovery(recoverPaddingBits(JSON.parse(JSON.stringify(qr_array)))); + $("#div-patching-recovery-title").val("Padding Bits Recovery"); + $("#div-patching-recovery").show(); + $("#div-tools").hide(); }) - $("#btn-pad-rec-apply").click(function(){ + $("#btn-patching-rec-apply").click(function(){ qr_array = JSON.parse(JSON.stringify(qr_temp_array)); refreshTable(); updateHistory("Padding bits recovery"); - $("#div-padding-recovery").hide(); + $("#div-patching-recovery").hide(); changed_state = true; }) - $("#btn-pad-rec-cancel").click(function(){ - $("#div-padding-recovery").hide(); + $("#btn-patching-rec-cancel").click(function(){ + $("#div-patching-recovery").hide(); }) /**************************** From eb1d87530969628101d6e9d77acac3a3c811b108 Mon Sep 17 00:00:00 2001 From: wphiphi <96982181+wphiphi@users.noreply.github.com> Date: Fri, 7 Jan 2022 13:55:54 +0100 Subject: [PATCH 29/33] fix patching recovery title --- js/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/main.js b/js/main.js index 19693a4..d9d8e43 100644 --- a/js/main.js +++ b/js/main.js @@ -1899,7 +1899,7 @@ $(document).ready(function(){ $("#tools-pad-recovery").click(function(){ patchingRecovery(recoverPaddingBits(JSON.parse(JSON.stringify(qr_array)))); - $("#div-patching-recovery-title").val("Padding Bits Recovery"); + $("#div-patching-recovery-title").text("Padding Bits Recovery"); $("#div-patching-recovery").show(); $("#div-tools").hide(); From 99021efcc2a9166e1cead3b41069788960ae4fa0 Mon Sep 17 00:00:00 2001 From: wphiphi <96982181+wphiphi@users.noreply.github.com> Date: Fri, 7 Jan 2022 15:23:47 +0100 Subject: [PATCH 30/33] update history for patching recovery windows show the correct operation --- js/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/main.js b/js/main.js index d9d8e43..6755910 100644 --- a/js/main.js +++ b/js/main.js @@ -1908,7 +1908,7 @@ $(document).ready(function(){ $("#btn-patching-rec-apply").click(function(){ qr_array = JSON.parse(JSON.stringify(qr_temp_array)); refreshTable(); - updateHistory("Padding bits recovery"); + updateHistory( $("#div-patching-recovery-title").val() ); $("#div-patching-recovery").hide(); changed_state = true; }) From 31ceb0d9335edf0d0eb120d951fe406362d0239e Mon Sep 17 00:00:00 2001 From: wphiphi <96982181+wphiphi@users.noreply.github.com> Date: Fri, 7 Jan 2022 16:44:27 +0100 Subject: [PATCH 31/33] fix patch windows apply and cancel bouton --- js/main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/main.js b/js/main.js index 6755910..a0c5c92 100644 --- a/js/main.js +++ b/js/main.js @@ -1905,7 +1905,7 @@ $(document).ready(function(){ $("#div-tools").hide(); }) - $("#btn-patching-rec-apply").click(function(){ + $("#btn-patch-rec-apply").click(function(){ qr_array = JSON.parse(JSON.stringify(qr_temp_array)); refreshTable(); updateHistory( $("#div-patching-recovery-title").val() ); @@ -1913,7 +1913,7 @@ $(document).ready(function(){ changed_state = true; }) - $("#btn-patching-rec-cancel").click(function(){ + $("#btn-patch-rec-cancel").click(function(){ $("#div-patching-recovery").hide(); }) From dac35f1e30ba8c8525e52a36edf4a25d20f3f106 Mon Sep 17 00:00:00 2001 From: wphiphi <96982181+wphiphi@users.noreply.github.com> Date: Fri, 7 Jan 2022 17:10:00 +0100 Subject: [PATCH 32/33] fix updateHistory for patching windows --- js/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/main.js b/js/main.js index a0c5c92..e95d8d1 100644 --- a/js/main.js +++ b/js/main.js @@ -1908,7 +1908,7 @@ $(document).ready(function(){ $("#btn-patch-rec-apply").click(function(){ qr_array = JSON.parse(JSON.stringify(qr_temp_array)); refreshTable(); - updateHistory( $("#div-patching-recovery-title").val() ); + updateHistory( $("#div-patching-recovery-title").text() ); $("#div-patching-recovery").hide(); changed_state = true; }) From aa642448e02cf70d8226ecb1886050dc4d3dc4ac Mon Sep 17 00:00:00 2001 From: wphiphi <96982181+wphiphi@users.noreply.github.com> Date: Thu, 20 Jan 2022 22:58:21 +0100 Subject: [PATCH 33/33] fix: data masking toogle only when apply --- js/main.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/js/main.js b/js/main.js index e95d8d1..4dfd4a4 100644 --- a/js/main.js +++ b/js/main.js @@ -1845,14 +1845,6 @@ $(document).ready(function(){ $("#data-masking-slider div.active").removeClass("active"); $("#data-masking-slider div[data="+current_mask+"]").addClass("active"); - if($(this).hasClass("active")){ - masking_mode = false; - $(this).removeClass("active"); - } else { - masking_mode = true; - $(this).addClass("active"); - } - $("#div-data-masking").show(); $("#div-tools").hide(); }) @@ -1880,6 +1872,16 @@ $(document).ready(function(){ maskDataBits(); $("#div-data-masking").hide(); + + //masking toogle visual + if($("#tools-masking").hasClass("active")){ + masking_mode = false; + $("#tools-masking").removeClass("active"); + } else { + masking_mode = true; + $("#tools-masking").addClass("active"); + } + }) $("#btn-mask-show-pattern-area").click(function(){