Remove Tree Mode

This commit is contained in:
Whispering Wind
2025-05-01 23:34:29 +03:30
committed by GitHub
parent f2f2401b52
commit 8d9fda0c09

View File

@ -25,14 +25,12 @@
const editor = new JSONEditor(container, { const editor = new JSONEditor(container, {
mode: "code", mode: "code",
modes: ["code", "tree"],
onChange: validateJson onChange: validateJson
}); });
// Function to validate the JSON and update UI elements
function validateJson() { function validateJson() {
try { try {
editor.get(); // Validate the JSON editor.get();
updateSaveButton(true); updateSaveButton(true);
hideErrorMessage(); hideErrorMessage();
} catch (error) { } catch (error) {
@ -41,7 +39,6 @@
} }
} }
// Function to update save button based on JSON validity
function updateSaveButton(isValid) { function updateSaveButton(isValid) {
saveButton.disabled = !isValid; saveButton.disabled = !isValid;
saveButton.style.cursor = isValid ? "pointer" : "not-allowed"; saveButton.style.cursor = isValid ? "pointer" : "not-allowed";
@ -51,7 +48,6 @@
//saveButton.style.setProperty('border-color', isValid ? "#28a745" : "#ccc", 'important'); //saveButton.style.setProperty('border-color', isValid ? "#28a745" : "#ccc", 'important');
} }
// Function to show error message with SweetAlert2
function showErrorMessage(message) { function showErrorMessage(message) {
Swal.fire({ Swal.fire({
title: "Error", title: "Error",
@ -66,12 +62,10 @@
}); });
} }
// Function to hide error message if JSON is fixed
function hideErrorMessage() { function hideErrorMessage() {
Swal.close(); Swal.close();
} }
// Function to ask the user before saving and save the JSON if confirmed
function saveJson() { function saveJson() {
Swal.fire({ Swal.fire({
title: 'Are you sure?', title: 'Are you sure?',
@ -99,7 +93,6 @@
}); });
} }
// Function to load JSON from the server
function restoreJson() { function restoreJson() {
fetch("{{ url_for('get_file') }}") fetch("{{ url_for('get_file') }}")
.then(response => response.json()) .then(response => response.json())
@ -113,6 +106,6 @@
}); });
} }
restoreJson(); // Initial JSON load restoreJson();
</script> </script>
{% endblock %} {% endblock %}