better UI

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

View File

@ -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>
@ -57,21 +57,29 @@ 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 class="form-group">
Add new String
<label for="inputKey">Key</label>
<input type="text" class="form-control" id="inputKey" placeholder="Enter Key">
<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">
<label for="inputKey">Key</label>
<input type="text" class="form-control" id="inputKey" placeholder="Enter Key">
</div>
<div class="form-group">
<label for="inputString">String</label>
<textarea class="form-control" id="inputString" placeholder="Enter String"></textarea>
</div>
<button type="button" class="btn btn-primary" id="addLink">Add</button>
</div>
</div>
<div class="form-group">
<label for="inputString">String</label>
<textarea class="form-control" id="inputString" placeholder="Enter String"></textarea>
</div>
<button type="button" class="btn btn-primary" id="addLink">Add</button>
<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});
// Function to resize textarea based on content
function resizeTextarea() {
this.style.height = 'auto';
this.style.height = (this.scrollHeight) + 'px';
}
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();
});
});
// Select element change event handler
// Select element change event handler
$('#tableName').change(function () {
$('.table').DataTable().destroy();
$('.table tbody').html('');
var selectedTable = $(this).val();
@ -130,12 +149,27 @@ 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);
});
});
});
});
// Delete link click event handler
$(document).on('click', '.delete-link', function (event) {
event.preventDefault();
@ -225,24 +259,28 @@ 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();
// 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);
$('textarea').each(function () {
this.style.height = 'auto';
this.style.height = (this.scrollHeight) + 'px';
});
setInterval(function () {
$('textarea').each(resizeTextarea);
}, 4000);
});
</script>
<style>
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>