변수 보기

This commit is contained in:
현성필
2024-01-10 20:47:32 +09:00
parent 19ec9d3bdd
commit 06bee094e3
3 changed files with 154 additions and 82 deletions
@@ -35,6 +35,7 @@
<button type="button" class="btn btn-primary btn-sm" id="new_scenario"><i class="fa fa-plus"></i> 새로운 시나리오
</button>
<button type="button" class="btn btn-primary btn-sm" id="full_screen"><i class="fa-solid fa-display"></i> 전체화면</button>
<button type="button" class="btn btn-primary btn-sm" id="show_variable"><i class="fa-solid fa-list"></i> 변수 보기</button>
</div>
<div class="tester">
<section th:replace="page/tester/apiScenario :: scenarioFragment">
@@ -59,10 +60,61 @@
container.classList.toggle('full-screen');
});
function populateVariablesTable() {
var tbody = $('.variables');
tbody.empty(); // Clear existing rows
$.each(window.globals, function(key, value) {
var row = $('<tr>');
var keyInput = $('<input>').attr('type', 'text').addClass('form-control key-input').val(key);
var valueInput = $('<input>').attr('type', 'text').addClass('form-control value-input').val(value);
var deleteButton = $('<button>').attr('type', 'button').addClass('btn btn-danger btn-sm delete-variable').html('<i class="fa fa-trash"></i>');
row.append($('<td>').append(keyInput));
row.append($('<td>').append(valueInput));
row.append($('<td>').append(deleteButton));
tbody.append(row);
});
// Event listener for changes in key
$('.key-input').on('change', function() {
var oldKey = $(this).closest('tr').find('.value-input').attr('data-old-key');
var newKey = $(this).val();
var value = window.globals[oldKey];
delete window.globals[oldKey];
window.globals[newKey] = value;
$(this).closest('tr').find('.value-input').attr('data-old-key', newKey);
});
// Event listener for changes in value
$('.value-input').on('change', function() {
var key = $(this).closest('tr').find('.key-input').val();
var newValue = $(this).val();
window.globals[key] = newValue;
});
$('.delete-variable').on('click', function() {
var key = $(this).closest('tr').find('.key-input').val();
delete window.globals[key];
$(this).closest('tr').remove();
});
// Set data-old-key attribute for tracking key changes
$('.value-input').each(function() {
var key = $(this).closest('tr').find('.key-input').val();
$(this).attr('data-old-key', key);
});
}
$('#show_variable').on('click', function () {
populateVariablesTable();
$('#variable_modal').modal('show');
});
document.addEventListener('keydown', (event) => {
if (event.key === 'Escape') {
container.classList.remove('full-screen');
// layoutManager.resize();
}
});