Оптимизация вёрстки, удаление дублирующегося функционала.

This commit is contained in:
Igor Barkov (iwork) 2020-07-21 18:57:15 +03:00
parent 12feda506a
commit 7b17c51bb8
2 changed files with 145 additions and 303 deletions

View File

@ -73,6 +73,7 @@ class User
private function UserInfoDoll($isBattle = 0, $isMain = 0)
{
//https://jsfiddle.net/ngx0yvhc
//TODO переверстать grid, чтобы он касался только куклы.
$di = new DressedItems($this->id);
$dressedItems = $di->getItemsInSlots();
for ($i = 1; $i <= 12; $i++) {

447
main.php
View File

@ -25,7 +25,7 @@ if (!empty($user['battle'])) {
}
//БС
if ( isset($user['in_tower']) && $user['in_tower'] == 1) {
if (isset($user['in_tower']) && $user['in_tower'] == 1) {
header('Location: towerin.php');
die();
}
@ -677,141 +677,121 @@ if (isset($_GET['edit'])) {
}
}
if (!in_array(input::get('mZeAjax'), ['mZeInventory', 'mZeFilter'])): ?>
<!doctype html>
<HTML lang="ru">
<HEAD>
<meta charset="utf-8">
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="css/tooltip.css"/>
<script src="js/jquery.plugins.js"></script>
<script src="js/jquery-1.7.2.min.js"></script>
<script src="js/jquery.simplemodal.js"></script>
<script src="js/jquery.ui.js?100"></script>
<script src="js/tooltip.js"></script>
<script type="text/javascript" src="js/funcs.js"></script>
<script>
$(function () {
$(".tooltip").tipTip({maxWidth: "auto", edgeOffset: 0, fadeIn: 300, fadeOut: 500});
});
}
function saveComplect() {
new miDialog({title: 'Сохранить комплект'}, {edit: 1}, function () {
document.location = '/main.php?' + $.param(this.data);
},
$('<div>Название комплекта :<br /><div style="font-size: smaller;"><b>может содеражать только буквы (англ / русс) и цифры.</b></div></div>').append(miDialog._oneInput({name: 'savecomplect'})), {width: 250});
}
?>
let Hint3Name = '';
<!doctype html>
<HTML lang="ru">
<HEAD>
<meta charset="utf-8">
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="css/tooltip.css">
<link rel="stylesheet" href="css/btn.css">
<script src="js/jquery.plugins.js"></script>
<script src="js/jquery-1.7.2.min.js"></script>
<script src="js/jquery.simplemodal.js"></script>
<script src="js/jquery.ui.js?100"></script>
<script src="js/tooltip.js"></script>
<script src="js/funcs.js"></script>
<script>
$(function () {
$(".tooltip").tipTip({maxWidth: "auto", edgeOffset: 0, fadeIn: 300, fadeOut: 500});
});
function okno(title, script, name, coma, errk) {
let errkom = '';
let com = '';
if (errk === 1) {
errkom = 'Нельзя использовать символы: /\:*?"<>|+%<br>';
com = coma
function gotohref(filename) {
location.href = filename;
}
function saveComplect() {
new miDialog({title: 'Сохранить комплект'}, {edit: 1}, function () {
document.location = '/main.php?' + $.param(this.data);
},
$('<div>Название комплекта :<br /><div style="font-size: smaller;"><b>может содеражать только буквы (англ / русс) и цифры.</b></div></div>').append(miDialog._oneInput({name: 'savecomplect'})), {width: 250});
}
let Hint3Name = '';
function okno(title, script, name, coma, errk) {
let errkom = '';
let com = '';
if (errk === 1) {
errkom = 'Нельзя использовать символы: /\:*?"<>|+%<br>';
com = coma
}
if (errk === 2) {
errkom = 'Такой комплект уже существует<br>';
com = coma
}
document.getElementById("hint3").innerHTML = '<table width=100% cellspacing=1 cellpadding=0 bgcolor=CCC3AA><tr><td align=center><B>' + title + '</td><td width=20 align=right valign=top style="cursor: pointer" onclick="closehint3();"><BIG><B>x</td></tr><tr><td colspan=2>' +
'<form action="' + script + '" method=POST><table width=100% cellspacing=0 cellpadding=2 bgcolor=FFF6DD><tr><INPUT TYPE=hidden name=sd4 value="6"><td colspan=2><span class="error">' +
errkom + '</span>введите название предмета</TD></TR><TR><TD width=50% align=right><INPUT TYPE=text NAME="' + name + '" value="' + com + '"></TD><TD width=50%><INPUT TYPE="submit" value=" »» "></TD></TR></TABLE></FORM></td></tr></table>';
document.getElementById("hint3").style.visibility = "visible";
document.getElementById("hint3").style.left = '100';
document.getElementById("hint3").style.top = '100';
document.getElementById(name).focus();
Hint3Name = name;
}
const delay = 30;
let TimerOn = -1, tkHP, maxHP, speed = 750;
const stLen = 185, redHP = 0.33, yellowHP = 0.66;
function setHPlocal() {
tkHP > maxHP && (tkHP = maxHP);
let a = Math.round(tkHP) + "/" + maxHP;
a = stLen - (a.length + 2) * 7;
const b = Math.round((a - 1) / maxHP * tkHP);
a -= b;
const HP = document.getElementById("hp_value");
const HP1 = document.getElementById("HP1");
const HP2 = document.getElementById("HP2");
if (HP) {
HP1.width = b, HP2.width = a, HP1.src = tkHP / maxHP < redHP ? "i/1red.gif" : tkHP / maxHP < yellowHP ? "i/1yellow.gif" : "i/1green.gif", HP.innerHTML = Math.round(tkHP) + "/" + maxHP;
}
tkHP += maxHP / 53 / 230 * (speed / 100);
TimerOn = tkHP < maxHP ? setTimeout("setHPlocal()", delay * 100) : -1
}
$(document).ready(function () {
$('a').live('click', function () {
if ($(this).attr('ajax') !== undefined) {
const ajaxModule = $(this).attr('ajax');
switch (ajaxModule) {
case'mZeInventory':
$('#mZeInventory').html('<div align="center" style="padding:10px;background-color:#d4d2d2;color:grey;"><b>Загрузка...</b></div>');
$.ajax({
url: $(this).attr('href') + '&mZeAjax=' + ajaxModule,
cache: false,
dataType: 'html',
success: function (html) {
$('#mZeInventory').html(html);
}
});
break;
}
if (errk === 2) {
errkom = 'Такой комплект уже существует<br>';
com = coma
}
document.getElementById("hint3").innerHTML = '<table width=100% cellspacing=1 cellpadding=0 bgcolor=CCC3AA><tr><td align=center><B>' + title + '</td><td width=20 align=right valign=top style="cursor: pointer" onclick="closehint3();"><BIG><B>x</td></tr><tr><td colspan=2>' +
'<form action="' + script + '" method=POST><table width=100% cellspacing=0 cellpadding=2 bgcolor=FFF6DD><tr><INPUT TYPE=hidden name=sd4 value="6"><td colspan=2><span class="error">' +
errkom + '</span>введите название предмета</TD></TR><TR><TD width=50% align=right><INPUT TYPE=text NAME="' + name + '" value="' + com + '"></TD><TD width=50%><INPUT TYPE="submit" value=" »» "></TD></TR></TABLE></FORM></td></tr></table>';
document.getElementById("hint3").style.visibility = "visible";
document.getElementById("hint3").style.left = '100';
document.getElementById("hint3").style.top = '100';
document.getElementById(name).focus();
Hint3Name = name;
return false;
}
const delay = 30;
let TimerOn = -1, tkHP, maxHP, speed = 750;
const stLen = 185, redHP = 0.33, yellowHP = 0.66;
function setHPlocal() {
tkHP > maxHP && (tkHP = maxHP);
let a = Math.round(tkHP) + "/" + maxHP;
a = stLen - (a.length + 2) * 7;
const b = Math.round((a - 1) / maxHP * tkHP);
a -= b;
const HP = document.getElementById("hp_value");
const HP1 = document.getElementById("HP1");
const HP2 = document.getElementById("HP2");
if (HP) {
HP1.width = b, HP2.width = a, HP1.src = tkHP / maxHP < redHP ? "i/1red.gif" : tkHP / maxHP < yellowHP ? "i/1yellow.gif" : "i/1green.gif", HP.innerHTML = Math.round(tkHP) + "/" + maxHP;
}
tkHP += maxHP / 53 / 230 * (speed / 100);
TimerOn = tkHP < maxHP ? setTimeout("setHPlocal()", delay * 100) : -1
}
<?= topsethp(); ?>
$(document).ready(function () {
$('a').live('click', function () {
if ($(this).attr('ajax') !== undefined) {
const ajaxModule = $(this).attr('ajax');
switch (ajaxModule) {
case'mZeInventory':
$('#mZeInventory').html('<div align="center" style="padding:10px;background-color:#d4d2d2;color:grey;"><b>Загрузка...</b></div>');
$.ajax({
url: $(this).attr('href') + '&mZeAjax=' + ajaxModule,
cache: false,
dataType: 'html',
success: function (html) {
$('#mZeInventory').html(html);
}
});
break;
}
return false;
}
});
});
</script>
<style>
.jGrowl .jGrowl-notification, .jGrowl .jGrowl-closer {
border: 2px groove threedface;
background: #E6E6E6 !important;
}
.jGrowl .jGrowl-notification, .jGrowl div.jGrowl-closer {
margin: 10px;
}
.jGrowl div.jGrowl-notification {
min-height: 40px;
}
.jGrowl .jGrowl-notification, .jGrowl .jGrowl-closer {
background-color: #000;
opacity: .85;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=85)";
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=85);
zoom: 1;
width: 235px;
padding: 10px;
margin-top: 5px;
margin-bottom: 5px;
font-family: Tahoma, Arial, Helvetica, sans-serif;
font-size: 1em;
text-align: left;
display: none;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
}
</style>
<title></title>
</HEAD>
<body>
<div id=hint3 class=ahint></div>
<div id="hint4" style="position: absolute;"></div>
<div id="chpassbank" style="display:none; position:absolute; top:50px; left:250px;"></div>
<FORM METHOD=POST ACTION="main.php?edit=1">
<table width=100%>
<TR>
<td style="vertical-align: top; width: 250px">
});
});
</script>
<title>Окно игры</title>
</HEAD>
<body>
<?php
try {
$online = db::c()->query('SELECT 1 FROM `online` WHERE `real_time` >= ?i', (time() - 60));
} catch (Exception $e) {
echo '<div class="debug">В таблице online нет ячейки real_time так как неясно что она делает. Ошибка обращения в базу.</div>';
}
?>
<div id=hint3 class=ahint></div>
<div id="hint4" style="position: absolute;"></div>
<div id="chpassbank" style="display:none; position:absolute; top:50px; left:250px;"></div>
<table width=100%>
<TR>
<td style="vertical-align: top; width: 350px">
<?php
$showUser = new User($_SESSION['uid']);
$getItemsBonuses = new DressedItems($_SESSION['uid']);
@ -846,7 +826,7 @@ if (isset($_GET['edit'])) {
</div>
<br>
</td>
<TD style="vertical-align: top; width: 207px"> <!-- Второй столбец -->
<td style="vertical-align: top; width: 250px"> <!-- Второй столбец -->
<div>
<br>Уровень: <strong><?= $showUser->level ?></strong>
<br>Опыт: <strong><?= $showUser->experience ?></strong>
@ -862,8 +842,10 @@ if (isset($_GET['edit'])) {
Сила: <?= $showUser->getStrength(1) ?> +<?= $getItemsBonuses->getStrengthBonus() ?><br>
Ловкость: <?= $showUser->getDexterity(1) ?> +<?= $getItemsBonuses->getDexterityBonus() ?><br>
Интуиция: <?= $showUser->getIntuition(1) ?> +<?= $getItemsBonuses->getIntuitionBonus() ?><br>
Выносливость: <?= $showUser->getEndurance(1) ?> +<?= $getItemsBonuses->getEnduranceBonus() ?><br>
Интеллект: <?= $showUser->getIntelligence(1) ?> +<?= $getItemsBonuses->getIntelliganceBonus() ?><br>
Выносливость: <?= $showUser->getEndurance(1) ?> +<?= $getItemsBonuses->getEnduranceBonus() ?>
<br>
Интеллект: <?= $showUser->getIntelligence(1) ?> +<?= $getItemsBonuses->getIntelliganceBonus() ?>
<br>
Мудрость: <?= $showUser->getWisdom(1) ?> +<?= $getItemsBonuses->getWisdomBonus() ?><br>
<small style="color: darkgreen;">Возможных увеличений: <?= $showUser->stat_points ?></small><br>
<br>
@ -886,42 +868,31 @@ if (isset($_GET['edit'])) {
</div>
</div>
</TD>
<!--Меню-->
<TD valign=top>
<link rel="stylesheet" href="css/btn.css" type="text/css">
<div align=right class="btn-control inventory">
<FORM METHOD=POST ACTION="?edit=1" name=f1>
<?php if ($user['shadow'] == '0.gif' || $user['admin'] == 1): ?>
<INPUT class="button-mid btn" TYPE="submit" name="setshadow" value="Образы" title="Образы">
<?php endif; ?>
<INPUT class="button-mid btn" TYPE=button name=combats value="Поединки"
onClick="location.href='zayavka.php';" style="font-weight:bold;">
<INPUT class="button-mid btn" TYPE=button name=combats value="Состояние"
onClick="location.href='module_quest.php';" style="font-weight:bold;">
<INPUT class="button-mid btn" TYPE="button" onClick="location.href='main.php';" value="Вернуться"
title="Вернуться">
</div>
<div id="jGrowl" class="top-right jGrowl">
<div class="jGrowl-notification"></div>
</div>
<div id="mZeInventory">
<?php endif ?>
<table class="allzeroes" style="background-color: #a5a5a5;">
<tr>
<td align=center>
<B>Рюкзак (масса: <?= $getItemsBonuses->getItemsWeight() . '/' . $showUser->strength * 4 ?>)</B>
<tr>
<td style="text-align: center">
</td>
<td valign=top>
<div align=right class="btn-control inventory"> <!--Меню-кнопки-->
<FORM METHOD=POST ACTION="?edit=1" name=f1>
<?php if ($user['shadow'] == '0.gif' || $user['admin'] == 1): ?>
<INPUT class="button-mid btn" TYPE="submit" name="setshadow" value="Образы" title="Образы">
<?php endif; ?>
<button class="button-mid btn" onclick="gotohref('zayavka.php')">Поединки</button>
<button class="button-mid btn" onclick="gotohref('module_quest.php')">Активные задания</button>
<button class="button-mid btn" onclick="gotohref('main.php?edit=1')">Инвентарь</button>
<?php if ($user['room'] === 20): ?>
<button class="button-mid btn" onclick="gotohref('main.php?goto=arena')">Войти внутрь
</button>
<?php else: ?>
<button class="button-mid btn" onclick="gotohref('main.php?goto=plo')">Выйти на улицу
</button>
<?php endif; ?>
<button class="button-mid btn" onclick="gotohref('main.php')">Обновить страницу</button>
</div>
<div id="mZeInventory"> <!--рюкзак-->
<table BORDER=0 WIDTH=100% CELLSPACING="1" CELLPADDING="2" BGCOLOR="#A5A5A5">
<?php if ($showUser->money): ?>
<tr style="background-color: #c7c7c7">
<td style="text-align: center; width: 100px;"><img src="i/sh/money-bag.png">
<td valign="top">Мешок денег (Масса: 0)<br><b><?= $user['money'] ?> кр.</b>
<?php endif;
<caption>Рюкзак
(масса: <?= $getItemsBonuses->getItemsWeight() . '/' . $showUser->strength * 4 ?>)
</caption>
<?php
$data_query = 'SELECT * FROM inventory WHERE owner_id = ?i AND dressed_slot = 0 AND on_sale = 0';
$data = db::c()->query($data_query, $_SESSION['uid']);
@ -930,9 +901,8 @@ if (isset($_GET['edit'])) {
$getItems = [];
$row = [];
$iteminfo = [];
#while ($row = $data->fetch_assoc()) showitem($row, null, "edit=1&razdel=$_SESSION[razdel]");
#while ($row = $data->fetch_assoc()) showitem($row);
while ($row = $data->fetch_assoc()) {
//FIXME Какая-то хуета. Зачем я каждый прежмет делал новым классом?
$iteminfo[] = new InventoryItem($row);
}
@ -959,138 +929,9 @@ if (isset($_GET['edit'])) {
}
?>
</table>
</table>
<?php if (!in_array(input::get('mZeAjax'), ['mZeInventory', 'mZeFilter'])): ?>
</div>
</td>
</form>
</tr>
</table>
</body>
</html>
<?php
endif;
die();
}
?>
<HTML lang="ru">
<HEAD>
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="css/btn.css">
<meta charset="utf-8">
<link rel="stylesheet" href="css/tooltip.css">
<script src="js/jquery-1.7.2.min.js"></script>
<script src="js/tooltip.js"></script>
<script>
$(function () {
$(".tooltip").tipTip({maxWidth: "auto", edgeOffset: 0, fadeIn: 300, fadeOut: 500});
});
</script>
<script>
let Hint3Name = '';
// Заголовок, название скрипта, имя поля с логином
function findlogin(title, script, name) {
document.getElementById("hint3").innerHTML = '<table width=100% cellspacing=1 cellpadding=0 bgcolor=CCC3AA><tr><td align=center><B>' + title + '</td><td width=20 align=right valign=top style="cursor: pointer" onclick="closehint3();"><BIG><B>x</td></tr><tr><td colspan=2>' +
'<form action="' + script + '" method=POST><table width=100% cellspacing=0 cellpadding=2 bgcolor=FFF6DD><tr><INPUT TYPE=hidden name=sd4 value="6"><td colspan=2>' +
'Укажите логин персонажа:<small><BR>(можно щелкнуть по логину в чате)</TD></TR><TR><TD width=50% align=right><INPUT TYPE=text NAME="' + name + '"></TD><TD width=50%><INPUT TYPE="submit" value=" »» "></TD></TR></TABLE></FORM></td></tr></table>';
document.getElementById("hint3").style.visibility = "visible";
document.getElementById("hint3").style.left = '100';
document.getElementById("hint3").style.top = '100';
document.getElementById(name).focus();
Hint3Name = name;
}
// Заголовок, название скрипта, имя поля с шмоткой
function okno(title, script, name) {
const errkom = '';
document.getElementById("hint3").innerHTML = '<table width=100% cellspacing=1 cellpadding=0 bgcolor=CCC3AA><tr><td align=center><B>' + title + '</td><td width=20 align=right valign=top style="cursor: pointer" onclick="closehint3();"><BIG><B>x</td></tr><tr><td colspan=2>' +
'<form action="' + script + '" method=POST><table width=100% cellspacing=0 cellpadding=2 bgcolor=FFF6DD><tr><INPUT TYPE=hidden name=sd4 value="6"><td colspan=2><span class="error">' +
errkom + '</span>введите название предмета</TD></TR><TR><TD width=50% align=right><INPUT TYPE=text NAME="' + name + '"></TD><TD width=50%><INPUT TYPE="submit" value=" »» "></TD></TR></TABLE></FORM></td></tr></table>';
document.getElementById("hint3").style.visibility = "visible";
document.getElementById("hint3").style.left = '100';
document.getElementById("hint3").style.top = '100';
document.getElementById(name).focus();
Hint3Name = name;
}
function closehint3() {
document.getElementById("hint3").style.visibility = "hidden";
Hint3Name = '';
}
const delay = 30;
let TimerOn = -1, tkHP, maxHP, speed = 750;
const stLen = 185, redHP = 0.33, yellowHP = 0.66;
function setHP(a, b, c) {
tkHP = a;
maxHP = b;
TimerOn >= 0 && (clearTimeout(TimerOn), TimerOn = -1);
speed = c;
setHPlocal()
}
function setHPlocal() {
tkHP > maxHP && (tkHP = maxHP);
let a = Math.round(tkHP) + "/" + maxHP;
a = stLen - (a.length + 2) * 7;
const b = Math.round((a - 1) / maxHP * tkHP);
a -= b;
const HP = document.getElementById("hp_value");
const HP1 = document.getElementById("HP1");
const HP2 = document.getElementById("HP2");
if (HP) {
HP1.width = b, HP2.width = a, HP1.src = tkHP / maxHP < redHP ? "i/1red.gif" : tkHP / maxHP < yellowHP ? "i/1yellow.gif" : "i/1green.gif", HP.innerHTML = Math.round(tkHP) + "/" + maxHP;
}
tkHP += maxHP / 53 / 230 * (speed / 100);
TimerOn = tkHP < maxHP ? setTimeout("setHPlocal()", delay * 100) : -1
}
</script>
<title></title>
</HEAD>
<body onLoad="<?= topsethp(); ?>">
<?php
try {
$online = db::c()->query('SELECT 1 FROM `online` WHERE `real_time` >= ?i', (time() - 60));
} catch (Exception $e) {
echo '<div class="debug">В таблице online нет ячейки real_time так как неясно что она делает. Ошибка обращения в базу.</div>';
}
?>
<div id=hint3 class=ahint></div>
<table class="allzeroes">
<tr>
<td style="width:250px;">
<?php
$userInfo = new User($_SESSION['uid']);
$userInfo->showUserInfoMain();
?>
</td>
<td>&nbsp;</td>
<TD style="text-align: right;">
<div class="hint-text">Сейчас в игре: <strong><?= 'неизвестно' /*$online->getNumRows()*/ ?></strong> чел.
</div>
<button onclick="gotohref('zayavka.php')">Поединки</button>
<br>
<button onclick="gotohref('main.php?edit=1')">Инвентарь</button>
<br>
<button onclick="gotohref('module_quest.php')">Активные задания</button>
<br>
<?php if ($user['room'] === 20): ?>
<button onclick="gotohref('main.php?goto=arena')">Войти внутрь</button><br>
<?php else: ?>
<button onclick="gotohref('main.php?goto=plo')">Выйти на улицу</button><br>
<?php endif; ?>
<button onclick="gotohref('main.php')">Обновить страницу</button>
</TD>
</td>
</tr>
</table>
<script>
function gotohref(filename) {
location.href = filename;
}
</script>
</BODY>
</HTML>
</body>
</html>