function getTasks() { return ['status-change', 'autorefresh', 'parent-child', 'settings-access', 'activate-user', 'notify-note-unassigned', 'user-manage-notification-settings', 'settings-table', 'verified-emails-table', 'pending-verification-emails-table', 'pending-verification-tickets-table', 'miscellaneous']; } function processUninstallation() { var tasks = getTasks(); //-- Change status column to default HESK values tasks.forEach(function(task) { startUninstallation(task); executeUninstallation(task); }); } function startUninstallation(task) { $('#spinner-'+task) .removeClass('fa-exclamation-triangle') .addClass('fa-spinner') .addClass('fa-pulse'); changeRowTo('row', task, 'info'); changeTextTo('span', task, 'In Progress'); } function changeTextTo(prefix, task, text) { $('#'+prefix+'-'+task).text(text); } function changeRowTo(prefix, task, clazz) { //-- Remove all classes $('#'+prefix+'-'+task) .removeClass('info') .removeClass('warning') .removeClass('danger') .removeClass('success'); //-- Re-add the requested class $('#'+prefix+'-'+task).addClass(clazz); } function executeUninstallation(task) { appendToInstallConsole('INFOStarting task code: ' + task + ''); $.ajax({ type: 'POST', url: 'ajax/uninstall-database-ajax.php', data: { task: task }, success: function(data) { markUninstallAsSuccess(task); checkForCompletion(); }, error: function(data) { if (data.status == 400) { appendToInstallConsole('ERRORThe task '+ task +' was not recognized. Check the value submitted and try again.'); } else { appendToInstallConsole('ERROR'+ data.responseText + ''); } markUninstallAsFailure(task); } }); } function checkForCompletion() { // If all rows have a .success row, installation is finished var numberOfTasks = getTasks().length; var numberOfCompletions = $('tr.success').length; if (numberOfTasks == numberOfCompletions) { uninstallationFinished(); } } function uninstallationFinished() { appendToInstallConsole('SUCCESSUninstallation complete'); var output = '
' + '
' + '

' + '

Awesome! The automated portion of uninstalling Mods for HESK has completed. ' + 'Please follow these instructions ' + 'on the Mods for HESK website to finish uninstallation.

' + '
' + '
'; $('#uninstall-information').html(output); } function markUninstallAsSuccess(task) { removeSpinner(task); $('#spinner-'+task).addClass('fa-check-circle'); changeTextTo('span', task, 'Completed Successfully'); changeRowTo('row', task, 'success'); appendToInstallConsole('SUCCESSUninstall for task code: ' + task + ' complete'); } function markUninstallAsFailure(task) { removeSpinner(task); $('#spinner-'+task).addClass('fa-times-circle'); changeRowTo('row', task, 'danger'); changeTextTo('span', task, 'Uninstall failed! Check the console for more information'); } function removeSpinner(task) { $('#spinner-'+task) .removeClass('fa-pulse') .removeClass('fa-spinner'); } jQuery(document).ready(loadJquery);