1import translate from "/-d1127---RDTYinol/dictionary.js?_linka=a68655";export default class DownloadFile{constructor(){this.selectors={LIBRARY_DOWNLOADER_ELEMENT:".download-file",LIBRARY_DOWNLOADER_ELEMENT_SAMPLE:".download-file-sample",LIBRARY_DOWNLOADER_ELEMENT_CDI:".download-file--full",DOWNLOAD_CONTAINER:".download-container",LIBRARY_DOWNLOADER_ELEMENT_PRE_REQUEST:".download-file-pre-request"},this.formData={},this.options={LIB_TIMEOUT:window.constants.LIB_TIMEOUT,LIB_INTERVAL:window.constants.LIB_INTERVAL, 2FORMAT:"",PUBLIC_URL:"",ADVICE_LINK:"",IS_SAMPLE:false};this.formats,this.init()}init(){this.bind();this.downloadCall=null;history.replaceState({},null,window.location)}bind(){$(document.body).on("click",this.selectors.LIBRARY_DOWNLOADER_ELEMENT,$.proxy(this._handleFileDownloader,this));$(document.body).on("click",this.selectors.LIBRARY_DOWNLOADER_ELEMENT_CDI,$.proxy(this.renderDownloadHtmlFullDone,this));$(document.body).on("click",this.selectors.LIBRARY_DOWNLOADER_ELEMENT_PRE_REQUEST,$.proxy(this._handleFormatModal, 3this))}_handleFormatModal(e){let $selector=$(e.currentTarget);let formats=$selector.data("formats").length?$selector.data("formats").split(","):$selector.data("formats");let productOrder=$selector.data("product-order");let ajaxUrl=$selector.data("ajax-url");this.formats=formats;this.options.FORMAT=$selector.data("format");this.options.ADVICE_LINK=$selector.data("advice-link");let str="";let strAtt="";if($selector.hasClass("sample"))this.options.IS_SAMPLE=true;if(formats.length<=0){const $el=$(e.target); 4const startTime=(new Date).getTime();this._handleFileDownloaderCDI(e)}else if(this.options.FORMAT=="AUDIOBOOK")this._handleFileDownloaderCDI(e);else{str=`<div class='selling-card__read-formats--modal'><p>Vyberte form\u00e1t ${translate(this.options.FORMAT)} ke sta\u017een\u00ed</p><div>`;for(let i=0;i<formats.length;i++){strAtt=`<a data-ajax-url="${ajaxUrl}${formats[i]}" class="btn--link btn--round download-file" target="_blank" title="${formats[i]}"> 5 <span class="tdi icon icon-${formats[i]}"></span> 6 ${formats[i]} 7 </a>`;str=str+strAtt}if(typeof window.attachmentsURL!=="undefined"&&typeof window.attachmentsFormat!=="undefined"&&window.attachmentsURL[productOrder]&&Object.keys(window.attachmentsURL[productOrder]).length>0){strAtt=`</div><div class='selling-card__read-formats--modal attachments t-center m-top-30'><h6 class="as-h5">${translate("DOWNLOAD_FILE_ATTACHMENTS")}</h6><div class="m-top-15">`;for(let key in window.attachmentsURL[productOrder])if(window.attachmentsURL[productOrder].hasOwnProperty(key)){let format= 8window.attachmentsFormat[productOrder][key];let countValue=Object.keys(window.attachmentsURL[productOrder]).length>1?`${parseInt(key)+1}${translate("FILE_PART")}`:"";let title=`${translate("DOWNLOAD_FILE_"+format.toUpperCase())} ${countValue}`;strAtt+=` 9 <a href="${window.attachmentsURL[productOrder][key]}" class="btn--link btn--round" target="_blank"> 10 <span class="icon icon-${format}"></span> 11 ${title} 12 </a>`}strAtt=strAtt+`</div>`;str=str+strAtt}str=str+`</div><div class="advice"><span class="icon icon-info"></span><p>Pot\u0159ebujete pomoc? Pod\u00edvejte se do na\u0161\u00ed <a href="${this.options.ADVICE_LINK}">n\u00e1pov\u011bdy</a>.</div></div>`;window.Modal.open(`${str}`,"Sta\u017een\u00ed souboru","","small")}}renderDownloadHtml(json){clearInterval(this.downloadCall);this.downloadCall=null;let i=0;let a=0;const items=json.response.items;let contentType;let str="";let strNew=""; 13let strAtt="";for(i;i<items.length;i++){switch(json.response.items[i].contentType){case "application/pdf":contentType="pdf";break;case "application/epub+zip":contentType="epub";break;case "application/x-mobipocket-ebook":contentType="mobi";break;case "application/zip":contentType="zip";break;default:contentType="other"}if(items.length>1){strNew=`<a href="${items[i].publicUrl}" title="${translate("DOWNLOAD")}${i+1}. ${translate("PART")}" class="btn--link btn--round"> 14 <span class="icon icon-zip"></span>${translate("DOWNLOAD")} ${i+1}. ${translate("PART")} 15 </a>`;str=str+strNew}else if(items[i].publicUrl.length>0)if(this.options.FORMAT=="AUDIOBOOK"){strNew=`<div class='selling-card__read-formats--modal'><p>Vyberte form\u00e1t ${translate(this.options.FORMAT)} ke sta\u017een\u00ed</p><div><a data-href="${items[i].publicUrl}" title="${translate("DOWNLOAD")}${i+1}. ${translate("PART")}" class="btn--link btn--round download-file--full"> 16 <span class="icon icon-zip"></span>ZIP 17 </a></div><div class="advice"><span class="icon icon-info"></span>
17<p>Pot\u0159ebujete pomoc? Pod\u00edvejte se do na\u0161\u00ed <a href="${this.options.ADVICE_LINK}">n\u00e1pov\u011bdy</a>.</div></div>`;str=str+strNew;$("#js-modal__content").html(str)}else if(json.response.attachments){strNew=`<div class='selling-card__read-formats--modal'><a href="${items[i].publicUrl}" title="${contentType}" class="btn--link btn--round"> 18 <span class="icon icon-${contentType}"></span>${contentType} 19 </a></div>`;strAtt=`<div class='selling-card__read-formats--modal attachments t-center m-top-30'><h6 class="as-h5">${translate("DOWNLOAD_FILE_ATTACHMENTS")}</h6><div class="m-top-15">`;const attLen=json.response.attachments.length-1;for(;a<=attLen;a++){const item=json.response.attachments[a];let contentType;switch(json.response.attachments[a].contentType){case "application/pdf":contentType="pdf";break;case "application/epub+zip":contentType="epub";break;case "application/x-mobipocket-ebook":contentType= 20"mobi";break;case "application/zip":contentType="zip";break;default:contentType="other"}let title=item.ord?`${translate("DOWNLOAD_FILE_"+contentType.toUpperCase())} ${item.ord}${translate("FILE_PART")}`:`${translate("DOWNLOAD_FILE_"+contentType.toUpperCase())} ${a+1}${translate("FILE_PART")}`;strAtt=strAtt+` 21 <a href="${item.publicUrl}" class="btn--link btn--round" target="_blank"> 22 <span class="icon icon-${contentType}"></span> 23 ${title} 24 </a>`}strAtt=strAtt+`</div></div>`;str=str+strNew+strAtt;$("#js-modal__content").html(str)}else{str=`<div class='selling-card__read-formats--modal'><div class="loading-container relative-content no-border is-loading"></div><div><p class="text t-center">Prob\u00edh\u00e1 stahov\u00e1n\u00ed ${translate(this.options.FORMAT)}. Pokud stahov\u00e1n\u00ed neza\u010dalo automaticky, klikn\u011bte <a href="${items[i].publicUrl}" class="rendered-file">zde</a>.</p></div></div></div>`;str=str+`</div>`; 25$("#js-modal__content").html(str);setTimeout(function(){$(".rendered-file")[0].click();window.Modal.close()},500)}else{str="";str=str+`<div class='selling-card__read-formats--modal'><div><p class="t-center">${translate("FORMAT_NO_RESULTS")}</p>`;$("#js-modal__content").html(str)}}if(items.length>1){str=`<div class='selling-card__read-formats--modal'> 26 <p>Kniha je rozd\u011blena do ${items.length} soubor\u016f, vyberte pros\u00edm kter\u00fd soubor chcete st\u00e1hnout.</p><div>`+str+`</div><div class="advice"><span class="icon icon-info"></span><p>Pot\u0159ebujete pomoc? Pod\u00edvejte se do na\u0161\u00ed <a href="${this.options.ADVICE_LINK}">n\u00e1pov\u011bdy</a>.</div></div>`;$("#js-modal__content").html(str)}}renderDownloadHtmlFull(json){clearInterval(this.downloadCall);this.downloadCall=null;let i=0;let a=0;let strAtt="";let strNew= 27"";let str="\x3cdiv class\x3d'selling-card__read-formats--modal'\x3e\x3cp\x3eVyberte form\u00e1t e-knihy ke sta\u017een\u00ed\x3c/p\x3e\x3cdiv\x3e";const arrLen=json.response.items.length-1;for(;i<=arrLen;i++){const item=json.response.items[i];let contentType;switch(json.response.items[i].contentType){case "application/pdf":contentType="pdf";break;case "application/epub+zip":contentType="epub";break;case "application/x-mobipocket-ebook":contentType="mobi";break;case "application/zip":contentType= 28"zip";break;default:contentType="other"}let title=item.ord?`${translate("DOWNLOAD_FILE_"+contentType.toUpperCase())} ${item.ord}${translate("FILE_PART")}`:`${translate("DOWNLOAD_FILE_"+contentType.toUpperCase())}`;str=str+` 29 30 <a data-href="${item.publicUrl}" data-variant="${contentType}" class="download-file--full btn--link btn--round" title="${title}"> 31 <span class="tdi icon icon-${contentType}"></span>${title} 32 </a> 33 `}if(json.response.attachments){strNew=`<div class='selling-card__read-formats--modal'><a href="${items[i].publicUrl}" title="${contentType}" class="btn--link btn--round"> 34 <span class="icon icon-${contentType}"></span>${contentType} 35 </a></div>`;strAtt=`<div class='selling-card__read-formats--modal attachments t-center m-top-30'><h6 class="as-h5">${translate("DOWNLOAD_FILE_ATTACHMENTS")}</h6><div class="m-top-15">`;const attLen=json.response.attachments.length-1;for(;a<=attLen;a++){const item=json.response.attachments[a];let contentType;switch(json.response.attachments[a].contentType){case "application/pdf":contentType="pdf";break;case "application/epub+zip":contentType="epub";break;case "application/x-mobipocket-ebook":contentType= 36"mobi";break;case "application/zip":contentType="zip";break;default:contentType="other"}let title=item.ord?`${translate("DOWNLOAD_FILE_"+contentType.toUpperCase())} ${item.ord}${translate("FILE_PART")}`:`${translate("DOWNLOAD_FILE_"+contentType.toUpperCase())} ${a+1}${translate("FILE_PART")}`;strAtt=strAtt+` 37 <a href="${item.publicUrl}" class="btn--link btn--round" target="_blank">
38 <span class="icon icon-${contentType}"></span> 39 ${title} 40 </a>`}strAtt=strAtt+`</div></div>`;str=str+strNew+strAtt}str=str+`</div><div class="advice"><span class="icon icon-info"></span><p>Pot\u0159ebujete pomoc? Pod\u00edvejte se do na\u0161\u00ed <a href="${this.options.ADVICE_LINK}">n\u00e1pov\u011bdy</a>.</div></div>`;window.Modal.open(`${str}`,"Sta\u017een\u00ed souboru","","small")}renderDownloadHtmlFullDone(e){clearInterval(this.downloadCall);this.downloadCall=null;let i=0;let a=0;const publicUrl=$(e.currentTarget).data("href");const format= 41this.options.FORMAT;if(publicUrl.length>0){let str=`<div class='selling-card__read-formats--modal'><div class="loading-container relative-content no-border is-loading"></div><div><p class="text t-center">Prob\u00edh\u00e1 stahov\u00e1n\u00ed ${translate(format)}. Pokud stahov\u00e1n\u00ed neza\u010dalo automaticky, klikn\u011bte <a href="${publicUrl}" class="rendered-file">zde</a>.</p></div></div></div>`;str=str+`</div>`;$("#js-modal__content").html(str);setTimeout(function(){$(".rendered-file")[0].click(); 42this.Modal.close()},500)}else{let str="";str=str+`<div class='selling-card__read-formats--modal'><div><p class="t-center">${translate("FORMAT_NO_RESULTS")}</p>`;$("#js-modal__content").html(str)}}noDownloadHtml(){clearInterval(this.downloadCall);this.downloadCall=null;let str="";str=str+`<div class='selling-card__read-formats--modal'><div><p class="t-center">${translate("NO_DOWNLOAD_RESULTS")}</p>`;$("#js-modal__content").html(str)}_handleFileDownloader(e){e.preventDefault();const self=this;const $el= 43$(e.target);if($el){let str;let strSample;if(this.options.IS_SAMPLE){str=`<div class="selling-card__read-formats--modal"><div class="loading-container relative-content no-border is-loading"></div><p class="text">P\u0159ipravujeme sta\u017een\u00ed uk\u00e1zky ${translate(this.options.FORMAT)}. Stahujete ji jako prvn\u00ed a proto m\u016f\u017ee p\u0159\u00edprava chvilku trvat.</p></div>`;$("#js-modal__content").html(str)}else{str=`<div class="selling-card__read-formats--modal"><div class="loading-container relative-content no-border is-loading"></div><p class="text">P\u0159ipravujeme ke sta\u017een\u00ed V\u00e1\u0161 soubor ${translate(this.options.FORMAT)}.</p></div>`; 44$("#js-modal__content").html(str);window.Modal.open(`${str}`,"Sta\u017een\u00ed souboru","","small")}const startTime=(new Date).getTime();self._intervalFileDownloader($el,startTime);this.downloadCall=setInterval(function(){self._intervalFileDownloader($el,startTime)},this.options.LIB_INTERVAL)}else throw"Button not a viable download link",e.currentTarget;}_handleFileDownloaderCDI(e){e.preventDefault();const self=this;const $el=$(e.target);if($el){let str;let strSample;if(this.options.IS_SAMPLE){str= 45`<div class="selling-card__read-formats--modal"><div class="loading-container relative-content no-border is-loading"></div><p class="text">P\u0159ipravujeme form\u00e1ty uk\u00e1zky ${translate(this.options.FORMAT)}. Stahujete ji jako prvn\u00ed a proto m\u016f\u017ee p\u0159\u00edprava chvilku trvat.</p></div>`;$("#js-modal__content").html(str)}else{str=`<div class="selling-card__read-formats--modal"><div class="loading-container relative-content no-border is-loading"></div><p class="text">P\u0159ipravujeme dostupn\u00e9 form\u00e1ty ke sta\u017een\u00ed ${translate(this.options.FORMAT)}.</p></div>`; 46$("#js-modal__content").html(str)}window.Modal.open(`${str}`,"Sta\u017een\u00ed souboru","","small");const startTime=(new Date).getTime();self._intervalFileDownloader($el,startTime);this.downloadCall=setInterval(function(){self._intervalFileDownloader($el,startTime)},this.options.LIB_INTERVAL)}else throw"Button not a viable download link",e.currentTarget;}_intervalFileDownloader($el,startTime){const self=this;if((new Date).getTime()-startTime>this.options.LIB_TIMEOUT){clearInterval(this.downloadCall); 47$("#js-modal__content").html(`<p class="m-bottom-0 t-center">${translate("LIBRARY_IT_TAKES_MORE_TIME")}</p><p class="t-center">${translate("LIBRARY_TRY_AGAIN_LATER")}</p>`);return}const ajaxUrl=$el.data("ajax-url")||$el.parents("a").data("ajax-url");fetch(ajaxUrl,{method:"GET",headers:{"Content-Type":"application/json"}}).then(response=>response.json()).then(data=>{if(data.status==200)if($(".hystmodal").hasClass("hystmodal--active"))if(self.formats.length)self.renderDownloadHtml(data);else self.renderDownloadHtmlFull(data); 48if(data.status==204){clearInterval(this.downloadCall);self.noDownloadHtml()}}).catch(e=>console.log(e))}};
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.