Рефакторинг яваскриптов. Уборка jQuery.
This commit is contained in:
parent
023d9856ea
commit
f3d475a0b8
@ -1525,13 +1525,14 @@ JS;
|
|||||||
$jstext = json_encode($log['text']);
|
$jstext = json_encode($log['text']);
|
||||||
$jsvars = json_encode($log['vars']);
|
$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']]);
|
Db::sql('update stats set alog = ? where id = ?', [$u->info['alog'], $u->info['id']]);
|
||||||
$js .= "id_log=$pll;";
|
$js .= "id_log=$pll;";
|
||||||
|
|
||||||
return htmlspecialchars($js, ENT_QUOTES);
|
//return htmlspecialchars($js, ENT_QUOTES);
|
||||||
|
return $js;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -442,56 +442,76 @@ var id_log_ar = [];
|
|||||||
var id_log;
|
var id_log;
|
||||||
var type_log = top.type_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) {
|
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
|
if (top.des === 1) type_log = 0
|
||||||
else type_log = 1;
|
else type_log = 1;
|
||||||
|
|
||||||
if (type_log === 1) {
|
if (type_log === 1) {
|
||||||
chsee = 'chsee2';
|
chsee = 'chsee2';
|
||||||
|
|
||||||
//if(id_log_ar[id]!=id)
|
|
||||||
//{
|
|
||||||
text = looklogrep(text, vars);
|
text = looklogrep(text, vars);
|
||||||
id_log_ar[id] = id;
|
id_log_ar[id] = id;
|
||||||
id_log = 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
|
if (fstlh === 0) fstlh = hod_id
|
||||||
lsthd[lsti] = hod_id;
|
lsthd[lsti] = hod_id;
|
||||||
lsti++;
|
lsti++;
|
||||||
$(top.frames['main'].document.getElementById('battle_logg')).prepend(`<div style="padding-top:2px;padding-bottom:2px;" id="battle_log_'${hod_id}" class="battle_hod_style"></div>`);
|
logsdiv.insertAdjacentHTML('afterbegin', `<div style="padding-top:2px;padding-bottom:2px;" id="battle_log_'${hod_id}" class="battle_hod_style"></div>`);
|
||||||
} else if (!top.frames['main'].document.getElementById(`battle_log_${hod_id}`)) {
|
hodlogdiv = getElementByIdInMainFrame(`battle_log_${hod_id}`);
|
||||||
top.frames['main'].document.getElementById('battle_logg').innerHTML = top.frames['main'].document.getElementById('battle_logg').innerHTML + `<div style="padding-top:2px;padding-bottom:2px;" id="battle_log_${hod_id}"></div>`;
|
} else if (!hodlogdiv) {
|
||||||
|
logsdiv.insertAdjacentHTML('beforeend', `<div style="padding-top:2px;padding-bottom:2px;" id="battle_log_${hod_id}"></div>`);
|
||||||
|
hodlogdiv = getElementByIdInMainFrame(`battle_log_${hod_id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!top.frames['main'].document.getElementById(`log_id_${id}`)) {
|
if (!logid) {
|
||||||
$(top.frames['main'].document.getElementById(`battle_log_${hod_id}`)).prepend(`<span id="log_id_${id}" class="foryou0">${text}</span><br>`);
|
hodlogdiv.insertAdjacentHTML('afterbegin', `<span id="log_id_${id}" class="foryou0">${text}</span><br>`);
|
||||||
}
|
}
|
||||||
//}
|
|
||||||
if (top.frames['main'].document.getElementById(`battle_log_${hod_id - 25}`)) {
|
if (hodlogdiv25) {
|
||||||
top.rmve(`#battle_log_${hod_id - 25}`);
|
top.rmve(`#battle_log_${hod_id - 25}`);
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
chsee = 'chsee2';
|
chsee = 'chsee2';
|
||||||
|
|
||||||
text = looklogrep(text, vars);
|
text = looklogrep(text, vars);
|
||||||
id_log_ar[id] = id;
|
id_log_ar[id] = id;
|
||||||
id_log = id;
|
id_log = id;
|
||||||
if (!top.document.getElementById(`battle_log_${hod_id}`) && hod_id != 1) {
|
if (!hodlogdiv && hod_id !== 1) {
|
||||||
if (fstlh === 0) {
|
if (fstlh === 0) {
|
||||||
fstlh = hod_id;
|
fstlh = hod_id;
|
||||||
}
|
}
|
||||||
lsthd[lsti] = hod_id;
|
lsthd[lsti] = hod_id;
|
||||||
lsti++;
|
lsti++;
|
||||||
$(top.document.getElementById('battle_logg')).prepend(`<div style="padding-top:2px;padding-bottom:2px;" id="battle_log_${hod_id}" tabindex="${0 - hod_id}" class="battle_hod_style"></div>`);
|
logsdiv.insertAdjacentHTML('afterbegin', `<div style="padding-top:2px;padding-bottom:2px;" id="battle_log_${hod_id}" tabindex="${0 - hod_id}" class="battle_hod_style"></div>`);
|
||||||
} else if (!top.document.getElementById("battle_log_" + hod_id + "")) {
|
hodlogdiv = getElementByIdInMainFrame(`battle_log_${hod_id}`);
|
||||||
top.document.getElementById('battle_logg').innerHTML = top.document.getElementById('battle_logg').innerHTML + `<div style="padding-top:2px;padding-bottom:2px;" id="battle_log_${hod_id}"></div>`;
|
} else if (!hodlogdiv) {
|
||||||
|
logsdiv.insertAdjacentHTML('beforeend', `<div style="padding-top:2px;padding-bottom:2px;" id="battle_log_${hod_id}"></div>`);
|
||||||
|
hodlogdiv = getElementByIdInMainFrame(`battle_log_${hod_id}`);
|
||||||
}
|
}
|
||||||
if (!top.document.getElementById(`log_id_${id}`)) {
|
if (!logid) {
|
||||||
$(top.document.getElementById(`battle_log_${hod_id}`)).prepend(`<span id="log_id_${id}" class="foryou0">${text}</span><br>`);
|
hodlogdiv.insertAdjacentHTML('afterbegin', `<span id="log_id_${id}" class="foryou0">${text}</span><br>`);
|
||||||
}
|
}
|
||||||
if (top.document.getElementById(`battle_log_${hod_id - 7}`)) {
|
if (hodlogdiv7) {
|
||||||
top.rmve(`#battle_log_${hod_id - 7}`);
|
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) {
|
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';
|
chsee = 'chsee7';
|
||||||
text = looklogrep(text, vars);
|
text = looklogrep(text, vars);
|
||||||
id_log_ar[id] = id;
|
id_log_ar[id] = id;
|
||||||
id_log = id;
|
id_log = id;
|
||||||
if (!top.document.getElementById(`battle_mlog_${hod_id}`) && hod_id != 1) {
|
if (!hodlogdiv && hod_id !== 1) {
|
||||||
$(top.document.getElementById('battle_mlogg')).prepend(`<div style="padding-top:2px;padding-bottom:2px;" id="battle_mlog_${hod_id}" tabindex="${0 - hod_id}" class="battle_hod_style"></div>`);
|
logsdiv.insertAdjacentHTML('afterbegin', `<div style="padding-top:2px;padding-bottom:2px;" id="battle_mlog_${hod_id}" tabindex="${0 - hod_id}" class="battle_hod_style"></div>`);
|
||||||
|
hodlogdiv = getElementByIdInMainFrame(`battle_mlog_${hod_id}`);
|
||||||
} else if (!top.document.getElementById(`battle_mlog_${hod_id}`)) {
|
} else if (!hodlogdiv) {
|
||||||
top.document.getElementById('battle_mlogg').innerHTML = top.document.getElementById('battle_mlogg').innerHTML + `<div style="padding-top:2px;padding-bottom:2px;" id="battle_mlog_${hod_id}"></div>`;
|
logsdiv.insertAdjacentHTML('beforeend', `<div style="padding-top:2px;padding-bottom:2px;" id="battle_mlog_${hod_id}"></div>`);
|
||||||
|
hodlogdiv = getElementByIdInMainFrame(`battle_mlog_${hod_id}`);
|
||||||
}
|
}
|
||||||
|
if (!logid) {
|
||||||
if (!top.document.getElementById(`mlog_id_${id}`)) {
|
hodlogdiv.insertAdjacentHTML('afterbegin', `<span id="mlog_id_${id}" class="foryou0">${text}</span><br>`);
|
||||||
$(top.document.getElementById(`battle_mlog_${hod_id}`)).prepend(`<span id="mlog_id_${id}" class="foryou0">${text}</span><br>`);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if (top.document.getElementById(`battle_mlog_${hod_id - 14}`)) {
|
if (hodlogdiv14) {
|
||||||
top.rmve(`#battle_mlog_${hod_id - 14}`);
|
top.rmve(`#battle_mlog_${hod_id - 14}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user