Каталог файловtilda-upwidget-1.1.js
601 var wrapBtnRemove = progress.closest('.t-upwidget-container__data_table_actions');602 var svg = wrapBtnRemove.querySelector('svg');603 604 window.t_upwidget__xhrObj[id][currentUpload] = xhr;605 svg.setAttribute('curUPL', currentUpload);606 607 formData.append(upKey, file);608 609 xhr.open('POST', url, true);610 xhr.onload = function() {611 if (xhr.status >= 200 && xhr.status < 400) {612
История файла и сравнение версий
var data = xhr.responseText;
615 var objData = JSON.parse(data); 617 if (objData.status !== 'fail') { 618 t_upwidget__buttonValue(container, id); 620 t_upwidget__errorFn(objData); 624 window.t_upwidget__progressObj[id][currentUpload] = 100; 626 var fileLink = objData[0]; 627 var strHTML = '<div class="t-upwidget-container__data_table_actions_remove" fileid="' + fileLink['url'] + '/' + encodeURIComponent(fileLink['filename']) + '">' + 628 '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="16" viewBox="0 0 14 18"><g style="fill:none;stroke-width:1;stroke:none"><g fill="#000"><path d="M1 16C1 17.1 1.9 18 3 18L11 18C12.1 18 13 17.1 13 16L13 4 1 4 1 16ZM14 1L10.5 1 9.5 0 4.5 0 3.5 1 0 1 0 3 14 3 14 1Z"/></g></g></svg>\n' + 631 wrapBtnRemove.innerHTML = strHTML; 632 containerData.insertAdjacentHTML('beforeend', '<input type="hidden" value="' + fileLink['url'] + '/' + encodeURIComponent(fileLink['filename']) + '">'); 634 t_upwidget__rewriteInputs(containerData); 635 t_upwidget__buttonValue(container, id); 637 var btnSvg = wrapBtnRemove.querySelector('.t-upwidget-container__data_table_actions_remove svg'); 638 btnSvg.addEventListener('click', t_upwidget__containerClickTableActions); 639 container.dispatchEvent(new CustomEvent('uwFileUploaded', { bubbles: true })); 642 console.log('JSON Error: ' + error); 645 error: t_upwidget_dict('fileUploadError'), 647 t_upwidget__errorFn(objData); 655 * @param {object} objData - received object when sending 657 function t_upwidget__errorFn(objData) { 658 window.t_upwidget__progressObj[id][currentUpload] = 100; 659 window.t_upwidget__errorUpload[id][currentUpload] = t_upwidget_dict('uploadError') + ' ' + objData.error; 661 var errorSpan = '<span style="font-size: small; color: red">' + t_upwidget_dict('uploadError') + ' ' + objData.error + '</span>'; 662 var progress = wrapBtnRemove.querySelector('.t-upwidget-container__data_progress'); 663 if (progress && progress.parentNode) { 664 progress.parentNode.removeChild(progress); 666 wrapBtnRemove.insertAdjacentHTML('afterbegin', errorSpan); 667 t_upwidget__buttonValue(container, id); 671 xhr.onerror = function() { 673 console.log('Fatal error: ' + xhr); 674 window.t_upwidget__progressObj[id][currentUpload] = 100; 675 t_upwidget__buttonValue(container, id); 676 wrapBtnRemove.innerHTML = (t_upwidget_dict('fileUploadError') + stopSvg); 679 xhr.upload.addEventListener('progress', function(e) { 680 if (e.lengthComputable) { 681 var percentage = Math.round((e.loaded * 100) / e.total); 683 if (percentage == 100) { 687 window.t_upwidget__progressObj[id][currentUpload] = percentage; 688 progress.style.width = percentage + '%'; 689 t_upwidget__buttonValue(container, id); 697 * Add new hidden input value 699 * @param {Node} containerData - block data container