diff --git a/_incl_data/class/Battle.php b/_incl_data/class/Battle.php index fc683ae5..c721b487 100644 --- a/_incl_data/class/Battle.php +++ b/_incl_data/class/Battle.php @@ -1525,13 +1525,14 @@ JS; $jstext = json_encode($log['text']); $jsvars = json_encode($log['vars']); - $js = "add_log({$log['id']},$jstext,{$log['id_hod']},$jsvars)" . $js; + $js = "add_log({$log['id']},$jstext,{$log['id_hod']},$jsvars);" . $js; } Db::sql('update stats set alog = ? where id = ?', [$u->info['alog'], $u->info['id']]); $js .= "id_log=$pll;"; - return htmlspecialchars($js, ENT_QUOTES); + //return htmlspecialchars($js, ENT_QUOTES); + return $js; } diff --git a/js/btl_mini.js b/js/btl_mini.js index 5f1b5179..d5ad3e8e 100644 --- a/js/btl_mini.js +++ b/js/btl_mini.js @@ -442,56 +442,76 @@ var id_log_ar = []; var id_log; var type_log = top.type_log; +// Эта функция получает элемент по идентификатору из фрейма 'main'. +const getElementByIdInMainFrame = (id) => { + const frame = top.frames['main']; + if (!frame) { + console.error("Фрейм 'main' не найден!"); + return null; + } + + return frame.document.getElementById(id); +}; + function add_log(id, text, hod_id, vars) { + const logsdiv = getElementByIdInMainFrame('battle_logg'); + let hodlogdiv = getElementByIdInMainFrame(`battle_log_${hod_id}`); + const hodlogdiv7 = getElementByIdInMainFrame(`battle_log_${hod_id - 7}`); + const hodlogdiv25 = getElementByIdInMainFrame(`battle_log_${hod_id - 25}`); + const logid = getElementByIdInMainFrame(`log_id_${id}`); + if (top.des === 1) type_log = 0 else type_log = 1; if (type_log === 1) { chsee = 'chsee2'; - //if(id_log_ar[id]!=id) - //{ text = looklogrep(text, vars); id_log_ar[id] = id; id_log = id; - // if (top.frames['main'].document.getElementById("battle_log_" + hod_id + "") == undefined && hod_id != 1) { - if (!top.frames['main'].document.getElementById(`battle_log_${hod_id}`) && hod_id != 1) { + + if (!hodlogdiv && hod_id !== 1) { if (fstlh === 0) fstlh = hod_id lsthd[lsti] = hod_id; lsti++; - $(top.frames['main'].document.getElementById('battle_logg')).prepend(`
`); - } else if (!top.frames['main'].document.getElementById(`battle_log_${hod_id}`)) { - top.frames['main'].document.getElementById('battle_logg').innerHTML = top.frames['main'].document.getElementById('battle_logg').innerHTML + `
`; + logsdiv.insertAdjacentHTML('afterbegin', `
`); + hodlogdiv = getElementByIdInMainFrame(`battle_log_${hod_id}`); + } else if (!hodlogdiv) { + logsdiv.insertAdjacentHTML('beforeend', `
`); + hodlogdiv = getElementByIdInMainFrame(`battle_log_${hod_id}`); } - if (!top.frames['main'].document.getElementById(`log_id_${id}`)) { - $(top.frames['main'].document.getElementById(`battle_log_${hod_id}`)).prepend(`${text}
`); + if (!logid) { + hodlogdiv.insertAdjacentHTML('afterbegin', `${text}
`); } - //} - if (top.frames['main'].document.getElementById(`battle_log_${hod_id - 25}`)) { + + if (hodlogdiv25) { top.rmve(`#battle_log_${hod_id - 25}`); } return } + chsee = 'chsee2'; text = looklogrep(text, vars); id_log_ar[id] = id; id_log = id; - if (!top.document.getElementById(`battle_log_${hod_id}`) && hod_id != 1) { + if (!hodlogdiv && hod_id !== 1) { if (fstlh === 0) { fstlh = hod_id; } lsthd[lsti] = hod_id; lsti++; - $(top.document.getElementById('battle_logg')).prepend(`
`); - } else if (!top.document.getElementById("battle_log_" + hod_id + "")) { - top.document.getElementById('battle_logg').innerHTML = top.document.getElementById('battle_logg').innerHTML + `
`; + logsdiv.insertAdjacentHTML('afterbegin', `
`); + hodlogdiv = getElementByIdInMainFrame(`battle_log_${hod_id}`); + } else if (!hodlogdiv) { + logsdiv.insertAdjacentHTML('beforeend', `
`); + hodlogdiv = getElementByIdInMainFrame(`battle_log_${hod_id}`); } - if (!top.document.getElementById(`log_id_${id}`)) { - $(top.document.getElementById(`battle_log_${hod_id}`)).prepend(`${text}
`); + if (!logid) { + hodlogdiv.insertAdjacentHTML('afterbegin', `${text}
`); } - if (top.document.getElementById(`battle_log_${hod_id - 7}`)) { + if (hodlogdiv7) { top.rmve(`#battle_log_${hod_id - 7}`); } } @@ -499,22 +519,26 @@ function add_log(id, text, hod_id, vars) { //-- Мой лог-------------------------------- //------------------------------------------- function add_mlog(id, text, hod_id, vars) { + const logsdiv = getElementByIdInMainFrame('battle_mlogg'); + let hodlogdiv = getElementByIdInMainFrame(`battle_mlog_${hod_id}`); + const hodlogdiv14 = getElementByIdInMainFrame(`battle_mlog_${hod_id - 14}`); + const logid = getElementByIdInMainFrame(`mlog_id_${id}`); + chsee = 'chsee7'; text = looklogrep(text, vars); id_log_ar[id] = id; id_log = id; - if (!top.document.getElementById(`battle_mlog_${hod_id}`) && hod_id != 1) { - $(top.document.getElementById('battle_mlogg')).prepend(`
`); - - } else if (!top.document.getElementById(`battle_mlog_${hod_id}`)) { - top.document.getElementById('battle_mlogg').innerHTML = top.document.getElementById('battle_mlogg').innerHTML + `
`; + if (!hodlogdiv && hod_id !== 1) { + logsdiv.insertAdjacentHTML('afterbegin', `
`); + hodlogdiv = getElementByIdInMainFrame(`battle_mlog_${hod_id}`); + } else if (!hodlogdiv) { + logsdiv.insertAdjacentHTML('beforeend', `
`); + hodlogdiv = getElementByIdInMainFrame(`battle_mlog_${hod_id}`); } - - if (!top.document.getElementById(`mlog_id_${id}`)) { - $(top.document.getElementById(`battle_mlog_${hod_id}`)).prepend(`${text}
`); - + if (!logid) { + hodlogdiv.insertAdjacentHTML('afterbegin', `${text}
`); } - if (top.document.getElementById(`battle_mlog_${hod_id - 14}`)) { + if (hodlogdiv14) { top.rmve(`#battle_mlog_${hod_id - 14}`); } }