CoreFiles by mySites.guru
helpsite.js57 lines, 1,554 bytes, from Joomla_4.0.0-alpha6-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha5
md5
2abecea4004101952510f43210714bf3
sha1
1d14c8d6c60998d9d2c3cbaa260b881b23032dfb
sha256
b488bd95cb21c2d449cab9e548eba61110b82fc29a65c84dc4bf9fab3ca11fb8
/**
 * @package		Joomla.JavaScript
 * @copyright	Copyright (C) 2005 - 2018 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 3 releases, Joomla 4.0.0-alpha3 to 4.0.0-alpha6. See them all, or every version of this file.