mirror of
https://gitlab.com/hashborgir/d2tools.git
synced 2025-10-13 16:34:23 -05:00
textarea line breaks, bootswatch, etc. I don't fucking remember
This commit is contained in:
@@ -35,7 +35,7 @@ foreach (glob($tbl . "*.tbl") as $filename) {
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.11.4/css/jquery.dataTables.min.css">
|
||||
|
||||
|
||||
<!-- JS -->
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/1.11.4/js/jquery.dataTables.min.js"></script>
|
||||
@@ -51,6 +51,7 @@ foreach (glob($tbl . "*.tbl") as $filename) {
|
||||
<!-- Bootstrap DataTables JS -->
|
||||
<script src="https://cdn.datatables.net/1.11.4/js/dataTables.bootstrap4.min.js"></script>
|
||||
<title>Editable Tables</title>
|
||||
<link rel="stylesheet" href="https://bootswatch.com/4/lumen/bootstrap.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
@@ -115,6 +116,8 @@ foreach (glob($tbl . "*.tbl") as $filename) {
|
||||
|
||||
// Select element change event handler
|
||||
$('#tableName').change(function () {
|
||||
$('.table').DataTable().destroy();
|
||||
|
||||
var selectedTable = $(this).val();
|
||||
|
||||
// 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
|
||||
var key = $('.row-' + rowid + ' input').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
|
||||
$.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
|
||||
|
||||
// Update DataTable
|
||||
$('.table').DataTable().draw();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -195,23 +199,23 @@ foreach (glob($tbl . "*.tbl") as $filename) {
|
||||
// Handle the response here
|
||||
rowid = response;
|
||||
// Create the HTML markup for the new row
|
||||
var newRow = '<tr class="row-' + rowid + '">' +
|
||||
'<td>' + rowid + '</td>' +
|
||||
'<td><input type="text" value="' + key + '" class="form-control"></td>' +
|
||||
'<td><textarea class="form-control">' + string + '</textarea></td>' +
|
||||
'<td><div>' +
|
||||
'<a href="#" class="update-link btn btn-primary" data-rowid="' + rowid + '">Update</a>' +
|
||||
'<a href="#" class="delete-link btn btn-danger" data-rowid="' + rowid + '">Delete</a>' +
|
||||
'</div></td>' +
|
||||
'</tr>';
|
||||
;
|
||||
var newRow = '<tr class="row-' + rowid + '">' +
|
||||
'<td>' + rowid + '</td>' +
|
||||
'<td><input type="text" value="' + key + '" class="form-control"></td>' +
|
||||
'<td><textarea class="form-control">' + string + '</textarea></td>' +
|
||||
'<td><div>' +
|
||||
'<a href="#" class="update-link btn btn-primary" data-rowid="' + rowid + '">Update</a>' +
|
||||
'<a href="#" class="delete-link btn btn-danger" data-rowid="' + rowid + '">Delete</a>' +
|
||||
'</div></td>' +
|
||||
'</tr>';
|
||||
;
|
||||
|
||||
|
||||
// Append the new row to the table
|
||||
$('.table').DataTable().destroy();
|
||||
|
||||
|
||||
$('.table tbody').append(newRow);
|
||||
|
||||
|
||||
$('.table').DataTable();
|
||||
});
|
||||
});
|
||||
@@ -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>
|
||||
|
Reference in New Issue
Block a user