1// window.uploader_item_html = '<div class=file-item><span class=file-remove></span>' + 2// '<div class=file-img><img src="//spim.ru/i/stat_icons/add_photo.png" /></div><span class=file-desc>ÐÑикÑепиÑе Ñайл</span>' + 3// '<input type="file" id="op_file" class="op_file" name="claim_file[]" onchange="return add_file(this)"></div>'; 4// 5// window.availible_updload_types = ['image/gif', 'image/png', 'image/jpg', 6// 'image/jpeg', 'image/tiff', 'image/jpeg', 'image/pjpeg', 7// 'application/pdf', 'application/msword', 'application/vnd.oasis.opendocument.text', 8// 'application/vnd.openxmlformats-officedocument.wordprocessingml.document']; 9// 10//function add_file(sender) 11//{ 12// var files = $(sender).prop('files'); 13// var item = $(sender).closest('.file-item'); 14// var isOverrideValue = item.hasClass('file-loaded'); 15// 16// var file = files[0]; 17// 18// if(window.availible_updload_types.indexOf(file.type) < 0) 19// { 20// $(sender).val(''); 21// return false; 22// } 23// 24// item.addClass('file-loaded'); 25// 26// item.find('.file-remove').click(function() { 27// $(item).remove(); 28// }); 29// 30// if (file) 31// { 32// var reader = new FileReader(); 33// 34// reader.onload = function (event) { 35// $('.file-img img', item).attr('src', event.target.result); 36// } 37// 38// reader.readAsDataURL(file); 39// } 40// 41// item.find('.file-desc').html(file.name); 42// 43// if(isOverrideValue == false) 44// $(sender).closest('.file-uploader').append(window.uploader_item_html); 45// 46// return true; 47//} 48// 49//$('.file-uploader').append(window.uploader_item_html); 50 51/* star rating*/ 52var rating_val = $('#opinion-rating'); 53var rating_stars = $('.opinion-rating .star'); 54 55function restoreRating() 56{ 57 rating_stars.removeClass('on'); 58 59 if(rating_val.val() > 0) 60 { 61 var rating = rating_val.val() - 1; 62 63 rating_stars.eq(rating).addClass('on') 64 .prevAll().addClass('on'); 65 } 66} 67 68rating_stars.hover(function() { 69 70 rating_stars.removeClass('on'); 71 72 $(this).addClass('on') 73 .prevAll().addClass('on'); 74 75}, function() { 76 77 restoreRating() 78 79}).click(function() { 80 81 $('#rating-error').remove(); 82 rating_stars.removeClass('grey'); 83 var rating = rating_stars.index(this); 84 rating_val.val(rating + 1); 85 restoreRating(); 86}); 87 88$(function(){ 89 let inputFile = $('#myInput'); 90 let button = $('.file-uploader .file-img'); 91 let buttonSubmit = $('.opinion-send'); 92 let filesContainer = $('#myFiles'); 93 let files = []; 94 95 inputFile.change(function() { 96 let newFiles = []; 97 for(let index = 0; index < inputFile[0].files.length; index++) { 98 let file = inputFile[0].files[index]; 99 newFiles.push(file); 100 files.push(file); 101 } 102 103 newFiles.forEach(file => { 104 //let fileElement = $(`<p>${file.name} ❌</p>`); 105 let fileElement = $(`<div class="file-item"><span class=remove-cross>❌</span><div class="file-img"><img src="`+ URL.createObjectURL(file) +`"></div></div>`); 106 107 fileElement.data('fileData', file); 108 filesContainer.append(fileElement); 109 110 $(fileElement, ".remove-cross").click(function(event) { 111 let fileElement = $(event.target); 112 113 let indexToRemove = files.indexOf(fileElement.parent().data('fileData')); 114 $(this, ".file-item").remove(); 115 if(window.colorbox !== undefined){ 116 $.colorbox.resize(); 117 } 118 files.splice(indexToRemove, 1); 119 120 }); 121 }); 122 }); 123 124 button.click(function() { 125 inputFile.click(); 126 }); 127 128 buttonSubmit.click(function() { 129 130 let formData = new FormData(); 131 132 files.forEach(file => { 133 /* here I just put file as file[] so now in submitting it will send all 134 files */ 135 formData.append('file[]', file); 136 }); 137 138 checkOpForm(formData); 139 140 }); 141}); 142 143function checkOpForm(formData){ 144 145 //ÑдалÑем required Ñ Ð¿Ð¾Ð»Ñ Ð¾ÑзÑва еÑли имеÑÑÑÑ Ð·Ð°Ð³ÑÑженнÑе ÑÐ°Ð¹Ð»Ñ 146 if( $('#myFiles .file-item').length >= 1){ 147 $(".opinion-desc").removeAttr("required"); 148 $(".opinion-desc").removeClass("error"); 149 $("#descr-error").remove(); 150 } 151 152 var modal = $('#opinion-modal'); 153
154 var validator = $("#opinion_form", modal).validate(); 155 156 $.validator.messages.required = 'ÐаполниÑе поле'; 157 158 var validationRes = validator.form(); 159 160 if(validationRes) 161 { 162 163 var data = $('#opinion_form').serialize(); 164 165 console.log('Sending...'); 166 167 $.ajax({ 168 url: '/shop/get_opinion.php?' + data + '&action=set_opinion', 169 data: formData, 170 processData: false, 171 contentType: false, 172 type: 'POST', 173 beforeSend: function() { 174 //$('#myFiles').hide(); 175 $('#opinion_form input, #opinion_form textarea, .btn.opinion-send').attr('disabled','disabled'); 176 if(window.colorbox !== undefined){ 177 $.colorbox.resize(); 178 } 179 $('.file-uploader').html("<div class='op-ajax-div'><img class='op-ajax-gif' src='/i/ajax-big.gif'></div>"); 180 }, 181 success: function (res) { 182 183 callbackFormStatus(res.status, {text: 'СпаÑибо за ÐÐ°Ñ Ð¾ÑзÑв!'}); 184// $('.modal-body', modal).html('<h2>' + res.message + '</h2>'); 185// $('.modal-footer', modal).hide(); 186// setTimeout(function() { $('#opinion-modal', modal).modal('hide'); }, 3000); 187 188 } 189 }); 190 191 192 return false; 193 194 } 195 196} 197 198//function goodOpinionFormSubmit(idgood) 199//{ 200// var idgood = idgood || $("#good_id").val(); 201// 202// window.popup_was_shown = true; 203// 204// //ÑдалÑем required Ñ Ð¿Ð¾Ð»Ñ Ð¾ÑзÑва еÑли имеÑÑÑÑ Ð·Ð°Ð³ÑÑженнÑе ÑÐ°Ð¹Ð»Ñ 205// if( $('.file-uploader .op_file').length > 1){ 206// $(".opinion-desc").removeAttr("required"); 207// $(".opinion-desc").removeClass("error"); 208// $("#descr-error").remove(); 209// } 210// 211// var validator = $("#opinion_form").validate(); 212// 213// $.validator.messages.required = 'ÐаполниÑе поле'; 214// 215// //var validationRes = validator.form(); 216// 217// var validationRes = true; 218// 219// if($('#opinion-rating').val() == 0) 220// { 221// $('<label id="rating-error" class="error">ÐÑениÑе ÑоваÑ</label>').insertAfter($('#opinion-rating')); 222// } 223// else if(validationRes) 224// { 225// 226// var fd = new FormData; 227// 228// var data = $('#opinion_form').serialize(); 229// 230// $(".file-uploader").find(".op_file").each(function(index){ 231// 232// fd.append('img-'+index, $(this).prop('files')[0]); 233// 234// }) 235// 236// $.ajax({ 237// url: '/shop/get_opinion.php?' + data + '&action=set_opinion', 238// data: fd, 239// processData: false, 240// contentType: false, 241// type: 'POST', 242// success: function (res) { 243// callbackFormStatus(res.status, res.message); 244// } 245// }); 246// 247// 248// return false; 249// 250// } 251// 252//}
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.