const VIEWABLE_EXTENSIONS = ["HTML", "HTM", "XHTML", "EPUB", "MHTML", "MD"]; var fileDrop = {}, fileDrop2 = {}; function showLoader() { $(".progress > .progress-bar").html("15%"), $(".progress > .progress-bar").css("width", "15%"), $("#loader").removeClass("hidden"), hideAlert() } function hideLoader() { $("#loader").addClass("hidden") } function generateViewerLink(e) { var r = void 0 !== e.FolderName ? e.FolderName : e.id; return encodeURI(o.ViewerPathWF + r + "/" + e.FileName) } function generateEditorLink(e) { var r = void 0 !== e.FolderName ? e.FolderName : e.id; return encodeURI(o.EditorPath + "FileName=" + e.FileName + "&FolderName=" + r + "&CallbackURL=" + o.AppURL) } function sendPageView(e) { if ("ga" in window) try { var o = ga.getAll()[0]; void 0 !== o && o.send("pageview", e) } catch (e) { } } function workSuccess(e, r, t) { if (hideLoader(), 200 === e.StatusCode) { if (void 0 !== e.FileProcessingErrorCode && 0 !== e.FileProcessingErrorCode) return void showAlert(o.FileProcessingErrorCodes[e.FileProcessingErrorCode]); if ($("#WorkPlaceHolder").addClass("hidden"), $(".appfeaturesectionlist").addClass("hidden"), $(".howtolist").addClass("hidden"), $(".app-features-section").addClass("hidden"), $(".app-product-section").addClass("hidden"), $("#DownloadPlaceHolder").removeClass("hidden"), $("#OtherApps").removeClass("hidden"), void 0 === o.ReturnFromViewer) { const e = o.AppDownloadURL.indexOf("?"); sendPageView(-1 === e ? o.AppDownloadURL : o.AppDownloadURL.substring(0, e)) } var n = encodeURI(o.APIBasePath + `Common/DownloadFile/${e.FolderName}?file=${e.FileName}`); if ($("#DownloadButton").attr("href", n), o.DownloadUrl = n, o.ShowViewerButton) { let o = $("#ViewerLink"), r = e.FileName.lastIndexOf("."), t = r >= 0 ? e.FileName.substring(r + 1).toUpperCase() : null; null !== t && o.length && -1 !== VIEWABLE_EXTENSIONS.indexOf(t) ? o.on("click", function (o) { o.preventDefault(), o.stopPropagation(), openIframe(generateViewerLink(e), "/html/viewer", "/html/view") }) : (o.hide(), $(o[0].parentNode.previousElementSibling).hide()) } } else showAlert(e.Status) } function hideAlert() { $("#alertMessage").addClass("hidden"), $("#alertMessage").text(""), $("#alertSuccess").addClass("hidden"), $("#alertSuccess").text("") } function showAlert(e) { hideLoader(), $("#alertMessage").html(e), $("#alertMessage").removeClass("hidden"), $("#alertMessage").fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100) } function showMessage(e) { hideLoader(), $("#alertSuccess").text(e), $("#alertSuccess").removeClass("hidden") } function progress(e) { if (e.lengthComputable) { var o = e.total, r = e.loaded, t = Math.round(100 * r / o); t = (t < 15 ? 15 : t) + "%", $(".progress > .progress-bar").html(t), $(".progress > .progress-bar").css("width", t) } } function removeAllFileBlocks() { fileDrop.droppedFiles.forEach(function (e) { $("#fileupload-" + e.id).remove() }), fileDrop.droppedFiles = [], hideLoader() } function openIframe(e, o, r) { window.history.pushState(null, null, o), $("body").css("overflow-y", "hidden"); var t = $('<div id="iframe-wrap"></div>'); $("<iframe>", { src: e, id: "iframe-document", frameborder: 0, scrolling: "yes" }).appendTo(t), t.appendTo("body"), sendPageView(r) } function closeIframe() { removeAllFileBlocks(), $("div#iframe-wrap").remove(), $("body").css("overflow-y", "auto") } function request(e, o) { showLoader(), $.ajax({ method: "POST", url: e, data: o, processData: !1, contentType: !1, cache: !1, timeout: 6e5, success: workSuccess, xhr: function () { var e = $.ajaxSettings.xhr(); return e.upload && e.upload.addEventListener("progress", progress, !1), e }, error: function (e) { void 0 !== e.data && void 0 !== e.data.Status ? showAlert(e.data.Status) : showAlert("Error " + e.status + ": " + e.statusText) } }) } function requestConversion() { let e = fileDrop.prepareFormData(); null !== e && request(o.APIBasePath + "AsposeHtmlConversion/Convert?inputType=" + getInputType() + "&outputType=" + $("#saveAs").val(), e) } function prepareDownloadUrl() { o.AppDownloadURL = o.AppURL; var e = o.AppDownloadURL.indexOf(":"); e > 0 && (o.AppDownloadURL = (e > 0 ? o.AppDownloadURL.substring(e + 3) : o.AppURL) + "/download"), e = o.AppDownloadURL.indexOf("/"), o.AppDownloadURL = o.AppDownloadURL.substring(e) } function getInputType() { var e = window.location.pathname.toLowerCase(), o = e.indexOf("conversion"); if (o < 0) return "html"; var r = e.substring(o + 11); if (0 === r.length) return "html"; var t = r.split("-"); return console.log(t[0]), t[0] } $.extend($.expr[":"], { isEmpty: function (e) { return "" === e.value } }), jQuery.fn.inputFilter = function (e) { return this.on("input keydown keyup mousedown mouseup select contextmenu drop", function () { e(this.value) ? (this.oldValue = this.value, this.oldSelectionStart = this.selectionStart, this.oldSelectionEnd = this.selectionEnd) : this.hasOwnProperty("oldValue") ? (this.value = this.oldValue, this.setSelectionRange(this.oldSelectionStart, this.oldSelectionEnd)) : this.value = "" }) }, jQuery.QueryString = function (e) { let o = {}; for (let r = 0; r < e.length; ++r) { let t = e[r].split("=", 2); 2 === t.length && (o[t[0]] = decodeURIComponent(t[1].replace(/\+/g, " "))) } return o }(window.location.search.substr(1).split("&")), $(document).ready(function () { prepareDownloadUrl(), fileDrop = $("form#UploadFile").filedrop(Object.assign({ showAlert: showAlert, hideAlert: hideAlert, showLoader: showLoader, progress: progress }, o)), window.onpopstate = function (e) { $("div#iframe-wrap").length > 0 && closeIframe() }, o.UploadAndRedirect || $("#uploadButton").on("click", o.Method) });