first draft html file works. todo: optimize speed

This commit is contained in:
color.diff=auto 2021-05-06 04:12:03 -06:00
parent 5c6a657820
commit 10a2db46ad
3 changed files with 17560 additions and 69380 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,5 @@
<?php
error_reporting(E_ERROR | E_PARSE);
set_time_limit(-1);
ini_set('max_input_time', '-1');
@ -69,175 +70,179 @@ if ($cmd == "genDocUniqueItems") {
// grab unique item index only (to save on memory)
$sql = "SELECT `index` FROM `uniqueitems` WHERE `enabled`='1'";
$uIndex = PDO_FetchAll($sql);
//ddump($uIndex);
// $htmltop = <<<EOT
//<!doctype html>
//<html lang="en">
//<head>
// <!-- Required meta tags -->
// <meta charset="utf-8">
// <meta name="viewport" content="width=device-width, initial-scale=1">
// <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
//
// <!-- Bootstrap CSS -->
// <link rel="stylesheet" href="res/bootstrap.min.css">
// <link rel="stylesheet" href="res/font-awesome.min.css">
// <link rel="preconnect" href="https://fonts.gstatic.com">
// <link href="https://fonts.googleapis.com/css2?family=Lato:wght@300&display=swap" rel="stylesheet">
// <link rel="stylesheet" href="https://bootswatch.com/4/sketchy/bootstrap.min.css">
// <link rel="stylesheet" href="res/style.css">
// <style>
//
// .item_desc {
// height: 600px;
// width: 620px;
// position: relative;
// left: 0;
// top: 0;
//
// /* background: black url(/img/items/bg.png) center top no-repeat;*/
//
// text-align: center;
// padding: 10px;
// text-transform: uppercase;
//
// }
// .green {
// color: #00FF00; /*Set items*/
// }
// .gold{
// color: #A59263; /*Set items*/
// }
// .orange{
// color: #FFA500; /*Set items*/
// }
// .yellow {
// color: #FFFF00; /*Set items*/
// }
//
// .blue {
// color: #4169E1;
// }
//
// </style>
// <script src="res/jquery-3.6.0.min.js"></script>
// <script src="res/bootstrap.bundle.min.js"></script>
// <script src="res/app.js"></script>
//
//</script>
//<title>D2Modder</title>
//</head>
//
//<body>
// <div class="container container-top">
//<h1>{$_SESSION['modname']} Unique Items</h1>
//<p>Auto generated with D2Modder by Hash Casper</p>
//
//EOT;
//
// $htmlbottom = <<<EOT
// </div>
//</body>
//</html>
//EOT;
$htmltop = <<<EOT
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
// $htmlFinal = $htmltop;
//
// //echo $htmltop;
//
// $dir = getcwd()."/docs/{$_SESSION['modname']}";
//
// mkdir($dir, 0777, true);
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="res/bootstrap.min.css">
<link rel="stylesheet" href="res/font-awesome.min.css">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Lato:wght@300&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://bootswatch.com/4/sketchy/bootstrap.min.css">
<link rel="stylesheet" href="res/style.css">
<style>
.item_desc {
height: 600px;
width: 620px;
position: relative;
left: 0;
top: 0;
// for each unique item index, now grab the whole row
/* background: black url(/img/items/bg.png) center top no-repeat;*/
text-align: center;
padding: 10px;
text-transform: uppercase;
}
.green {
color: #00FF00; /*Set items*/
}
.gold{
color: #A59263; /*Set items*/
}
.orange{
color: #FFA500; /*Set items*/
}
.yellow {
color: #FFFF00; /*Set items*/
}
.blue {
color: #4169E1;
}
</style>
<script src="res/jquery-3.6.0.min.js"></script>
<script src="res/bootstrap.bundle.min.js"></script>
<script src="res/app.js"></script>
</script>
<title>D2Modder</title>
</head>
<body>
<div class="container container-top">
<h1>{$_SESSION['modname']} Unique Items</h1>
<p>Auto generated with D2Modder by Hash Casper</p>
EOT;
$htmlbottom = <<<EOT
</div>
</body>
</html>
EOT;
$htmlFinal = '';
$htmlFinal .= $htmltop;
echo $htmltop;
ob_flush();
$dir = getcwd() . "/docs/{$_SESSION['modname']}";
mkdir($dir, 0777, true);
/*
START MAIN LOOP HERE
*
* For each unique item index, now grab item data
*
*/
foreach ($uIndex as $u) {
//$items[] = $idata->uniqueItems($u['index'], true);
//var_dump($u['index']);
$item = $idata->uniqueItems($u['index'], true);
//
//
//
echo ($item['index']) . "\n";
ob_flush();
//
// //index
// $props = "<li class='gold'>{$item['index']}</li>";
//
// //type
// $props .= "<li class='gold'>{$item["*type"]}</li>";
//
// //level
// $props .= "<li style='color: white;' class=''>Level: {$item["lvl"]}</li>";
//
// //lvlreq
// $props .= "<li style='color: white;' class=''>Level Required: {$item["lvl req"]}</li>";
//
// //code
// $props .= "<li style='color: #aaa;' class=''>Item Code: {$item["code"]}</li>";
//
// //reqstr
// if ($item["reqstr"]) {
// $props .= "<li style='color: white;' class=''>{$item["reqstr"]}</li>";
// }
// //reqdex
// if ($item["reqdex"]) {
// $props .= "<li style='color: white;' class=''>{$item["reqdex"]}</li>";
// }
// //sock
// if ($item["gemsockets"] && $item["gemsockets"] > 6) {
// $item["gemsockets"] = 6;
// $props .= "<li style='color: white;' class=''>{$item["gemsockets"]}</li>";
// }
//
//
// foreach ($item['props'] as $prop) {
// if ($prop['string'][0]) {
// $props .= "<li class='blue'>{$prop['string'][0]}</li>";
// }
// }
//
// $itemBoxTop = <<<EOT
//<div class="center item_desc" style="">
//
// <div style="height: 116px;background: url(img/items/bg.png) center top no-repeat;">
// <a href="" target="_blank" class="item_debug_link">
// <img style="" class="item img-fluid" src="img/items/{$item["invfile"]}.png">
// </a>
//
// </div>
// <div class="item_stats" style="">
// <div class="">
// <p>
//EOT;
//
// $itemBoxBottom = <<<EOT
// </p>
// </div>
// </div>
//</div>
//
//EOT;
// $itemFull .= $itemBoxTop . $props . $itemBoxBottom;
//// echo $itemFull;
//// ob_flush();
//
// $htmlFinal .= $itemFull;
$itemBoxTop = <<<EOT
<div class="center item_desc" style="">
<div style="height: 116px;background: url(img/items/bg.png) center top no-repeat;">
<a href="" target="_blank" class="item_debug_link">
<img style="" class="item img-fluid" src="img/items/{$item["invfile"]}.png">
</a>
</div>
<div class="item_stats" style="">
<div class="">
<p>
EOT;
$itemBoxBottom = <<<EOT
</p>
</div>
</div>
</div>
}// end loop
// $htmlFinal .= $htmlbottom;
EOT;
echo $itemBoxTop;
ob_flush();
$htmlFinal .= $itemBoxTop;
//index
$props = "<ul><li class='gold'>{$item['index']}</li>";
//file_put_contents("$dir/uniqueitems.html", $htmlFinal);
//header("Location: /docs/{$_SESSION['modname']}/uniqueitems.html");
//type
$props .= "<li class='gold'>{$item["*type"]}</li>";
//level
$props .= "<li style='color: white;' class=''>Level: {$item["lvl"]}</li>";
//lvlreq
$props .= "<li style='color: white;' class=''>Level Required: {$item["lvl req"]}</li>";
//code
$props .= "<li style='color: #aaa;' class=''>Item Code: {$item["code"]}</li>";
//reqstr
if ($item["reqstr"]) {
$props .= "<li style='color: white;' class=''>{$item["reqstr"]}</li>";
}
//reqdex
if ($item["reqdex"]) {
$props .= "<li style='color: white;' class=''>{$item["reqdex"]}</li>";
}
//sock
if ($item["gemsockets"] > 6) {
$item["gemsockets"] = 6;
$props .= "<li style='color: white;' class=''>{$item["gemsockets"]}</li>";
}
foreach ($item['props'] as $prop) {
if ($prop['string'][0]) {
$props .= "<li class='blue'>{$prop['string'][0]}</li>";
}
}
$props .= "</ul>";
// $itemFull .= $itemBoxTop . $props . $itemBoxBottom;
// echo $itemFull;
echo $props;
echo $itemBoxBottom;
ob_flush();
$htmlFinal .= $props.$itemBoxBottom;
}// end loop
echo $htmlbottom;
$htmlFinal .= $htmlbottom;
file_put_contents("$dir/uniqueitems.html", $htmlFinal);
header("Location: /docs/{$_SESSION['modname']}/uniqueitems.html");
}

