function tmst__getRootZone() {
214 if (window.tmst_rootzone) return window.tmst_rootzone; 217 const allRecords = document.getElementById('allrecords'); 220 rootZone = allRecords.getAttribute('data-tilda-root-zone'); 223 return rootZone || 'com'; 226function tmst__setRootZone(rootZone) { 227 window.tmst_rootzone = rootZone; 233 * @returns {string} Токен 235function tmst__getToken() { 236 const emptyUserToken = ''; 237 const allRecords = document.getElementById('allrecords'); 240 const projectId = allRecords.getAttribute('data-tilda-project-id'); 241 const profile = window.localStorage.getItem(`tilda_members_profile${projectId}`); 244 return JSON.parse(profile).token; 246 console.info('Error parsing JSON:', `"${profile}"`, error); 247 return emptyUserToken; 252 return emptyUserToken; 256 * Формирует строку запроса из объекта параметров 258 * @param {Object<string, string|number>} queryParams - Объект с параметрами запроса 259 * @returns {string} Строка запроса 261function tmst__getQueryString(queryParams) { 262 return Object.keys(queryParams) 263 .map(key => `${encodeURIComponent(key)}=${encodeURIComponent(queryParams[key])}`) 268 * Добавляет разрядность числу 270 * @param {number} number 273function tmst__prettifyNumber(number) { 274 return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ' '); 278 * @param {unknown} value 281function tmst__roundMoney(value) { 282 const n = typeof value === 'number' ? value : parseFloat(value); 283 if (!Number.isFinite(n)) return 0; 284 return Math.round(n * 100) / 100; 288 * Параметры десятичного формата из настроек валюты проекта. 289 * `dec`: "" — без дробной части, "0" — один знак, "00" — два, "000" — три. 291 * @typedef {Object} TmstCurrencyFormat 292 * @property {string} [dec] 293 * @property {string} [sep] 294 * @property {string} [tho] 295 * @property {string} [txt] 299 * Форматирует сумму по десятичному формату валюты проекта. 300 * Без `dec` оставляет прежнее поведение: до двух знаков, без хвостовых нулей.