/** * */ const displayCantoId = '#displaycanto'; const displayCantoWrapperId = '#displaycantoWrapper'; const minimapviewerId = '#minimapviewer'; const displayminimapId = '#displayminimap'; const visCantoClass = '.visCanto'; const fillerClass = '.filler'; const bodyScript = ' ' let minimap = document.createElement('div'); let viewer = document.createElement('div'); let minimapContent = document.createElement('iframe'); let realScale; let currentMinimap = ''; let initOffset = ''; let correctionFactor = 1; let scrollCorrectionFactor = 0.997; function drawMinimap(name, onlyContent = false, cantoOffset = 0){ var cantoHeightToSet = $("body")[0].clientHeight*cssCantoHeight; var maxCantoHeightToSet = $("body")[0].clientHeight*cssTableMainHeight-110; // 63 padding top + 47 margine bottom $(visCantoClass).css("max-height", maxCantoHeightToSet); $(displayCantoId).css("max-height", maxCantoHeightToSet); currentMinimap = name; if (currentMinimap == '#vistaFrasi') { //correctionFactor = 1.003; correctionFactor = 1.009; scrollCorrectionFactor = 0.997; //scrollCorrectionFactor = 1; } else { correctionFactor = 1; scrollCorrectionFactor = 0.997; }; initOffset = parseInt($("body").css("padding-top").replace("px", ""))+63; if ($(displayminimapId).lenght > 0) { $(displayminimapId)[0].remove(); } showMinimap(onlyContent); if (onlyContent == false) { $(displayCantoWrapperId).scrollTop(cantoOffset); $(minimapviewerId).offset({ top: initOffset}); var minimapTopPos = $(minimapviewerId).offset().top; $(minimapviewerId).draggable({ axis: "y", containment: $(displayminimapId), scroll: false, start: function(event, ui) { minimapScrolling = true; }, stop: function(event, ui) { minimapScrolling = false; latestOffset = $(displayCantoWrapperId).scrollTop() }, drag: function(event, ui) { minimapScrolling = true; $(displayCantoWrapperId).scrollTop((ui.offset.top - minimapTopPos) / (realScale*correctionFactor)); } }); trackScrollCanto(); }; } function showMinimap(onlyContent) { viewer.className = 'minimap__viewer'; viewer.id = 'minimapviewer'; minimapContent.className = 'minimap__content'; minimap.append(viewer, minimapContent); $(displayminimapId).append(minimap); let html = $(currentMinimap)[0].outerHTML; if (html == null | html == '') return; let iFrameDoc = minimapContent.contentWindow.document; var cssLinkb = document.createElement("link"); cssLinkb.href = $("#" + currStyle + "-Boot")[0].href; cssLinkb.rel = "stylesheet"; cssLinkb.type = "text/css"; var cssLinkscroll = document.createElement("link"); cssLinkscroll.href = $("#" + currStyle + "-Custom")[0].href; cssLinkscroll.rel = "stylesheet"; cssLinkscroll.type = "text/css"; iFrameDoc.open(); iFrameDoc.write('