mirror of
https://gitlab.com/hashborgir/d2tools.git
synced 2025-04-27 14:55:38 +00:00
textarea line breaks, bootswatch, etc. I don't fucking remember
This commit is contained in:
parent
eca6598fdf
commit
6eadbcfebb
@ -33,38 +33,39 @@ if ($cmd == "getTable") {
|
|||||||
|
|
||||||
// Iterate over the rows
|
// Iterate over the rows
|
||||||
foreach ($rows as $row) {
|
foreach ($rows as $row) {
|
||||||
$tableMarkup .= '<tr class="row-' . $row['rowid'] . '">';
|
$string = str_replace('\n', " ", $row['String']);
|
||||||
|
|
||||||
|
$tableMarkup .= "<tr class='row-{$row['rowid']}'>";
|
||||||
|
|
||||||
$tableMarkup .= "<td>{$row['rowid']}</td>";
|
$tableMarkup .= "<td>{$row['rowid']}</td>";
|
||||||
|
|
||||||
// Display the Key column as a text input with Bootstrap form-control class
|
// Display the Key column as a text input with Bootstrap form-control class
|
||||||
$tableMarkup .= '<td><input type="text" value="' . $row['Key'] . '" class="form-control"></td>';
|
$tableMarkup .= "<td><input type='text' value='{$row['Key']}' class='form-control'><span style='visibility: hidden;'>{$row['Key']}</span></td>";
|
||||||
|
|
||||||
// Display the String column as a textarea with Bootstrap form-control class
|
// Display the String column as a textarea with Bootstrap form-control class
|
||||||
$tableMarkup .= '<td><textarea class="form-control">' . $row['String'] . '</textarea></td>';
|
$tableMarkup .= "<td><textarea class='form-control'>{$string}</textarea></td>";
|
||||||
|
|
||||||
// Add the Update and Delete links within a single td element
|
// Add the Update and Delete links within a single td element
|
||||||
$tableMarkup .= '<td><div>';
|
$tableMarkup .= "<td><div>";
|
||||||
|
|
||||||
// Add the Update link with Bootstrap btn and btn-primary classes
|
// Add the Update link with Bootstrap btn and btn-primary classes
|
||||||
$tableMarkup .= '<a href="#" class="update-link btn btn-primary" data-rowid="' . $row['rowid'] . '">Update</a>';
|
$tableMarkup .= "<a href='#' class='update-link btn btn-primary' data-rowid='{$row['rowid']}'>Update</a>";
|
||||||
|
|
||||||
// Add the Delete link with Bootstrap btn and btn-danger classes
|
// Add the Delete link with Bootstrap btn and btn-danger classes
|
||||||
$tableMarkup .= '<a href="#" class="delete-link btn btn-danger" data-rowid="' . $row['rowid'] . '">Delete</a>';
|
$tableMarkup .= "<a style='float:right' href='#' class='delete-link btn btn-danger' data-rowid='{$row['rowid']}'>Delete</a>";
|
||||||
|
|
||||||
$tableMarkup .= '</div></td>';
|
$tableMarkup .= "</div></td>";
|
||||||
|
|
||||||
$tableMarkup .= '</tr>';
|
$tableMarkup .= "</tr>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Return the table markup
|
// Return the table markup
|
||||||
echo $tableMarkup;
|
echo $tableMarkup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($cmd == "update") {
|
if ($cmd == "update") {
|
||||||
$query = "UPDATE patchstring SET Key = ?, String = ? WHERE ROWID = ?";
|
$query = "UPDATE $tableName SET Key = ?, String = ? WHERE ROWID = ?";
|
||||||
PDO_Execute($query, [$_REQUEST['key'], $_REQUEST['string'], $_REQUEST['rowid']]);
|
PDO_Execute($query, [$_REQUEST['key'], $_REQUEST['string'], $_REQUEST['rowid']]);
|
||||||
|
|
||||||
echo $_REQUEST['key'] . " updated";
|
echo $_REQUEST['key'] . " updated";
|
||||||
@ -88,12 +89,9 @@ if ($cmd == "add") {
|
|||||||
// Execute the insert statement
|
// Execute the insert statement
|
||||||
$result = PDO_Execute($query, $params);
|
$result = PDO_Execute($query, $params);
|
||||||
|
|
||||||
|
|
||||||
// Retrieve the last inserted rowid from the table
|
// Retrieve the last inserted rowid from the table
|
||||||
$query = "SELECT last_insert_rowid() AS rowid";
|
$query = "SELECT last_insert_rowid() AS rowid";
|
||||||
$result = PDO_FetchOne($query);
|
$result = PDO_FetchOne($query);
|
||||||
|
|
||||||
|
|
||||||
echo $result;
|
echo $result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,7 @@ foreach (glob($tbl . "*.tbl") as $filename) {
|
|||||||
<!-- Bootstrap DataTables JS -->
|
<!-- Bootstrap DataTables JS -->
|
||||||
<script src="https://cdn.datatables.net/1.11.4/js/dataTables.bootstrap4.min.js"></script>
|
<script src="https://cdn.datatables.net/1.11.4/js/dataTables.bootstrap4.min.js"></script>
|
||||||
<title>Editable Tables</title>
|
<title>Editable Tables</title>
|
||||||
|
<link rel="stylesheet" href="https://bootswatch.com/4/lumen/bootstrap.min.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
@ -115,6 +116,8 @@ foreach (glob($tbl . "*.tbl") as $filename) {
|
|||||||
|
|
||||||
// Select element change event handler
|
// Select element change event handler
|
||||||
$('#tableName').change(function () {
|
$('#tableName').change(function () {
|
||||||
|
$('.table').DataTable().destroy();
|
||||||
|
|
||||||
var selectedTable = $(this).val();
|
var selectedTable = $(this).val();
|
||||||
|
|
||||||
// Send GET request to TblEditor.php?getTable with selected table name
|
// Send GET request to TblEditor.php?getTable with selected table name
|
||||||
@ -172,6 +175,9 @@ foreach (glob($tbl . "*.tbl") as $filename) {
|
|||||||
// Get the updated values from the corresponding input and textarea
|
// Get the updated values from the corresponding input and textarea
|
||||||
var key = $('.row-' + rowid + ' input').val();
|
var key = $('.row-' + rowid + ' input').val();
|
||||||
var string = $('.row-' + rowid + ' textarea').val();
|
var string = $('.row-' + rowid + ' textarea').val();
|
||||||
|
string = string.replace(/ /g, '\\n');
|
||||||
|
string = string.replace(/\n/g, '\\n');
|
||||||
|
|
||||||
|
|
||||||
// Send POST request to TblEditor.php with the updated values
|
// Send POST request to TblEditor.php with the updated values
|
||||||
$.post('TblEditor.php', {cmd: 'update', tableName: selectedTable, rowid: rowid, key: key, string: string}, function (response) {
|
$.post('TblEditor.php', {cmd: 'update', tableName: selectedTable, rowid: rowid, key: key, string: string}, function (response) {
|
||||||
@ -179,8 +185,6 @@ foreach (glob($tbl . "*.tbl") as $filename) {
|
|||||||
|
|
||||||
// Optional: Update any UI elements if needed
|
// Optional: Update any UI elements if needed
|
||||||
|
|
||||||
// Update DataTable
|
|
||||||
$('.table').DataTable().draw();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -195,7 +199,7 @@ foreach (glob($tbl . "*.tbl") as $filename) {
|
|||||||
// Handle the response here
|
// Handle the response here
|
||||||
rowid = response;
|
rowid = response;
|
||||||
// Create the HTML markup for the new row
|
// Create the HTML markup for the new row
|
||||||
var newRow = '<tr class="row-' + rowid + '">' +
|
var newRow = '<tr class="row-' + rowid + '">' +
|
||||||
'<td>' + rowid + '</td>' +
|
'<td>' + rowid + '</td>' +
|
||||||
'<td><input type="text" value="' + key + '" class="form-control"></td>' +
|
'<td><input type="text" value="' + key + '" class="form-control"></td>' +
|
||||||
'<td><textarea class="form-control">' + string + '</textarea></td>' +
|
'<td><textarea class="form-control">' + string + '</textarea></td>' +
|
||||||
@ -204,7 +208,7 @@ var newRow = '<tr class="row-' + rowid + '">' +
|
|||||||
'<a href="#" class="delete-link btn btn-danger" data-rowid="' + rowid + '">Delete</a>' +
|
'<a href="#" class="delete-link btn btn-danger" data-rowid="' + rowid + '">Delete</a>' +
|
||||||
'</div></td>' +
|
'</div></td>' +
|
||||||
'</tr>';
|
'</tr>';
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
// Append the new row to the table
|
// Append the new row to the table
|
||||||
@ -220,7 +224,18 @@ var newRow = '<tr class="row-' + rowid + '">' +
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$(document).ready(function () {
|
||||||
|
// Iterate over each div with the form-control class
|
||||||
|
$('.form-control').each(function () {
|
||||||
|
// Get the text content of the div
|
||||||
|
var text = $(this).val();
|
||||||
|
|
||||||
|
// Set the height of the div to fit the text content
|
||||||
|
$(this).height('auto'); // Reset the height to auto
|
||||||
|
var contentHeight = $(this).prop('scrollHeight');
|
||||||
|
$(this).height(contentHeight);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user