Ремонт чата и рефакторинг js.

This commit is contained in:
Ivor Barhansky 2023-06-11 14:50:52 +03:00
parent a073a02176
commit 2440ad3cc1
8 changed files with 1864 additions and 1765 deletions

View File

@ -25,7 +25,6 @@ function er($e)
exit($err);
}
Config::init();
Database::init();
define('IP', UserIp::get());
@ -72,7 +71,8 @@ $u->stats = $u->getStats($u->info['id'], 0);
<link rel="stylesheet" href="css/windows.css"/>
<link rel="stylesheet" href="css/hack.css"/>
<script>
const des = 1;
window.des = 1;
const c = {
noEr: 0,
noErTmr: 0,
@ -95,22 +95,22 @@ $u->stats = $u->getStats($u->info['id'], 0);
money: <?= $u->info['money'] ?>
},
sd4key = "<?= $u->info['nextAct'] ?>",
lafstReg = {},
enterUse = 0;
lafstReg = {};
// Проверка на совпедение города.
function ctest(city) {
if (city != c['city']) {
if (city !== c['city']) {
top.location = '/bk';
}
}
let enterUse = 0;
function testKey(event) {
if (event.keyCode == 10 || event.keyCode == 13) {
if (top.enterUse == 0) {
if (event.keyCode === 10 || event.keyCode === 13) {
if (enterUse === 0) {
chat.subSend();
top.enterUse = 1;
setTimeout('top.enterUse = 0', 1000);
enterUse = 1;
setTimeout('enterUse = 0', 1000);
}
}
}
@ -123,10 +123,12 @@ $u->stats = $u->getStats($u->info['id'], 0);
$(window).error(function () {
return true;
});
let iusrno = {};
//Есть зависимость в interface.js - infoMenu()!
window.iusrno = {};
function ignoreUser(u) {
if (iusrno[u] == undefined || iusrno[u] == 0) {
if (iusrno[u] === undefined || iusrno[u] === 0) {
$('#main').attr({'src': 'main.php?friends=1&ignore=' + u + ''});
} else {
$('#main').attr({'src': 'main.php?friends=1&ignore=' + u + ''});
@ -140,7 +142,6 @@ $u->stats = $u->getStats($u->info['id'], 0);
<script type="text/javascript" src="js/gameEngine.js?<?= time() ?>"></script>
<script type="text/javascript" src="js/interface.js"></script>
<script type="text/javascript" src="js/dataCenter.js"></script>
<script type="text/javascript" src="js/onlineList.js"></script>
<script type="text/javascript" src="js/hpregen.js"></script>
@ -493,7 +494,6 @@ $u->stats = $u->getStats($u->info['id'], 0);
.proza {
filter: progid:DXImageTransform.Microsoft.Alpha(opacity=87); /* IE 5.5+*/
-moz-opacity: 0.87; /* Mozilla 1.6 и ниже */
-khtml-opacity: 0.87; /* Konqueror 3.1, Safari 1.1 */
opacity: 0.87; /* CSS3 - Mozilla 1.7b +, Firefox 0.9 +, Safari 1.2+, Opera 9+ */
}
@ -562,21 +562,22 @@ $u->stats = $u->getStats($u->info['id'], 0);
</head>
<body>
<div style="display:none" class="qel0" id="qel0"></div>
<noscript>В вашем браузере отсутствует поддержка <strong>javascript<strong></noscript>
<noscript>В вашем браузере отсутствует поддержка <strong>javascript</strong></noscript>
<script>
window.onLoad = function () {
bodyLoaded();
chat.sendMsg(["new", "<?=time()?>", "1", "", "<?=$u->info['login']?>", "global:<b style='background-color:#ffcccc'>&nbsp; Приветствуем в игре, не забываем поздороваться и прочесть новости проекта! <a href='/n' target='_blank'>читать новости</a> &nbsp;</b>", "red", "1", "1", "0"]);
}
if (window.top != window.self) {
if (window.top !== window.self) {
document.write = "";
window.top.location = window.self.location;
setTimeout(function () {
document.body.innerHTML = 'Ошибка доступа.';
}, 500);
window.self.onload = function (evt) {
window.self.onload = function () {
document.body.innerHTML = 'Ошибка доступа.';
};
}
@ -592,7 +593,7 @@ $u->stats = $u->getStats($u->info['id'], 0);
$(window).resize();
}
var lasts = [-1, -1];
const lasts = [-1, -1];
function myexpLineTop27(e1, e2) {
$('#exp23mkrtkm').attr('title', "Опыт персонажа" + "\n" + e1 + " / " + e2);
@ -603,7 +604,7 @@ $u->stats = $u->getStats($u->info['id'], 0);
if (lasts[1] < e2) {
$('#myexplin233').css('width', '1%');
}
if (lasts[0] != e1 || lasts[1] != e2) {
if (lasts[0] !== e1 || lasts[1] !== e2) {
$('#myexplin233').animate({'width': Math.ceil(e1 / e2 * 100) + '%'}, 3000);
}
}
@ -614,7 +615,7 @@ $u->stats = $u->getStats($u->info['id'], 0);
let smlk1 = 0;
function smiles1load() {
if (smlk1 == 0) {
if (smlk1 === 0) {
$('#btnsmlrz').html('<small>&nbsp; Общие смайлики &nbsp;</small>');
smlk1 = 1;
$('#smilesDiv').hide();
@ -802,7 +803,7 @@ $u->stats = $u->getStats($u->info['id'], 0);
<tr>
<td id="chat_block" style="position:relative;border-top:1px solid #808080; vertical-align: top;">
<!-- display:block;-->
<div id="mini_qsst" onClick="top.qn_slk()" style="cursor:pointer"></div>
<div id="mini_qsst" onClick='qn_slk()' style="cursor:pointer"></div>
<div id="onbon"></div>
<div id="chat_menus" unselectable="on" onselectstart="return false;"
style="display:block;position:absolute; right:0; top:3px; padding-right:20px; height:18px; text-align:right; white-space:nowrap;">
@ -1110,7 +1111,7 @@ $u->stats = $u->getStats($u->info['id'], 0);
return {
date: divFullDateTime(objDate),
time: mskTime,
redDay: todayDay == 5 || todayDay == 6 || todayDay == 0
redDay: todayDay === 5 || todayDay === 6 || todayDay === 0
}
}
}
@ -1169,7 +1170,7 @@ $u->stats = $u->getStats($u->info['id'], 0);
document.getElementById("dateRed").style.color = redDay ? "red" : ""
}
$button.addEventListener("mouseover", function (event) {
$button.addEventListener("mouseover", function () {
timeoutClear = setTimeout(() => {
@ -1186,7 +1187,7 @@ $u->stats = $u->getStats($u->info['id'], 0);
}, 550)
})
$button.addEventListener("mouseout", function (event) {
$button.addEventListener("mouseout", function () {
$div.hidden = true
clearInterval(intervalClear)
clearTimeout(timeoutClear)

View File

@ -418,7 +418,7 @@ $dost = [
-->
</style>
<script>
var c = {
let c = {
url: '<?=$c['host']?>',
img: '<?=$c['img']?>',
uid: <?=(0 + $f->user['id'])?>,
@ -437,12 +437,12 @@ $dost = [
}, sd4key = "0f27a8a6a79921703aee0ba6ff02e4c2", lafstReg = {}, enterUse = 0;
function ctest(city) {
if (city != c['city']) {
if (city !== c['city']) {
top.location = 'club';
}
}
var key_actions = {};
let key_actions = {};
<!--
function MM_jumpMenu(targ, selObj, restore) { //v3.0
eval(targ + ".location='" + selObj.options[selObj.selectedIndex].value + "'");

View File

File diff suppressed because it is too large Load Diff

View File

@ -1,97 +1,100 @@
var timerHP = 0;
var lasttimeHP = 0;
let timerHP = 0;
let lasttimeHP = 0;
let tt1 = '';
function startHpRegen(f, id, hpnow, hpmax, mpnow, mpmax, sec_h, sec_m, speed_hp, speed_mp, news, tmr) {
var d = document;
let d = document;
if (news != 0) {
if (news !== 0) {
lasttimeHP++;
tmr = lasttimeHP;
timerHP = tmr;
}
if (news == 1 && tt1 != undefined) {
if (news === 1 && tt1 !== undefined) {
clearTimeout(tt1);
}
if (lasttimeHP != tmr) {
if (lasttimeHP !== tmr) {
return;
}
if (f === 'top') d = top.document;
else if (f === 'main') d = top.frames['main'].document;
if (d !== undefined && lafstReg[id]) {
//здоровье
const h1 = d.getElementById(`vhp${id}`);
const m1 = d.getElementById(`vmp${id}`);
const widb1 = h1 ? parseInt(h1.style.width) : 0;
} else {
if (f == 'top') d = top.document;
else if (f == 'main') d = top.frames['main'].document;
if (h1) {
const h2 = d.getElementById(`lhp${id}`);
if (h2) {
if (d != undefined && lafstReg[id] != undefined && lafstReg[id] != 0) {
//здоровье
var h1 = d.getElementById(`vhp${id}`);
var m1 = d.getElementById(`vmp${id}`);
var widb1 = h1 ? parseInt(h1.style.width) : 0;
//Восстанавливаем НР
let newHP = sec_h * speed_hp;
if (h1 != undefined) {
var h2 = d.getElementById(`lhp${id}`);
if (h2 != undefined) {
//Восстанавливаем НР
var newHP = '';
newHP = sec_h * speed_hp;
function newHP_work(ifTrue) {
if (ifTrue) hpnow += newHP;
if (hpnow < 0) hpnow = 0;
if (hpnow > hpmax) hpnow = hpmax;
function newHP_work (ifTrue) {
if (ifTrue) hpnow += newHP;
if (hpnow < 0) hpnow = 0;
if (hpnow > hpmax) hpnow = hpmax;
var formuleNewHP = Math.floor(hpnow / hpmax * widb1)
h1.innerHTML = ' ' + Math.floor(hpnow) + '/' + hpmax + '';
const formuleNewHP = Math.floor(hpnow / hpmax * widb1);
h1.innerHTML = ' ' + Math.floor(hpnow) + '/' + hpmax + '';
switch (true) {
case (formuleNewHP < 1): h2.className = 'hp_none';
case (formuleNewHP > 0): h2.className = 'hp_1';
case (formuleNewHP > 32): h2.className = 'hp_2';
case (formuleNewHP > 65): h2.className = 'hp_3';
case (formuleNewHP <= widb1):
h2.style.width = `${formuleNewHP}px`;
break
}
switch (true) {
case (formuleNewHP < 1):
h2.className = 'hp_none';
case (formuleNewHP > 0):
h2.className = 'hp_1';
case (formuleNewHP > 32):
h2.className = 'hp_2';
case (formuleNewHP > 65):
h2.className = 'hp_3';
case (formuleNewHP <= widb1):
h2.style.width = `${formuleNewHP}px`;
break
}
if (newHP != 0) newHP_work(true)
else newHP_work(false)
}
if (newHP !== 0) newHP_work(true)
else newHP_work(false)
}
//мана
if (m1 != undefined) {
var m2 = d.getElementById(`lmp${id}`);
if (m2 != undefined) {
//Восстанавливаем MP
var newMP = '';
newMP = sec_m * speed_mp;
}
//мана
if (m1) {
const m2 = d.getElementById(`lmp${id}`);
if (m2) {
//Восстанавливаем MP
let newMP = sec_m * speed_mp;
function newMP_work (ifTrue) {
if (ifTrue) mpnow += newMP;
if (mpnow < 0) mpnow = 0;
if (mpnow > mpmax) mpnow = mpmax;
var formuleNewMP = Math.floor(mpnow / mpmax * widb1)
m1.innerHTML = ' ' + Math.floor(mpnow) + '/' + mpmax + '';
function newMP_work(ifTrue) {
if (ifTrue) mpnow += newMP;
if (mpnow < 0) mpnow = 0;
if (mpnow > mpmax) mpnow = mpmax;
switch (true) {
case (formuleNewMP < 1): m2.className = 'hp_none';
case (formuleNewMP != 1): m2.className = 'hp_mp';
case (formuleNewMP <= widb1):
m2.style.width = `${formuleNewMP}px`;
break
}
const formuleNewMP = Math.floor(mpnow / mpmax * widb1);
m1.innerHTML = ' ' + Math.floor(mpnow) + '/' + mpmax + '';
switch (true) {
case (formuleNewMP < 1):
m2.className = 'hp_none';
case (formuleNewMP !== 1):
m2.className = 'hp_mp';
case (formuleNewMP <= widb1):
m2.style.width = `${formuleNewMP}px`;
break
}
if (newMP != 0) newMP_work(true)
else newMP_work(false)
}
if (newMP !== 0) newMP_work(true)
else newMP_work(false)
}
lafstReg[id] = 0 + lafstReg[id] + 1;
var tt1 = setTimeout(`top.startHpRegen("${f}",${id},${hpnow},${hpmax},${mpnow},${mpmax},1,1,${speed_hp},${speed_mp},0,${timerHP});`, 1000);
}
if (lafstReg[id] == 0 || lafstReg[id] == undefined) {
lafstReg[id] = 0 + lafstReg[id] + 1;
var tt1 = setTimeout(`top.startHpRegen("${f}",${id},${hpnow},${hpmax},${mpnow},${mpmax},1,1,${speed_hp},${speed_mp},0,${timerHP});`, 1000);
}
lafstReg[id] = 0 + lafstReg[id] + 1;
tt1 = setTimeout(`top.startHpRegen("${f}", ${id}, ${hpnow}, ${hpmax}, ${mpnow}, ${mpmax}, 1, 1, ${speed_hp}, ${speed_mp}, 0, ${timerHP});`, 1000);
}
if (!lafstReg[id]) {
lafstReg[id] = 0 + lafstReg[id] + 1;
tt1 = setTimeout(`top.startHpRegen("${f}", ${id}, ${hpnow}, ${hpmax}, ${mpnow}, ${mpmax}, 1, 1, ${speed_hp}, ${speed_mp}, 0, ${timerHP});`, 1000);
}
}

View File

@ -12,23 +12,22 @@ $(document).ready(function () {
});
function bodyLoaded() {
top.recounter();
//генерируем смайлики
let i = 0,
j = '';
while (i != -1) {
if (top.sml[i] != undefined) {
j += `<img style="cursor:pointer" onclick="chat.addSmile(\'${top.sml[i]}\')" src="https://${c['img']}/i/smile/${top.sml[i]}.gif" width="${top.sml[i + 1]}" height="${top.sml[i + 2]}" title=":${top.sml[i]}:"/> `;
while (i !== -1) {
if (sml[i] !== undefined) {
j += `<img style="cursor:pointer" onclick="chat.addSmile(\'${sml[i]}\')" src="https://${c.img}/i/smile/${sml[i]}.gif" width="${sml[i + 1]}" height="${sml[i + 2]}" title=":${sml[i]}:"/> `;
} else i = -4;
i += 3;
}
$('#smilesDiv').html(j);
delete i, j;
}
function startEngine() {
//стандартные настройки
if ($.cookie('chatCfg0') == undefined) {
if ($.cookie('chatCfg0') === undefined) {
$.cookie('chatCfg0', 2, {expires: 320});
$.cookie('chatCfg1', 'Black', {expires: 320});
}
@ -55,7 +54,7 @@ function startEngine() {
resizeFinish();
//Добавляем действия
var i = 0;
while (i != -1) {
while (i !== -1) {
if ($(`#chcf${i}`).attr('id') != undefined) {
$(`#chcf${i}`).change(function () {
saveChatConfig();
@ -309,19 +308,19 @@ function MBcMenu() {
function getNameBrouser() {
var ua = navigator.userAgent.toLowerCase();
if (ua.indexOf("msie") != -1 && ua.indexOf("opera") == -1 && ua.indexOf("webtv") == -1) {
if (ua.indexOf("msie") !== -1 && ua.indexOf("opera") === -1 && ua.indexOf("webtv") === -1) {
return "msie"
}
if (ua.indexOf("opera") != -1) {
if (ua.indexOf("opera") !== -1) {
return "opera"
}
if (ua.indexOf("gecko") != -1) {
if (ua.indexOf("gecko") !== -1) {
return "gecko";
}
if (ua.indexOf("safari") != -1) {
if (ua.indexOf("safari") !== -1) {
return "safari";
}
if (ua.indexOf("konqueror") != -1) {
if (ua.indexOf("konqueror") !== -1) {
return "konqueror";
}
return "unknown";
@ -345,35 +344,35 @@ function mousePageXY(e) {
function infoMenu(u, e, f) {
if (!e) e = window.event;
var d = top.document.getElementById('persmenu');
var d2 = top.document.getElementById('upbox');
if (d != undefined) {
var dptop = -5;
var dpleft = -5;
if (f == 'main') {
const d = top.document.getElementById('persmenu');
const d2 = top.document.getElementById('upbox');
if (d) {
let dptop = -5;
const dpleft = -5;
if (f === 'main') {
dptop += 30;
}
var dp = top;
var s = d.style;
const dp = top;
const s = d.style;
d2.style.display = '';
d.className = 'topusermenu';
s.display = '';
var obtop = mousePageXY(e)['y'] + dptop;
if (getNameBrouser() == 'msie') {
let obtop = mousePageXY(e)['y'] + dptop;
if (getNameBrouser() === 'msie') {
obtop -= dp.document.body.scrollTop;
} else {
obtop -= dp.document.documentElement.scrollTop + dp.document.body.scrollTop;
}
var obleft = mousePageXY(e)['x'] + dpleft;
let obleft = mousePageXY(e)['x'] + dpleft;
d.style.top = `${obtop}px`;
d.style.left = `${obleft}px`;
var hmmmt = `<DIV onmouseover="top.doTest = false;" onmouseout="top.doTest = true; top.MBcMenu();">
<div onClick="top.chat.addto(\'${u}\',\'to\'); infoMenuClose(4);" class="topusermenuBtn">TO</div>
<div onClick="top.chat.addto(\'${u}\',\'private\'); infoMenuClose(4);" class="topusermenuBtn">PRIVATE</div>
<div onClick="window.open(\'inf.php?login=${u}\'); infoMenuClose(4);" class="topusermenuBtn">INFO</div>
<div onClick="top.infoMenuClose(4);" class="topusermenuBtn"><div id="d_clip_button">COPY</div></div>`;
let hmmmt = `<DIV onmouseover="top.doTest = false;" onmouseout="top.doTest = true; top.MBcMenu();">
<div onClick="top.chat.addto(\'${u}\',\'to\'); infoMenuClose(4);" class="topusermenuBtn">TO</div>
<div onClick="top.chat.addto(\'${u}\',\'private\'); infoMenuClose(4);" class="topusermenuBtn">PRIVATE</div>
<div onClick="window.open(\'inf.php?login=${u}\'); infoMenuClose(4);" class="topusermenuBtn">INFO</div>
<div onClick="top.infoMenuClose(4);" class="topusermenuBtn"><div id="d_clip_button">COPY</div></div>`;
if (top.iusrno[u] == undefined || top.iusrno[u] == 0) {
if (!top.iusrno[u]) {
hmmmt = `${hmmmt}<div onClick="top.ignoreUser(\'${u}\'); infoMenuClose(4);" class="topusermenuBtn">IGNORE</div>`;
} else {
hmmmt = `${hmmmt}<div onClick="top.ignoreUser(\'${u}\'); infoMenuClose(4);" class="topusermenuBtn">- IGNORE</div>`;
@ -381,12 +380,12 @@ function infoMenu(u, e, f) {
hmmmt = `${hmmmt}</DIV>`;
d.innerHTML = hmmmt;
var bdx = document.body.clientWidth;
var bdy = document.body.clientHeight;
var obx = d.clientWidth;
var oby = d.clientHeight;
var ots = bdy - obtop - oby;
var ols = bdx - obleft - obx;
const bdx = document.body.clientWidth;
const bdy = document.body.clientHeight;
const obx = d.clientWidth;
const oby = d.clientHeight;
const ots = bdy - obtop - oby;
const ols = bdx - obleft - obx;
if (ots < 10) {
obtop = bdy - 10 - oby;
d.style.top = `${obtop}px`;
@ -395,24 +394,18 @@ function infoMenu(u, e, f) {
obleft = bdx - 10 - obx;
d.style.left = `${obleft}px`;
}
$("#d_clip_button").zclip({
path: "js/ZeroClipboard.swf",
copy: function () {
return u;
}
});
}
}
function infoMenuClose(id) {
var d = top.document.getElementById('persmenu');
var d2 = top.document.getElementById('upbox');
if (d != undefined) {
const d = top.document.getElementById('persmenu');
const d2 = top.document.getElementById('upbox');
if (d) {
if (id > 0 && id < 5) {
d.className = `topusermenu inviseMen${id}`;
T_mn = setTimeout(`top.infoMenuClose(${(id + 1)})`, 30);
} else if (id == 5) {
var s = d.style;
} else if (id === 5) {
const s = d.style;
s.display = 'none';
d2.style.display = 'none';
d.innerHTML = '';
@ -425,29 +418,29 @@ function infoMenuClose(id) {
function infoMenuMy(u, e, f, dtm) {
if (!e) e = window.event;
var d = top.document.getElementById('persmenu');
var d2 = top.document.getElementById('upbox');
if (d != undefined) {
var dptop = -5;
var dpleft = -5;
var dp = top;
var s = d.style;
const d = top.document.getElementById('persmenu');
const d2 = top.document.getElementById('upbox');
if (d) {
const dptop = -5;
const dpleft = -5;
const dp = top;
const s = d.style;
d2.style.display = '';
d.className = 'topusermenu';
s.display = '';
var obtop = mousePageXY(e)['y'] + dptop;
if (getNameBrouser() == 'msie') {
let obtop = mousePageXY(e)['y'] + dptop;
if (getNameBrouser() === 'msie') {
obtop -= dp.document.body.scrollTop;
} else {
obtop -= dp.document.documentElement.scrollTop + dp.document.body.scrollTop;
}
var obleft = mousePageXY(e)['x'] + dpleft;
let obleft = mousePageXY(e)['x'] + dpleft;
d.style.top = `${obtop}px`;
d.style.left = `${obleft}px`;
var hmmmt = '<DIV onmouseover="top.doTest = false;" onmouseout="top.doTest = true; top.MBcMenu();">';
var i = 0;
while (i != -1) {
if (dtm[i] != undefined) {
let hmmmt = '<DIV onmouseover="top.doTest = false;" onmouseout="top.doTest = true; top.MBcMenu();">';
let i = 0;
while (i !== -1) {
if (dtm[i] !== undefined && dtm[i] !== null) {
hmmmt += `<div onClick="${dtm[i][0]} infoMenuClose(4);" class="topusermenuBtn">${dtm[i][1]}</div>`;
i++;
} else i = -1;
@ -455,12 +448,12 @@ function infoMenuMy(u, e, f, dtm) {
hmmmt = `${hmmmt}</DIV>`;
d.innerHTML = hmmmt;
var bdx = document.body.clientWidth;
var bdy = document.body.clientHeight;
var obx = d.clientWidth;
var oby = d.clientHeight;
var ots = bdy - obtop - oby;
var ols = bdx - obleft - obx;
const bdx = document.body.clientWidth;
const bdy = document.body.clientHeight;
const obx = d.clientWidth;
const oby = d.clientHeight;
const ots = bdy - obtop - oby;
const ols = bdx - obleft - obx;
if (ots < 10) {
obtop = bdy - 10 - oby;
d.style.top = `${obtop}px`;
@ -469,12 +462,6 @@ function infoMenuMy(u, e, f, dtm) {
obleft = bdx - 10 - obx;
d.style.left = `${obleft}px`;
}
$("#d_clip_button").zclip({
path: "js/ZeroClipboard.swf",
copy: function () {
return u;
}
});
}
}
@ -631,9 +618,9 @@ var win = {
delete nw;
},
addaction: function (nm, vl) {
top.key_actions[nm] = vl;
key_actions[nm] = vl;
if (nm != 2) {
top.key_actions[2] = 1;
key_actions[2] = 1;
}
},
closew: function (id) {

File diff suppressed because it is too large Load Diff

BIN
tab.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 313 B