All Jquery removed replaced with stand JS and non jqery dependent libs

This commit is contained in:
johnnyq
2026-08-14 17:28:06 -04:00
parent 2354dd1511
commit bbbfff7413
35 changed files with 753 additions and 328 deletions

View File

@@ -49,34 +49,48 @@ ob_start();
</form>
<script>
$(document).ready(function(){
document.addEventListener('DOMContentLoaded', function () {
$('#generateAIContent').on('click', function(){
var prompt = $('#aiPrompt').val().trim();
if(prompt === '') {
var button = document.getElementById('generateAIContent');
var promptField = document.getElementById('aiPrompt');
if (!button || !promptField) {
return;
}
button.addEventListener('click', function () {
var prompt = promptField.value.trim();
if (prompt === '') {
alert('Please enter a prompt.');
return;
}
$('#generateAIContent').prop('disabled', true).html('<i class="fa fa-spinner fa-spin"></i> Generating...');
button.disabled = true;
button.innerHTML = '<i class="fa fa-spinner fa-spin"></i> Generating...';
$.ajax({
url: '/agent/ajax.php?ai_create_document_template', // The PHP script that calls the OpenAI API
fetch('/agent/ajax.php?ai_create_document_template', {
method: 'POST',
data: { prompt: prompt },
dataType: 'html',
success: function(response) {
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
credentials: 'same-origin',
body: new URLSearchParams({ prompt: prompt }).toString()
})
.then(function (res) {
if (!res.ok) {
throw new Error('HTTP ' + res.status);
}
return res.text();
})
.then(function (response) {
// Assuming you have exactly one TinyMCE instance on the page
// and it's targeting the .tinymce textarea:
tinymce.activeEditor.setContent(response);
},
error: function() {
})
.catch(function () {
alert('Error generating content. Please try again.');
},
complete: function() {
$('#generateAIContent').prop('disabled', false).html('<i class="fa fa-fw fa-magic me-1"></i>Generate with AI');
}
});
})
.finally(function () {
button.disabled = false;
button.innerHTML = '<i class="fa fa-fw fa-magic me-1"></i>Generate with AI';
});
});
});
</script>

View File

@@ -227,7 +227,7 @@ new Sortable(document.querySelector('table#ticket_templates tbody'), {
order: index
}));
$.post('/agent/ajax.php', {
itflowPostForm('/agent/ajax.php', {
update_project_template_ticket_order: true,
csrf_token: '<?= $_SESSION['csrf_token'] ?>',
project_template_id: <?= $project_template_id ?>,

View File

@@ -145,7 +145,7 @@ new Sortable(document.querySelector('table#tasks tbody'), {
order: index
}));
$.post('/agent/ajax.php', {
itflowPostForm('/agent/ajax.php', {
update_task_templates_order: true,
csrf_token: '<?= $_SESSION['csrf_token'] ?>',
ticket_template_id: <?= $ticket_template_id ?>,