HEX
Server: LiteSpeed
System: Linux d8 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
User: wbwebdes (3015)
PHP: 8.1.31
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: /home/wbwebdes/domains/files.wb-cloud.nl/private_html/apps/survey_client/js/admin.js
/*
 * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-only
 */
$(document).ready(function() {
	var $section = $('#survey_client');
	$section.find('.survey_client_category').change(function() {
		var $button = $(this);
		$button.attr('disabled', true);

		OCP.AppConfig.setValue(
			'survey_client',
			$(this).attr('name').substring(14),
			$(this).prop('checked') ? 'yes' : 'no',
			{
				success: function() {
					$button.attr('disabled', false);
				}
			}
		);
	});

	$section.find('#survey_client_monthly_report').change(function() {
		var $button = $(this);
		$button.attr('disabled', true);

		$.ajax({
			url: OC.linkToOCS('apps/survey_client/api/v1', 2) + 'monthly?format=json',
			type: $(this).prop('checked') ? 'POST' : 'DELETE',
			success: function() {
				$button.attr('disabled', false);
			}
		});
	});

	$section.find('button').click(function() {
		var $button = $(this);
		$button.attr('disabled', true);
		$.ajax({
			url: OC.linkToOCS('apps/survey_client/api/v1', 2) + 'report?format=json',
			type: 'POST',
			success: function(response) {
				$button.attr('disabled', false);

				$section.find('.last_report').text(JSON.stringify(response.ocs.data, undefined, 4));
				$section.find('.last_sent').text(t('survey_client', 'Last report sent on: {on}', {
					on: moment().format('LL')
				}));
				$section.find('.last_report').closest('div').removeClass('empty');
			},
			error: function(xhr) {
				$button.attr('disabled', false);
				OCP.Toast.error(t('survey_client', 'An error occurred while sending your report.'));

				var response = xhr.responseJSON;
				$section.find('.last_report').text(JSON.stringify(response.ocs.data, undefined, 4));
			}
		});
	});

	$('#last_report h3').on('click', function(e) {
		if (!$(this).parent().hasClass('empty')) {
			$(this).parent().find('p').toggleClass('hidden');
			$(this).find('.icon').toggleClass('icon-triangle-s');
		}
	});
});