Set active tab to Uniqueitems. header.php, set uniqueitems to first tab active.

ajax/uniqueitems.php, add save/delete functionality
app.js, handle save/delete calls
src/tabs/optionsubmit.php, add delete button
tabs/UniqueItems.php remove form action

Ajax save, and delete working.
This commit is contained in:
Hash Borgir 2023-05-30 13:12:19 -06:00
parent 961a061662
commit 1f7ac14963
5 changed files with 631 additions and 540 deletions

View File

@ -48,150 +48,197 @@ $idesc = new D2ItemDesc();
*/
if (!empty($_GET['cmd']))
$cmd = $_GET['cmd'];
if (!empty($_GET['sort']))
$sort = $_GET['sort'];
if (!empty($_GET['view']))
$view = $_GET['view'];
/*
* @cmd = getUniqueItem
*
*
* */
$cmd = $_GET['cmd'] ?? '';
$sort = $_GET['sort'] ?? '';
$view = $_GET['view'] ?? '';
// first search code in all 3 tables. Grab from where it exists.
if ($cmd == "getUniqueItem") {
echo $idata->uniqueItems($_GET['index']);
if ($_GET['cmd'] === "getUniqueItem") {
$index = $_GET['index'];
echo $idata->uniqueItems($index);
}
/*
* @cmd = sortBy
*
*
* */
if ($cmd == "sortBy") {
$sql = "SELECT `index`, `$sort` FROM uniqueitems WHERE enabled='1' ORDER BY ?";
$res = PDO_FetchAll($sql, [$sort]);
//ddump($res);
if ($cmd === "sortBy") {
$sql = "SELECT `index`, `$sort` FROM uniqueitems WHERE enabled='1' ORDER BY ? ASC";
$res = PDO_FetchAll($sql, [$sort]);
$html = '';
foreach ($res as $r) {
if ($sort == 'index') {
$html .= "<option value=\"{$r['index']}\">{$r['index']}</option>";
} else {
$html .= "<option value=\"{$r['index']}\">$r[$sort] - {$r['index']}</option>";
}
}
echo $html;
// Sort the results if the sorting is based on 'index'
if ($sort === 'index') {
sort($res);
}
// Generate HTML options based on the sorted results
$html = '';
foreach ($res as $r) {
if ($sort === 'index') {
$html .= "<option value=\"{$r['index']}\">{$r['index']}</option>";
} else {
$html .= "<option value=\"{$r['index']}\">$r[$sort] - {$r['index']}</option>";
}
}
// Output the generated HTML
echo $html;
}
/*
* @cmd = viewOnly
*
*
* */
//@cmd = viewOnly
if ($cmd == "viewOnly") {
$table = 'misc';
$sql = "SELECT uniqueitems.`index`, uniqueitems.`code`, misc.`type`
$table = 'misc';
$sql = "SELECT uniqueitems.`index`, uniqueitems.`code`, misc.`type`
FROM uniqueitems
LEFT JOIN misc ON uniqueitems.`code` = misc.`code`
WHERE `type` IS NOT NULL AND uniqueitems.`code`='$view'";
if ($view == 'armo') {
$table = 'armor';
$sql = "SELECT uniqueitems.`index`, uniqueitems.`code`, $table.`code`
if ($view == 'armo') {
$table = 'armor';
$sql = "SELECT uniqueitems.`index`, uniqueitems.`code`, $table.`code`
FROM uniqueitems
LEFT JOIN $table ON uniqueitems.`code` = $table.`code`
WHERE `type` IS NOT NULL AND uniqueitems.`code`= $table.`code` AND $table.`code` != '' ORDER BY `index`";
}
if ($view == 'weap') {
$table = 'weapons';
$sql = "SELECT uniqueitems.`index`, uniqueitems.`code`, $table.`code`
}
if ($view == 'weap') {
$table = 'weapons';
$sql = "SELECT uniqueitems.`index`, uniqueitems.`code`, $table.`code`
FROM uniqueitems
LEFT JOIN $table ON uniqueitems.`code` = $table.`code`
WHERE `type` IS NOT NULL AND uniqueitems.`code`= $table.`code` AND $table.`code` != '' ORDER BY `index`";
}
if ($view == "char") { // charm
$sql .= " OR uniqueitems.`code`='cm1' OR uniqueitems.`code`='cm2' OR uniqueitems.`code`='cm3'";
}
$res = PDO_FetchAll($sql);
$html = '';
foreach ($res as $r) {
if ($sort == 'index') {
$html .= "<option value=\"{$r['index']}\">{$r['index']}</option>";
} else {
$html .= "<option value=\"{$r['index']}\">{$r['index']}</option>";
}
}
echo $html;
}
if ($view == "char") { // charm
$sql .= " OR uniqueitems.`code`='cm1' OR uniqueitems.`code`='cm2' OR uniqueitems.`code`='cm3'";
}
$res = PDO_FetchAll($sql);
$html = '';
foreach ($res as $r) {
if ($sort == 'index') {
$html .= "<option value=\"{$r['index']}\">{$r['index']}</option>";
} else {
$html .= "<option value=\"{$r['index']}\">{$r['index']}</option>";
}
}
echo $html;
}
/*
* @cmd = search
*
*
*
*
*/
// @cmd = search
if ($cmd == 'search') {
$search = $_GET['search'];
$sql = "SELECT * FROM uniqueitems WHERE `index` LIKE '%$search%' OR code LIKE '%$search%' AND enabled=1 ORDER BY `index`";
$res = PDO_FetchAll($sql);
$search = $_GET['search'];
$sql = "SELECT * FROM uniqueitems WHERE `index` LIKE '%$search%' OR code LIKE '%$search%' AND enabled=1 ORDER BY `index`";
$res = PDO_FetchAll($sql);
$html = '';
foreach ($res as $r) {
if ($sort == 'index') {
$html .= "<option value=\"{$r['index']}\">{$r['index']}</option>";
} else {
$html .= "<option value=\"{$r['index']}\">{$r['index']}</option>";
}
}
echo $html;
$html = '';
foreach ($res as $r) {
if ($sort == 'index') {
$html .= "<option value=\"{$r['index']}\">{$r['index']}</option>";
} else {
$html .= "<option value=\"{$r['index']}\">{$r['index']}</option>";
}
}
echo $html;
}
/*
* @cmd = getString
*
* @arg = property, par, min, max
*
*
*/
// @cmd = getString
// @arg = property, par, min, max
if ($cmd == 'getString') {
$prop = $_GET['prop'];
// stat2,stat3,stat4,stat5,stat6,stat7
if (!empty($prop)) {
$sql = "SELECT stat1 FROM properties WHERE code = ?";
$stat = array_filter(PDO_FetchRow($sql, [$prop]));
$s = array_filter($idata->getIscStrings($prop));
$prop = $_GET['prop'];
// now combine isc strings with par, min, max
$params = array_merge($_GET, $s);
$return = $idesc->getDesc($params);
}
/* This goes into D2ItemDesc->getDesc();
$s1 = $params['string1'];
$s2 = $params['string2'];
$prop = $params['prop'];
$par = $params['par'];
$min = (int) $params['min'];
@return string
*/
// stat2,stat3,stat4,stat5,stat6,stat7
$sql = "SELECT stat1 FROM properties WHERE code = ?";
$stat = array_filter(PDO_FetchRow($sql, [$prop]));
$s = array_filter($idata->getIscStrings($prop));
// now combine isc strings with par, min, max
$params = array_merge($_GET, $s);
$return = $idesc->getDesc($params);
/*
* This goes into D2ItemDesc->getDesc();
*
$s1 = $params['string1'];
$s2 = $params['string2'];
$prop = $params['prop'];
$par = $params['par'];
$min = (int) $params['min'];
*
* @return string
*/
header('Content-Type: application/json');
echo json_encode($return, JSON_INVALID_UTF8_IGNORE);
header('Content-Type: application/json');
echo json_encode($return, JSON_INVALID_UTF8_IGNORE);
}
function saveFile() {
$bin = '..\bin\sqlite3.exe ';
$dbfile = '../' . $_SESSION['modname'] . ".db";
$outputFile = TXT_PATH . 'uniqueitems.txt';
// Prepare the command
$command = escapeshellarg($bin) . " " . escapeshellarg($dbfile) . ' ".mode tabs" ".header on" "SELECT * FROM uniqueitems;" > ' . escapeshellarg($outputFile);
$output = exec($command);
var_dump($command);
return $output;
}
if ($cmd == 'delete') {
$sql = "DELETE FROM uniqueitems WHERE `index` = \"{$_GET['index']}\";";
$res = PDO_Execute($sql);
saveFile();
header('Content-Type: application/json');
echo json_encode($res, JSON_INVALID_UTF8_IGNORE);
}
if ($cmd == "save") {
unset($_GET['formtype']);
unset($_GET['submit']);
unset($_GET['item']);
unset($_GET['cmd']);
// if ladder or carry1 is 0, set empty field.
$_GET['ladder'] = $_GET['ladder'] ?? '';
$_GET['carry1'] = $_GET['carry1'] ?? '';
$index = $_GET['index'];
$sql = "SELECT COUNT(*) FROM uniqueitems WHERE `index` = ?";
$indexExists = PDO_FetchOne($sql, [$index]);
$columns = array_keys($_GET);
// Build the INSERT query
$insertQuery = 'INSERT INTO uniqueitems (';
foreach ($_GET as $k => $v) {
$column = str_replace("_", " ", $k);
$insertQuery .= "`$column`, ";
}
$insertQuery = rtrim($insertQuery, ", ");
$insertQuery .= ") VALUES (";
foreach ($_GET as $k => $v) {
$insertQuery .= "\"$v\", ";
}
$insertQuery = rtrim($insertQuery, ", ");
$insertQuery .= ")";
// Build the UPDATE query
$updateQuery = 'UPDATE uniqueitems SET ';
foreach ($_GET as $k => $v) {
$column = str_replace("_", " ", $k);
$updateQuery .= "`$column` = \"$v\", ";
}
$updateQuery = rtrim($updateQuery, ", ");
$updateQuery .= " WHERE `index`=\"$index\"";
if ($indexExists) {
$res = PDO_Execute($updateQuery);
} else {
$res = PDO_Execute($insertQuery);
}
$output = saveFile();
header('Content-Type: application/json');
echo json_encode($output, JSON_INVALID_UTF8_IGNORE);
}

View File

@ -39,108 +39,108 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// highlight json dump for item debugger
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>';
});
}
function search() {
$.get("/ajax/uniqueitems.php?cmd=search&search=" + searchbox.value, function (data) {
$('.uniqueitems-select').html(data)
});
$.get("/ajax/uniqueitems.php?cmd=search&search=" + searchbox.value, function (data) {
$('.uniqueitems-select').html(data)
});
}
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
return string.charAt(0).toUpperCase() + string.slice(1);
}
$(document).ready(function () {
$('.form-text').hide();
$('.help').click(function () {
// $('.form-text').slideToggle();
});
$('.form-text').hide();
$('.help').click(function () {
// $('.form-text').slideToggle();
});
$('.op1').val(this.checked);
$('.op1').change(function () {
if (this.checked) {
$('option[disabled="disabled"]').hide();
} else {
$('option[disabled="disabled"]').show();
}
});
$('.op1').val(this.checked);
$('.op1').change(function () {
if (this.checked) {
$('option[disabled="disabled"]').hide();
} else {
$('option[disabled="disabled"]').show();
}
});
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
$('.w-select').change(function () {
$('.a-select,.m-select').each(function (i, v) {
v.value = '';
v.required = '';
});
$('.w-select').change(function () {
$('.a-select,.m-select').each(function (i, v) {
v.value = '';
v.required = '';
});
x = $(this).find(':selected').text();
y = document.getElementById('item');
y.value = x;
x = $(this).find(':selected').text();
y = document.getElementById('item');
y.value = x;
});
});
$('.a-select').change(function () {
$('.w-select,.m-select').each(function (i, v) {
v.value = '';
v.required = '';
});
$('.a-select').change(function () {
$('.w-select,.m-select').each(function (i, v) {
v.value = '';
v.required = '';
});
x = $(this).find(':selected').text();
y = document.getElementById('item');
y.value = x;
});
$('.m-select').change(function () {
$('.w-select,.a-select').each(function (i, v) {
v.value = '';
v.required = '';
});
x = $(this).find(':selected').text();
y = document.getElementById('item');
y.value = x;
});
$('.m-select').change(function () {
$('.w-select,.a-select').each(function (i, v) {
v.value = '';
v.required = '';
});
x = $(this).find(':selected').text();
y = document.getElementById('item');
y.value = x;
});
x = $(this).find(':selected').text();
y = document.getElementById('item');
y.value = x;
});
$(".btnconfig").click(function () {
$(".ctrl-config").hide();
$("#loading").show();
$(".btnconfig").click(function () {
$(".ctrl-config").hide();
$("#loading").show();
});
});
$('.help').click(function () {
$(".fa-help").remove();
$(this).next().fadeToggle().focus().css({
"position": "absolute",
"z-index": "1000",
"background": "#eee",
"color": "black !important",
"border": "1px solid #aaa",
"width": "300px",
})
});
$('.help').click(function () {
$(".fa-help").remove();
$(this).next().fadeToggle().focus().css({
"position": "absolute",
"z-index": "1000",
"background": "#eee",
"color": "black !important",
"border": "1px solid #aaa",
"width": "300px",
})
});
// $('.help').prev().hover(function () {
// $(".fa-help").remove();
@ -156,291 +156,299 @@ $(document).ready(function () {
$('.form-text').click(function () {
$(this).fadeOut("slow");
});
$('.form-text').click(function () {
$(this).fadeOut("slow");
});
$('').change(function () {
if (this.checked) {
$('option[disabled="disabled"]').hide();
} else {
$('option[disabled="disabled"]').show();
}
});
$('').change(function () {
if (this.checked) {
$('option[disabled="disabled"]').hide();
} else {
$('option[disabled="disabled"]').show();
}
});
$('input[name="invfile"]').keyup(function(){
$('input[name="invfile"]').keyup(function () {
invImg = docpath + '/img/items/' + this.value + ".png";
$(".item").attr("src", invImg);
});
// every time we change a prop dropdown,
//
// 1 send to server,
// 2 grab string,
// 3 update item display
$('select[name^="prop"]').change(function () {
prop = capitalizeFirstLetter($(this).attr("name"));
propNum = prop.substring(4);
par = $(this).next().val();
min = $(this).next().next().val();
max = $(this).next().next().next().val();
// every time we change a prop dropdown,
//
// 1 send to server,
// 2 grab string,
// 3 update item display
$('select[name^="prop"]').change(function () {
prop = capitalizeFirstLetter($(this).attr("name"));
propNum = prop.substring(4);
par = $(this).next().val();
min = $(this).next().next().val();
max = $(this).next().next().next().val();
val = escape(this.value);
$.get(`/ajax/uniqueitems.php?cmd=getString&prop=${val}&par=${par}&min=${min}&max=${max}`, function (data) {
console.log(data);
$(`.item_stats ul .${prop}`).html(data);
});
});
val = escape(this.value);
$.get(`/ajax/uniqueitems.php?cmd=getString&prop=${val}&par=${par}&min=${min}&max=${max}`, function (data) {
console.log(data);
$(`.item_stats ul .${prop}`).html(data);
});
});
/*
* Properties/par/min/max onchange function, updated item string stats
*
*
*
*
*
*
*
*
/*
* Properties/par/min/max onchange function, updated item string stats
*
*
*
*
*
*
*
*
**/
**/
$('.par1, .min1, .max1').change(function () {
prop = "Prop1";
$('.par1, .min1, .max1').change(function () {
prop = "Prop1";
par = $('.par1').val();
if (par == '')
par = 0;
min = $('.min1').val();
max = $('.max1').val();
par = $('.par1').val();
if (par == '')
par = 0;
min = $('.min1').val();
max = $('.max1').val();
val = escape($("*[name='prop1'").val());
$.get(`/ajax/uniqueitems.php?cmd=getString&prop=${val}&par=${par}&min=${min}&max=${max}`, function (data) {
console.log(data);
$(`.item_stats ul .${prop}`).html(data);
});
});
val = escape($("*[name='prop1'").val());
$.get(`/ajax/uniqueitems.php?cmd=getString&prop=${val}&par=${par}&min=${min}&max=${max}`, function (data) {
console.log(data);
$(`.item_stats ul .${prop}`).html(data);
});
});
$('.par2, .min2, .max2').change(function () {
prop = "Prop2";
$('.par2, .min2, .max2').change(function () {
prop = "Prop2";
par = $('.par2').val();
if (par == '')
par = 0;
min = $('.min2').val();
max = $('.max2').val();
par = $('.par2').val();
if (par == '')
par = 0;
min = $('.min2').val();
max = $('.max2').val();
val = escape($("*[name='prop2'").val());
$.get(`/ajax/uniqueitems.php?cmd=getString&prop=${val}&par=${par}&min=${min}&max=${max}`, function (data) {
console.log(data);
$(`.item_stats ul .${prop}`).html(data);
});
});
val = escape($("*[name='prop2'").val());
$.get(`/ajax/uniqueitems.php?cmd=getString&prop=${val}&par=${par}&min=${min}&max=${max}`, function (data) {
console.log(data);
$(`.item_stats ul .${prop}`).html(data);
});
});
$('.par3, .min3, .max3').change(function () {
prop = "Prop3";
$('.par3, .min3, .max3').change(function () {
prop = "Prop3";
par = $('.par3').val();
if (par == '')
par = 0;
min = $('.min3').val();
max = $('.max3').val();
par = $('.par3').val();
if (par == '')
par = 0;
min = $('.min3').val();
max = $('.max3').val();
val = escape($("*[name='prop3'").val());
$.get(`/ajax/uniqueitems.php?cmd=getString&prop=${val}&par=${par}&min=${min}&max=${max}`, function (data) {
console.log(data);
$(`.item_stats ul .${prop}`).html(data);
});
});
val = escape($("*[name='prop3'").val());
$.get(`/ajax/uniqueitems.php?cmd=getString&prop=${val}&par=${par}&min=${min}&max=${max}`, function (data) {
console.log(data);
$(`.item_stats ul .${prop}`).html(data);
});
});
$('.par4, .min4, .max4').change(function () {
prop = "Prop4";
$('.par4, .min4, .max4').change(function () {
prop = "Prop4";
par = $('.par4').val();
if (par == '')
par = 0;
min = $('.min4').val();
max = $('.max4').val();
par = $('.par4').val();
if (par == '')
par = 0;
min = $('.min4').val();
max = $('.max4').val();
val = escape($("*[name='prop4'").val());
$.get(`/ajax/uniqueitems.php?cmd=getString&prop=${val}&par=${par}&min=${min}&max=${max}`, function (data) {
console.log(data);
$(`.item_stats ul .${prop}`).html(data);
});
});
val = escape($("*[name='prop4'").val());
$.get(`/ajax/uniqueitems.php?cmd=getString&prop=${val}&par=${par}&min=${min}&max=${max}`, function (data) {
console.log(data);
$(`.item_stats ul .${prop}`).html(data);
});
});
$('.par5, .min5, .max5').change(function () {
prop = "Prop5";
$('.par5, .min5, .max5').change(function () {
prop = "Prop5";
par = $('.par5').val();
if (par == '') par = 0;
min = $('.min5').val();
max = $('.max5').val();
par = $('.par5').val();
if (par == '')
par = 0;
min = $('.min5').val();
max = $('.max5').val();
val = escape($("*[name='prop5'").val());
$.get(`/ajax/uniqueitems.php?cmd=getString&prop=${val}&par=${par}&min=${min}&max=${max}`, function (data) {
console.log(data);
$(`.item_stats ul .${prop}`).html(data);
});
});
val = escape($("*[name='prop5'").val());
$.get(`/ajax/uniqueitems.php?cmd=getString&prop=${val}&par=${par}&min=${min}&max=${max}`, function (data) {
console.log(data);
$(`.item_stats ul .${prop}`).html(data);
});
});
$('.par6, .min6, .max6').change(function () {
prop = "Prop6";
$('.par6, .min6, .max6').change(function () {
prop = "Prop6";
par = $('.par6').val();
if (par == '') par = 0;
min = $('.min6').val();
max = $('.max6').val();
par = $('.par6').val();
if (par == '')
par = 0;
min = $('.min6').val();
max = $('.max6').val();
val = escape($("*[name='prop6'").val());
$.get(`/ajax/uniqueitems.php?cmd=getString&prop=${val}&par=${par}&min=${min}&max=${max}`, function (data) {
console.log(data);
$(`.item_stats ul .${prop}`).html(data);
});
});
val = escape($("*[name='prop6'").val());
$.get(`/ajax/uniqueitems.php?cmd=getString&prop=${val}&par=${par}&min=${min}&max=${max}`, function (data) {
console.log(data);
$(`.item_stats ul .${prop}`).html(data);
});
});
$('.par7, .min7, .max7').change(function () {
prop = "Prop7";
$('.par7, .min7, .max7').change(function () {
prop = "Prop7";
par = $('.par7').val();
if (par == '') par = 0;
min = $('.min7').val();
max = $('.max7').val();
par = $('.par7').val();
if (par == '')
par = 0;
min = $('.min7').val();
max = $('.max7').val();
val = escape($("*[name='prop7'").val());
$.get(`/ajax/uniqueitems.php?cmd=getString&prop=${val}&par=${par}&min=${min}&max=${max}`, function (data) {
console.log(data);
$(`.item_stats ul .${prop}`).html(data);
});
});
val = escape($("*[name='prop7'").val());
$.get(`/ajax/uniqueitems.php?cmd=getString&prop=${val}&par=${par}&min=${min}&max=${max}`, function (data) {
console.log(data);
$(`.item_stats ul .${prop}`).html(data);
});
});
$('.par8, .min8, .max8').change(function () {
prop = "Prop8";
$('.par8, .min8, .max8').change(function () {
prop = "Prop8";
par = $('.par8').val();
if (par == '') par = 0;
min = $('.min8').val();
max = $('.max8').val();
par = $('.par8').val();
if (par == '')
par = 0;
min = $('.min8').val();
max = $('.max8').val();
val = escape($("*[name='prop8'").val());
$.get(`/ajax/uniqueitems.php?cmd=getString&prop=${val}&par=${par}&min=${min}&max=${max}`, function (data) {
console.log(data);
$(`.item_stats ul .${prop}`).html(data);
});
});
val = escape($("*[name='prop8'").val());
$.get(`/ajax/uniqueitems.php?cmd=getString&prop=${val}&par=${par}&min=${min}&max=${max}`, function (data) {
console.log(data);
$(`.item_stats ul .${prop}`).html(data);
});
});
$('.par9, .min9, .max9').change(function () {
prop = "Prop9";
$('.par9, .min9, .max9').change(function () {
prop = "Prop9";
par = $('.par9').val();
if (par == '') par = 0;
min = $('.min9').val();
max = $('.max9').val();
par = $('.par9').val();
if (par == '')
par = 0;
min = $('.min9').val();
max = $('.max9').val();
val = escape($("*[name='prop9'").val());
$.get(`/ajax/uniqueitems.php?cmd=getString&prop=${val}&par=${par}&min=${min}&max=${max}`, function (data) {
console.log(data);
$(`.item_stats ul .${prop}`).html(data);
});
});
val = escape($("*[name='prop9'").val());
$.get(`/ajax/uniqueitems.php?cmd=getString&prop=${val}&par=${par}&min=${min}&max=${max}`, function (data) {
console.log(data);
$(`.item_stats ul .${prop}`).html(data);
});
});
$('.par10, .min10, .max10').change(function () {
prop = "Prop10";
$('.par10, .min10, .max10').change(function () {
prop = "Prop10";
par = $('.par10').val();
if (par == '') par = 0;
min = $('.min10').val();
max = $('.max10').val();
par = $('.par10').val();
if (par == '')
par = 0;
min = $('.min10').val();
max = $('.max10').val();
val = escape($("*[name='prop10'").val());
$.get(`/ajax/uniqueitems.php?cmd=getString&prop=${val}&par=${par}&min=${min}&max=${max}`, function (data) {
console.log(data);
$(`.item_stats ul .${prop}`).html(data);
});
});
val = escape($("*[name='prop10'").val());
$.get(`/ajax/uniqueitems.php?cmd=getString&prop=${val}&par=${par}&min=${min}&max=${max}`, function (data) {
console.log(data);
$(`.item_stats ul .${prop}`).html(data);
});
});
$('.par11, .min11, .max11').change(function () {
prop = "Prop11";
$('.par11, .min11, .max11').change(function () {
prop = "Prop11";
par = $('.par11').val();
if (par == '') par = 0;
min = $('.min11').val();
max = $('.max11').val();
par = $('.par11').val();
if (par == '')
par = 0;
min = $('.min11').val();
max = $('.max11').val();
val = escape($("*[name='prop11'").val());
$.get(`/ajax/uniqueitems.php?cmd=getString&prop=${val}&par=${par}&min=${min}&max=${max}`, function (data) {
console.log(data);
$(`.item_stats ul .${prop}`).html(data);
});
});
val = escape($("*[name='prop11'").val());
$.get(`/ajax/uniqueitems.php?cmd=getString&prop=${val}&par=${par}&min=${min}&max=${max}`, function (data) {
console.log(data);
$(`.item_stats ul .${prop}`).html(data);
});
});
$('.par12, .min12, .max12').change(function () {
prop = "Prop12";
$('.par12, .min12, .max12').change(function () {
prop = "Prop12";
par = $('.par12').val();
if (par == '') par = 0;
min = $('.min12').val();
max = $('.max12').val();
par = $('.par12').val();
if (par == '')
par = 0;
min = $('.min12').val();
max = $('.max12').val();
val = escape($("*[name='prop12'").val());
$.get(`/ajax/uniqueitems.php?cmd=getString&prop=${val}&par=${par}&min=${min}&max=${max}`, function (data) {
console.log(data);
$(`.item_stats ul .${prop}`).html(data);
});
});
val = escape($("*[name='prop12'").val());
$.get(`/ajax/uniqueitems.php?cmd=getString&prop=${val}&par=${par}&min=${min}&max=${max}`, function (data) {
console.log(data);
$(`.item_stats ul .${prop}`).html(data);
});
});
/*
*
* END on change for inputs
*
*
*
* update item index, lvl, lvl req
*
*
*
**/
/*
*
* END on change for inputs
*
*
*
* update item index, lvl, lvl req
*
*
*
**/
$("input[name='index']").keyup(function(){
$(".itemindex").html($(this).val());
});
$("input[name='index']").keyup(function () {
$(".itemindex").html($(this).val());
});
$('input[name="lvl"]').keyup(function(){
$(".itemlvl").html("Level: "+$(this).val());
});
$('input[name="lvl req"]').keyup(function(){
$(".itemlvlreq").html("Level Required: "+$(this).val());
});
$('input[name="lvl"]').keyup(function () {
$(".itemlvl").html("Level: " + $(this).val());
});
$('input[name="lvl req"]').keyup(function () {
$(".itemlvlreq").html("Level Required: " + $(this).val());
});
// cmd = getUniqueItem
$('.uniqueitems-select').change(function () {
// 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) {
$(".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;
debugData = (JSON.stringify(data, null, 4));
$('.debug, .debug_preview').html(syntaxHighlight(debugData));
props = data.props;
// update preview
//$('.item_stats div').hide().html("<p></p>");
// update preview
//$('.item_stats div').hide().html("<p></p>");
invImg = docpath + '/img/items/' + data.invfile + ".png";
$(".item").attr("src", invImg);
@ -449,51 +457,51 @@ $(document).ready(function () {
this.src = invImg;
};
type = data["*type"];
lvlreq = data["lvl req"];
type = data["*type"];
lvlreq = data["lvl req"];
base = data.baseItemInfo;
base = data.baseItemInfo;
$('.item_stats ul .itemindex').html(data.index);
$('.item_stats ul .itemtype').html(`(${type})`);
$('.item_stats ul .itemlvl').html(`Level: ${base.level}`);
$('.item_stats ul .itemlvlreq').html(`Level Required: ${lvlreq}`);
$('.item_stats ul .itemindex').html(data.index);
$('.item_stats ul .itemtype').html(`(${type})`);
$('.item_stats ul .itemlvl').html(`Level: ${base.level}`);
$('.item_stats ul .itemlvlreq').html(`Level Required: ${lvlreq}`);
$('.item_stats ul .itemcode').html(`Item Code: (${base.code})`);
$('.item_stats ul .itemcode').html(`Item Code: (${base.code})`);
if (base.reqstr) {
$('.item_stats ul .itemstreq').html(`Required Strength: ${base.reqstr}`);
}
if (base.reqdex) {
$('.item_stats ul .itemdexreq').html(`Required Dexterity: ${base.reqdex}`);
}
if (base['gemsockets']) {
$('.item_stats ul .itemgemsockets').html(`Max Sockets: (${base.gemsockets})`);
if (base.reqstr) {
$('.item_stats ul .itemstreq').html(`Required Strength: ${base.reqstr}`);
}
if (base.reqdex) {
$('.item_stats ul .itemdexreq').html(`Required Dexterity: ${base.reqdex}`);
}
if (base['gemsockets']) {
$('.item_stats ul .itemgemsockets').html(`Max Sockets: (${base.gemsockets})`);
}
}
/*
* THIS LINE BREAKS hidden fields and set them to blank.
*
*/
/*
* THIS LINE BREAKS hidden fields and set them to blank.
*
*/
$('.props-container select, .props-container input').val('');
$('.props-container select, .props-container input').val('');
$('.item_stats ul .blue').each(function (i, v) {
$(v).html("");
});
$('.item_stats ul .blue').each(function (i, v) {
$(v).html("");
});
// add the rest of the prop li's here
$.each(props, function (i, v) {
if (v.string) {
$(`.item_stats ul .${i}`).html(v.string[0]);
}
});
// add the rest of the prop li's here
$.each(props, function (i, v) {
if (v.string) {
$(`.item_stats ul .${i}`).html(v.string[0]);
}
});
// add the rest of the prop li's here
// add the rest of the prop li's here
// var i;
// for (i = 1; i <= 12; i++) {
@ -503,48 +511,48 @@ $(document).ready(function () {
// }
//$('.item_stats div').show();
//$('.item_stats div').show();
//console.log(data['lvl req']);
//console.log(data['lvl req']);
$.each(data, function (i, v) {
$('*[name="' + i + '"]').val(v);
if (i == 'code') {
$('select[name="code[]"]').val(v);
$('select[name="code[]"]').prop('required', '');
}
});
});
});
$.each(data, function (i, v) {
$('*[name="' + i + '"]').val(v);
if (i == 'code') {
$('select[name="code[]"]').val(v);
$('select[name="code[]"]').prop('required', '');
}
});
});
});
$(".btnDebug").click(function () {
$(".debug_preview").slideToggle();
});
$(".btnDebug").click(function () {
$(".debug_preview").slideToggle();
});
// cmd = sortBy
$('input[name="sort"]').change(function () {
$.get("/ajax/uniqueitems.php?cmd=sortBy&sort=" + this.value, function (data) {
$('.uniqueitems-select').html(data)
});
});
// cmd = sortBy
$('input[name="sort"]').change(function () {
$.get("/ajax/uniqueitems.php?cmd=sortBy&sort=" + this.value, function (data) {
$('.uniqueitems-select').html(data)
});
});
// cmd = viewOnly
$('input[name="view"]').change(function () {
$.get("/ajax/uniqueitems.php?cmd=viewOnly&view=" + this.value, function (data) {
$('.uniqueitems-select').html(data)
});
});
// cmd = viewOnly
$('input[name="view"]').change(function () {
$.get("/ajax/uniqueitems.php?cmd=viewOnly&view=" + this.value, function (data) {
$('.uniqueitems-select').html(data)
});
});
searchbox = document.getElementById('search');
searchbox.addEventListener('input', search);
searchbox = document.getElementById('search');
searchbox.addEventListener('input', search);
$('input[name="theme"]').change(function () {
modname = $('input[name="modname"]').val();
$.get("/res/css.php?theme=" + this.value + "&modname=" + modname, function (data) {
location.reload();
});
$('input[name="theme"]').change(function () {
modname = $('input[name="modname"]').val();
$.get("/res/css.php?theme=" + this.value + "&modname=" + modname, function (data) {
location.reload();
});
// $('body').toggleClass("body-dark");
@ -553,16 +561,43 @@ $(document).ready(function () {
// $('select').toggleClass("select-dark");
// $('option').toggleClass("option-dark");
// $('.col-2,.col-3,.col-4').attr({"style":""});
});
});
//genDocUniqueItems
$("#Unique .btnDocs").click(function () {
window.open('/genDocs.php?cmd=genDocUniqueItems', '_blank');
});
//genDocUniqueItems
$("#Unique .btnDocs").click(function () {
window.open('/genDocs.php?cmd=genDocUniqueItems', '_blank');
});
$('.btn-delete').click(function (event) {
event.preventDefault(); // Prevent default button click behavior
// delete item index
$.get('/ajax/uniqueitems.php?cmd=delete&index=' + $(".uniqueform input[name='index']").val(), function (response) {
// Handle the response from the server
// remove option from list
$('.uniqueitems-select option[value="' + $(".uniqueform input[name='index']").val() + '"]').remove();
console.log(response);
});
});
$('.btn-save').click(function (event) {
event.preventDefault(); // Prevent default button click behavior
// Get form data
var formData = $(".uniqueform").serialize();
// delete item index
$.get('/ajax/uniqueitems.php?cmd=save&' + formData, function (response) {
// Handle the response from the server
console.log(response);
});
});

View File

@ -61,7 +61,7 @@
</div>
<ul class="nav nav-tabs" id="Tabs" role="tablist">
<li class="nav-item" role="presentation">
<a class="nav-link" id="Unique-tab" data-toggle="tab" href="#Unique" role="tab" aria-controls="Unique" aria-selected="true">Unique Items</a>
<a class="nav-link active" id="Unique-tab" data-toggle="tab" href="#Unique" role="tab" aria-controls="Unique" aria-selected="true">Unique Items</a>
</li>
<!-- <li class="nav-item" role="presentation">
<a class="nav-link" id="Set-tab" data-toggle="tab" href="#Set" role="tab" aria-controls="Set" aria-selected="false">Set Items</a>
@ -77,7 +77,7 @@
</li>
-->
<li class="nav-item" role="presentation">
<a class="nav-link active" id="Chars-tab" data-toggle="tab" href="#Chars" role="tab" aria-controls="Chars" aria-selected="false">Character Editor</a>
<a class="nav-link" id="Chars-tab" data-toggle="tab" href="#Chars" role="tab" aria-controls="Chars" aria-selected="false">Character Editor</a>
</li>
<li class="nav-item" role="presentation">
@ -94,7 +94,7 @@
</div>
</div>
<div class="tab-content" id="TabContent">
<div class="tab-pane fade" id="Unique" role="tabpanel" aria-labelledby="Unique-tab">
<div class="tab-pane fade show active" id="Unique" role="tabpanel" aria-labelledby="Unique-tab">
<?php require_once 'tabs/UniqueItems.php'; ?>
</div>
<div class="tab-pane fade" id="Set" role="tabpanel" aria-labelledby="Set-tab">
@ -113,7 +113,7 @@
<div class="tab-pane fade" id="Doc" role="tabpanel" aria-labelledby="Doc-tab">
<?php require_once 'tabs/Doc.php'; ?>
</div>
<div class="tab-pane fade show active" id="Chars" role="tabpanel" aria-labelledby="Chars-tab">
<div class="tab-pane fade" id="Chars" role="tabpanel" aria-labelledby="Chars-tab">
<?php require_once 'tabs/Chars.php'; ?>
</div>
<div class="tab-pane fade" id="Debug" role="tabpanel" aria-labelledby="Debug-tab">

View File

@ -107,13 +107,13 @@
</select>
</div>
</div>
<form action="/saveD2ModderEditorData.php" method="post">
<form class="uniqueform" action="" method="post">
<div class="form-group row">
<div class="col-2" style="background: #fec;">
<p>Index</p>
<div class="input-group">
<input name="index" type="text" aria-describedby="indexHelpBlock" required="required" class="form-control">
<input name="index" type="text" aria-describedby="indexHelpBlock" required="required" class="form-control input-uindex">
</div><span class="help"><i class="fa fa-question-circle" aria-hidden="true"></i>
</span>
<span class="form-text">Index: the ID pointer that is referenced by the game in TreasureClassEx.txt and CubeMain.txt, this column also contains the string-key used in the TBL files.</span>

View File

@ -1,6 +1,15 @@
<div class="row options" style="background: none;">
<div class="offset-10 col-2" style="background: none;">
<button style="" name="submit" type="submit" class="btn btn-success">SAVE</button>
<button name="submit" type="reset" class="btn btn-danger">CLEAR</button>
<button name="submit" type="submit" class="btn btn-success btn-save">SAVE</button>
<button name="submit" type="reset" class="btn btn-warning btn-clear">CLEAR</button>
<button name="submit" type="submit" class="btn btn-danger btn-delete">DELETE</button>
</div>
</div>
<!--<div class="row options" style="background: none;">
<div class="offset-10 col-2" style="background: none;">
<a href="" name="submit" type="submit" class="btn btn-success btn-save">SAVE</a>
<button name="submit" type="reset" class="btn btn-warning btn-clear">CLEAR</button>
<a href="" name="submit" class="btn btn-danger btn-delete">DELETE</a>
</div>
</div>-->