Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/pull/client/src/ |
Upload File : |
/* eslint-disable @bitrix24/bitrix24-rules/no-bx-message */ import { isNotEmptyString } from '../../util/src/util'; export class StorageManager { constructor(params = {}) { this.userId = params.userId ?? (BX.message && BX.message.USER_ID ? BX.message.USER_ID : 0); this.siteId = params.siteId ?? (BX.message && BX.message.SITE_ID ? BX.message.SITE_ID : 'none'); } set(name: string, value: any): void { if (!window.localStorage) { return false; } let encoded = value; if (isNotEmptyString(value)) { encoded = JSON.stringify(value); } return window.localStorage.setItem(this.getKey(name), encoded); } get(name: string, defaultValue: any = null): any { if (!window.localStorage) { return defaultValue; } const result = window.localStorage.getItem(this.getKey(name)); if (result === null) { return defaultValue; } return JSON.parse(result); } remove(name: string): void { if (!window.localStorage) { return; } window.localStorage.removeItem(this.getKey(name)); } getKey(name: string): string { return `bx-pull-${this.userId}-${this.siteId}-${name}`; } compareKey(eventKey, userKey): boolean { return eventKey === this.getKey(userKey); } }