CoreFiles by mySites.guru
helpsite.js57 lines, 1,554 bytes, from Joomla_4.0.0-alpha7-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha6
md5
ef5bcb3e6678b4f1b64cb91402c827be
sha1
d4777a76fbb25b0f326aa0e451658b3564f5f1ce
sha256
72cb2cb8f11996c79aa0ea91fbfbdd866a463ffffa54cedf9da789377325d620
/**
 * @package		Joomla.JavaScript
 * @copyright	Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 */

/**
 * Rebuilds the list with the available help sites
 */
"use strict";

var resetHelpSiteList = function() {

	// Uses global variable helpsite_base for bast uri
	var select_id   = this.getAttribute('rel');
	var showDefault = this.getAttribute('showDefault');

	Joomla.request(
		{
			url:    'index.php?option=com_users&task=profile.gethelpsites&format=json',
			method: 'GET',
			data:    '',
			perform: true,
			headers: {'Content-Type': 'application/json;charset=utf-8'},
			onSuccess: function(response, xhr)
			{
				response = JSON.parse(response);

				// The response contains the options to use in help site select field
				var node;

				document.getElementById(select_id).innerHTML = '';

				// Build options
				response.data.forEach(function(item) {
					if (item.value !== '' || showDefault === 'true') {
						node = document.createElement('option');
						node.value = item.value;
						node.innerHTML = item.text;
						document.getElementById(select_id).appendChild(node);
					}
				});
			},
			onError: function(xhr)
			{
				// Remove js messages, if they exist.
				Joomla.removeMessages();

				Joomla.renderMessages(Joomla.ajaxErrorsMessages(xhr));
			}
		}
	);
};

document.addEventListener('DOMContentLoaded', function() {
	document.getElementById('helpsite-refresh').addEventListener('click', resetHelpSiteList);
});

The same content is in 6 releases, Joomla 4.0.0-alpha7 to 4.0.0-alpha12. See them all, or every version of this file.