1(function (window) { 2 var post = x(currentExecutingScript()); 3 console.log('[t5special]'); 4 var inAction = false; 5 6 //xlsImport 7 var xlsImportContainer = null; 8 var xlsImportItemStart = null; 9 var xlsImportItemCount = null; 10 var xlsImportItem = null; 11 var xlsImportItemEnd = null; 12 var xlsImportRefresh = true; 13 14 $(document).on('click', '.k2fx5xlsImport .k2btnUploadSpecial', function (e) { 15 e.preventDefault(); 16 xlsImportUploadSpecial($(this)); 17 }); 18 19 function xlsImportUploadSpecial(btn) { 20 var _modul = 'k2fx5xlsImport'; 21 var _action = 'save'; 22 var fce = btn.closest('.k2fx'); 23 var col1 = fce.attr('data-k2-code'); 24 var col2 = fce.attr('data-k2-amount'); 25 var field = fce.attr('data-k2-field'); 26 var strict = fce.attr('data-k2-strict'); 27 var explicitsearchedfields = fce.attr('data-k2-explicitsearchedfields'); 28 var useexactmatch = fce.attr('data-k2-useexactmatch'); 29 var use1st = fce.attr('data-k2-use1st'); 30 var use2nd = fce.attr('data-k2-use2nd'); 31 var el = fce.find('.k2uploadFile'); 32 var fail = true; 33 //console.log(el); 34 fce.find('.k2msg').hide(); 35 if (el.length) { 36 if (!col1 || !col2) { 37 console.log('missing fx import attr'); 38 } else { 39 var file = el.prop('files')[0]; 40 if (file && file.size < 33554432 && !inAction) { 41 fail = false; 42 inAction = true; 43 $(document).trigger('k2trigger', [{ modul: _modul, state: 'start', action: _action }]); 44 console.log(file); 45 var formData = new FormData(); 46 formData.append('l', 1044); 47 formData.append('file', file); 48 $.ajax({
49 url: post, 50 dataType: 'text', 51 cache: false, 52 contentType: false, 53 processData: false, 54 data: formData, 55 type: 'post', 56 success: function (data) { 57 //console.log('DATA = ' + data); 58 var o = tryParseJSON(data); 59 if (o) { 60 console.log(o); 61 if (o.fail != true) { 62 console.log('upload OK'); 63 k2msg = '.k2msg2'; 64 $(document).trigger('k2trigger', [{ modul: _modul, state: 'end', action: _action, fail: false, msg: [k2msg] }]); 65 xlsImportLogStartSpecial(o.f1, o.f2, col1, col2, field, strict, explicitsearchedfields, useexactmatch, use1st, use2nd); 66 } else { 67 console.log('upload KO'); 68 k2msg = '.k2msg1'; 69 $(document).trigger('k2trigger', [{ modul: _modul, state: 'end', action: _action, fail: true, msg: [k2msg] }]); 70 } 71 fce.find(k2msg).show(); 72 } 73 inAction = false; 74 } 75 }); 76 } 77 } 78 } 79 if (fail) { 80 fce.find('.k2msg1').show(); 81 } 82 //el.val(''); //reset 83 } 84 85 function xlsImportLogStartSpecial(f1, f2, col1, col2, field, strict, explicitsearchedfields, useexactmatch, use1st, use2nd) { 86 var _modul = 'k2fx5xlsImport'; 87 var _action = 'load'; 88 if (f1 && f2) { 89 if (!xlsImportContainer) { 90 xlsImportContainer = $('.k2fx5xlsImport .k2container'); 91 xlsImportItemStart = $('.k2fx5xlsImport .k2itemStart'); 92 xlsImportItemCount = $('.k2fx5xlsImport .k2itemCount'); 93 xlsImportItem = $('.k2fx5xlsImport .k2item'); 94 xlsImportItemEnd = $('.k2fx5xlsImport .k2itemEnd'); 95 $('.k2fx5xlsImport .k2items').remove(); 96 } 97 xlsImportContainer.html(''); 98 //remove 99 setTimeout(function () { 100 xlsImportCheckLogSpecial(f2); 101 }, 1000); 102 $(document).trigger('k2trigger', [{ modul: _modul, post: 'start', action: _action }]); 103 $.post(post, { 104 l: 1045, 105 f1: f1, 106 f2: f2, 107 col1: col1, 108 col2: col2, 109 field: field, 110 strict: strict, 111 explicitsearchedfields: explicitsearchedfields, 112 useexactmatch: useexactmatch, 113 use1st: use1st, 114 use2nd: use2nd 115 }, function (data) { 116 console.log('IMPORT FINISHED'); 117 var d = tryParseJSON(data); 118 if (typeof d === 'object') { 119 if (d.fail == false) { 120 $(document).trigger('k2trigger', [{ modul: _modul, post: 'end', action: _action, fail: false, msg: [k2msg] }]); 121 } else { 122 if (d.import.typefail == true) { 123 k2msg = '.k2msg3'; //spatny typ ceniku 124 xlsImportRefresh = false; 125 } 126 $(document).trigger('k2trigger', [{ modul: _modul, post: 'end', action: _action, fail: true, msg: [k2msg] }]); 127 } 128 console.log(d); 129 } else { 130 console.log(data); 131 } 132 133 inAction = false; 134 }); //endpost 135 } 136 } 137 138 function xlsImportCheckLogSpecial(f2) { 139 console.log('----REFRESH----'); 140 var _modul = 'k2fx5xlsImport'; 141 var _action = 'refresh'; 142 $(document).trigger('k2trigger', [{ modul: _modul, post: 'start', action: _action }]); 143 $.post(post, {//+ 'f5.php' 144 l: 1046, 145 f2: f2 146 }, function (data) { 147 //console.log('REFRESH DATA = ' + data); 148 var d = tryParseJSON(data); 149 if (typeof d === 'object' && d.fail == false) { 150 $(document).trigger('k2trigger', [{ modul: _modul, post: 'end', action: _action, fail: false, msg: [k2msg] }]); 151 omg = d.data.match(/[^\r\n]+/g); 152 //console.log(omg); 153 xlsImportContainer.html(''); 154 Object.keys(omg).forEach(function (key) { 155 var d = tryParseJSON(omg[key]); 156 //console.log(d); 157 if (typeof d === 'object') { 158 console.log(d); 159 if (d.hasOwnProperty('id')) { 160 var tx = $(xlsImportItem[0].outerHTML); 161 tx.removeClass('k2found,k2reduced,k2added'); 162 if (d.is == 1) { 163 tx.addClass('k2found'); 164 } 165 if (d._r) { 166 tx.addClass('k2reduced'); 167 } 168 if (d.ks && d.ks != d._t) { 169 tx.addClass('k2changed'); 170 } 171 if (d.ok) { 172 tx.addClass('k2added'); 173 } 174 tx.find('.k2code').html(d.id); 175 tx.find('.k2title').html(d.tx); 176 tx.find('.k2amount').html(d.ks); 177 tx.find('.k2fr').html(d._f); 178 tx.find('.k2to').html(d._t); 179 xlsImportContainer.append(tx[0].outerHTML); 180 } else if (d.hasOwnProperty('start')) { 181 xlsImportContainer.append(xlsImportItemStart); 182 } else if (d.hasOwnProperty('count')) { 183 xlsImportItemCount.find('.k2n').html(d.count); 184 xlsImportContainer.append(xlsImportItemCount); 185 } else if (d.hasOwnProperty('end')) { 186 xlsImportContainer.append(xlsImportItemEnd); 187 } 188 } 189 }); 190 if (d.end == false) { 191 setTimeout(function () { 192 xlsImportCheckLogSpecial(f2); 193 }, 1000); 194 } else if (xlsImportRefresh) { 195 k2m5.basketRefresh();(0); //refresh vsech kosiku 196 $(document).trigger('k2trigger', [{ modul: _modul, post: 'end', action: _action, fail: false, data: 'importDone' }]); 197 } 198 } else { 199 $(document).trigger('k2trigger', [{ modul: _modul, post: 'end', action: _action, fail: true, msg: [k2msg] }]); 200 console.log(d); 201 } 202 inAction = false; 203 xlsImportRefresh = true; 204 }); //endpost 205 } 206 207 208})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.