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/pdf/web
File: ep-scripts.js
"use strict";
[0] Fix | Delete
[1] Fix | Delete
//Create theme mode function
[2] Fix | Delete
const setThemeMode = (themeMode) => {
[3] Fix | Delete
const htmlEL = document.getElementsByTagName("html")[0];
[4] Fix | Delete
if (htmlEL) {
[5] Fix | Delete
htmlEL.setAttribute('ep-data-theme', themeMode);
[6] Fix | Delete
}
[7] Fix | Delete
}
[8] Fix | Delete
[9] Fix | Delete
[10] Fix | Delete
const getParamObj = (hash) => {
[11] Fix | Delete
[12] Fix | Delete
let paramsObj = {};
[13] Fix | Delete
let colorsObj = {};
[14] Fix | Delete
[15] Fix | Delete
if (location.hash) {
[16] Fix | Delete
let hashParams = new URLSearchParams(hash.substring(1));
[17] Fix | Delete
[18] Fix | Delete
if (hashParams.get('key') !== null) {
[19] Fix | Delete
hashParams = '#' + atob(hashParams.get('key'));
[20] Fix | Delete
hashParams = new URLSearchParams(hashParams.substring(1));
[21] Fix | Delete
}
[22] Fix | Delete
[23] Fix | Delete
if (hashParams.get('themeMode') == 'custom') {
[24] Fix | Delete
colorsObj = {
[25] Fix | Delete
customColor: hashParams.get('customColor'),
[26] Fix | Delete
};
[27] Fix | Delete
}
[28] Fix | Delete
paramsObj = {
[29] Fix | Delete
themeMode: hashParams.get('themeMode'),
[30] Fix | Delete
...colorsObj,
[31] Fix | Delete
presentation: hashParams.get('presentation'),
[32] Fix | Delete
copy_text: hashParams.get('copy_text'),
[33] Fix | Delete
add_text: hashParams.get('add_text'),
[34] Fix | Delete
draw: hashParams.get('draw'),
[35] Fix | Delete
add_image: hashParams.get('add_image'),
[36] Fix | Delete
position: hashParams.get('position'),
[37] Fix | Delete
download: hashParams.get('download'),
[38] Fix | Delete
toolbar: hashParams.get('toolbar'),
[39] Fix | Delete
doc_details: hashParams.get('pdf_details'),
[40] Fix | Delete
doc_rotation: hashParams.get('pdf_rotation'),
[41] Fix | Delete
};
[42] Fix | Delete
[43] Fix | Delete
[44] Fix | Delete
[45] Fix | Delete
if (hashParams.get('download') !== 'true' && hashParams.get('download') !== 'yes') {
[46] Fix | Delete
window.addEventListener('beforeunload', function (event) {
[47] Fix | Delete
event.stopImmediatePropagation();
[48] Fix | Delete
});
[49] Fix | Delete
}
[50] Fix | Delete
}
[51] Fix | Delete
[52] Fix | Delete
return paramsObj;
[53] Fix | Delete
}
[54] Fix | Delete
[55] Fix | Delete
const isDisplay = (selectorName) => {
[56] Fix | Delete
if (selectorName == 'false' || selectorName == false) {
[57] Fix | Delete
selectorName = 'none';
[58] Fix | Delete
}
[59] Fix | Delete
else {
[60] Fix | Delete
selectorName = 'block';
[61] Fix | Delete
}
[62] Fix | Delete
return selectorName;
[63] Fix | Delete
}
[64] Fix | Delete
[65] Fix | Delete
[66] Fix | Delete
const adjustHexColor = (hexColor, percentage) => {
[67] Fix | Delete
// Convert hex color to RGB values
[68] Fix | Delete
const r = parseInt(hexColor.slice(1, 3), 16);
[69] Fix | Delete
const g = parseInt(hexColor.slice(3, 5), 16);
[70] Fix | Delete
const b = parseInt(hexColor.slice(5, 7), 16);
[71] Fix | Delete
[72] Fix | Delete
// Calculate adjusted RGB values
[73] Fix | Delete
const adjustment = Math.round((percentage / 100) * 255);
[74] Fix | Delete
const newR = Math.max(Math.min(r + adjustment, 255), 0);
[75] Fix | Delete
const newG = Math.max(Math.min(g + adjustment, 255), 0);
[76] Fix | Delete
const newB = Math.max(Math.min(b + adjustment, 255), 0);
[77] Fix | Delete
[78] Fix | Delete
// Convert adjusted RGB values back to hex color
[79] Fix | Delete
const newHexColor = '#' + ((1 << 24) + (newR << 16) + (newG << 8) + newB).toString(16).slice(1);
[80] Fix | Delete
[81] Fix | Delete
return newHexColor;
[82] Fix | Delete
}
[83] Fix | Delete
[84] Fix | Delete
[85] Fix | Delete
const getColorBrightness = (hexColor) => {
[86] Fix | Delete
const r = parseInt(hexColor.slice(1, 3), 16);
[87] Fix | Delete
const g = parseInt(hexColor.slice(3, 5), 16);
[88] Fix | Delete
const b = parseInt(hexColor.slice(5, 7), 16);
[89] Fix | Delete
[90] Fix | Delete
// Convert the RGB color to HSL
[91] Fix | Delete
const max = Math.max(r, g, b);
[92] Fix | Delete
const min = Math.min(r, g, b);
[93] Fix | Delete
const l = (max + min) / 2;
[94] Fix | Delete
[95] Fix | Delete
// Calculate the brightness position in percentage
[96] Fix | Delete
const brightnessPercentage = Math.round(l / 255 * 100);
[97] Fix | Delete
[98] Fix | Delete
return brightnessPercentage;
[99] Fix | Delete
}
[100] Fix | Delete
const pdfIframeStyle = (data) => {
[101] Fix | Delete
[102] Fix | Delete
const isAllNull = Object.values(data).every(value => value === null);;
[103] Fix | Delete
[104] Fix | Delete
if (isAllNull) {
[105] Fix | Delete
return false;
[106] Fix | Delete
};
[107] Fix | Delete
[108] Fix | Delete
let settingsPos = '';
[109] Fix | Delete
[110] Fix | Delete
if (data.toolbar === false || data.toolbar == 'false') {
[111] Fix | Delete
data.presentation = false; data.download = true; data.copy_text = true; data.add_text = true; data.draw = true, data.doc_details = false; data.doc_rotation = false, data.add_image = false;
[112] Fix | Delete
}
[113] Fix | Delete
[114] Fix | Delete
let position = 'top';
[115] Fix | Delete
let toolbar = isDisplay(data.toolbar);
[116] Fix | Delete
let presentation = isDisplay(data.presentation);
[117] Fix | Delete
let download = isDisplay(data.download);
[118] Fix | Delete
let copy_text = isDisplay(data.copy_text);
[119] Fix | Delete
let add_text = isDisplay(data.add_text);
[120] Fix | Delete
let draw = isDisplay(data.draw);
[121] Fix | Delete
[122] Fix | Delete
if (copy_text === 'block' || copy_text == 'true' || copy_text == true) {
[123] Fix | Delete
copy_text = 'text';
[124] Fix | Delete
}
[125] Fix | Delete
[126] Fix | Delete
[127] Fix | Delete
let doc_details = isDisplay(data.doc_details);
[128] Fix | Delete
let doc_rotation = isDisplay(data.doc_rotation);
[129] Fix | Delete
let add_image = isDisplay(data.add_image);
[130] Fix | Delete
[131] Fix | Delete
const otherhead = document.getElementsByTagName("head")[0];
[132] Fix | Delete
[133] Fix | Delete
const style = document.createElement("style");
[134] Fix | Delete
style.setAttribute('id', 'EBiframeStyleID');
[135] Fix | Delete
[136] Fix | Delete
let pdfCustomColor = '';
[137] Fix | Delete
[138] Fix | Delete
if (data.themeMode == 'custom') {
[139] Fix | Delete
if (!data.customColor) {
[140] Fix | Delete
data.customColor = '#38383d';
[141] Fix | Delete
}
[142] Fix | Delete
[143] Fix | Delete
let colorBrightness = getColorBrightness(data.customColor);
[144] Fix | Delete
[145] Fix | Delete
let iconsTextsColor = 'white';
[146] Fix | Delete
if (colorBrightness > 60) {
[147] Fix | Delete
iconsTextsColor = 'black';
[148] Fix | Delete
}
[149] Fix | Delete
[150] Fix | Delete
pdfCustomColor = `
[151] Fix | Delete
[ep-data-theme="custom"] {
[152] Fix | Delete
--body-bg-color: ${data.customColor};
[153] Fix | Delete
--toolbar-bg-color: ${adjustHexColor(data.customColor, 15)};
[154] Fix | Delete
--doorhanger-bg-color: ${data.customColor};
[155] Fix | Delete
--field-bg-color: ${data.customColor};
[156] Fix | Delete
--dropdown-btn-bg-color: ${data.customColor};
[157] Fix | Delete
--button-hover-color: ${adjustHexColor(data.customColor, 25)};
[158] Fix | Delete
--toggled-btn-bg-color: ${adjustHexColor(data.customColor, 25)};
[159] Fix | Delete
--doorhanger-hover-bg-color: ${adjustHexColor(data.customColor, 20)};
[160] Fix | Delete
--toolbar-border-color: ${adjustHexColor(data.customColor, 10)};
[161] Fix | Delete
--doorhanger-border-color: ${adjustHexColor(data.customColor, 10)};
[162] Fix | Delete
--doorhanger-border-color-whcm: ${adjustHexColor(data.customColor, 10)};
[163] Fix | Delete
--separator-color: ${adjustHexColor(data.customColor, 10)};
[164] Fix | Delete
--doorhanger-separator-color: ${adjustHexColor(data.customColor, 15)};
[165] Fix | Delete
--toolbar-icon-bg-color: ${iconsTextsColor};
[166] Fix | Delete
--toolbar-icon-bg-color: ${iconsTextsColor};
[167] Fix | Delete
--main-color: ${iconsTextsColor};
[168] Fix | Delete
--field-color: ${iconsTextsColor};
[169] Fix | Delete
--doorhanger-hover-color: ${iconsTextsColor};
[170] Fix | Delete
--toolbar-icon-hover-bg-color: ${iconsTextsColor};
[171] Fix | Delete
--toggled-btn-color: ${iconsTextsColor};
[172] Fix | Delete
[173] Fix | Delete
}`;
[174] Fix | Delete
}
[175] Fix | Delete
[176] Fix | Delete
if (data.position === 'top') {
[177] Fix | Delete
position = 'top:0;bottom:auto;'
[178] Fix | Delete
settingsPos = '';
[179] Fix | Delete
}
[180] Fix | Delete
else {
[181] Fix | Delete
position = 'bottom:0;top:auto;'
[182] Fix | Delete
settingsPos = `
[183] Fix | Delete
.findbar, .secondaryToolbar {
[184] Fix | Delete
top: auto;bottom: 32px;
[185] Fix | Delete
}
[186] Fix | Delete
.doorHangerRight:after{
[187] Fix | Delete
transform: rotate(180deg);
[188] Fix | Delete
bottom: -16px;
[189] Fix | Delete
}
[190] Fix | Delete
.doorHangerRight:before {
[191] Fix | Delete
transform: rotate(180deg);
[192] Fix | Delete
bottom: -18px;
[193] Fix | Delete
}
[194] Fix | Delete
[195] Fix | Delete
.findbar.doorHanger:before {
[196] Fix | Delete
bottom: -18px;
[197] Fix | Delete
transform: rotate(180deg);
[198] Fix | Delete
}
[199] Fix | Delete
.findbar.doorHanger:after {
[200] Fix | Delete
bottom: -16px;
[201] Fix | Delete
transform: rotate(180deg);
[202] Fix | Delete
}
[203] Fix | Delete
[204] Fix | Delete
div#editorInkParamsToolbar, #editorFreeTextParamsToolbar {
[205] Fix | Delete
bottom: 32px;
[206] Fix | Delete
top: auto;
[207] Fix | Delete
}
[208] Fix | Delete
`;
[209] Fix | Delete
}
[210] Fix | Delete
[211] Fix | Delete
style.textContent = `
[212] Fix | Delete
.toolbar{
[213] Fix | Delete
display: ${toolbar}!important;
[214] Fix | Delete
position: absolute;
[215] Fix | Delete
${position}
[216] Fix | Delete
}
[217] Fix | Delete
#secondaryToolbar{
[218] Fix | Delete
display: ${toolbar};
[219] Fix | Delete
}
[220] Fix | Delete
#secondaryPresentationMode, #toolbarViewerRight #presentationMode{
[221] Fix | Delete
display: ${presentation}!important;
[222] Fix | Delete
}
[223] Fix | Delete
#secondaryOpenFile, #toolbarViewerRight #openFile{
[224] Fix | Delete
display: none!important;
[225] Fix | Delete
}
[226] Fix | Delete
#secondaryDownload, #secondaryPrint, #print, #download{
[227] Fix | Delete
display: ${download}!important;
[228] Fix | Delete
}
[229] Fix | Delete
#pageRotateCw{
[230] Fix | Delete
display: ${doc_rotation}!important;
[231] Fix | Delete
}
[232] Fix | Delete
#editorStamp{
[233] Fix | Delete
display: ${add_image}!important;
[234] Fix | Delete
}
[235] Fix | Delete
#pageRotateCcw{
[236] Fix | Delete
display: ${doc_rotation}!important;
[237] Fix | Delete
}
[238] Fix | Delete
#documentProperties{
[239] Fix | Delete
display: ${doc_details}!important;
[240] Fix | Delete
}
[241] Fix | Delete
.textLayer{
[242] Fix | Delete
user-select: ${copy_text}!important;
[243] Fix | Delete
}
[244] Fix | Delete
button#cursorSelectTool{
[245] Fix | Delete
display: ${copy_text}!important;
[246] Fix | Delete
}
[247] Fix | Delete
[248] Fix | Delete
#editorFreeText{
[249] Fix | Delete
display: ${add_text}!important;
[250] Fix | Delete
}
[251] Fix | Delete
#editorInk{
[252] Fix | Delete
display: ${draw}!important;
[253] Fix | Delete
}
[254] Fix | Delete
[255] Fix | Delete
${pdfCustomColor}
[256] Fix | Delete
[257] Fix | Delete
${settingsPos}
[258] Fix | Delete
`;
[259] Fix | Delete
[260] Fix | Delete
if (otherhead) {
[261] Fix | Delete
if (document.getElementById("EBiframeStyleID")) {
[262] Fix | Delete
document.getElementById("EBiframeStyleID").remove();
[263] Fix | Delete
}
[264] Fix | Delete
otherhead.appendChild(style);
[265] Fix | Delete
}
[266] Fix | Delete
}
[267] Fix | Delete
[268] Fix | Delete
const manupulatePDFIframe = (e) => {
[269] Fix | Delete
let hashNewUrl = new URL(e.newURL);
[270] Fix | Delete
let data = getParamObj(hashNewUrl.hash);
[271] Fix | Delete
pdfIframeStyle(data);
[272] Fix | Delete
setThemeMode(data.themeMode);
[273] Fix | Delete
}
[274] Fix | Delete
[275] Fix | Delete
window.addEventListener('hashchange', (e) => {
[276] Fix | Delete
manupulatePDFIframe(e);
[277] Fix | Delete
}, false);
[278] Fix | Delete
[279] Fix | Delete
[280] Fix | Delete
let data = getParamObj(location.hash);
[281] Fix | Delete
[282] Fix | Delete
pdfIframeStyle(data);
[283] Fix | Delete
setThemeMode(data.themeMode);
[284] Fix | Delete
[285] Fix | Delete
[286] Fix | Delete
[287] Fix | Delete
document.querySelector(".presentationMode")?.addEventListener("click", function () {
[288] Fix | Delete
[289] Fix | Delete
console.log("presentation mode clicked");
[290] Fix | Delete
var mainContainer = document.getElementById("mainContainer");
[291] Fix | Delete
if (mainContainer && !document.fullscreenElement) {
[292] Fix | Delete
mainContainer.requestFullscreen().catch(err => {
[293] Fix | Delete
alert(`Error attempting to enable full-screen mode: ${err.message} (${err.name})`);
[294] Fix | Delete
});
[295] Fix | Delete
} else {
[296] Fix | Delete
if (document.exitFullscreen) {
[297] Fix | Delete
document.exitFullscreen();
[298] Fix | Delete
}
[299] Fix | Delete
}
[300] Fix | Delete
});
[301] Fix | Delete
[302] Fix | Delete
document.getElementById("viewBookmark")?.addEventListener('click', (e) => {
[303] Fix | Delete
e.preventDefault();
[304] Fix | Delete
const url = e.target.getAttribute('href');
[305] Fix | Delete
if (url !== null) {
[306] Fix | Delete
alert(`Current Page: ${url}`);
[307] Fix | Delete
}
[308] Fix | Delete
});
[309] Fix | Delete
[310] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function