Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/embedpre.../assets/js
File: documents-viewer-script.js
[0] Fix | Delete
const embedpressDocViewer = {};
[1] Fix | Delete
[2] Fix | Delete
document.addEventListener("fullscreenchange", () => {
[3] Fix | Delete
if (!document.fullscreenElement) {
[4] Fix | Delete
const viwerParentEl = document.querySelector('.ep-file-download-option-masked.fullscreen-enabled');
[5] Fix | Delete
if (viwerParentEl) {
[6] Fix | Delete
viwerParentEl.classList.remove("fullscreen-enabled");
[7] Fix | Delete
viwerParentEl.querySelector(".ep-doc-minimize-icon").style.display = 'none';
[8] Fix | Delete
viwerParentEl.querySelector(".ep-doc-fullscreen-icon").style.display = 'flex';
[9] Fix | Delete
}
[10] Fix | Delete
}
[11] Fix | Delete
});
[12] Fix | Delete
[13] Fix | Delete
document.addEventListener("keydown", (event) => {
[14] Fix | Delete
if (event.key === "Escape") {
[15] Fix | Delete
const viwerParentEl = document.querySelector('.ep-file-download-option-masked.fullscreen-enabled');
[16] Fix | Delete
if (viwerParentEl) {
[17] Fix | Delete
if (document.exitFullscreen) {
[18] Fix | Delete
document.exitFullscreen();
[19] Fix | Delete
} else if (document.webkitExitFullscreen) {
[20] Fix | Delete
document.webkitExitFullscreen();
[21] Fix | Delete
} else if (document.msExitFullscreen) {
[22] Fix | Delete
document.msExitFullscreen();
[23] Fix | Delete
}
[24] Fix | Delete
}
[25] Fix | Delete
}
[26] Fix | Delete
});
[27] Fix | Delete
[28] Fix | Delete
[29] Fix | Delete
embedpressDocViewer.getColorBrightness = (hexColor) => {
[30] Fix | Delete
const r = parseInt(hexColor.slice(1, 3), 16);
[31] Fix | Delete
const g = parseInt(hexColor.slice(3, 5), 16);
[32] Fix | Delete
const b = parseInt(hexColor.slice(5, 7), 16);
[33] Fix | Delete
[34] Fix | Delete
// Convert the RGB color to HSL
[35] Fix | Delete
const max = Math.max(r, g, b);
[36] Fix | Delete
const min = Math.min(r, g, b);
[37] Fix | Delete
const l = (max + min) / 2;
[38] Fix | Delete
[39] Fix | Delete
// Calculate the brightness position in percentage
[40] Fix | Delete
const brightnessPercentage = Math.round(l / 255 * 100);
[41] Fix | Delete
[42] Fix | Delete
return brightnessPercentage;
[43] Fix | Delete
}
[44] Fix | Delete
[45] Fix | Delete
embedpressDocViewer.adjustHexColor = (hexColor, percentage) => {
[46] Fix | Delete
// Convert hex color to RGB values
[47] Fix | Delete
const r = parseInt(hexColor.slice(1, 3), 16);
[48] Fix | Delete
const g = parseInt(hexColor.slice(3, 5), 16);
[49] Fix | Delete
const b = parseInt(hexColor.slice(5, 7), 16);
[50] Fix | Delete
[51] Fix | Delete
// Calculate adjusted RGB values
[52] Fix | Delete
const adjustment = Math.round((percentage / 100) * 255);
[53] Fix | Delete
const newR = Math.max(Math.min(r + adjustment, 255), 0);
[54] Fix | Delete
const newG = Math.max(Math.min(g + adjustment, 255), 0);
[55] Fix | Delete
const newB = Math.max(Math.min(b + adjustment, 255), 0);
[56] Fix | Delete
[57] Fix | Delete
// Convert adjusted RGB values back to hex color
[58] Fix | Delete
const newHexColor = '#' + ((1 << 24) + (newR << 16) + (newG << 8) + newB).toString(16).slice(1);
[59] Fix | Delete
[60] Fix | Delete
return newHexColor;
[61] Fix | Delete
}
[62] Fix | Delete
[63] Fix | Delete
embedpressDocViewer.viewerStyle = () => {
[64] Fix | Delete
const viwerParentEls = document.querySelectorAll('.ep-file-download-option-masked');
[65] Fix | Delete
[66] Fix | Delete
let customStyle = document.getElementById('custom-styles') || document.createElement('style');
[67] Fix | Delete
customStyle.id = 'custom-styles';
[68] Fix | Delete
customStyle.type = 'text/css';
[69] Fix | Delete
customStyle.innerHTML = ''
[70] Fix | Delete
[71] Fix | Delete
if (viwerParentEls !== null) {
[72] Fix | Delete
viwerParentEls.forEach((el) => {
[73] Fix | Delete
let customColor = el.getAttribute('data-custom-color');
[74] Fix | Delete
if (customColor == null) {
[75] Fix | Delete
return false;
[76] Fix | Delete
}
[77] Fix | Delete
let colorBrightness = embedpressDocViewer.getColorBrightness(customColor);
[78] Fix | Delete
let docId = el.getAttribute('data-id');
[79] Fix | Delete
[80] Fix | Delete
let iconsColor = '#f2f2f6';
[81] Fix | Delete
if (colorBrightness > 60) {
[82] Fix | Delete
iconsColor = '#343434';
[83] Fix | Delete
}
[84] Fix | Delete
[85] Fix | Delete
if (el.getAttribute('data-theme-mode') == 'custom') {
[86] Fix | Delete
[87] Fix | Delete
viewerCustomColor = `
[88] Fix | Delete
[data-id='${docId}'][data-theme-mode='custom'] {
[89] Fix | Delete
--viewer-primary-color: ${customColor};
[90] Fix | Delete
--viewer-icons-color: ${iconsColor};
[91] Fix | Delete
--viewer-icons-hover-bgcolor: ${embedpressDocViewer.adjustHexColor(customColor, -10)};
[92] Fix | Delete
[93] Fix | Delete
}`;
[94] Fix | Delete
customStyle.innerHTML += viewerCustomColor;
[95] Fix | Delete
}
[96] Fix | Delete
});
[97] Fix | Delete
[98] Fix | Delete
document.head.appendChild(customStyle);
[99] Fix | Delete
}
[100] Fix | Delete
}
[101] Fix | Delete
embedpressDocViewer.epDocumentsViewerController = () => {
[102] Fix | Delete
const viwerParentEls = document.querySelectorAll('.ep-file-download-option-masked');
[103] Fix | Delete
[104] Fix | Delete
function handleFullscreenChange() {
[105] Fix | Delete
if (!document.fullscreenElement) {
[106] Fix | Delete
viwerParentEls.forEach((el) => {
[107] Fix | Delete
el.classList.remove('fullscreen-enabled');
[108] Fix | Delete
el.querySelector('.ep-doc-minimize-icon').style.display = 'none';
[109] Fix | Delete
el.querySelector('.ep-doc-fullscreen-icon').style.display = 'flex';
[110] Fix | Delete
});
[111] Fix | Delete
}
[112] Fix | Delete
}
[113] Fix | Delete
[114] Fix | Delete
function handleClick(event) {
[115] Fix | Delete
event.stopPropagation();
[116] Fix | Delete
[117] Fix | Delete
const viwerParentEl = event.target.closest('.ep-file-download-option-masked');
[118] Fix | Delete
[119] Fix | Delete
if (!viwerParentEl) return;
[120] Fix | Delete
[121] Fix | Delete
const viewerIframeEl = viwerParentEl.querySelector('iframe');
[122] Fix | Delete
if (!viewerIframeEl) return;
[123] Fix | Delete
[124] Fix | Delete
const iframeSrc = decodeURIComponent(viewerIframeEl.getAttribute('src'));
[125] Fix | Delete
if (!iframeSrc) return;
[126] Fix | Delete
[127] Fix | Delete
const regex = /(url|src)=([^&]+)/;
[128] Fix | Delete
const match = iframeSrc.match(regex);
[129] Fix | Delete
let fileUrl = match && match[2];
[130] Fix | Delete
[131] Fix | Delete
if (!fileUrl) {
[132] Fix | Delete
fileUrl = iframeSrc;
[133] Fix | Delete
}
[134] Fix | Delete
[135] Fix | Delete
const popupIcon = event.target.closest('.ep-doc-popup-icon svg');
[136] Fix | Delete
const printIcon = event.target.closest('.ep-doc-print-icon svg');
[137] Fix | Delete
const downloadcIcon = event.target.closest('.ep-doc-download-icon svg');
[138] Fix | Delete
const minimizeIcon = event.target.closest('.ep-doc-minimize-icon svg');
[139] Fix | Delete
const fullscreenIcon = event.target.closest('.ep-doc-fullscreen-icon svg');
[140] Fix | Delete
[141] Fix | Delete
if (popupIcon instanceof SVGElement) {
[142] Fix | Delete
window.open(fileUrl, '_blank');
[143] Fix | Delete
} else if (printIcon instanceof SVGElement) {
[144] Fix | Delete
const newTab = window.open(`https://view.officeapps.live.com/op/view.aspx?src=${fileUrl}&wdOrigin=BROWSELINK`, '_blank');
[145] Fix | Delete
} else if (downloadcIcon instanceof SVGElement) {
[146] Fix | Delete
fetch(fileUrl, { mode: 'no-cors' })
[147] Fix | Delete
.then(response => {
[148] Fix | Delete
if (response.ok) {
[149] Fix | Delete
response.blob().then(blob => {
[150] Fix | Delete
const url = window.URL.createObjectURL(blob);
[151] Fix | Delete
const a = document.createElement('a');
[152] Fix | Delete
a.href = url;
[153] Fix | Delete
a.download = fileUrl.substring(fileUrl.lastIndexOf('/') + 1);
[154] Fix | Delete
document.body.appendChild(a);
[155] Fix | Delete
a.click();
[156] Fix | Delete
a.remove();
[157] Fix | Delete
});
[158] Fix | Delete
} else {
[159] Fix | Delete
window.location.href = fileUrl;
[160] Fix | Delete
}
[161] Fix | Delete
})
[162] Fix | Delete
.catch(error => {
[163] Fix | Delete
window.location.href = fileUrl;
[164] Fix | Delete
});
[165] Fix | Delete
} else if (minimizeIcon instanceof SVGElement) {
[166] Fix | Delete
if (document.exitFullscreen) {
[167] Fix | Delete
document.exitFullscreen();
[168] Fix | Delete
} else if (document.webkitExitFullscreen) {
[169] Fix | Delete
document.webkitExitFullscreen();
[170] Fix | Delete
} else if (document.msExitFullscreen) {
[171] Fix | Delete
document.msExitFullscreen();
[172] Fix | Delete
}
[173] Fix | Delete
} else if (fullscreenIcon instanceof SVGElement) {
[174] Fix | Delete
if (viwerParentEl.requestFullscreen) {
[175] Fix | Delete
viwerParentEl.requestFullscreen();
[176] Fix | Delete
} else if (viwerParentEl.webkitRequestFullscreen) {
[177] Fix | Delete
viwerParentEl.webkitRequestFullscreen();
[178] Fix | Delete
} else if (viwerParentEl.msRequestFullscreen) {
[179] Fix | Delete
viwerParentEl.msRequestFullscreen();
[180] Fix | Delete
}
[181] Fix | Delete
[182] Fix | Delete
viwerParentEl.querySelector(".ep-doc-minimize-icon").style.display = 'flex';
[183] Fix | Delete
viwerParentEl.querySelector(".ep-doc-fullscreen-icon").style.display = 'none';
[184] Fix | Delete
viwerParentEl.classList.add("fullscreen-enabled");
[185] Fix | Delete
}
[186] Fix | Delete
}
[187] Fix | Delete
[188] Fix | Delete
function handleDrawIconClick(event) {
[189] Fix | Delete
event.stopPropagation();
[190] Fix | Delete
[191] Fix | Delete
const drawIcon = event.target.closest('.ep-doc-draw-icon svg');
[192] Fix | Delete
if (!drawIcon) return;
[193] Fix | Delete
[194] Fix | Delete
const viwerParentEl = drawIcon.closest('.ep-file-download-option-masked');
[195] Fix | Delete
if (!viwerParentEl) return;
[196] Fix | Delete
[197] Fix | Delete
const canvas = viwerParentEl.querySelector(".ep-doc-canvas");
[198] Fix | Delete
const drawToggle = viwerParentEl.querySelector(".ep-doc-draw-icon svg");
[199] Fix | Delete
if (!canvas || !drawToggle) return;
[200] Fix | Delete
[201] Fix | Delete
const ctx = canvas.getContext("2d");
[202] Fix | Delete
let isDrawing = false;
[203] Fix | Delete
let canDraw = false;
[204] Fix | Delete
[205] Fix | Delete
canvas.addEventListener("mousedown", function (e) {
[206] Fix | Delete
if (canDraw) {
[207] Fix | Delete
isDrawing = true;
[208] Fix | Delete
const rect = canvas.getBoundingClientRect();
[209] Fix | Delete
const scrollX = window.pageXOffset || document.documentElement.scrollLeft;
[210] Fix | Delete
const x = e.pageX - rect.left - scrollX;
[211] Fix | Delete
const y = e.pageY - rect.top;
[212] Fix | Delete
ctx.beginPath();
[213] Fix | Delete
ctx.moveTo(x, y);
[214] Fix | Delete
}
[215] Fix | Delete
});
[216] Fix | Delete
[217] Fix | Delete
canvas.addEventListener("mousemove", function (e) {
[218] Fix | Delete
if (isDrawing && canDraw) {
[219] Fix | Delete
const rect = canvas.getBoundingClientRect();
[220] Fix | Delete
const scrollX = window.pageXOffset || document.documentElement.scrollLeft;
[221] Fix | Delete
const x = e.pageX - rect.left - scrollX;
[222] Fix | Delete
const y = e.pageY - rect.top;
[223] Fix | Delete
ctx.lineTo(x, y);
[224] Fix | Delete
ctx.stroke();
[225] Fix | Delete
}
[226] Fix | Delete
});
[227] Fix | Delete
[228] Fix | Delete
canvas.addEventListener("mouseup", function (e) {
[229] Fix | Delete
isDrawing = false;
[230] Fix | Delete
});
[231] Fix | Delete
[232] Fix | Delete
[233] Fix | Delete
drawToggle.parentNode.classList.toggle("active");
[234] Fix | Delete
canDraw = drawToggle.parentNode.classList.contains("active");
[235] Fix | Delete
canvas.style.display = canDraw ? "block" : "none";
[236] Fix | Delete
}
[237] Fix | Delete
[238] Fix | Delete
document.addEventListener('click', handleClick);
[239] Fix | Delete
document.addEventListener('click', handleDrawIconClick);
[240] Fix | Delete
document.addEventListener('fullscreenchange', handleFullscreenChange);
[241] Fix | Delete
};
[242] Fix | Delete
[243] Fix | Delete
[244] Fix | Delete
if (typeof embedpressDocViewer.epDocumentsViewerController === "function") {
[245] Fix | Delete
if (jQuery('.wp-block-embedpress-document.embedpress-document-embed').length > 0) {
[246] Fix | Delete
embedpressDocViewer.epDocumentsViewerController();
[247] Fix | Delete
}
[248] Fix | Delete
}
[249] Fix | Delete
[250] Fix | Delete
if (typeof wp !== 'undefined' && typeof wp.editor !== 'undefined') {
[251] Fix | Delete
if (typeof embedpressDocViewer.viewerStyle === "function") {
[252] Fix | Delete
embedpressDocViewer.epDocumentsViewerController();
[253] Fix | Delete
}
[254] Fix | Delete
}
[255] Fix | Delete
[256] Fix | Delete
[257] Fix | Delete
if (typeof embedpressDocViewer.viewerStyle === "function") {
[258] Fix | Delete
if (jQuery('.wp-block-embedpress-document.embedpress-document-embed').length > 0) {
[259] Fix | Delete
embedpressDocViewer.viewerStyle();
[260] Fix | Delete
}
[261] Fix | Delete
}
[262] Fix | Delete
jQuery(window).on("elementor/frontend/init", function () {
[263] Fix | Delete
var filterableGalleryHandler = function ($scope, $) {
[264] Fix | Delete
if (typeof embedpressDocViewer.epDocumentsViewerController === "function") {
[265] Fix | Delete
embedpressDocViewer.epDocumentsViewerController();
[266] Fix | Delete
}
[267] Fix | Delete
if (typeof embedpressDocViewer.epDocumentsViewerController === "function") {
[268] Fix | Delete
embedpressDocViewer.viewerStyle();
[269] Fix | Delete
}
[270] Fix | Delete
[271] Fix | Delete
};
[272] Fix | Delete
elementorFrontend.hooks.addAction("frontend/element_ready/embedpres_document.default", filterableGalleryHandler);
[273] Fix | Delete
});
[274] Fix | Delete
[275] Fix | Delete
[276] Fix | Delete
const myDivs = document.querySelectorAll('.ep-file-download-option-masked');
[277] Fix | Delete
const canDownloadDivs = document.querySelectorAll('.enabled-file-download');
[278] Fix | Delete
[279] Fix | Delete
[280] Fix | Delete
myDivs.forEach(function (div) {
[281] Fix | Delete
div.addEventListener('contextmenu', preventRightClick);
[282] Fix | Delete
});
[283] Fix | Delete
[284] Fix | Delete
function preventRightClick(event) {
[285] Fix | Delete
event.preventDefault();
[286] Fix | Delete
}
[287] Fix | Delete
[288] Fix | Delete
canDownloadDivs.forEach(function (div) {
[289] Fix | Delete
div.removeEventListener('contextmenu', preventRightClick);
[290] Fix | Delete
});
[291] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function