better UI

This commit is contained in:
Hash Borgir 2023-06-13 12:58:28 -06:00
parent 6eadbcfebb
commit 5a8bac8e87

View File

@ -57,13 +57,18 @@ foreach (glob($tbl . "*.tbl") as $filename) {
<div class="container">
<h2>Select .tbl File</h2>
<select name="tableName" id="tableName" class="form-control">
<option value="" selected></option>
<?php foreach ($tableNames as $tableName): ?>
<option value="<?php echo $tableName; ?>" <?php echo ($tableName == "patchstring") ? "selected" : ""; ?>><?php echo $tableName; ?></option>
<option value="<?php echo $tableName; ?>" <?php echo ($tableName == "") ? "selected" : ""; ?>><?php echo $tableName; ?></option>
<?php endforeach; ?>
</select>
<h2>Table</h2>
<div>
<button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#collapseForm" aria-expanded="false" aria-controls="collapseForm">
Add new String Key
</button>
<div class="collapse" id="collapseForm">
<div class="form-group">
Add new String
<label for="inputKey">Key</label>
<input type="text" class="form-control" id="inputKey" placeholder="Enter Key">
</div>
@ -72,6 +77,9 @@ foreach (glob($tbl . "*.tbl") as $filename) {
<textarea class="form-control" id="inputString" placeholder="Enter String"></textarea>
</div>
<button type="button" class="btn btn-primary" id="addLink">Add</button>
</div>
</div>
<br>
<hr>
@ -97,26 +105,37 @@ foreach (glob($tbl . "*.tbl") as $filename) {
<script>
function resizeTextarea() {
this.style.height = 'auto';
this.style.height = (this.scrollHeight) + 'px';
}
$(document).ready(function () {
// Get the initial selected table
var selectedTable = $('#tableName').val();
// var selectedTable = $('#tableName').val();
//
// // Send GET request to TblEditor.php?getTable with selected table name
// var request = $.get('TblEditor.php', {cmd: 'getTable', tableName: selectedTable});
//
// request.done(function (response) {
// // Handle the response here
// $('.tablediv tbody').html(response).promise().done(function () {
// // Callback function after HTML content is loaded
//
// // Initialize DataTables on the table
// $('.table').DataTable();
// });
// });
// Send GET request to TblEditor.php?getTable with selected table name
var request = $.get('TblEditor.php', {cmd: 'getTable', tableName: selectedTable});
request.done(function (response) {
// Handle the response here
$('.tablediv tbody').html(response).promise().done(function () {
// Callback function after HTML content is loaded
// Initialize DataTables on the table
$('.table').DataTable();
});
});
// Function to resize textarea based on content
function resizeTextarea() {
this.style.height = 'auto';
this.style.height = (this.scrollHeight) + 'px';
}
// Select element change event handler
$('#tableName').change(function () {
$('.table').DataTable().destroy();
$('.table tbody').html('');
var selectedTable = $(this).val();
@ -130,9 +149,24 @@ foreach (glob($tbl . "*.tbl") as $filename) {
// Initialize DataTables on the table
$('.table').DataTable();
// Resize textareas on page load
$('textarea').each(resizeTextarea);
// Resize textareas on input
$('textarea').on('input', resizeTextarea);
// Resize textareas on custom select change
$('.custom-select').change(function () {
$('textarea').each(resizeTextarea);
});
$('.page-link').click(function () {
$('textarea').each(resizeTextarea);
});
});
});
});
@ -225,17 +259,15 @@ foreach (glob($tbl . "*.tbl") as $filename) {
$(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();
$('textarea').each(function () {
this.style.height = 'auto';
this.style.height = (this.scrollHeight) + 'px';
});
setInterval(function () {
$('textarea').each(resizeTextarea);
}, 4000);
});
// 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>
@ -243,6 +275,12 @@ foreach (glob($tbl . "*.tbl") as $filename) {
div.dataTables_wrapper div.dataTables_length select {
width: 75px !important;
}
textarea {
overflow: hidden;
resize: none;
scrollbar-width: none; /* For Firefox */
-ms-overflow-style: none; /* For Internet Explorer and Edge */
}
</style>
</body>
</html>