View File

@ -41,22 +41,22 @@
*/
function syntaxHighlight(json) {
json = json.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {
var cls = 'number';
if (/^"/.test(match)) {
if (/:$/.test(match)) {
cls = 'key';
} else {
cls = 'string';
}
} else if (/true|false/.test(match)) {
cls = 'boolean';
} else if (/null/.test(match)) {
cls = 'null';
}
return '<span class="' + cls + '">' + match + '</span>';
});
json = json.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {
var cls = 'number';
if (/^"/.test(match)) {
if (/:$/.test(match)) {
cls = 'key';
} else {
cls = 'string';
}
} else if (/true|false/.test(match)) {
cls = 'boolean';
} else if (/null/.test(match)) {
cls = 'null';
}
return '<span class="' + cls + '">' + match + '</span>';
});
}
@ -67,7 +67,7 @@ function search() {
}
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
return string.charAt(0).toUpperCase() + string.slice(1);
}
$(document).ready(function () {
@ -172,41 +172,41 @@ $(document).ready(function () {
// every time we change a prop dropdown,
//
// 1 send to server,
// 2 grab string,
// 3 update item display
$('select[name^="prop"]').change(function(){
$('select[name^="prop"]').change(function () {
prop = capitalizeFirstLetter($(this).attr("name"));
val = escape(this.value);
$.get("/ajax/uniqueitems.php?cmd=getString&prop=" + val, function (data) {
console.log(data)
$("."+prop).html(data.string1);
$("." + prop).html(data.string1);
});
});
// cmd = getUniqueItem
$('.uniqueitems-select').change(function () {
$(".item").attr("src", "/img/items/1.png");
$(".item_debug_link").attr('href', "/ajax/uniqueitems.php?cmd=getUniqueItem&index=" + this.value)
$.get("/ajax/uniqueitems.php?cmd=getUniqueItem&index=" + this.value, function (data) {
debugData = (JSON.stringify(data, null, 4));
$('.debug, .debug_preview').html(syntaxHighlight(debugData));
props = data.props;
// update preview
$('.item_stats div').hide().html("<p></p>");
invImg = "/img/items/" + data.invfile + ".png";
$(".item").hide().attr("src", invImg).fadeIn(500);
// update preview
$('.item_stats div').hide().html("<p></p>");
invImg = "/img/items/" + data.invfile + ".png";
$(".item").hide().attr("src", invImg);
type = data["*type"];
lvlreq = data["lvl req"];
base = data.baseItemInfo;
@ -214,29 +214,32 @@ $(document).ready(function () {
$('.item_stats p').append(`<li class="stattype">${type}</li>`);
$('.item_stats p').append(`<li class="statlvlreq">Level: ${base.level}</li>`);
$('.item_stats p').append(`<li class="statlvlreq">Level Required: ${lvlreq}</li>`);
$('.item_stats p').append(`<li class="code" style="color:grey;">Item Code: ${base.code}</li>`);
if(base.reqstr){
if (base.reqstr) {
$('.item_stats p').append(`<li class="statlvlreq">Requires Strength: ${base.reqstr}</li>`);
}
if(base.reqdex){
}
if (base.reqdex) {
$('.item_stats p').append(`<li class="statlvlreq">Required Dexterity: ${base.reqdex}</li>`);
}
if(base['gemsockets'] && base['gemsockets'] > 6){
base['gemsockets'] = 6;
if (base['gemsockets']) {
if (base['gemsockets'] > 6) {
base['gemsockets'] = 6;
}
$('.item_stats p').append(`<li class="statlvlreq">Maximum Sockets: <span color="#aaa">(${base.gemsockets})</span></li>`);
}
$.each(props, function (i, v) {
if(v.string){
$('.item_stats p').append('<li class="'+i+'">'+v.string[0]+"</li>");
}
$.each(props, function (i, v) {
if (v.string) {
$('.item_stats p').append('<li class="' + i + '">' + v.string[0] + "</li>");
}
});
$('.item_stats div').fadeIn(500);
$('.item_stats div').show();
$.each(data, function (i, v) {
$('*[name="' + i.replace(/\s/g, '') + '"]').val(v);
@ -244,11 +247,11 @@ $(document).ready(function () {
$('select[name="code[]"]').val(v);
$('select[name="code[]"]').prop('required', '');
}
});
});
});
});
$(".btnDebug").click(function(){
$(".btnDebug").click(function () {
$(".debug_preview").slideToggle();
});
@ -287,13 +290,13 @@ $(document).ready(function () {
});
//genDocUniqueItems
$("#Unique .btnDocs").click(function (){
window.open('/genDocs.php?cmd=genDocUniqueItems', '_blank');
$("#Unique .btnDocs").click(function () {
window.open('/genDocs.php?cmd=genDocUniqueItems', '_blank');
});