SHA256
CORE/CONTENT test5593 и адаптация UI
This commit is contained in:
@@ -0,0 +1,980 @@
|
||||
import { preparePublicFile } from '../services/file-preparation-service.js';
|
||||
import { formatDateTime, formatNumber } from '../i18n/format.js';
|
||||
import { t, th } from '../i18n/index.js';
|
||||
import {
|
||||
buildArweaveDataUrl,
|
||||
getArweaveUploadPrice,
|
||||
loadArweaveFileMetadata,
|
||||
sha256HexFromArrayBuffer,
|
||||
uploadArweaveFile,
|
||||
validateArweaveTxId,
|
||||
} from '../services/arweave-file-service.js';
|
||||
import { addArweaveWalletSecret, getArweaveBalance, getArweaveWalletChoices } from '../services/arweave-wallet-service.js';
|
||||
import { escapeHtml, formatBytes, normalizeAttachment } from '../services/attachment-format.js';
|
||||
import { getStoredSolanaWalletChoices } from '../services/solana-wallet-service.js';
|
||||
import { iconHtml } from './ui-icon.js';
|
||||
import {
|
||||
estimateTurboUploadPrice,
|
||||
formatTurboCredits,
|
||||
getFreeTurboUploadBytesLimit,
|
||||
getTurboBalanceForStoredSolanaKey,
|
||||
topUpTurboWithSolana,
|
||||
uploadFileWithTurbo,
|
||||
} from '../services/turbo-upload-service.js';
|
||||
|
||||
const HISTORY_KEY = 'shine-ui-arweave-attachment-history-v1';
|
||||
const LAST_WALLET_KEY_PREFIX = 'shine-ui-arweave-last-wallet-v1:';
|
||||
const MAX_HISTORY_ITEMS = 100;
|
||||
const RECENT_UPLOAD_MS = 20 * 60 * 1000;
|
||||
|
||||
function normalizeHistoryItem(input = {}) {
|
||||
const item = normalizeAttachment(input);
|
||||
const placedInShineAtMs = Number(input.placedInShineAtMs || 0) || 0;
|
||||
const purpose = String(input.purpose || '').trim() === 'avatar' ? 'avatar' : 'attachment';
|
||||
return {
|
||||
...item,
|
||||
purpose,
|
||||
pendingPlacement: input.pendingPlacement === true && !placedInShineAtMs,
|
||||
placedInShineAtMs,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
export function readArweaveAttachmentHistory(login) {
|
||||
try {
|
||||
const raw = sessionStorage.getItem(HISTORY_KEY);
|
||||
const parsed = raw ? JSON.parse(raw) : {};
|
||||
const key = String(login || '').trim().toLowerCase();
|
||||
const rows = Array.isArray(parsed?.[key]) ? parsed[key] : [];
|
||||
return rows.map((item) => normalizeHistoryItem(item)).filter(Boolean);
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
export function saveArweaveAttachmentHistory(login, rows) {
|
||||
try {
|
||||
const key = String(login || '').trim().toLowerCase();
|
||||
const raw = sessionStorage.getItem(HISTORY_KEY);
|
||||
const parsed = raw ? JSON.parse(raw) : {};
|
||||
parsed[key] = (Array.isArray(rows) ? rows : [])
|
||||
.map((item) => normalizeHistoryItem(item))
|
||||
.slice(0, MAX_HISTORY_ITEMS);
|
||||
sessionStorage.setItem(HISTORY_KEY, JSON.stringify(parsed));
|
||||
} catch {
|
||||
// ignore sessionStorage errors
|
||||
}
|
||||
}
|
||||
|
||||
export function clearArweaveAttachmentHistory(login) {
|
||||
saveArweaveAttachmentHistory(login, []);
|
||||
}
|
||||
|
||||
export function addArweaveAttachmentToHistory(login, attachment, { pendingPlacement = undefined, markPlaced = false } = {}) {
|
||||
const item = normalizeHistoryItem(attachment);
|
||||
const rows = readArweaveAttachmentHistory(login);
|
||||
const existing = rows.find((row) => row.ar === item.ar) || {};
|
||||
const placedInShineAtMs = markPlaced
|
||||
? Date.now()
|
||||
: Number(existing.placedInShineAtMs || item.placedInShineAtMs || 0) || 0;
|
||||
const nextPendingPlacement = pendingPlacement === undefined
|
||||
? (existing.pendingPlacement === true && !placedInShineAtMs)
|
||||
: (!!pendingPlacement && !placedInShineAtMs);
|
||||
const nextItem = {
|
||||
...item,
|
||||
pendingPlacement: nextPendingPlacement,
|
||||
placedInShineAtMs,
|
||||
};
|
||||
const nextRows = rows.filter((row) => row.ar !== item.ar);
|
||||
nextRows.unshift(nextItem);
|
||||
saveArweaveAttachmentHistory(login, nextRows);
|
||||
return nextItem;
|
||||
}
|
||||
|
||||
export function markArweaveAttachmentPlaced(login, attachment) {
|
||||
const item = normalizeHistoryItem(attachment);
|
||||
const rows = readArweaveAttachmentHistory(login);
|
||||
const existing = rows.find((row) => row.ar === item.ar) || {};
|
||||
const nextItem = {
|
||||
...item,
|
||||
uploadedAtMs: item.uploadedAtMs || existing.uploadedAtMs || Date.now(),
|
||||
pendingPlacement: false,
|
||||
placedInShineAtMs: Number(existing.placedInShineAtMs || 0) || Date.now(),
|
||||
};
|
||||
const nextRows = rows.filter((row) => row.ar !== item.ar);
|
||||
nextRows.unshift(nextItem);
|
||||
saveArweaveAttachmentHistory(login, nextRows);
|
||||
return nextItem;
|
||||
}
|
||||
|
||||
export function formatArweaveHistoryTime(ms) {
|
||||
const value = Number(ms || 0);
|
||||
if (!Number.isFinite(value) || value <= 0) return '–';
|
||||
const diffMs = Date.now() - value;
|
||||
if (diffMs >= 0 && diffMs < RECENT_UPLOAD_MS) {
|
||||
const minutes = Math.max(1, Math.floor(diffMs / 60000));
|
||||
return t('screens.arweave_attachment_manager.text_065', { value1: minutes });
|
||||
}
|
||||
return formatDateTime(new Date(value));
|
||||
}
|
||||
|
||||
export function formatArweaveHistoryDateTime(ms) {
|
||||
const value = Number(ms || 0);
|
||||
if (!Number.isFinite(value) || value <= 0) return '–';
|
||||
return formatDateTime(new Date(value));
|
||||
}
|
||||
|
||||
export async function getArweaveAttachmentAvailability({ gateway, attachment } = {}) {
|
||||
const item = normalizeAttachment(attachment);
|
||||
const url = buildArweaveDataUrl({ gateway, txId: item.ar });
|
||||
try {
|
||||
const response = await fetch(url, { method: 'HEAD', cache: 'no-store' });
|
||||
if (response.ok) return { status: 'available', label: t('screens.arweave_attachment_manager.text_001'), url };
|
||||
} catch {
|
||||
// gateway может временно не отвечать или блокировать HEAD; для UI это всё равно недоступно.
|
||||
}
|
||||
const ageMs = Date.now() - Number(item.uploadedAtMs || 0);
|
||||
if (Number.isFinite(ageMs) && ageMs >= 0 && ageMs < RECENT_UPLOAD_MS) {
|
||||
return { status: 'pending', label: t('screens.arweave_attachment_manager.text_002'), url };
|
||||
}
|
||||
return { status: 'unavailable', label: t('screens.arweave_attachment_manager.text_003'), url };
|
||||
}
|
||||
|
||||
function setText(node, text) {
|
||||
if (node) node.textContent = String(text || '');
|
||||
}
|
||||
|
||||
function shortAddress(value) {
|
||||
const raw = String(value || '').trim();
|
||||
if (raw.length <= 16) return raw;
|
||||
return `${raw.slice(0, 8)}...${raw.slice(-6)}`;
|
||||
}
|
||||
|
||||
function lastWalletStorageKey(login) {
|
||||
return `${LAST_WALLET_KEY_PREFIX}${String(login || '').trim().toLowerCase() || 'anonymous'}`;
|
||||
}
|
||||
|
||||
function readLastWalletId(login) {
|
||||
try {
|
||||
return sessionStorage.getItem(lastWalletStorageKey(login)) || '';
|
||||
} catch {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
function writeLastWalletId(login, walletId) {
|
||||
try {
|
||||
const clean = String(walletId || '').trim();
|
||||
if (clean) sessionStorage.setItem(lastWalletStorageKey(login), clean);
|
||||
} catch {
|
||||
// Если sessionStorage недоступен, выбор сохраняется хотя бы в текущем окне менеджера.
|
||||
}
|
||||
}
|
||||
|
||||
export async function prepareAvatarImageFile(file) {
|
||||
const source = file instanceof File ? file : null;
|
||||
if (!source) throw new Error(t('screens.arweave_attachment_manager.text_045'));
|
||||
const dataUrl = await new Promise((resolve, reject) => {
|
||||
const reader = new FileReader();
|
||||
reader.onload = () => resolve(String(reader.result || ''));
|
||||
reader.onerror = () => reject(new Error(t('screens.arweave_attachment_manager.text_046')));
|
||||
reader.readAsDataURL(source);
|
||||
});
|
||||
const image = await new Promise((resolve, reject) => {
|
||||
const img = new Image();
|
||||
img.onload = () => resolve(img);
|
||||
img.onerror = () => reject(new Error(t('screens.arweave_attachment_manager.text_047')));
|
||||
img.src = dataUrl;
|
||||
});
|
||||
const side = Math.min(image.naturalWidth || image.width, image.naturalHeight || image.height);
|
||||
if (!side || side <= 0) throw new Error(t('screens.arweave_attachment_manager.text_048'));
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.width = 512;
|
||||
canvas.height = 512;
|
||||
const ctx = canvas.getContext('2d');
|
||||
if (!ctx) throw new Error(t('screens.arweave_attachment_manager.text_049'));
|
||||
const sx = Math.max(0, ((image.naturalWidth || image.width) - side) / 2);
|
||||
const sy = Math.max(0, ((image.naturalHeight || image.height) - side) / 2);
|
||||
ctx.drawImage(image, sx, sy, side, side, 0, 0, 512, 512);
|
||||
const blob = await new Promise((resolve) => canvas.toBlob(resolve, 'image/jpeg', 0.9));
|
||||
if (!blob) throw new Error(t('screens.arweave_attachment_manager.text_050'));
|
||||
return new File([blob], 'avatar.jpg', { type: 'image/jpeg', lastModified: Date.now() });
|
||||
}
|
||||
|
||||
export function openArweaveAttachmentManager({
|
||||
login,
|
||||
storagePwd,
|
||||
gateway,
|
||||
onSelect,
|
||||
selectedTxIds = [],
|
||||
historyOnly = false,
|
||||
persistToHistory = true,
|
||||
allowHistorySelection = true,
|
||||
allowExistingTxInput = true,
|
||||
mode = 'attachment',
|
||||
historyPurpose = '',
|
||||
uploadTransport = 'turbo',
|
||||
turboKeySource = 'blockchain',
|
||||
dialogTitle = '',
|
||||
uploadButtonLabel = '',
|
||||
initialFile = null,
|
||||
initialSha256 = '',
|
||||
initialName = '',
|
||||
fixedFile = false,
|
||||
autoOpenFileDialog = false,
|
||||
shineType = '',
|
||||
extraUploadTags = [],
|
||||
signal = null,
|
||||
hostElement = null,
|
||||
embedded = false,
|
||||
} = {}) {
|
||||
const cleanLogin = String(login || '').trim();
|
||||
const cleanStoragePwd = String(storagePwd || '').trim();
|
||||
const cleanGateway = String(gateway || 'https://arweave.net').trim();
|
||||
if (!cleanLogin || !cleanStoragePwd) return Promise.reject(new Error(t('screens.arweave_attachment_manager.text_051')));
|
||||
|
||||
const embeddedHost = hostElement instanceof HTMLElement ? hostElement : null;
|
||||
const isEmbedded = Boolean(embeddedHost || embedded);
|
||||
const root = embeddedHost || document.createElement('div');
|
||||
if (!embeddedHost) {
|
||||
root.className = 'ar-attachment-manager-root';
|
||||
document.body.append(root);
|
||||
} else {
|
||||
root.classList.add('ar-attachment-manager-embedded-root');
|
||||
}
|
||||
|
||||
let closed = false;
|
||||
let wallets = [];
|
||||
let turboKeyChoices = [];
|
||||
let selectedWalletId = readLastWalletId(cleanLogin) || 'derived-blockchain-key';
|
||||
const selectedTurboKeySource = 'blockchain';
|
||||
let selectedUploadTransport = String(uploadTransport || '').trim().toLowerCase() === 'arweave' ? 'arweave' : 'turbo';
|
||||
let selectedFile = null;
|
||||
let selectedSha256 = '';
|
||||
let selectedPrepared = null;
|
||||
let priceInfo = null;
|
||||
let balanceInfo = null;
|
||||
let autoOpenedFileDialogOnce = false;
|
||||
const isAvatarMode = String(mode || '') === 'avatar';
|
||||
if (isAvatarMode && !String(uploadTransport || '').trim()) {
|
||||
selectedUploadTransport = 'turbo';
|
||||
}
|
||||
const historyPurposeMode = String(historyPurpose || '').trim();
|
||||
const purposeFilter = isAvatarMode || historyPurposeMode === 'avatar' ? 'avatar' : 'attachment';
|
||||
const selectedTxIdSet = new Set((Array.isArray(selectedTxIds) ? selectedTxIds : []).map((item) => String(item || '').trim()).filter(Boolean));
|
||||
const effectiveDialogTitle = String(dialogTitle || '').trim();
|
||||
const effectiveUploadButtonLabel = String(uploadButtonLabel || '').trim();
|
||||
const forcedShineType = String(shineType || '').trim();
|
||||
const normalizedExtraUploadTags = Array.isArray(extraUploadTags)
|
||||
? extraUploadTags.filter((item) => item?.name && item?.value)
|
||||
: [];
|
||||
if (initialFile instanceof File) {
|
||||
selectedFile = initialFile;
|
||||
if (initialSha256) selectedSha256 = String(initialSha256 || '').trim().toLowerCase();
|
||||
}
|
||||
|
||||
function isTurboUpload() {
|
||||
return selectedUploadTransport === 'turbo';
|
||||
}
|
||||
|
||||
function selectedWallet() {
|
||||
return wallets.find((item) => String(item.id) === String(selectedWalletId)) || wallets[0] || null;
|
||||
}
|
||||
|
||||
function close(resolve, result = null) {
|
||||
if (closed) return;
|
||||
closed = true;
|
||||
if (embeddedHost) root.replaceChildren();
|
||||
else root.remove();
|
||||
resolve(result);
|
||||
}
|
||||
|
||||
function finish(resolve, attachment, { pendingPlacement = undefined } = {}) {
|
||||
if (closed) return;
|
||||
const item = persistToHistory
|
||||
? addArweaveAttachmentToHistory(cleanLogin, attachment, {
|
||||
pendingPlacement,
|
||||
markPlaced: false,
|
||||
})
|
||||
: {
|
||||
...attachment,
|
||||
...normalizeAttachment(attachment),
|
||||
};
|
||||
if (!pendingPlacement && typeof onSelect === 'function') onSelect(item);
|
||||
close(resolve, item);
|
||||
}
|
||||
|
||||
return new Promise((resolve) => {
|
||||
const onAbort = () => close(resolve, null);
|
||||
if (signal?.aborted) { onAbort(); return; }
|
||||
signal?.addEventListener('abort', onAbort, { once: true });
|
||||
const shellOpen = (extraClass = '') => isEmbedded
|
||||
? `<div class="stack ar-attachment-manager-card ar-attachment-manager-card--embedded ${extraClass}">`
|
||||
: `<div class="modal" data-ar-attach-modal="true"><div class="modal-card stack ar-attachment-manager-card ${extraClass}">`;
|
||||
const shellClose = () => isEmbedded ? '</div>' : '</div></div>';
|
||||
const bindBackdrop = () => {
|
||||
if (isEmbedded) return;
|
||||
const modal = root.querySelector('[data-ar-attach-modal="true"]');
|
||||
modal?.addEventListener('click', (event) => {
|
||||
if (event.target === modal) close(resolve, null);
|
||||
});
|
||||
};
|
||||
|
||||
const renderWalletOptions = () => wallets.map((wallet) => (
|
||||
`<option value="${escapeHtml(wallet.id)}">${escapeHtml(wallet.isDefault ? t('screens.arweave_attachment_manager.text_013') : wallet.label)} · ${escapeHtml(shortAddress(wallet.address))}</option>`
|
||||
)).join('');
|
||||
|
||||
const loadWallets = async (errorEl = null) => {
|
||||
try {
|
||||
wallets = await getArweaveWalletChoices({ login: cleanLogin, storagePwd: cleanStoragePwd });
|
||||
if (!wallets.some((item) => String(item.id) === String(selectedWalletId))) {
|
||||
selectedWalletId = String(wallets[0]?.id || 'derived-blockchain-key');
|
||||
}
|
||||
writeLastWalletId(cleanLogin, selectedWalletId);
|
||||
} catch (error) {
|
||||
setText(errorEl, error?.message || t('screens.arweave_attachment_manager.text_052'));
|
||||
}
|
||||
};
|
||||
|
||||
const loadTurboKeyChoices = async (errorEl = null) => {
|
||||
try {
|
||||
turboKeyChoices = await getStoredSolanaWalletChoices({
|
||||
login: cleanLogin,
|
||||
storagePwd: cleanStoragePwd,
|
||||
});
|
||||
if (!turboKeyChoices.some((item) => String(item.keySource) === 'blockchain')) {
|
||||
throw new Error(t('screens.arweave_attachment_manager.text_053'));
|
||||
}
|
||||
} catch (error) {
|
||||
setText(errorEl, error?.message || t('screens.arweave_attachment_manager.text_054'));
|
||||
}
|
||||
};
|
||||
|
||||
const updateBalanceButton = () => {
|
||||
const button = root.querySelector('[data-action="check-balance"]');
|
||||
if (!button) return;
|
||||
if (isTurboUpload()) {
|
||||
button.textContent = balanceInfo
|
||||
? t('screens.arweave_attachment_manager.text_066', { value1: formatTurboCredits(balanceInfo.effectiveCredits, 6) })
|
||||
: t('screens.arweave_attachment_manager.text_014');
|
||||
return;
|
||||
}
|
||||
button.textContent = balanceInfo
|
||||
? t('screens.arweave_attachment_manager.text_067', { value1: formatNumber(Number(balanceInfo.ar || 0), { maximumFractionDigits: 6 }) })
|
||||
: t('screens.arweave_attachment_manager.text_015');
|
||||
};
|
||||
|
||||
const renderTurboMeta = (mainMetaEl) => {
|
||||
updateBalanceButton();
|
||||
if (!mainMetaEl) return;
|
||||
if (!selectedFile) {
|
||||
mainMetaEl.innerHTML = '';
|
||||
return;
|
||||
}
|
||||
const uploadPrice = priceInfo ? `${formatTurboCredits(priceInfo.credits, 6)} credits` : '';
|
||||
const fileSize = formatBytes(selectedFile.size);
|
||||
const isFreeSize = Number(selectedFile.size || 0) <= getFreeTurboUploadBytesLimit();
|
||||
mainMetaEl.innerHTML = `
|
||||
<div class="ar-attachment-summary">${th('remaining.file_upload.size')}${escapeHtml(fileSize)} · ${isFreeSize
|
||||
? t('screens.arweave_attachment_manager.text_016')
|
||||
: (uploadPrice ? t('screens.arweave_attachment_manager.text_068', { value1: escapeHtml(uploadPrice) }) : t('screens.arweave_attachment_manager.text_017'))}</div>
|
||||
<details class="ar-attachment-details">
|
||||
<summary>${th('screens.arweave_attachment_manager.text_070')}</summary>
|
||||
<div>SHA-256: ${escapeHtml(selectedSha256 || '–')}</div>
|
||||
${uploadPrice ? `<div>${th('remaining.file_upload.turbo_price')}${escapeHtml(uploadPrice)}</div>` : ''}
|
||||
<div>${th('remaining.file_upload.free_up_to')}${escapeHtml(formatBytes(getFreeTurboUploadBytesLimit()))}</div>
|
||||
</details>
|
||||
`;
|
||||
};
|
||||
|
||||
const refreshTurboBalance = async (mainMetaEl, errorEl) => {
|
||||
try {
|
||||
balanceInfo = await getTurboBalanceForStoredSolanaKey({
|
||||
login: cleanLogin,
|
||||
storagePwd: cleanStoragePwd,
|
||||
keySource: selectedTurboKeySource,
|
||||
});
|
||||
renderTurboMeta(mainMetaEl);
|
||||
if (errorEl && String(errorEl.textContent || '').includes('Turbo balance')) {
|
||||
setText(errorEl, '');
|
||||
}
|
||||
} catch (error) {
|
||||
setText(errorEl, error?.message || t('screens.arweave_attachment_manager.text_055'));
|
||||
}
|
||||
};
|
||||
|
||||
const promptTurboTopUp = async (mainMetaEl, errorEl) => {
|
||||
await refreshTurboBalance(mainMetaEl, errorEl);
|
||||
const previous = document.getElementById('turbo-topup-modal');
|
||||
previous?.remove();
|
||||
const overlay = document.createElement('div');
|
||||
overlay.id = 'turbo-topup-modal';
|
||||
overlay.className = 'modal ar-balance-modal';
|
||||
const sol = String(balanceInfo?.solBalance ?? '–');
|
||||
const credits = balanceInfo ? formatTurboCredits(balanceInfo.effectiveCredits, 6) : '–';
|
||||
const address = String(balanceInfo?.address || '').trim();
|
||||
overlay.innerHTML = `
|
||||
<div class="modal-card stack ar-balance-modal__card" role="dialog" aria-modal="true">
|
||||
<h3 class="modal-title">${t('dialogs.modals.arweave_attachment_manager.label_001')}</h3>
|
||||
<p class="ar-attachment-note">${t('dialogs.modals.arweave_attachment_manager.label_002')}</p>
|
||||
<div class="ar-balance-grid">
|
||||
<div><span>${t('dialogs.modals.arweave_attachment_manager.label_003')}</span><strong>${escapeHtml(shortAddress(address || '–'))}</strong></div>
|
||||
<div><span>${t('dialogs.modals.arweave_attachment_manager.label_004')}</span><strong>${escapeHtml(sol)} SOL</strong></div>
|
||||
<div><span>${t('dialogs.modals.arweave_attachment_manager.label_005')}</span><strong>${escapeHtml(credits)}</strong></div>
|
||||
</div>
|
||||
<label class="form-field"><span>${t('dialogs.modals.arweave_attachment_manager.label_006')}</span><input class="input" data-role="amount" inputmode="decimal" value="0.01" /></label>
|
||||
<p class="inline-error" data-role="topup-error"></p>
|
||||
<div class="form-actions-grid">
|
||||
<button class="secondary-btn" type="button" data-action="cancel">${t('dialogs.modals.arweave_attachment_manager.label_007')}</button>
|
||||
<button class="primary-btn" type="button" data-action="confirm">${t('dialogs.modals.arweave_attachment_manager.label_008')}</button>
|
||||
</div>
|
||||
</div>`;
|
||||
document.body.append(overlay);
|
||||
await new Promise((done) => {
|
||||
const finish = () => { overlay.remove(); done(); };
|
||||
overlay.querySelector('[data-action="cancel"]')?.addEventListener('click', finish);
|
||||
overlay.addEventListener('click', (event) => { if (event.target === overlay) finish(); });
|
||||
overlay.querySelector('[data-action="confirm"]')?.addEventListener('click', async () => {
|
||||
const amount = String(overlay.querySelector('[data-role="amount"]')?.value || '').trim();
|
||||
const localError = overlay.querySelector('[data-role="topup-error"]');
|
||||
const btn = overlay.querySelector('[data-action="confirm"]');
|
||||
if (btn) btn.disabled = true;
|
||||
setText(localError, t('screens.arweave_attachment_manager.text_004'));
|
||||
try {
|
||||
const result = await topUpTurboWithSolana({
|
||||
login: cleanLogin,
|
||||
storagePwd: cleanStoragePwd,
|
||||
keySource: selectedTurboKeySource,
|
||||
amountSol: amount,
|
||||
});
|
||||
await refreshTurboBalance(mainMetaEl, errorEl);
|
||||
setText(errorEl, t('screens.arweave_attachment_manager.text_069', { value1: result.txId || t('screens.arweave_attachment_manager.text_056') }));
|
||||
finish();
|
||||
} catch (error) {
|
||||
setText(localError, error?.message || t('screens.arweave_attachment_manager.text_057'));
|
||||
if (btn) btn.disabled = false;
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const showArweaveTopUp = async (mainMetaEl, errorEl) => {
|
||||
const wallet = selectedWallet();
|
||||
if (!wallet?.address) {
|
||||
setText(errorEl, t('screens.arweave_attachment_manager.text_005'));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
balanceInfo = await getArweaveBalance({ gateway: cleanGateway, address: wallet.address });
|
||||
renderArweaveMeta(mainMetaEl);
|
||||
} catch {
|
||||
// Адрес всё равно можно показать для пополнения.
|
||||
}
|
||||
const previous = document.getElementById('arweave-topup-modal');
|
||||
previous?.remove();
|
||||
const overlay = document.createElement('div');
|
||||
overlay.id = 'arweave-topup-modal';
|
||||
overlay.className = 'modal ar-balance-modal';
|
||||
overlay.innerHTML = `
|
||||
<div class="modal-card stack ar-balance-modal__card" role="dialog" aria-modal="true">
|
||||
<h3 class="modal-title">${t('dialogs.modals.arweave_attachment_manager.label_009')}</h3>
|
||||
<p class="ar-attachment-note">${t('dialogs.modals.arweave_attachment_manager.label_010')}</p>
|
||||
<div class="ar-wallet-address" data-role="address">${escapeHtml(wallet.address)}</div>
|
||||
<div class="ar-balance-grid"><div><span>${t('dialogs.modals.arweave_attachment_manager.label_011')}</span><strong>${escapeHtml(formatNumber(Number(balanceInfo?.ar || 0), { maximumFractionDigits: 6 }))} AR</strong></div></div>
|
||||
<div class="form-actions-grid">
|
||||
<button class="secondary-btn" type="button" data-action="copy">${t('dialogs.modals.arweave_attachment_manager.label_012')}</button>
|
||||
<button class="primary-btn" type="button" data-action="close">${t('dialogs.modals.arweave_attachment_manager.label_013')}</button>
|
||||
</div>
|
||||
</div>`;
|
||||
document.body.append(overlay);
|
||||
overlay.querySelector('[data-action="copy"]')?.addEventListener('click', async () => {
|
||||
try { await navigator.clipboard.writeText(wallet.address); } catch { /* ignore */ }
|
||||
});
|
||||
const closeOverlay = () => overlay.remove();
|
||||
overlay.querySelector('[data-action="close"]')?.addEventListener('click', closeOverlay);
|
||||
overlay.addEventListener('click', (event) => { if (event.target === overlay) closeOverlay(); });
|
||||
};
|
||||
|
||||
const renderArweaveMeta = (mainMetaEl) => {
|
||||
updateBalanceButton();
|
||||
if (!mainMetaEl) return;
|
||||
if (!selectedFile) {
|
||||
mainMetaEl.innerHTML = '';
|
||||
return;
|
||||
}
|
||||
mainMetaEl.innerHTML = `
|
||||
${isAvatarMode ? '' : `<div>${th('remaining.file_upload.name')}${escapeHtml(selectedFile.name || 'file')}</div>`}
|
||||
<div>${th('remaining.file_upload.size_label')}${escapeHtml(formatBytes(selectedFile.size || 0))}</div>
|
||||
<div>SHA-256: ${escapeHtml(selectedSha256 || '–')}</div>
|
||||
${priceInfo ? `<div>${th('remaining.file_upload.price')}${escapeHtml(formatNumber(Number(priceInfo.ar || 0), { maximumFractionDigits: 6 }))} AR</div>` : ''}
|
||||
`;
|
||||
};
|
||||
|
||||
const recalculateArweaveState = async (mainMetaEl, errorEl, uploadBtn) => {
|
||||
uploadBtn.disabled = true;
|
||||
priceInfo = null;
|
||||
balanceInfo = null;
|
||||
setText(errorEl, '');
|
||||
if (!selectedFile || !selectedSha256) {
|
||||
setText(mainMetaEl, '');
|
||||
return;
|
||||
}
|
||||
const wallet = selectedWallet();
|
||||
if (!wallet?.address) throw new Error(t('screens.arweave_attachment_manager.text_058'));
|
||||
const mainPrice = await getArweaveUploadPrice({ gateway: cleanGateway, byteLength: selectedFile.size });
|
||||
const totalWinston = BigInt(mainPrice.winston);
|
||||
balanceInfo = await getArweaveBalance({ gateway: cleanGateway, address: wallet.address });
|
||||
priceInfo = {
|
||||
ar: Number(totalWinston) / 1e12,
|
||||
winston: totalWinston.toString(),
|
||||
};
|
||||
renderArweaveMeta(mainMetaEl);
|
||||
const hasFunds = BigInt(balanceInfo.winston) >= totalWinston;
|
||||
if (!hasFunds) {
|
||||
setText(errorEl, t('screens.arweave_attachment_manager.text_006'));
|
||||
return;
|
||||
}
|
||||
uploadBtn.disabled = false;
|
||||
};
|
||||
|
||||
const refreshTurboStateForCurrentFile = async (mainMetaEl, errorEl, uploadBtn) => {
|
||||
uploadBtn.disabled = true;
|
||||
priceInfo = null;
|
||||
balanceInfo = null;
|
||||
setText(errorEl, '');
|
||||
if (!selectedFile || !selectedSha256) {
|
||||
renderTurboMeta(mainMetaEl);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const mainPrice = await estimateTurboUploadPrice({
|
||||
login: cleanLogin,
|
||||
storagePwd: cleanStoragePwd,
|
||||
keySource: selectedTurboKeySource,
|
||||
byteLength: selectedFile.size,
|
||||
});
|
||||
const totalWinc = BigInt(mainPrice.winc);
|
||||
priceInfo = {
|
||||
...mainPrice,
|
||||
byteLength: Number(selectedFile.size || 0),
|
||||
isFree: Number(selectedFile.size || 0) <= getFreeTurboUploadBytesLimit(),
|
||||
winc: totalWinc.toString(),
|
||||
credits: Number(totalWinc) / 1_000_000_000_000,
|
||||
};
|
||||
balanceInfo = await getTurboBalanceForStoredSolanaKey({
|
||||
login: cleanLogin,
|
||||
storagePwd: cleanStoragePwd,
|
||||
keySource: selectedTurboKeySource,
|
||||
});
|
||||
renderTurboMeta(mainMetaEl);
|
||||
if (!priceInfo.isFree && BigInt(balanceInfo.effectiveWinc) < BigInt(priceInfo.winc)) {
|
||||
setText(errorEl, t('screens.arweave_attachment_manager.text_007'));
|
||||
return;
|
||||
}
|
||||
uploadBtn.disabled = false;
|
||||
} catch (error) {
|
||||
setText(errorEl, error?.message || t('screens.arweave_attachment_manager.text_059'));
|
||||
}
|
||||
};
|
||||
|
||||
const showUpload = async () => {
|
||||
const turboMode = isTurboUpload();
|
||||
const titleText = effectiveDialogTitle
|
||||
|| (isAvatarMode ? t('screens.arweave_attachment_manager.text_018') : (historyOnly ? t('screens.arweave_attachment_manager.text_019') : t('screens.arweave_attachment_manager.text_020')));
|
||||
const uploadText = effectiveUploadButtonLabel || (historyOnly ? t('screens.arweave_attachment_manager.text_021') : t('screens.arweave_attachment_manager.text_022'));
|
||||
const canShowHistory = allowHistorySelection;
|
||||
const canShowExisting = allowExistingTxInput;
|
||||
root.innerHTML = `${shellOpen()}
|
||||
${isEmbedded ? '' : `<div class="ar-attachment-manager-head">
|
||||
<h3 class="modal-title">${escapeHtml(titleText)}</h3>
|
||||
<button class="icon-btn ar-attachment-manager-close" type="button" data-action="cancel" aria-label="${t('dialogs.remaining.components.arweave_attachment_manager.markup.zakryt')}">${iconHtml('close')}</button>
|
||||
</div>`}
|
||||
<div class="tabs tabs--auto" role="radiogroup" aria-label="${t('dialogs.remaining.components.arweave_attachment_manager.markup.sposob_zagruzki')}">
|
||||
<button class="tab-btn" role="radio" aria-checked="${turboMode}" type="button" data-action="switch-turbo">Turbo</button>
|
||||
<button class="tab-btn" role="radio" aria-checked="${!turboMode}" type="button" data-action="switch-arweave">${t('dialogs.remaining.components.arweave_attachment_manager.markup.napryamuyu_v_arweave')}</button>
|
||||
</div>
|
||||
${turboMode
|
||||
? `
|
||||
<p class="ar-attachment-note"><strong>Turbo</strong> ${th('screens.arweave_attachment_manager.text_071')}</p>
|
||||
`
|
||||
: `
|
||||
<div class="form-field">
|
||||
<label for="ar-attach-wallet">${th('screens.arweave_attachment_manager.text_072')}</label>
|
||||
<select class="select ar-attachment-wallet-select" id="ar-attach-wallet"></select>
|
||||
<button class="text-btn ar-attachment-link" type="button" data-action="add-wallet">${th('screens.arweave_attachment_manager.text_073')}</button>
|
||||
</div>
|
||||
<p class="ar-attachment-note">${th('screens.arweave_attachment_manager.text_074')}</p>${isAvatarMode ? t('screens.arweave_attachment_manager.text_023') : ''}
|
||||
`}
|
||||
${canShowHistory || canShowExisting ? `
|
||||
<div class="ar-attachment-alt-sources">
|
||||
${canShowHistory ? `<button class="text-btn ar-attachment-link" type="button" data-action="history-top">${isAvatarMode ? t('screens.arweave_attachment_manager.text_024') : t('screens.arweave_attachment_manager.text_025')}</button>` : ''}
|
||||
${canShowExisting ? `<button class="text-btn ar-attachment-link" type="button" data-action="existing-top">${isAvatarMode ? t('screens.arweave_attachment_manager.text_026') : t('screens.arweave_attachment_manager.text_027')}</button>` : ''}
|
||||
</div>` : ''}
|
||||
${fixedFile ? '' : `<label class="ar-attachment-file-picker">
|
||||
<input class="ar-attachment-file-input" id="ar-attach-file" type="file" ${isAvatarMode ? 'accept="image/*"' : ''} />
|
||||
<span class="ar-attachment-file-btn">${th('screens.arweave_attachment_manager.text_075')}</span>
|
||||
<span class="ar-attachment-file-name" data-file-name="true">${th('screens.arweave_attachment_manager.text_076')}</span>
|
||||
</label>`}
|
||||
<div class="ar-attachment-meta" data-meta-main="true"></div>
|
||||
<p class="meta-muted inline-error" data-error="true"></p>
|
||||
<div class="form-actions-grid">
|
||||
${turboMode ? t('screens.arweave_attachment_manager.text_028') : t('screens.arweave_attachment_manager.text_029')}
|
||||
<button class="primary-btn" type="button" data-action="upload" disabled>${escapeHtml(uploadText)}</button>
|
||||
</div>
|
||||
${shellClose()}
|
||||
`;
|
||||
bindBackdrop();
|
||||
const walletEl = root.querySelector('#ar-attach-wallet');
|
||||
const fileEl = root.querySelector('#ar-attach-file');
|
||||
const mainMetaEl = root.querySelector('[data-meta-main="true"]');
|
||||
const errorEl = root.querySelector('[data-error="true"]');
|
||||
const uploadBtn = root.querySelector('[data-action="upload"]');
|
||||
|
||||
root.querySelector('[data-action="switch-arweave"]')?.addEventListener('click', async () => {
|
||||
if (selectedUploadTransport === 'arweave') return;
|
||||
selectedUploadTransport = 'arweave';
|
||||
selectedFile = null;
|
||||
selectedSha256 = '';
|
||||
selectedPrepared = null;
|
||||
priceInfo = null;
|
||||
balanceInfo = null;
|
||||
await showUpload();
|
||||
});
|
||||
root.querySelector('[data-action="switch-turbo"]')?.addEventListener('click', async () => {
|
||||
if (selectedUploadTransport === 'turbo') return;
|
||||
selectedUploadTransport = 'turbo';
|
||||
selectedFile = null;
|
||||
selectedSha256 = '';
|
||||
selectedPrepared = null;
|
||||
priceInfo = null;
|
||||
balanceInfo = null;
|
||||
await showUpload();
|
||||
});
|
||||
root.querySelector('[data-action="history-top"]')?.addEventListener('click', showHistory);
|
||||
root.querySelector('[data-action="existing-top"]')?.addEventListener('click', showExisting);
|
||||
|
||||
if (turboMode) {
|
||||
await loadTurboKeyChoices(errorEl);
|
||||
await refreshTurboStateForCurrentFile(mainMetaEl, errorEl, uploadBtn);
|
||||
} else {
|
||||
await loadWallets(errorEl);
|
||||
if (walletEl) {
|
||||
walletEl.innerHTML = renderWalletOptions();
|
||||
walletEl.value = selectedWalletId;
|
||||
walletEl.addEventListener('change', () => {
|
||||
selectedWalletId = String(walletEl.value || '');
|
||||
writeLastWalletId(cleanLogin, selectedWalletId);
|
||||
uploadBtn.disabled = true;
|
||||
selectedFile = null;
|
||||
selectedSha256 = '';
|
||||
priceInfo = null;
|
||||
balanceInfo = null;
|
||||
if (fileEl) fileEl.value = '';
|
||||
setText(mainMetaEl, '');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
root.querySelectorAll('[data-action="cancel"]').forEach((btn) => btn.addEventListener('click', () => close(resolve, null)));
|
||||
root.querySelector('[data-action="topup"]')?.addEventListener('click', async () => {
|
||||
await promptTurboTopUp(mainMetaEl, errorEl);
|
||||
if (turboMode && selectedFile && selectedSha256) {
|
||||
await refreshTurboStateForCurrentFile(mainMetaEl, errorEl, uploadBtn);
|
||||
}
|
||||
});
|
||||
root.querySelector('[data-action="check-balance"]')?.addEventListener('click', async () => {
|
||||
if (turboMode) {
|
||||
await refreshTurboBalance(mainMetaEl, errorEl);
|
||||
if (selectedFile && selectedSha256) await refreshTurboStateForCurrentFile(mainMetaEl, errorEl, uploadBtn);
|
||||
} else {
|
||||
const wallet = selectedWallet();
|
||||
if (!wallet?.address) { setText(errorEl, t('screens.arweave_attachment_manager.text_008')); return; }
|
||||
try {
|
||||
balanceInfo = await getArweaveBalance({ gateway: cleanGateway, address: wallet.address });
|
||||
renderArweaveMeta(mainMetaEl);
|
||||
setText(errorEl, '');
|
||||
} catch (error) {
|
||||
setText(errorEl, error?.message || t('screens.arweave_attachment_manager.text_060'));
|
||||
}
|
||||
}
|
||||
});
|
||||
root.querySelector('[data-action="arweave-topup"]')?.addEventListener('click', async () => {
|
||||
await showArweaveTopUp(mainMetaEl, errorEl);
|
||||
});
|
||||
if (!turboMode) {
|
||||
root.querySelector('[data-action="add-wallet"]')?.addEventListener('click', showAddWallet);
|
||||
}
|
||||
|
||||
fileEl?.addEventListener('change', () => {
|
||||
const nameEl = root.querySelector('[data-file-name="true"]');
|
||||
if (nameEl) nameEl.textContent = fileEl.files?.[0]?.name || t('dialogs.modals.arweave_attachment_manager.label_014');
|
||||
});
|
||||
fileEl?.addEventListener('change', async () => {
|
||||
selectedFile = fileEl.files?.[0] || null;
|
||||
selectedSha256 = '';
|
||||
selectedPrepared = null;
|
||||
priceInfo = null;
|
||||
balanceInfo = null;
|
||||
uploadBtn.disabled = true;
|
||||
setText(errorEl, '');
|
||||
setText(mainMetaEl, '');
|
||||
if (!selectedFile) return;
|
||||
|
||||
try {
|
||||
if (isAvatarMode && !String(selectedFile.type || '').startsWith('image/')) {
|
||||
throw new Error(t('screens.arweave_attachment_manager.text_061'));
|
||||
}
|
||||
if (isAvatarMode) {
|
||||
selectedFile = await prepareAvatarImageFile(selectedFile);
|
||||
}
|
||||
const buffer = await selectedFile.arrayBuffer();
|
||||
selectedSha256 = await sha256HexFromArrayBuffer(buffer);
|
||||
selectedPrepared = await preparePublicFile(selectedFile);
|
||||
if (turboMode) {
|
||||
await refreshTurboStateForCurrentFile(mainMetaEl, errorEl, uploadBtn);
|
||||
} else {
|
||||
await recalculateArweaveState(mainMetaEl, errorEl, uploadBtn);
|
||||
}
|
||||
} catch (error) {
|
||||
setText(errorEl, error?.message || t('screens.arweave_attachment_manager.text_062'));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
uploadBtn?.addEventListener('click', async () => {
|
||||
if (!selectedFile || !selectedSha256) {
|
||||
setText(errorEl, t('screens.arweave_attachment_manager.text_009'));
|
||||
return;
|
||||
}
|
||||
if (!turboMode) {
|
||||
const wallet = selectedWallet();
|
||||
if (!wallet?.jwk) {
|
||||
setText(errorEl, t('screens.arweave_attachment_manager.text_010'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
uploadBtn.disabled = true;
|
||||
setText(errorEl, turboMode ? t('screens.arweave_attachment_manager.text_030') : t('screens.arweave_attachment_manager.text_031'));
|
||||
try {
|
||||
const uploaded = turboMode
|
||||
? await uploadFileWithTurbo({
|
||||
login: cleanLogin,
|
||||
storagePwd: cleanStoragePwd,
|
||||
keySource: selectedTurboKeySource,
|
||||
file: selectedFile,
|
||||
shineType: forcedShineType || (isAvatarMode ? 'avatar' : 'attachment'),
|
||||
tags: [
|
||||
{ name: 'SHiNE-Login', value: cleanLogin },
|
||||
{ name: isAvatarMode ? 'SHiNE-Avatar' : 'SHiNE-Attachment-Name', value: isAvatarMode ? '1' : (selectedFile.name || 'file') },
|
||||
...normalizedExtraUploadTags,
|
||||
],
|
||||
})
|
||||
: await uploadArweaveFile({
|
||||
gateway: cleanGateway,
|
||||
jwk: selectedWallet()?.jwk,
|
||||
file: selectedFile,
|
||||
shineType: forcedShineType || (isAvatarMode ? 'avatar' : 'attachment'),
|
||||
tags: [
|
||||
{ name: 'SHiNE-Login', value: cleanLogin },
|
||||
{ name: isAvatarMode ? 'SHiNE-Avatar' : 'SHiNE-Attachment-Name', value: isAvatarMode ? '1' : (selectedFile.name || 'file') },
|
||||
...normalizedExtraUploadTags,
|
||||
],
|
||||
});
|
||||
const prepared = selectedPrepared || await preparePublicFile(selectedFile);
|
||||
finish(resolve, {
|
||||
pr: prepared.pr, mm: prepared.mm,
|
||||
name: isAvatarMode ? t('screens.arweave_attachment_manager.text_032') : (initialName || selectedFile.name || 'file'),
|
||||
size: selectedFile.size,
|
||||
sha256: selectedSha256,
|
||||
ar: uploaded.id,
|
||||
uploadTransport: turboMode ? 'turbo' : 'arweave',
|
||||
uploadedAtMs: Date.now(),
|
||||
purpose: isAvatarMode ? 'avatar' : 'attachment',
|
||||
}, { pendingPlacement: historyOnly && !isAvatarMode });
|
||||
} catch (error) {
|
||||
uploadBtn.disabled = false;
|
||||
setText(errorEl, error?.message || (turboMode ? t('screens.arweave_attachment_manager.text_033') : t('screens.arweave_attachment_manager.text_034')));
|
||||
}
|
||||
});
|
||||
|
||||
if (selectedFile && selectedSha256) {
|
||||
if (turboMode) {
|
||||
await refreshTurboStateForCurrentFile(mainMetaEl, errorEl, uploadBtn);
|
||||
} else {
|
||||
await recalculateArweaveState(mainMetaEl, errorEl, uploadBtn);
|
||||
}
|
||||
}
|
||||
|
||||
if (!fixedFile && autoOpenFileDialog && !autoOpenedFileDialogOnce) {
|
||||
autoOpenedFileDialogOnce = true;
|
||||
window.setTimeout(() => fileEl?.click(), 0);
|
||||
}
|
||||
};
|
||||
|
||||
const showExisting = () => {
|
||||
root.innerHTML = `${shellOpen()}
|
||||
<h3 class="modal-title">${isAvatarMode ? t('screens.arweave_attachment_manager.text_035') : t('screens.arweave_attachment_manager.text_036')}</h3>
|
||||
<label class="meta-muted" for="ar-existing-txid">Transaction ID</label>
|
||||
<input class="input" id="ar-existing-txid" type="text" maxlength="64" placeholder="${t('dialogs.remaining.components.arweave_attachment_manager.markup.43_simvola_txid')}" />
|
||||
${isAvatarMode ? '' : `
|
||||
<label class="meta-muted" for="ar-existing-name">${th('screens.arweave_attachment_manager.text_077')}</label>
|
||||
<input class="input" id="ar-existing-name" type="text" maxlength="180" placeholder="${th('screens.arweave_attachment_manager.text_078')}" />
|
||||
`}
|
||||
<div class="ar-attachment-meta" data-meta="true"></div>
|
||||
<p class="meta-muted inline-error" data-error="true"></p>
|
||||
<div class="form-actions-grid">
|
||||
<button class="secondary-btn" type="button" data-action="back">${t('dialogs.remaining.components.arweave_attachment_manager.markup.nazad')}</button>
|
||||
<button class="primary-btn" type="button" data-action="check">${t('dialogs.remaining.components.arweave_attachment_manager.markup.skachat_i_proverit')}</button>
|
||||
</div>
|
||||
${shellClose()}
|
||||
`;
|
||||
bindBackdrop();
|
||||
const txEl = root.querySelector('#ar-existing-txid');
|
||||
const nameEl = root.querySelector('#ar-existing-name');
|
||||
const metaEl = root.querySelector('[data-meta="true"]');
|
||||
const errorEl = root.querySelector('[data-error="true"]');
|
||||
const checkBtn = root.querySelector('[data-action="check"]');
|
||||
root.querySelector('[data-action="back"]')?.addEventListener('click', showUpload);
|
||||
checkBtn?.addEventListener('click', async () => {
|
||||
const txId = String(txEl?.value || '').trim();
|
||||
const name = isAvatarMode ? t('screens.arweave_attachment_manager.text_037') : (String(nameEl?.value || '').trim() || 'arweave-file');
|
||||
if (!validateArweaveTxId(txId)) {
|
||||
setText(errorEl, t('screens.arweave_attachment_manager.text_011'));
|
||||
return;
|
||||
}
|
||||
checkBtn.disabled = true;
|
||||
setText(errorEl, t('screens.arweave_attachment_manager.text_012'));
|
||||
setText(metaEl, '');
|
||||
try {
|
||||
const meta = await loadArweaveFileMetadata({ gateway: cleanGateway, txId });
|
||||
const item = normalizeAttachment({
|
||||
name,
|
||||
size: meta.sizeBytes,
|
||||
sha256: meta.sha256Hex,
|
||||
ar: txId,
|
||||
uploadedAtMs: Date.now(),
|
||||
purpose: isAvatarMode ? 'avatar' : 'attachment',
|
||||
});
|
||||
metaEl.innerHTML = `
|
||||
<div>${th('remaining.file_upload.size_label')}${escapeHtml(formatBytes(item.size))}</div>
|
||||
<div>SHA-256: ${escapeHtml(item.sha256)}</div>
|
||||
`;
|
||||
setText(errorEl, '');
|
||||
const addBtn = document.createElement('button');
|
||||
addBtn.className = 'primary-btn';
|
||||
addBtn.type = 'button';
|
||||
addBtn.textContent = isAvatarMode ? t('dialogs.modals.arweave_attachment_manager.label_015') : (historyOnly ? t('screens.arweave_attachment_manager.text_038') : t('screens.arweave_attachment_manager.text_039'));
|
||||
addBtn.addEventListener('click', () => finish(resolve, item, { pendingPlacement: historyOnly && !isAvatarMode }));
|
||||
metaEl.append(addBtn);
|
||||
} catch (error) {
|
||||
setText(errorEl, error?.message || t('screens.arweave_attachment_manager.text_063'));
|
||||
checkBtn.disabled = false;
|
||||
}
|
||||
});
|
||||
window.setTimeout(() => txEl?.focus(), 0);
|
||||
};
|
||||
|
||||
const showHistory = () => {
|
||||
const rows = readArweaveAttachmentHistory(cleanLogin)
|
||||
.filter((item) => purposeFilter === 'avatar' ? item.purpose === 'avatar' : item.purpose !== 'avatar')
|
||||
.slice()
|
||||
.reverse();
|
||||
root.innerHTML = `${shellOpen('ar-attachment-manager-card--wide')}
|
||||
<h3 class="modal-title">${t('dialogs.remaining.components.arweave_attachment_manager.markup.zhurnal_zagruzhennyh_faylov')}</h3>
|
||||
<p class="meta-muted">${t('dialogs.remaining.components.arweave_attachment_manager.markup.zhurnal_hranitsya_tolko_v_etoy_brauzernoy_sessii')}</p>
|
||||
<div class="ar-attachment-history-tiles" data-history-scroll="true">
|
||||
${rows.length ? rows.map((item, index) => {
|
||||
const isSelected = selectedTxIdSet.has(item.ar);
|
||||
return `
|
||||
<article class="ar-attachment-history-tile${isSelected ? ' is-selected' : ''}" data-history-tile="${index}">
|
||||
<strong class="ar-attachment-history-name">${escapeHtml(item.name)}${item.purpose === 'avatar' ? t('screens.arweave_attachment_manager.text_040') : ''}</strong>
|
||||
<div class="ar-attachment-history-meta-row">
|
||||
<span>${escapeHtml(formatBytes(item.size))}</span>
|
||||
<span>${escapeHtml(formatArweaveHistoryTime(item.uploadedAtMs))}</span>
|
||||
<span class="ar-attachment-status ar-attachment-status--pending" data-status="${index}">${th('screens.arweave_attachment_manager.text_079')}</span>
|
||||
${item.pendingPlacement ? t('screens.arweave_attachment_manager.text_041') : ''}
|
||||
</div>
|
||||
<div class="mono-cell ar-attachment-history-txid">${escapeHtml(item.ar)}</div>
|
||||
<button class="${isSelected ? 'secondary-btn' : 'ghost-btn'}" type="button" data-pick="${index}" ${isSelected ? 'disabled' : ''}>${isSelected ? t('screens.arweave_attachment_manager.text_042') : t('screens.arweave_attachment_manager.text_043')}</button>
|
||||
</article>
|
||||
`;
|
||||
}).join('') : t('screens.arweave_attachment_manager.text_044')}
|
||||
</div>
|
||||
<div class="form-actions-grid">
|
||||
<button class="secondary-btn" type="button" data-action="back">${t('dialogs.remaining.components.arweave_attachment_manager.markup.nazad')}</button>
|
||||
</div>
|
||||
${shellClose()}
|
||||
`;
|
||||
bindBackdrop();
|
||||
const scrollEl = root.querySelector('[data-history-scroll="true"]');
|
||||
window.setTimeout(() => {
|
||||
if (scrollEl) scrollEl.scrollTop = scrollEl.scrollHeight;
|
||||
}, 0);
|
||||
root.querySelector('[data-action="back"]')?.addEventListener('click', showUpload);
|
||||
root.querySelectorAll('[data-pick]').forEach((button) => {
|
||||
button.addEventListener('click', () => {
|
||||
const index = Number(button.getAttribute('data-pick'));
|
||||
const item = rows[index];
|
||||
if (item) finish(resolve, item);
|
||||
});
|
||||
});
|
||||
rows.forEach((item, index) => {
|
||||
const statusEl = root.querySelector(`[data-status="${index}"]`);
|
||||
void getArweaveAttachmentAvailability({ gateway: cleanGateway, attachment: item })
|
||||
.then((result) => {
|
||||
if (!statusEl) return;
|
||||
statusEl.className = `ar-attachment-status ar-attachment-status--${result.status}`;
|
||||
statusEl.textContent = result.label;
|
||||
})
|
||||
.catch(() => {
|
||||
if (!statusEl) return;
|
||||
statusEl.className = 'ar-attachment-status ar-attachment-status--unavailable';
|
||||
statusEl.textContent = t('dialogs.modals.arweave_attachment_manager.label_016');
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const showAddWallet = () => {
|
||||
root.innerHTML = `${shellOpen()}
|
||||
<h3 class="modal-title">${t('dialogs.remaining.components.arweave_attachment_manager.markup.dobavit_arweave_koshelyok')}</h3>
|
||||
<p class="meta-muted">${t('dialogs.remaining.components.arweave_attachment_manager.markup.vstavte_json_jwk_ili_korotkuyu_stroku_base64url_json_jwk_kly')}</p>
|
||||
<label class="meta-muted" for="ar-wallet-label">${t('dialogs.remaining.components.arweave_attachment_manager.markup.nazvanie')}</label>
|
||||
<input class="input" id="ar-wallet-label" type="text" maxlength="80" placeholder="${t('dialogs.remaining.components.arweave_attachment_manager.markup.naprimer_osnovnoy_ar')}" />
|
||||
<label class="meta-muted" for="ar-wallet-secret">${t('dialogs.remaining.components.arweave_attachment_manager.markup.sekret_arweave')}</label>
|
||||
<textarea class="input" id="ar-wallet-secret" rows="7" placeholder="${t('dialogs.remaining.components.arweave_attachment_manager.markup.json_jwk_ili_base64url_json')}"></textarea>
|
||||
<p class="meta-muted inline-error" data-error="true"></p>
|
||||
<div class="form-actions-grid">
|
||||
<button class="secondary-btn" type="button" data-action="back">${t('dialogs.remaining.components.arweave_attachment_manager.markup.nazad')}</button>
|
||||
<button class="primary-btn" type="button" data-action="save">${t('dialogs.remaining.components.arweave_attachment_manager.markup.dobavit')}</button>
|
||||
</div>
|
||||
${shellClose()}
|
||||
`;
|
||||
bindBackdrop();
|
||||
const labelEl = root.querySelector('#ar-wallet-label');
|
||||
const secretEl = root.querySelector('#ar-wallet-secret');
|
||||
const errorEl = root.querySelector('[data-error="true"]');
|
||||
const saveBtn = root.querySelector('[data-action="save"]');
|
||||
root.querySelector('[data-action="back"]')?.addEventListener('click', showUpload);
|
||||
saveBtn?.addEventListener('click', async () => {
|
||||
saveBtn.disabled = true;
|
||||
setText(errorEl, '');
|
||||
try {
|
||||
const wallet = await addArweaveWalletSecret({
|
||||
login: cleanLogin,
|
||||
storagePwd: cleanStoragePwd,
|
||||
label: String(labelEl?.value || '').trim(),
|
||||
secret: String(secretEl?.value || '').trim(),
|
||||
});
|
||||
selectedWalletId = wallet.id;
|
||||
writeLastWalletId(cleanLogin, selectedWalletId);
|
||||
await showUpload();
|
||||
} catch (error) {
|
||||
saveBtn.disabled = false;
|
||||
setText(errorEl, error?.message || t('screens.arweave_attachment_manager.text_064'));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
void showUpload();
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,202 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
import { state } from '../state.js';
|
||||
import { buildArweaveDataUrl, validateArweaveTxId } from '../services/arweave-file-service.js';
|
||||
import { getCachedAvatarObjectUrl } from '../services/arweave-avatar-cache-service.js';
|
||||
import { resolvePublicFileUrl } from '../services/public-file-service.js';
|
||||
import { updatedUserFileUrlAfterError } from '../services/user-file-server-service.js';
|
||||
import { validatePublicPiecesRoot } from '../services/public-pieces-root.js';
|
||||
|
||||
function normalizeLogin(value) {
|
||||
return String(value || '').trim();
|
||||
}
|
||||
|
||||
function pickSizeClass(size) {
|
||||
const raw = String(size || '').trim().toLowerCase();
|
||||
if (raw === 'node') return 'node-dot';
|
||||
if (raw === 'xs' || raw === 'xsmall' || raw === 'tiny') return 'avatar-xs';
|
||||
if (raw === 'sm' || raw === 'small') return 'avatar-sm';
|
||||
if (raw === 'md' || raw === 'medium' || raw === '') return 'avatar-md';
|
||||
if (raw === 'lg' || raw === 'big') return 'avatar-lg';
|
||||
if (raw === 'xl' || raw === 'xlarge' || raw === 'large' || raw === 'very-large') return 'avatar-xl';
|
||||
return raw || '';
|
||||
}
|
||||
|
||||
export function buildAvatarInitials({ login, firstName = '', lastName = '' } = {}) {
|
||||
const first = String(firstName || '').trim();
|
||||
const last = String(lastName || '').trim();
|
||||
if (first || last) {
|
||||
const initials = `${(first[0] || '').toUpperCase()}${(last[0] || '').toUpperCase()}`.trim();
|
||||
if (initials) return initials;
|
||||
}
|
||||
const cleanLogin = normalizeLogin(login);
|
||||
return (cleanLogin[0] || '?').toUpperCase();
|
||||
}
|
||||
|
||||
export function renderAvatar({
|
||||
initials = '?',
|
||||
avatar = null,
|
||||
size = 'xl',
|
||||
className = '',
|
||||
title = '',
|
||||
alt = t('remaining.avatar.avatar'),
|
||||
glow = false,
|
||||
official = false,
|
||||
authorLogin = '',
|
||||
} = {}) {
|
||||
const wrap = document.createElement('div');
|
||||
const classes = new Set(['avatar', 'avatar-image', 'avatar-framed']);
|
||||
const sizeClass = pickSizeClass(size);
|
||||
if (sizeClass) classes.add(sizeClass);
|
||||
const extraClass = String(className || '').trim();
|
||||
if (extraClass) extraClass.split(/\s+/g).filter(Boolean).forEach((value) => classes.add(value));
|
||||
if (glow) classes.add('avatar-glow');
|
||||
wrap.className = Array.from(classes).join(' ');
|
||||
if (title) wrap.title = String(title);
|
||||
|
||||
const fallback = document.createElement('span');
|
||||
fallback.className = 'avatar-fallback';
|
||||
fallback.textContent = String(initials || '?').trim().slice(0, 2).toUpperCase() || '?';
|
||||
wrap.append(fallback);
|
||||
|
||||
if (official) {
|
||||
const badge = document.createElement('img');
|
||||
badge.className = 'avatar-official-badge';
|
||||
badge.src = '/assets/shine-official-badge.svg?v=2';
|
||||
badge.alt = '';
|
||||
badge.setAttribute('aria-hidden', 'true');
|
||||
wrap.append(badge);
|
||||
}
|
||||
|
||||
const txId = String(avatar?.ar || '').trim();
|
||||
const pr = String(avatar?.pr || '').trim();
|
||||
const expectedPr = validatePublicPiecesRoot(pr) ? pr : '';
|
||||
const hasArweave = validateArweaveTxId(txId);
|
||||
const hasServerAvatar = !txId && expectedPr;
|
||||
if (!hasArweave && !hasServerAvatar) return wrap;
|
||||
|
||||
const img = document.createElement('img');
|
||||
img.className = 'avatar-photo';
|
||||
img.alt = String(alt || t('screens.avatar_image.text_002'));
|
||||
img.loading = 'lazy';
|
||||
img.decoding = 'async';
|
||||
img.referrerPolicy = 'no-referrer';
|
||||
wrap.append(img);
|
||||
|
||||
const setLoadedState = (loaded) => {
|
||||
wrap.classList.toggle('has-image', Boolean(loaded));
|
||||
};
|
||||
setLoadedState(false);
|
||||
|
||||
if (hasServerAvatar) {
|
||||
// All public avatars use exactly the same PR/Base58 R2 object key as attachments.
|
||||
img.onload = () => setLoadedState(true);
|
||||
let attemptedRefresh = false;
|
||||
img.onerror = async () => {
|
||||
const previousUrl = img.src;
|
||||
if (!attemptedRefresh && authorLogin) {
|
||||
attemptedRefresh = true;
|
||||
try {
|
||||
const updated = await updatedUserFileUrlAfterError({
|
||||
login: authorLogin, id: expectedPr, previousUrl,
|
||||
});
|
||||
if (updated && img.parentElement === wrap) { img.src = updated; return; }
|
||||
} catch { /* старый адрес останется недоступным */ }
|
||||
}
|
||||
img.removeAttribute('src'); setLoadedState(false);
|
||||
};
|
||||
void resolvePublicFileUrl({ pr: expectedPr, authorLogin }).then((url) => {
|
||||
if (img.parentElement === wrap) img.src = url;
|
||||
}).catch(() => { img.removeAttribute('src'); setLoadedState(false); });
|
||||
return wrap;
|
||||
}
|
||||
|
||||
const gateway = state?.entrySettings?.arweaveServer;
|
||||
void getCachedAvatarObjectUrl({ gateway, txId, expectedPr })
|
||||
.then((objectUrl) => {
|
||||
const directUrl = buildArweaveDataUrl({ gateway, txId });
|
||||
let triedDirectUrl = false;
|
||||
let objectUrlReleased = false;
|
||||
const releaseObjectUrl = () => {
|
||||
if (objectUrlReleased) return;
|
||||
objectUrlReleased = true;
|
||||
if (objectUrl.startsWith('blob:')) {
|
||||
URL.revokeObjectURL(objectUrl);
|
||||
}
|
||||
};
|
||||
img.onload = () => {
|
||||
setLoadedState(true);
|
||||
releaseObjectUrl();
|
||||
};
|
||||
img.onerror = () => {
|
||||
if (!triedDirectUrl) {
|
||||
if (expectedPr) {
|
||||
releaseObjectUrl();
|
||||
img.removeAttribute('src');
|
||||
setLoadedState(false);
|
||||
return;
|
||||
}
|
||||
triedDirectUrl = true;
|
||||
releaseObjectUrl();
|
||||
img.src = directUrl;
|
||||
return;
|
||||
}
|
||||
releaseObjectUrl();
|
||||
img.removeAttribute('src');
|
||||
setLoadedState(false);
|
||||
};
|
||||
img.src = objectUrl;
|
||||
})
|
||||
.catch(() => {
|
||||
if (expectedPr) {
|
||||
img.removeAttribute('src');
|
||||
setLoadedState(false);
|
||||
return;
|
||||
}
|
||||
let directUrl = '';
|
||||
try {
|
||||
directUrl = buildArweaveDataUrl({ gateway, txId });
|
||||
} catch {
|
||||
directUrl = '';
|
||||
}
|
||||
if (!directUrl) {
|
||||
img.removeAttribute('src');
|
||||
setLoadedState(false);
|
||||
return;
|
||||
}
|
||||
img.onload = () => {
|
||||
setLoadedState(true);
|
||||
};
|
||||
img.onerror = () => {
|
||||
img.removeAttribute('src');
|
||||
setLoadedState(false);
|
||||
};
|
||||
img.src = directUrl;
|
||||
});
|
||||
|
||||
return wrap;
|
||||
}
|
||||
|
||||
export function renderUserAvatar({
|
||||
login,
|
||||
firstName = '',
|
||||
lastName = '',
|
||||
avatar = null,
|
||||
size = 'xl',
|
||||
className = '',
|
||||
title = '',
|
||||
glow = false,
|
||||
official = false,
|
||||
authorLogin = '',
|
||||
} = {}) {
|
||||
return renderAvatar({
|
||||
initials: buildAvatarInitials({ login, firstName, lastName }),
|
||||
avatar,
|
||||
size,
|
||||
className,
|
||||
title,
|
||||
alt: t('screens.avatar_image.text_001'),
|
||||
glow,
|
||||
official,
|
||||
authorLogin: login,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
import { openChannelAttachmentManager } from './channel-attachment-manager.js';
|
||||
import { saveProfileAvatar } from '../services/user-profile-params.js';
|
||||
|
||||
export async function openAvatarWizard({
|
||||
login,
|
||||
storagePwd,
|
||||
gateway,
|
||||
navigate,
|
||||
onAvatarSaved,
|
||||
onStatus,
|
||||
} = {}) {
|
||||
const cleanLogin = String(login || '').trim();
|
||||
const cleanStoragePwd = String(storagePwd || '').trim();
|
||||
const cleanGateway = String(gateway || '').trim();
|
||||
if (!cleanLogin || !cleanStoragePwd) {
|
||||
throw new Error(t('screens.avatar_wizard.text_001'));
|
||||
}
|
||||
|
||||
const item = await openChannelAttachmentManager({
|
||||
login: cleanLogin,
|
||||
storagePwd: cleanStoragePwd,
|
||||
gateway: cleanGateway,
|
||||
mode: 'avatar',
|
||||
});
|
||||
|
||||
if (!item?.pr || !item?.size) return false;
|
||||
|
||||
if (typeof onStatus === 'function') {
|
||||
onStatus(t('screens.avatar_wizard.text_002'));
|
||||
}
|
||||
|
||||
await saveProfileAvatar(cleanLogin, item);
|
||||
|
||||
if (typeof onAvatarSaved === 'function') {
|
||||
await onAvatarSaved(item);
|
||||
}
|
||||
|
||||
if (typeof onStatus === 'function') {
|
||||
onStatus('');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
import { formatDateTime } from '../i18n/format.js';
|
||||
import { escapeHtml } from '../services/attachment-format.js';
|
||||
import { arweaveBlockUrl, checkArweavePayload, checkSolanaAuthor, readSignedBlock, signedDataItemFilename } from '../services/blockchain-proof-service.js';
|
||||
import { showToast } from '../services/channels-ux.js';
|
||||
|
||||
const validHash = (value) => /^[0-9a-f]{64}$/iu.test(String(value || ''));
|
||||
const label = (key) => t(`blockchain_details.${key}`);
|
||||
const safe = (value) => escapeHtml(String(value ?? ''));
|
||||
const shortened = (value) => String(value || '').length > 24
|
||||
? `${String(value).slice(0, 12)}…${String(value).slice(-8)}` : String(value || '');
|
||||
|
||||
function asVersions(details) {
|
||||
const raw = Array.isArray(details?.raw?.versions) ? details.raw.versions : [];
|
||||
if (raw.length) return raw.map((v, i) => ({ ...v, versionIndex: Number(v.versionIndex || i + 1) }));
|
||||
return [{ versionIndex: 1, blockNumber: details.blockNumber, blockHash: details.blockHash,
|
||||
createdAtMs: details.createdAtMs, arweaveDataItemId: details.raw?.arweaveDataItemId || '',
|
||||
arweavePublishPending: details.raw?.arweavePublishPending,
|
||||
arweavePublishedAtMs: details.raw?.arweavePublishedAtMs,
|
||||
signedDataItemBytes: details.raw?.signedDataItemBytes }];
|
||||
}
|
||||
function field(title, value, { code = false } = {}) {
|
||||
const valueHtml = code ? `<code title="${safe(value)}">${safe(value)}</code>` : `<strong>${safe(value)}</strong>`;
|
||||
return `<div class="block-proof-row"><span>${safe(title)}</span>${valueHtml}</div>`;
|
||||
}
|
||||
function statusFor(version) {
|
||||
if (version?.arweavePublishedAtMs > 0) return { color: 'success', text: label('published') };
|
||||
if (version?.arweavePublishPending === true) return { color: 'pending', text: label('pending') };
|
||||
return { color: 'unknown', text: label('unknown') };
|
||||
}
|
||||
async function copy(value) {
|
||||
const text = String(value || '');
|
||||
if (!text) return;
|
||||
if (navigator.clipboard?.writeText) {
|
||||
await navigator.clipboard.writeText(text);
|
||||
} else {
|
||||
const input = document.createElement('textarea');
|
||||
input.value = text; input.style.position = 'fixed'; input.style.opacity = '0';
|
||||
document.body.append(input); input.select(); document.execCommand('copy'); input.remove();
|
||||
}
|
||||
showToast(label('copied'));
|
||||
}
|
||||
function resultRow(name, status, reason = '') {
|
||||
const mark = status === 'valid' ? '✓' : status === 'invalid' ? '✕' : '—';
|
||||
const description = status === 'valid' ? label('verified') : status === 'invalid' ? label('failed') : label('not_verified');
|
||||
return `<div class="block-proof-check block-proof-check--${status}"><span aria-hidden="true">${mark}</span><div><strong>${safe(name)}: ${safe(description)}</strong>${reason ? `<small>${safe(reason)}</small>` : ''}</div></div>`;
|
||||
}
|
||||
|
||||
/** Единый диалог для ленты канала и страницы обсуждения. */
|
||||
export function openBlockchainDetailsModal(details, { authService, solanaEndpoint, isActive = () => true } = {}) {
|
||||
const root = document.getElementById('modal-root');
|
||||
if (!root) return;
|
||||
const versions = asVersions(details);
|
||||
let current = versions.length - 1;
|
||||
let busy = false;
|
||||
const rawText = JSON.stringify(details.raw || {}, null, 2);
|
||||
root.innerHTML = `
|
||||
<div class="modal" id="blockchain-details-modal">
|
||||
<section class="modal-card stack blockchain-details-card block-proof-card" role="dialog" aria-modal="true" aria-label="${safe(label('title'))}">
|
||||
<header class="block-proof-header">
|
||||
<span class="block-proof-icon" aria-hidden="true">⛓</span>
|
||||
<div><h3 class="modal-title">${safe(label('title'))}</h3><p class="meta-muted">${safe(label('description'))}</p></div>
|
||||
</header>
|
||||
${versions.length > 1 ? `<label class="field-label" for="block-proof-version">${safe(label('version'))}</label>
|
||||
<select class="input" id="block-proof-version">${versions.map((v, i) => `<option value="${i}" ${i === current ? 'selected' : ''}>${safe(label('version'))} ${i + 1} · #${safe(v.blockNumber)}</option>`).join('')}</select>` : ''}
|
||||
<div id="block-proof-content"></div>
|
||||
<div class="block-proof-actions">
|
||||
<a class="secondary-btn block-proof-link" id="block-proof-open" target="_blank" rel="noopener noreferrer">↗ ${safe(label('open_arweave'))}</a>
|
||||
<button class="secondary-btn" type="button" id="block-proof-copy-url">${safe(label('copy_url'))}</button>
|
||||
<button class="secondary-btn" type="button" id="block-proof-download">↓ ${safe(label('download_signed'))}</button>
|
||||
<button class="secondary-btn block-proof-verify" type="button" id="block-proof-verify">🛡 ${safe(label('verify'))}</button>
|
||||
</div>
|
||||
<div id="block-proof-results" class="block-proof-results" hidden aria-live="polite"></div>
|
||||
<details class="block-proof-raw"><summary>${safe(label('technical'))}</summary>
|
||||
<pre class="blockchain-raw-block">${safe(rawText)}</pre>
|
||||
<button class="secondary-btn" id="block-proof-copy-raw" type="button">${safe(label('copy_raw'))}</button>
|
||||
</details>
|
||||
<button class="secondary-btn" id="block-proof-close" type="button">${safe(label('close'))}</button>
|
||||
</section>
|
||||
</div>`;
|
||||
const get = (id) => root.querySelector(`#${id}`);
|
||||
const currentVersion = () => versions[current];
|
||||
const content = get('block-proof-content');
|
||||
const results = get('block-proof-results');
|
||||
const button = get('block-proof-download');
|
||||
const verify = get('block-proof-verify');
|
||||
const close = () => { if (get('blockchain-details-modal')) root.innerHTML = ''; };
|
||||
function renderVersion() {
|
||||
const v = currentVersion();
|
||||
const archive = statusFor(v);
|
||||
const hash = validHash(v.blockHash) ? v.blockHash : '';
|
||||
const url = arweaveBlockUrl(v.arweaveDataItemId);
|
||||
const date = Number(v.createdAtMs || details.createdAtMs);
|
||||
content.innerHTML = `
|
||||
<div class="block-proof-facts">
|
||||
${field(label('author'), details.authorLogin || '—')}
|
||||
${field(label('blockchain'), details.authorBlockchainName || '—', { code: true })}
|
||||
${field(label('block_number'), v.blockNumber)}
|
||||
${field(label('created'), date > 0 ? formatDateTime(new Date(date)) : '—')}
|
||||
${field(label('storage'), 'Arweave')}
|
||||
${field(label('signed_size'), Number.isInteger(v.signedDataItemBytes) ? `${v.signedDataItemBytes} ${label('bytes')}` : '—')}
|
||||
</div>
|
||||
${v.attachmentMetadataValid === false ? `<p class="block-proof-warning">${safe(label('invalid_attachment'))}</p>` : ''}
|
||||
<div class="block-proof-status block-proof-status--${archive.color}"><span class="block-proof-dot"></span>${safe(archive.text)}</div>
|
||||
<div class="block-proof-hash"><span>${safe(label('hash'))}</span><div><code title="${safe(hash)}">${safe(shortened(hash) || '—')}</code><button type="button" class="block-proof-copy-icon" id="block-proof-copy-hash" ${hash ? '' : 'disabled'} aria-label="${safe(label('copy_hash'))}" title="${safe(label('copy_hash'))}">⧉</button></div></div>
|
||||
${url ? `<div class="block-proof-hash"><span>Arweave DataItem ID</span><div><code title="${safe(v.arweaveDataItemId)}">${safe(shortened(v.arweaveDataItemId))}</code><button type="button" class="block-proof-copy-icon" id="block-proof-copy-id" aria-label="${safe(label('copy_id'))}" title="${safe(label('copy_id'))}">⧉</button></div></div>` : ''}`;
|
||||
get('block-proof-open').href = url || '#';
|
||||
get('block-proof-open').hidden = !url;
|
||||
get('block-proof-copy-url').disabled = !url;
|
||||
get('block-proof-copy-hash')?.addEventListener('click', () => { void copy(hash); });
|
||||
get('block-proof-copy-id')?.addEventListener('click', () => { void copy(v.arweaveDataItemId); });
|
||||
results.hidden = true;
|
||||
results.replaceChildren();
|
||||
}
|
||||
async function signedBlock() {
|
||||
const v = currentVersion();
|
||||
if (!validHash(v.blockHash)) throw new Error(label('missing_hash'));
|
||||
return readSignedBlock({ authService, blockchainName: details.authorBlockchainName,
|
||||
blockNumber: v.blockNumber, blockHash: v.blockHash, dataItemId: v.arweaveDataItemId });
|
||||
}
|
||||
get('block-proof-version')?.addEventListener('change', (event) => {
|
||||
if (busy) { event.target.value = String(current); return; }
|
||||
current = Number(event.target.value); renderVersion();
|
||||
});
|
||||
get('block-proof-copy-url')?.addEventListener('click', () => { void copy(arweaveBlockUrl(currentVersion().arweaveDataItemId)); });
|
||||
get('block-proof-copy-raw')?.addEventListener('click', () => { void copy(rawText); });
|
||||
get('block-proof-close')?.addEventListener('click', close);
|
||||
button.addEventListener('click', async () => {
|
||||
if (busy) return;
|
||||
busy = true; button.disabled = true; verify.disabled = true;
|
||||
try {
|
||||
const proof = await signedBlock();
|
||||
if (!isActive() || !get('blockchain-details-modal')) return;
|
||||
const blobUrl = URL.createObjectURL(new Blob([proof.bytes], { type: 'application/octet-stream' }));
|
||||
const link = document.createElement('a');
|
||||
link.href = blobUrl;
|
||||
link.download = signedDataItemFilename(details.authorBlockchainName, currentVersion().blockNumber);
|
||||
document.body.append(link); link.click(); link.remove();
|
||||
setTimeout(() => URL.revokeObjectURL(blobUrl), 30000);
|
||||
} catch (error) { if (isActive()) showToast(String(error?.message || error), { kind: 'error' }); }
|
||||
finally { busy = false; button.disabled = false; verify.disabled = false; }
|
||||
});
|
||||
verify.addEventListener('click', async () => {
|
||||
if (busy) return;
|
||||
busy = true; verify.disabled = true; button.disabled = true;
|
||||
const select = get('block-proof-version'); if (select) select.disabled = true;
|
||||
results.hidden = false; results.textContent = label('checking');
|
||||
try {
|
||||
const proof = await signedBlock();
|
||||
const id = currentVersion().arweaveDataItemId || proof.actualId;
|
||||
const [arweave, solana] = await Promise.all([
|
||||
checkArweavePayload(id, proof.data),
|
||||
checkSolanaAuthor({ authorLogin: details.authorLogin, blockchainName: details.authorBlockchainName,
|
||||
owner32: proof.owner32, solanaEndpoint }),
|
||||
]);
|
||||
if (!isActive() || !get('blockchain-details-modal')) return;
|
||||
results.innerHTML = [
|
||||
resultRow(label('signature'), 'valid'),
|
||||
resultRow(label('integrity'), 'valid'),
|
||||
resultRow(label('arweave_check'), arweave.status, arweave.reason),
|
||||
resultRow(label('solana_check'), solana.status, solana.reason),
|
||||
`<p class="meta-muted">${safe(label('proof_note'))}</p>`,
|
||||
].join('');
|
||||
} catch (error) {
|
||||
if (!isActive() || !get('blockchain-details-modal')) return;
|
||||
results.innerHTML = resultRow(label('signed_check'), 'unavailable', String(error?.message || error));
|
||||
} finally {
|
||||
busy = false;
|
||||
if (get('blockchain-details-modal')) { verify.disabled = false; button.disabled = false; if (select) select.disabled = false; }
|
||||
}
|
||||
});
|
||||
renderVersion();
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
import { t, th } from '../i18n/index.js';
|
||||
import { openArweaveAttachmentManager, prepareAvatarImageFile } from './arweave-attachment-manager.js';
|
||||
import { formatBytes } from '../services/attachment-format.js';
|
||||
import { uploadPublicFile } from '../services/public-file-service.js';
|
||||
import { state } from '../state.js';
|
||||
import { toUserMessage } from '../services/ui-error-texts.js';
|
||||
|
||||
export function openChannelAttachmentManager({
|
||||
login,
|
||||
storagePwd = '',
|
||||
gateway = '',
|
||||
selectedTxIds = [],
|
||||
signal = null,
|
||||
mode = 'attachment',
|
||||
} = {}) {
|
||||
const cleanLogin = String(login || '').trim();
|
||||
const isAvatarMode = String(mode || '').trim() === 'avatar';
|
||||
const root = document.createElement('div');
|
||||
root.className = 'public-attachment-manager-root';
|
||||
document.body.append(root);
|
||||
|
||||
let closed = false;
|
||||
let selectedFile = null;
|
||||
let uploading = false;
|
||||
let arweaveStarted = false;
|
||||
const arweaveAbortController = new AbortController();
|
||||
if (signal) signal.addEventListener('abort', () => arweaveAbortController.abort(), { once: true });
|
||||
|
||||
const close = (resolve, value = null) => {
|
||||
if (closed) return;
|
||||
closed = true;
|
||||
arweaveAbortController.abort();
|
||||
root.remove();
|
||||
resolve(value);
|
||||
};
|
||||
|
||||
return new Promise((resolve) => {
|
||||
const onAbort = () => close(resolve, null);
|
||||
if (signal?.aborted) { onAbort(); return; }
|
||||
signal?.addEventListener('abort', onAbort, { once: true });
|
||||
|
||||
root.innerHTML = `
|
||||
<div class="modal public-attachment-manager" data-public-attachment-modal="true">
|
||||
<div class="modal-card stack public-attachment-manager__card" role="dialog" aria-modal="true" aria-labelledby="public-attachment-title">
|
||||
<div class="public-attachment-manager__header">
|
||||
<h3 class="modal-title" id="public-attachment-title">${isAvatarMode ? t('screens.channel_attachment_manager.text_003') : t('screens.channel_attachment_manager.text_004')}</h3>
|
||||
<button class="icon-btn" type="button" data-action="close" aria-label="${th('screens.channel_attachment_manager.text_008')}">×</button>
|
||||
</div>
|
||||
|
||||
<div class="public-attachment-manager__sources" role="radiogroup" aria-label="${th('screens.channel_attachment_manager.text_009')}">
|
||||
<label class="public-attachment-manager__source is-selected">
|
||||
<input type="radio" name="attachment-storage" value="server" checked />
|
||||
<span><strong>${th('screens.channel_attachment_manager.text_010')}</strong><small>${th('screens.channel_attachment_manager.text_011')}</small></span>
|
||||
</label>
|
||||
<label class="public-attachment-manager__source">
|
||||
<input type="radio" name="attachment-storage" value="arweave" />
|
||||
<span><strong>ARWEAVE</strong><small>${th('screens.channel_attachment_manager.text_012')}</small></span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="public-attachment-manager__server" data-panel="server">
|
||||
<div class="public-attachment-manager__notice">
|
||||
<strong>${th('screens.channel_attachment_manager.text_013')}</strong>
|
||||
<p>${th('screens.channel_attachment_manager.text_014')}</p>
|
||||
<p>${th('screens.channel_attachment_manager.text_015')}</p>
|
||||
<p>${th('screens.channel_attachment_manager.text_016')}</p>
|
||||
<p>${th('screens.channel_attachment_manager.text_017')}</p>
|
||||
</div>
|
||||
<label class="ar-attachment-file-picker public-attachment-manager__file-picker">
|
||||
<input class="ar-attachment-file-input" type="file" data-role="file" ${isAvatarMode ? 'accept="image/*"' : ''} />
|
||||
<span class="ar-attachment-file-btn">${th('screens.channel_attachment_manager.text_018')}</span>
|
||||
<span class="ar-attachment-file-name" data-role="selected">${th('screens.channel_attachment_manager.text_019')}</span>
|
||||
</label>
|
||||
<div class="public-attachment-manager__status meta-muted" data-role="status"></div>
|
||||
<div class="public-attachment-manager__error inline-error" data-role="error"></div>
|
||||
<button class="primary-btn" type="button" data-action="upload" disabled>${isAvatarMode ? t('screens.channel_attachment_manager.text_005') : t('screens.channel_attachment_manager.text_006')}</button>
|
||||
</div>
|
||||
|
||||
<div class="public-attachment-manager__arweave" data-panel="arweave" hidden>
|
||||
<p class="meta-muted">${th('screens.channel_attachment_manager.text_020')}</p>
|
||||
<div class="public-attachment-manager__arweave-loading meta-muted">${th('screens.channel_attachment_manager.text_021')}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
const modal = root.querySelector('[data-public-attachment-modal="true"]');
|
||||
const fileInput = root.querySelector('[data-role="file"]');
|
||||
const selectedEl = root.querySelector('[data-role="selected"]');
|
||||
const statusEl = root.querySelector('[data-role="status"]');
|
||||
const errorEl = root.querySelector('[data-role="error"]');
|
||||
const uploadButton = root.querySelector('[data-action="upload"]');
|
||||
const radios = [...root.querySelectorAll('input[name="attachment-storage"]')];
|
||||
|
||||
const setSource = (value) => {
|
||||
root.querySelectorAll('.public-attachment-manager__source').forEach((label) => {
|
||||
label.classList.toggle('is-selected', label.querySelector('input')?.value === value);
|
||||
});
|
||||
root.querySelector('[data-panel="server"]').hidden = value !== 'server';
|
||||
root.querySelector('[data-panel="arweave"]').hidden = value !== 'arweave';
|
||||
};
|
||||
|
||||
const openArweaveFlow = async () => {
|
||||
if (arweaveStarted || closed) return;
|
||||
arweaveStarted = true;
|
||||
const hostElement = root.querySelector('[data-panel="arweave"]');
|
||||
if (!(hostElement instanceof HTMLElement)) { arweaveStarted = false; return; }
|
||||
try {
|
||||
const item = await openArweaveAttachmentManager({
|
||||
login: cleanLogin,
|
||||
storagePwd,
|
||||
gateway,
|
||||
selectedTxIds,
|
||||
signal: arweaveAbortController.signal,
|
||||
mode: isAvatarMode ? 'avatar' : 'attachment',
|
||||
historyPurpose: isAvatarMode ? 'avatar' : '',
|
||||
autoOpenFileDialog: false,
|
||||
hostElement,
|
||||
embedded: true,
|
||||
});
|
||||
if (item && !closed) close(resolve, item);
|
||||
} catch (error) {
|
||||
arweaveStarted = false;
|
||||
if (!closed && hostElement) {
|
||||
hostElement.replaceChildren();
|
||||
const message = document.createElement('p');
|
||||
message.className = 'inline-error';
|
||||
message.textContent = toUserMessage(error, t('screens.channel_attachment_manager.text_001'));
|
||||
hostElement.append(message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
radios.forEach((radio) => radio.addEventListener('change', () => {
|
||||
setSource(radio.value);
|
||||
if (radio.value === 'arweave' && radio.checked) void openArweaveFlow();
|
||||
}));
|
||||
root.querySelector('[data-action="close"]')?.addEventListener('click', () => close(resolve, null));
|
||||
modal?.addEventListener('click', (event) => {
|
||||
if (event.target === modal && !uploading) close(resolve, null);
|
||||
});
|
||||
|
||||
fileInput?.addEventListener('change', () => {
|
||||
selectedFile = fileInput.files?.[0] || null;
|
||||
if (selectedEl) selectedEl.textContent = selectedFile
|
||||
? `${selectedFile.name} · ${formatBytes(selectedFile.size)}`
|
||||
: t('screens.channel_attachment_manager.text_007');
|
||||
if (errorEl) errorEl.textContent = '';
|
||||
if (statusEl) statusEl.textContent = '';
|
||||
if (uploadButton) uploadButton.disabled = !selectedFile;
|
||||
});
|
||||
|
||||
uploadButton?.addEventListener('click', async () => {
|
||||
if (!selectedFile || uploading) return;
|
||||
uploading = true;
|
||||
uploadButton.disabled = true;
|
||||
fileInput.disabled = true;
|
||||
if (errorEl) errorEl.textContent = '';
|
||||
try {
|
||||
const uploadFile = isAvatarMode ? await prepareAvatarImageFile(selectedFile) : selectedFile;
|
||||
const item = await uploadPublicFile({
|
||||
file: uploadFile,
|
||||
purpose: isAvatarMode ? 'avatar' : 'attachment',
|
||||
login: cleanLogin,
|
||||
sessionId: state.session.sessionId,
|
||||
wsUrl: state.entrySettings.shineServer,
|
||||
onStatus: (message) => { if (statusEl) statusEl.textContent = message; },
|
||||
});
|
||||
close(resolve, { ...item, purpose: isAvatarMode ? 'avatar' : 'attachment' });
|
||||
} catch (error) {
|
||||
if (errorEl) errorEl.textContent = toUserMessage(error, t('screens.channel_attachment_manager.text_002'));
|
||||
if (statusEl) statusEl.textContent = '';
|
||||
uploading = false;
|
||||
fileInput.disabled = false;
|
||||
uploadButton.disabled = !selectedFile;
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,439 @@
|
||||
import { t, th } from '../i18n/index.js';
|
||||
import { iconHtml } from './ui-icon.js';
|
||||
import { confirmPublicHistoryAction } from '../services/public-history-consent.js';
|
||||
import { markArweaveAttachmentPlaced } from './arweave-attachment-manager.js';
|
||||
import { openChannelAttachmentManager } from './channel-attachment-manager.js';
|
||||
import { composeMessageWithAttachments, MAX_MESSAGE_ATTACHMENTS } from '../services/attachment-format.js';
|
||||
import { state } from '../state.js';
|
||||
import { toUserMessage } from '../services/ui-error-texts.js';
|
||||
import { renderUserAvatar } from './avatar-image.js';
|
||||
import { openAuthRequiredModal } from '../services/auth-required-modal.js';
|
||||
import { openHistoryLayer } from '../router.js';
|
||||
|
||||
const drafts = new Map();
|
||||
|
||||
function draftKey(key) {
|
||||
const login = String(state.session.login || 'guest').trim().toLowerCase();
|
||||
return `${login}:${String(key || 'editor')}`;
|
||||
}
|
||||
|
||||
// MVP: вложения показываются только строкой с именем, без запросов миниатюр.
|
||||
function attachmentLabel(item) {
|
||||
const name = String(item?.name || t('screens.channel_editor.text_012'));
|
||||
const size = Number(item?.size || 0);
|
||||
if (!size) return name;
|
||||
if (size < 1024) return t('screens.channel_editor.text_017', { value1: name, value2: size });
|
||||
if (size < 1024 * 1024) return t('screens.channel_editor.text_018', { value1: name, value2: Math.ceil(size / 1024) });
|
||||
return t('screens.channel_editor.text_019', { value1: name, value2: (size / 1024 / 1024).toFixed(1) });
|
||||
}
|
||||
|
||||
export function openChannelEditor({
|
||||
id = 'channel-editor',
|
||||
title = t('remaining.channel_editor.reply'),
|
||||
submitLabel = t('remaining.channel_editor.reply_2'),
|
||||
placeholder = t('remaining.channel_editor.write_a_reply'),
|
||||
context = null,
|
||||
destination = '',
|
||||
key = 'reply',
|
||||
extraControl = null,
|
||||
initialText = '',
|
||||
allowEmptyText = false,
|
||||
allowAttachments = true,
|
||||
rawText = false,
|
||||
openAttachOnStart = false,
|
||||
onSubmit,
|
||||
isActive = () => true,
|
||||
} = {}) {
|
||||
if (!state.session.isAuthorized) {
|
||||
openAuthRequiredModal({ title: t('dialogs.components.channel_editor.title_001'), text: t('dialogs.components.channel_editor.text_002') });
|
||||
return null;
|
||||
}
|
||||
const root = document.getElementById('modal-root');
|
||||
if (!root || typeof onSubmit !== 'function') return null;
|
||||
if (root.querySelector('.channel-editor-overlay')) return null;
|
||||
|
||||
const opener = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
||||
const storageKey = draftKey(key);
|
||||
const login = state.session.login;
|
||||
const saved = drafts.get(storageKey) || { text: initialText, attachments: [] };
|
||||
const attachments = Array.isArray(saved.attachments) ? [...saved.attachments] : [];
|
||||
const extraFields = extraControl ? [...extraControl.querySelectorAll('select,input')] : [];
|
||||
extraFields.forEach((field, index) => {
|
||||
if (saved.controls?.[index] !== undefined) field.value = saved.controls[index];
|
||||
});
|
||||
let inFlight = false;
|
||||
let composing = false;
|
||||
let closed = false;
|
||||
let picking = false;
|
||||
let completed = false;
|
||||
const attachmentController = new AbortController();
|
||||
|
||||
const overlay = document.createElement('div');
|
||||
overlay.className = 'channel-editor-overlay';
|
||||
overlay.id = id;
|
||||
overlay.setAttribute('role', 'dialog');
|
||||
overlay.setAttribute('aria-modal', 'true');
|
||||
overlay.setAttribute('aria-labelledby', `${id}-title`);
|
||||
|
||||
const dialog = document.createElement('div');
|
||||
dialog.className = 'channel-editor';
|
||||
|
||||
const header = document.createElement('header');
|
||||
header.className = 'channel-editor__header';
|
||||
const closeButton = document.createElement('button');
|
||||
closeButton.type = 'button';
|
||||
closeButton.className = 'icon-btn channel-editor__close';
|
||||
closeButton.setAttribute('aria-label', t('screens.channel_editor.text_025'));
|
||||
closeButton.innerHTML = iconHtml('close');
|
||||
const heading = document.createElement('h2');
|
||||
heading.id = `${id}-title`;
|
||||
heading.textContent = title;
|
||||
// Закрытие не теряет текст: черновик хранится до отправки
|
||||
const draftMark = document.createElement('span');
|
||||
draftMark.className = 'channel-editor__draft';
|
||||
draftMark.textContent = t('screens.channel_editor.text_001');
|
||||
const headerEnd = document.createElement('div');
|
||||
headerEnd.className = 'channel-editor__header-end';
|
||||
header.append(closeButton, heading, headerEnd);
|
||||
|
||||
const body = document.createElement('div');
|
||||
body.className = 'channel-editor__body';
|
||||
|
||||
// Цепочка как в Threads: исходная запись и ответы до той, на которую отвечаем, сверху вниз, соединены линией.
|
||||
// Поле ввода – последним звеном; к началу цепочки – прокруткой вверх.
|
||||
const chain = Array.isArray(context?.chain) ? context.chain.filter(Boolean) : [];
|
||||
if (chain.length) {
|
||||
const chainBox = document.createElement('ol');
|
||||
chainBox.className = 'channel-editor__chain';
|
||||
chainBox.setAttribute('aria-label', t('screens.channel_editor.text_026'));
|
||||
chain.forEach((item) => {
|
||||
const row = document.createElement('li');
|
||||
row.className = 'channel-editor__chain-item';
|
||||
const avatar = item.avatar instanceof Node ? item.avatar : renderUserAvatar({ login: item.author || 'unknown', className: 'avatar-plain', size: 'sm' });
|
||||
avatar.classList.add('channel-editor__chain-avatar');
|
||||
const main = document.createElement('div');
|
||||
main.className = 'channel-editor__chain-main';
|
||||
const head = document.createElement('div');
|
||||
head.className = 'channel-editor__chain-head';
|
||||
const name = document.createElement('strong');
|
||||
name.textContent = String(item.title || item.author || '');
|
||||
head.append(name);
|
||||
if (item.time) {
|
||||
const time = document.createElement('span');
|
||||
time.textContent = item.time;
|
||||
head.append(time);
|
||||
}
|
||||
const text = document.createElement('p');
|
||||
text.textContent = String(item.text || item.attachmentLabel || t('screens.channel_editor.text_013'));
|
||||
main.append(head, text);
|
||||
row.append(avatar, main);
|
||||
chainBox.append(row);
|
||||
});
|
||||
body.append(chainBox);
|
||||
} else if (context && (context.author || context.text || context.attachmentLabel)) {
|
||||
const contextBox = document.createElement('div');
|
||||
contextBox.className = 'channel-editor__context';
|
||||
const contextTitle = document.createElement('strong');
|
||||
contextTitle.textContent = context.author ? t('screens.channel_editor.text_020', { value1: context.author }) : t('screens.channel_editor.text_009');
|
||||
const quote = document.createElement('p');
|
||||
quote.textContent = String(context.text || context.attachmentLabel || t('screens.channel_editor.text_014'));
|
||||
const expand = document.createElement('button');
|
||||
expand.type = 'button';
|
||||
expand.className = 'text-btn channel-editor__context-toggle';
|
||||
expand.textContent = t('screens.channel_editor.text_002');
|
||||
expand.setAttribute('aria-expanded', 'false');
|
||||
expand.addEventListener('click', () => {
|
||||
const expanded = contextBox.classList.toggle('is-expanded');
|
||||
expand.textContent = expanded ? t('screens.channel_editor.text_010') : t('screens.channel_editor.text_011');
|
||||
expand.setAttribute('aria-expanded', String(expanded));
|
||||
});
|
||||
contextBox.append(contextTitle, quote, expand);
|
||||
body.append(contextBox);
|
||||
}
|
||||
|
||||
const textarea = document.createElement('textarea');
|
||||
textarea.className = 'channel-editor__input';
|
||||
textarea.rows = 1;
|
||||
textarea.maxLength = 2000;
|
||||
textarea.placeholder = placeholder;
|
||||
textarea.setAttribute('aria-label', placeholder);
|
||||
textarea.value = String(saved.text || '');
|
||||
|
||||
const attachmentsBox = document.createElement('div');
|
||||
attachmentsBox.className = 'channel-editor__attachments';
|
||||
attachmentsBox.setAttribute('aria-live', 'polite');
|
||||
|
||||
const error = document.createElement('p');
|
||||
error.className = 'channel-editor__error';
|
||||
error.setAttribute('role', 'alert');
|
||||
|
||||
const clearButton = document.createElement('button');
|
||||
clearButton.type = 'button';
|
||||
clearButton.className = 'text-btn channel-editor__clear';
|
||||
clearButton.textContent = t('screens.channel_editor.text_003');
|
||||
|
||||
const author = document.createElement('div');
|
||||
author.className = 'channel-editor__author';
|
||||
author.append(renderUserAvatar({ login: login || 'guest', className: 'avatar-plain', size: 'md' }));
|
||||
const authorText = document.createElement('span');
|
||||
authorText.className = 'channel-editor__author-text';
|
||||
const authorName = document.createElement('strong');
|
||||
authorName.textContent = login || t('screens.channel_editor.text_015');
|
||||
authorText.append(authorName);
|
||||
if (destination) {
|
||||
const where = document.createElement('small');
|
||||
where.textContent = destination;
|
||||
authorText.append(where);
|
||||
}
|
||||
author.append(authorText);
|
||||
if (chain.length) author.classList.add('is-chained');
|
||||
body.append(author);
|
||||
|
||||
const footer = document.createElement('footer');
|
||||
footer.className = 'channel-editor__footer';
|
||||
const attachButton = document.createElement('button');
|
||||
attachButton.type = 'button';
|
||||
attachButton.className = 'icon-btn channel-editor__attach';
|
||||
attachButton.innerHTML = `${iconHtml('image')}<span class="sr-only">${th('screens.channel_editor.text_024')}</span>`;
|
||||
attachButton.title = t('screens.channel_editor.text_004');
|
||||
attachButton.hidden = !allowAttachments;
|
||||
// Как в Threads: текст пишется прямо под именем, без рамки; под ним – вложения.
|
||||
// «Прикрепить» – в нижней панели у кнопки отправки, «Очистить» – в шапке, пока есть что очищать.
|
||||
const compose = document.createElement('div');
|
||||
compose.className = 'channel-editor__compose';
|
||||
compose.append(textarea, attachmentsBox, error);
|
||||
authorText.append(compose);
|
||||
headerEnd.append(clearButton, draftMark);
|
||||
const counter = document.createElement('span');
|
||||
counter.className = 'channel-editor__counter';
|
||||
const submitButton = document.createElement('button');
|
||||
submitButton.type = 'button';
|
||||
submitButton.className = 'primary-btn channel-editor__submit';
|
||||
submitButton.textContent = submitLabel;
|
||||
submitButton.title = t('screens.channel_editor.text_005');
|
||||
footer.append(attachButton);
|
||||
if (extraControl instanceof Node) {
|
||||
footer.classList.add('has-extra');
|
||||
footer.append(extraControl);
|
||||
}
|
||||
footer.append(counter, submitButton);
|
||||
dialog.append(header, body, footer);
|
||||
overlay.append(dialog);
|
||||
root.replaceChildren(overlay);
|
||||
|
||||
const saveDraft = () => {
|
||||
const value = { text: textarea.value, attachments: [...attachments], controls: extraFields.map((field) => field.value) };
|
||||
if (completed) { drafts.delete(storageKey); return; }
|
||||
if (value.text || value.attachments.length) drafts.set(storageKey, value);
|
||||
else drafts.delete(storageKey);
|
||||
};
|
||||
|
||||
const sync = () => {
|
||||
textarea.style.height = 'auto';
|
||||
textarea.style.height = `${Math.max(24, textarea.scrollHeight)}px`;
|
||||
const length = textarea.value.length;
|
||||
counter.textContent = `${length} / 2000`;
|
||||
counter.classList.toggle('is-near-limit', length >= 1800);
|
||||
// Счётчик нужен только у предела, пустой «0 / 2000» лишь шумит.
|
||||
counter.classList.toggle('is-hidden', length < 1500);
|
||||
submitButton.disabled = inFlight || picking || length > textarea.maxLength || (!allowEmptyText && !textarea.value.trim() && attachments.length === 0);
|
||||
dialog.setAttribute('aria-busy', String(inFlight || picking));
|
||||
clearButton.hidden = !textarea.value && attachments.length === 0;
|
||||
draftMark.hidden = !clearButton.hidden;
|
||||
attachmentsBox.replaceChildren();
|
||||
attachments.forEach((item, index) => {
|
||||
const card = document.createElement('div');
|
||||
card.className = 'channel-editor__attachment';
|
||||
const label = document.createElement('span');
|
||||
label.textContent = attachmentLabel(item);
|
||||
const remove = document.createElement('button');
|
||||
remove.type = 'button';
|
||||
remove.className = 'icon-btn';
|
||||
remove.setAttribute('aria-label', t('screens.channel_editor.text_022', { value1: item?.name || '' }));
|
||||
remove.textContent = '×';
|
||||
remove.disabled = inFlight;
|
||||
remove.addEventListener('click', () => {
|
||||
attachments.splice(index, 1);
|
||||
saveDraft();
|
||||
sync();
|
||||
});
|
||||
card.append(label, remove);
|
||||
attachmentsBox.append(card);
|
||||
});
|
||||
};
|
||||
|
||||
// «Назад» закрывает редактор, а не уводит со страницы; слой в истории ведёт роутер.
|
||||
const historyLayer = openHistoryLayer(() => close({ fromHistory: true }));
|
||||
const viewport = window.visualViewport;
|
||||
const updateViewport = () => {
|
||||
overlay.style.setProperty('--editor-height', `${viewport?.height || window.innerHeight}px`);
|
||||
overlay.style.setProperty('--editor-top', `${viewport?.offsetTop || 0}px`);
|
||||
};
|
||||
const observer = new MutationObserver(() => {
|
||||
if (!overlay.isConnected) close({ restoreFocus: false });
|
||||
});
|
||||
const close = ({ fromHistory = false, restoreFocus = true } = {}) => {
|
||||
if (closed) return;
|
||||
closed = true;
|
||||
saveDraft();
|
||||
observer.disconnect();
|
||||
attachmentController.abort();
|
||||
document.removeEventListener('keydown', onDocumentKeydown);
|
||||
viewport?.removeEventListener('resize', updateViewport);
|
||||
viewport?.removeEventListener('scroll', updateViewport);
|
||||
window.removeEventListener('resize', updateViewport);
|
||||
overlay.remove();
|
||||
if (!fromHistory) historyLayer.close();
|
||||
if (restoreFocus && opener?.isConnected) opener.focus({ preventScroll: true });
|
||||
};
|
||||
overlay.cleanup = () => close({ restoreFocus: false });
|
||||
|
||||
const submit = async () => {
|
||||
if (inFlight || submitButton.disabled) return;
|
||||
inFlight = true;
|
||||
error.textContent = '';
|
||||
textarea.disabled = true;
|
||||
attachButton.disabled = true;
|
||||
clearButton.disabled = true;
|
||||
if (extraControl) extraControl.querySelectorAll('select,button,input').forEach((el) => { el.disabled = true; });
|
||||
submitButton.textContent = t('screens.channel_editor.text_006');
|
||||
sync();
|
||||
try {
|
||||
const accepted = await confirmPublicHistoryAction({
|
||||
title: t('dialogs.final.consent.publish_title'),
|
||||
aboveEditor: true,
|
||||
text: t('dialogs.final.consent.publish_warning'),
|
||||
confirmLabel: t('dialogs.final.consent.publish_accept'),
|
||||
cancelLabel: t('dialogs.final.consent.return_to_draft'),
|
||||
});
|
||||
if (!isActive() || closed) return;
|
||||
if (!accepted) {
|
||||
inFlight = false;
|
||||
textarea.disabled = false;
|
||||
attachButton.disabled = false;
|
||||
clearButton.disabled = false;
|
||||
if (extraControl) extraControl.querySelectorAll('select,button,input').forEach((el) => { el.disabled = false; });
|
||||
submitButton.textContent = submitLabel;
|
||||
saveDraft();
|
||||
sync();
|
||||
return;
|
||||
}
|
||||
await onSubmit({
|
||||
text: rawText ? textarea.value.trim() : composeMessageWithAttachments(textarea.value.trim(), attachments),
|
||||
attachments: [...attachments],
|
||||
});
|
||||
completed = true;
|
||||
attachments.filter((item) => item?.ar).forEach((item) => markArweaveAttachmentPlaced(login, item));
|
||||
// Не удаляем новый черновик, открытый после закрытия отправляющего редактора.
|
||||
if (!closed || drafts.get(storageKey)?.text === textarea.value) drafts.delete(storageKey);
|
||||
if (!isActive() || closed) return;
|
||||
close();
|
||||
} catch (submitError) {
|
||||
if (!isActive() || closed) return;
|
||||
inFlight = false;
|
||||
textarea.disabled = false;
|
||||
attachButton.disabled = false;
|
||||
clearButton.disabled = false;
|
||||
if (extraControl) extraControl.querySelectorAll('select,button,input').forEach((el) => { el.disabled = false; });
|
||||
submitButton.textContent = submitLabel;
|
||||
error.textContent = toUserMessage(submitError, t('screens.channel_editor.text_007'));
|
||||
saveDraft();
|
||||
sync();
|
||||
}
|
||||
};
|
||||
|
||||
const onDocumentKeydown = (event) => {
|
||||
if (!overlay.isConnected || document.querySelector('.ar-attachment-manager-root, .public-attachment-manager-root')) return;
|
||||
if (event.key === 'Escape') {
|
||||
event.preventDefault();
|
||||
close();
|
||||
return;
|
||||
}
|
||||
if (event.key === 'Enter' && (event.ctrlKey || event.metaKey) && !composing && !event.isComposing) {
|
||||
event.preventDefault();
|
||||
void submit();
|
||||
return;
|
||||
}
|
||||
if (event.key !== 'Tab') return;
|
||||
const focusable = [...overlay.querySelectorAll('button:not(:disabled), textarea:not(:disabled), select:not(:disabled)')].filter((el) => !el.hidden);
|
||||
if (!focusable.length) return;
|
||||
const first = focusable[0];
|
||||
const last = focusable[focusable.length - 1];
|
||||
if (event.shiftKey && document.activeElement === first) {
|
||||
event.preventDefault();
|
||||
last.focus();
|
||||
} else if (!event.shiftKey && document.activeElement === last) {
|
||||
event.preventDefault();
|
||||
first.focus();
|
||||
}
|
||||
};
|
||||
|
||||
closeButton.addEventListener('click', () => close());
|
||||
clearButton.addEventListener('click', () => {
|
||||
textarea.value = '';
|
||||
attachments.splice(0);
|
||||
drafts.delete(storageKey);
|
||||
error.textContent = '';
|
||||
sync();
|
||||
textarea.focus();
|
||||
});
|
||||
textarea.addEventListener('input', () => {
|
||||
error.textContent = '';
|
||||
saveDraft();
|
||||
sync();
|
||||
});
|
||||
textarea.addEventListener('compositionstart', () => { composing = true; });
|
||||
extraFields.forEach((field) => field.addEventListener('change', saveDraft));
|
||||
textarea.addEventListener('compositionend', () => { composing = false; });
|
||||
attachButton.addEventListener('click', async () => {
|
||||
if (picking || inFlight) return;
|
||||
if (attachments.length >= MAX_MESSAGE_ATTACHMENTS) {
|
||||
error.textContent = t('screens.channel_editor.text_023', { value1: MAX_MESSAGE_ATTACHMENTS });
|
||||
return;
|
||||
}
|
||||
try {
|
||||
picking = true;
|
||||
dialog.inert = true;
|
||||
sync();
|
||||
const item = await openChannelAttachmentManager({
|
||||
login,
|
||||
storagePwd: state.session.storagePwdInMemory,
|
||||
gateway: state.entrySettings.arweaveServer,
|
||||
selectedTxIds: attachments.map((attachment) => attachment.ar),
|
||||
signal: attachmentController.signal,
|
||||
});
|
||||
if (!isActive() || !overlay.isConnected || !item) return;
|
||||
attachments.push(item);
|
||||
saveDraft();
|
||||
sync();
|
||||
} catch (attachError) {
|
||||
if (isActive() && overlay.isConnected) {
|
||||
error.textContent = toUserMessage(attachError, t('screens.channel_editor.text_008'));
|
||||
}
|
||||
} finally {
|
||||
picking = false;
|
||||
dialog.inert = false;
|
||||
if (!closed) { sync(); attachButton.focus(); }
|
||||
}
|
||||
});
|
||||
submitButton.addEventListener('click', () => void submit());
|
||||
document.addEventListener('keydown', onDocumentKeydown);
|
||||
viewport?.addEventListener('resize', updateViewport);
|
||||
viewport?.addEventListener('scroll', updateViewport);
|
||||
window.addEventListener('resize', updateViewport);
|
||||
observer.observe(root, { childList: true });
|
||||
updateViewport();
|
||||
sync();
|
||||
requestAnimationFrame(() => {
|
||||
if (closed || !isActive()) return;
|
||||
const quote = overlay.querySelector('.channel-editor__context p');
|
||||
const expand = overlay.querySelector('.channel-editor__context-toggle');
|
||||
if (quote && expand && quote.clientHeight > 0) expand.hidden = quote.scrollHeight <= quote.clientHeight;
|
||||
sync();
|
||||
if (chain.length) body.scrollTop = author.offsetTop - body.offsetTop - 120;
|
||||
textarea.focus({ preventScroll: chain.length > 0 });
|
||||
if (openAttachOnStart && allowAttachments) attachButton.click();
|
||||
textarea.setSelectionRange(textarea.value.length, textarea.value.length);
|
||||
});
|
||||
return { close };
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
// Возвращает Promise<boolean>: true — подтвердили, false — отмена, Escape или тап мимо.
|
||||
export function confirmDialog({
|
||||
title = t('remaining.confirmation.confirm_action'),
|
||||
text = '',
|
||||
confirmLabel = t('remaining.confirmation.yes'),
|
||||
cancelLabel = t('remaining.confirmation.cancel'),
|
||||
danger = false,
|
||||
aboveEditor = false,
|
||||
rememberChoice = null,
|
||||
} = {}) {
|
||||
return new Promise((resolve) => {
|
||||
const opener = document.activeElement;
|
||||
const modal = document.createElement('div');
|
||||
modal.className = `modal confirm-dialog${aboveEditor ? ' confirm-dialog--above-editor' : ''}`;
|
||||
modal.innerHTML = `
|
||||
<div class="modal-card confirm-dialog__card" role="alertdialog" aria-modal="true" aria-labelledby="confirm-dialog-title">
|
||||
<h2 class="modal-title" id="confirm-dialog-title"></h2>
|
||||
<p class="confirm-dialog__text"></p>
|
||||
<div class="form-actions-grid">
|
||||
<button type="button" class="secondary-btn" data-answer="no"></button>
|
||||
<button type="button" class="${danger ? 'destructive-btn confirm-dialog__danger' : 'primary-btn'}" data-answer="yes"></button>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
modal.querySelector('.modal-title').textContent = title;
|
||||
const textEl = modal.querySelector('.confirm-dialog__text');
|
||||
textEl.textContent = text;
|
||||
textEl.hidden = !text;
|
||||
let rememberCheckbox = null;
|
||||
if (rememberChoice?.label) {
|
||||
const label = document.createElement('label');
|
||||
label.className = 'confirm-dialog__remember';
|
||||
rememberCheckbox = document.createElement('input');
|
||||
rememberCheckbox.type = 'checkbox';
|
||||
const explanation = document.createElement('span');
|
||||
explanation.textContent = rememberChoice.label;
|
||||
label.append(rememberCheckbox, explanation);
|
||||
modal.querySelector('.form-actions-grid').before(label);
|
||||
}
|
||||
modal.querySelector('[data-answer="no"]').textContent = cancelLabel;
|
||||
modal.querySelector('[data-answer="yes"]').textContent = confirmLabel;
|
||||
|
||||
const finish = (answer) => {
|
||||
document.removeEventListener('keydown', onKeydown, true);
|
||||
modal.remove();
|
||||
opener?.focus?.();
|
||||
if (answer && rememberCheckbox?.checked) rememberChoice?.onConfirm?.();
|
||||
resolve(answer);
|
||||
};
|
||||
const onKeydown = (event) => {
|
||||
if (event.key === 'Escape') { event.stopPropagation(); finish(false); }
|
||||
};
|
||||
modal.addEventListener('click', (event) => {
|
||||
if (event.target === modal) { finish(false); return; }
|
||||
const answer = event.target.closest('[data-answer]')?.dataset.answer;
|
||||
if (answer) finish(answer === 'yes');
|
||||
});
|
||||
document.addEventListener('keydown', onKeydown, true);
|
||||
document.body.append(modal);
|
||||
modal.querySelector('[data-answer="no"]').focus();
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
import { openSheet } from './sheet.js';
|
||||
|
||||
// Пошаговое подтверждение перед публичной записью. Ни один шаг не выполняет сетевых запросов.
|
||||
// Текст задаёт вызывающий экран; запись начинается только после прохождения всех шагов.
|
||||
export function confirmConsentSteps({ title = t('remaining.consent.confirmation'), steps = [] } = {}) {
|
||||
if (!steps.length) return Promise.resolve(false);
|
||||
return new Promise((resolve) => {
|
||||
let completed = false;
|
||||
let stepIndex = 0;
|
||||
const content = document.createElement('div');
|
||||
content.className = 'stack profile-consent-flow';
|
||||
const progress = document.createElement('div');
|
||||
progress.className = 'meta-muted profile-consent-progress';
|
||||
const heading = document.createElement('h3');
|
||||
heading.className = 'profile-consent-heading';
|
||||
const paragraph = document.createElement('p');
|
||||
paragraph.className = 'profile-consent-description';
|
||||
const checkboxLabel = document.createElement('label');
|
||||
checkboxLabel.className = 'profile-consent-accept';
|
||||
const checkbox = document.createElement('input');
|
||||
checkbox.type = 'checkbox';
|
||||
const checkboxText = document.createElement('span');
|
||||
checkboxLabel.append(checkbox, checkboxText);
|
||||
const actions = document.createElement('div');
|
||||
actions.className = 'form-actions-grid';
|
||||
const cancelBtn = document.createElement('button');
|
||||
cancelBtn.type = 'button';
|
||||
cancelBtn.className = 'secondary-btn';
|
||||
cancelBtn.textContent = t('screens.consent_steps.text_001');
|
||||
const nextBtn = document.createElement('button');
|
||||
nextBtn.type = 'button';
|
||||
nextBtn.className = 'primary-btn';
|
||||
actions.append(cancelBtn, nextBtn);
|
||||
content.append(progress, heading, paragraph, checkboxLabel, actions);
|
||||
|
||||
const sheet = openSheet({
|
||||
title,
|
||||
className: 'profile-consent-sheet',
|
||||
content,
|
||||
onClose: () => resolve(completed),
|
||||
});
|
||||
function renderStep() {
|
||||
const step = steps[stepIndex];
|
||||
progress.textContent = `${stepIndex + 1} / ${steps.length}`;
|
||||
heading.textContent = step.title;
|
||||
paragraph.textContent = step.text;
|
||||
checkbox.checked = false;
|
||||
checkboxLabel.hidden = !step.accept;
|
||||
checkboxText.textContent = step.accept || '';
|
||||
nextBtn.disabled = Boolean(step.accept);
|
||||
nextBtn.textContent = step.button || (stepIndex === steps.length - 1 ? t('screens.consent_steps.text_002') : t('screens.consent_steps.text_003'));
|
||||
}
|
||||
checkbox.addEventListener('change', () => { nextBtn.disabled = !checkbox.checked; });
|
||||
cancelBtn.addEventListener('click', () => sheet.close());
|
||||
nextBtn.addEventListener('click', () => {
|
||||
if (steps[stepIndex].accept && !checkbox.checked) return;
|
||||
if (stepIndex === steps.length - 1) {
|
||||
completed = true;
|
||||
sheet.close();
|
||||
} else {
|
||||
stepIndex += 1;
|
||||
renderStep();
|
||||
}
|
||||
});
|
||||
renderStep();
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
// Вложения личных сообщений: превью картинок и видео после расшифровки и карточка файла со «Скачать».
|
||||
// Общие для ленты чата и экрана «Медиа и файлы».
|
||||
import { decryptDmFileToBlob, downloadAndDecryptDmFile, isDmFileExpired } from '../services/dm-file-service.js';
|
||||
import { formatBytes, getAttachmentKind } from '../services/attachment-format.js';
|
||||
import { showToast } from '../services/channels-ux.js';
|
||||
import { iconHtml } from './ui-icon.js';
|
||||
import { createSpinner } from './feedback.js';
|
||||
import { actionErrorText } from '../services/ui-error-texts.js';
|
||||
|
||||
// Картинки и видео в личке показываются так же, как в каналах (карусель + просмотрщик),
|
||||
// только файл сначала расшифровывается. Большие файлы остаются карточками со «Скачать»,
|
||||
// чтобы не тратить трафик на автозагрузку.
|
||||
const DM_INLINE_MEDIA_MAX_BYTES = 20 * 1024 * 1024;
|
||||
const DM_MEDIA_MIME = { jpg: 'image/jpeg', jpeg: 'image/jpeg', png: 'image/png', gif: 'image/gif', webp: 'image/webp', avif: 'image/avif', bmp: 'image/bmp', svg: 'image/svg+xml', mp4: 'video/mp4', m4v: 'video/mp4', webm: 'video/webm', mov: 'video/quicktime', ogv: 'video/ogg' };
|
||||
const dmMediaBlobs = new Map();
|
||||
const DM_MEDIA_CACHE_LIMIT = 40;
|
||||
|
||||
export function isDmInlineMedia(attachment) {
|
||||
if (attachment?.kind === 'voice' || isDmFileExpired(attachment)) return false;
|
||||
const size = Number(attachment?.size || 0);
|
||||
if (!(size > 0 && size <= DM_INLINE_MEDIA_MAX_BYTES)) return false;
|
||||
const kind = getAttachmentKind(attachment);
|
||||
return kind === 'image' || kind === 'video';
|
||||
}
|
||||
|
||||
// Расшифрованный файл держим в памяти: лента перерисовывается на каждое новое сообщение,
|
||||
// и без кэша картинка расшифровывалась бы и мигала заново.
|
||||
export function resolveDmMediaUrl(attachment) {
|
||||
if (isDmFileExpired(attachment)) return Promise.reject(new Error('DM_FILE_EXPIRED'));
|
||||
const key = String(attachment?.id || attachment?.url || '');
|
||||
let pending = dmMediaBlobs.get(key);
|
||||
if (!pending) {
|
||||
const ext = String(attachment?.name || '').split('.').pop().toLowerCase();
|
||||
pending = decryptDmFileToBlob(attachment)
|
||||
.then((blob) => new Blob([blob], { type: DM_MEDIA_MIME[ext] || blob.type || 'application/octet-stream' }));
|
||||
pending.catch(() => dmMediaBlobs.delete(key));
|
||||
dmMediaBlobs.set(key, pending);
|
||||
if (dmMediaBlobs.size > DM_MEDIA_CACHE_LIMIT) dmMediaBlobs.delete(dmMediaBlobs.keys().next().value);
|
||||
}
|
||||
return pending.then((blob) => ({ url: URL.createObjectURL(blob), objectUrl: true }));
|
||||
}
|
||||
|
||||
export function createDmExpiredAttachmentCard(attachment) {
|
||||
const card = document.createElement('div');
|
||||
card.className = 'dm-file-card';
|
||||
const copy = document.createElement('span');
|
||||
copy.className = 'dm-file-card__copy';
|
||||
const name = document.createElement('strong');
|
||||
name.className = 'dm-file-card__name';
|
||||
name.textContent = attachment?.name || 'file';
|
||||
const info = document.createElement('span');
|
||||
info.className = 'dm-file-card__meta';
|
||||
info.textContent = t('screens.dm_attachments.file_expired');
|
||||
copy.append(name, info);
|
||||
card.append(copy);
|
||||
return card;
|
||||
}
|
||||
|
||||
export function createDmFileAttachmentCard(attachment) {
|
||||
if (isDmFileExpired(attachment)) return createDmExpiredAttachmentCard(attachment);
|
||||
const fileCard = document.createElement('div');
|
||||
fileCard.className = 'dm-file-card';
|
||||
|
||||
const fileIcon = document.createElement('span');
|
||||
fileIcon.className = 'dm-file-card__icon';
|
||||
fileIcon.setAttribute('aria-hidden', 'true');
|
||||
fileIcon.innerHTML = iconHtml('doc');
|
||||
|
||||
const fileCopy = document.createElement('span');
|
||||
fileCopy.className = 'dm-file-card__copy';
|
||||
const fileName = document.createElement('strong');
|
||||
fileName.className = 'dm-file-card__name';
|
||||
fileName.textContent = attachment.name || 'file';
|
||||
const fileMeta = document.createElement('span');
|
||||
fileMeta.className = 'dm-file-card__meta';
|
||||
const metaParts = [formatBytes(attachment.size)];
|
||||
if (Number(attachment?.version || 1) === 2) metaParts.push('BitTorrent v2');
|
||||
fileMeta.textContent = metaParts.join(' · ');
|
||||
fileCopy.append(fileName, fileMeta);
|
||||
|
||||
// Круглая кнопка со стрелкой; пока файл качается и расшифровывается – проценты в ней же.
|
||||
const downloadBtn = document.createElement('button');
|
||||
downloadBtn.type = 'button';
|
||||
downloadBtn.className = 'dm-file-card__download';
|
||||
downloadBtn.title = t('screens.dm_attachments.text_001');
|
||||
downloadBtn.setAttribute('aria-label', t('screens.dm_attachments.text_007', { value1: attachment.name || t('screens.dm_attachments.text_006') }));
|
||||
const showDownloadIcon = () => {
|
||||
downloadBtn.classList.remove('is-busy');
|
||||
downloadBtn.innerHTML = iconHtml('download');
|
||||
};
|
||||
showDownloadIcon();
|
||||
downloadBtn.addEventListener('click', async (event) => {
|
||||
event.stopPropagation();
|
||||
if (downloadBtn.disabled) return;
|
||||
downloadBtn.disabled = true;
|
||||
downloadBtn.classList.add('is-busy');
|
||||
downloadBtn.replaceChildren(createSpinner({ size: 'sm', label: t('screens.dm_attachments.text_002') }));
|
||||
try {
|
||||
const result = await downloadAndDecryptDmFile(attachment, {
|
||||
onProgress: ({ processedBytes, totalBytes }) => {
|
||||
if (!totalBytes) return;
|
||||
const percent = Math.min(100, Math.max(0, Math.round((processedBytes / totalBytes) * 100)));
|
||||
downloadBtn.textContent = `${percent}%`;
|
||||
},
|
||||
});
|
||||
if (!result?.cancelled) {
|
||||
// Сохранён сразу на диск (по частям) или отдан браузеру – для человека это одно и то же.
|
||||
showToast(result?.streamed ? t('screens.dm_attachments.text_004') : t('screens.dm_attachments.text_005'), { timeoutMs: 1600 });
|
||||
}
|
||||
} catch (error) {
|
||||
showToast(actionErrorText(t('screens.dm_attachments.text_003'), error), { kind: 'error' });
|
||||
} finally {
|
||||
downloadBtn.disabled = false;
|
||||
showDownloadIcon();
|
||||
}
|
||||
});
|
||||
|
||||
fileCard.append(fileIcon, fileCopy, downloadBtn);
|
||||
return fileCard;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
// Пункт меню чата «Без звука» со сроком – общий для шапки чата и меню строки в списке чатов.
|
||||
// Срок выбирается во вложенном списке того же меню; включённый звук возвращается одним нажатием.
|
||||
import { iconHtml } from './ui-icon.js';
|
||||
import { formatDmMuteUntil, getDmChatMutedUntil, setDmChatMuted } from '../services/dm-chat-prefs.js';
|
||||
import { showToast } from '../services/channels-ux.js';
|
||||
|
||||
const HOUR = 60 * 60 * 1000;
|
||||
const DURATIONS = () => [
|
||||
[t('screens.dm_mute_menu.text_007'), HOUR],
|
||||
[t('screens.dm_mute_menu.text_008'), 8 * HOUR],
|
||||
[t('screens.dm_mute_menu.text_009'), 24 * HOUR],
|
||||
[t('screens.dm_mute_menu.text_010'), 7 * 24 * HOUR],
|
||||
[t('screens.dm_mute_menu.text_011'), 0],
|
||||
];
|
||||
|
||||
export function createDmMuteMenuItem(chatId, { iconClass = '', onChange = null } = {}) {
|
||||
const until = getDmChatMutedUntil(chatId);
|
||||
if (until !== null) {
|
||||
return {
|
||||
label: t('screens.dm_mute_menu.text_001'),
|
||||
hint: until ? t('screens.dm_mute_menu.text_005', { value1: formatDmMuteUntil(until) }) : '',
|
||||
iconHtml: iconHtml('bell', false, iconClass),
|
||||
action: () => {
|
||||
setDmChatMuted(chatId, false);
|
||||
showToast(t('screens.dm_mute_menu.text_003'), { timeoutMs: 1400 });
|
||||
onChange?.(false);
|
||||
},
|
||||
};
|
||||
}
|
||||
return {
|
||||
label: t('screens.dm_mute_menu.text_002'),
|
||||
iconHtml: iconHtml('bell-off', false, iconClass),
|
||||
submenu: DURATIONS().map(([label, ms]) => ({
|
||||
label,
|
||||
action: () => {
|
||||
const untilMs = ms ? Date.now() + ms : 0;
|
||||
setDmChatMuted(chatId, true, { untilMs });
|
||||
showToast(untilMs ? t('screens.dm_mute_menu.text_006', { value1: formatDmMuteUntil(untilMs) }) : t('screens.dm_mute_menu.text_004'), { timeoutMs: 1800 });
|
||||
onChange?.(true);
|
||||
},
|
||||
})),
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,282 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
import { iconHtml } from './ui-icon.js';
|
||||
|
||||
let activeDropdown = null;
|
||||
|
||||
function normalizeItems(items) {
|
||||
const value = typeof items === 'function' ? items() : items;
|
||||
return Array.isArray(value) ? value.filter(Boolean) : [];
|
||||
}
|
||||
|
||||
function resolvePlacement({ placement, align }) {
|
||||
if (placement === 'bottom-start' || placement === 'top-start') return 'left';
|
||||
if (placement === 'bottom-end' || placement === 'top-end') return 'right';
|
||||
return align === 'left' ? 'left' : 'right';
|
||||
}
|
||||
|
||||
export function createDropdownMenu({
|
||||
anchorEl,
|
||||
items = [],
|
||||
renderContent = null,
|
||||
className = '',
|
||||
minWidth = 210,
|
||||
offset = 7,
|
||||
placement = 'bottom-end',
|
||||
align = null,
|
||||
leftShift = 0,
|
||||
transparent = false,
|
||||
dimBackground = true,
|
||||
keepAnchorPressed = true,
|
||||
onOpen = null,
|
||||
onClose = null,
|
||||
} = {}) {
|
||||
let portal = null;
|
||||
let menuEl = null;
|
||||
let destroyed = false;
|
||||
|
||||
const setAnchorOpen = (isOpen) => {
|
||||
if (!anchorEl) return;
|
||||
anchorEl.setAttribute('aria-haspopup', 'menu');
|
||||
anchorEl.setAttribute('aria-expanded', isOpen ? 'true' : 'false');
|
||||
if (keepAnchorPressed && isOpen) anchorEl.dataset.open = 'true';
|
||||
else delete anchorEl.dataset.open;
|
||||
};
|
||||
|
||||
const close = ({ focusAnchor = false } = {}) => {
|
||||
if (!portal) return;
|
||||
portal.remove();
|
||||
portal = null;
|
||||
menuEl = null;
|
||||
if (activeDropdown === api) activeDropdown = null;
|
||||
setAnchorOpen(false);
|
||||
onClose?.();
|
||||
if (focusAnchor) anchorEl?.focus?.();
|
||||
};
|
||||
|
||||
const position = () => {
|
||||
if (!portal || !menuEl || !anchorEl) return;
|
||||
const rect = anchorEl.getBoundingClientRect();
|
||||
const margin = 10;
|
||||
const menuWidth = menuEl.offsetWidth || minWidth;
|
||||
const side = resolvePlacement({ placement, align });
|
||||
const baseLeft = side === 'left' ? rect.left : rect.right - menuWidth;
|
||||
const desiredLeft = baseLeft - Number(leftShift || 0);
|
||||
const left = Math.max(margin, Math.min(window.innerWidth - menuWidth - margin, desiredLeft));
|
||||
|
||||
const menuHeight = menuEl.offsetHeight || 180;
|
||||
const prefersTop = String(placement || '').startsWith('top-');
|
||||
let top = prefersTop ? rect.top - menuHeight - offset : rect.bottom + offset;
|
||||
if (!prefersTop && top + menuHeight > window.innerHeight - margin) {
|
||||
top = Math.max(margin, rect.top - menuHeight - offset);
|
||||
} else if (prefersTop && top < margin) {
|
||||
top = Math.min(window.innerHeight - menuHeight - margin, rect.bottom + offset);
|
||||
}
|
||||
|
||||
menuEl.style.left = `${Math.round(left)}px`;
|
||||
menuEl.style.top = `${Math.round(top)}px`;
|
||||
};
|
||||
|
||||
// Пункт с submenu не закрывает меню, а показывает вложенный список на том же месте
|
||||
// (сверху – «назад»): так выбирают, например, срок «без звука».
|
||||
const appendItems = (levelItems = items, parentTitle = '') => {
|
||||
if (parentTitle) {
|
||||
const back = document.createElement('button');
|
||||
back.type = 'button';
|
||||
back.className = 'dropdown-menu__item dropdown-menu__back';
|
||||
back.setAttribute('aria-label', t('screens.dropdown_menu.text_001', { value1: parentTitle }));
|
||||
back.innerHTML = `<span class="dropdown-menu__icon">${iconHtml('back')}</span>`;
|
||||
const backLabel = document.createElement('span');
|
||||
backLabel.textContent = parentTitle;
|
||||
back.append(backLabel);
|
||||
back.addEventListener('click', (event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
showLevel(items, '');
|
||||
});
|
||||
const divider = document.createElement('div');
|
||||
divider.className = 'dropdown-menu__divider';
|
||||
divider.setAttribute('role', 'separator');
|
||||
menuEl.append(back, divider);
|
||||
}
|
||||
normalizeItems(levelItems).forEach((item) => {
|
||||
if (item.divider) {
|
||||
const divider = document.createElement('div');
|
||||
divider.className = 'dropdown-menu__divider';
|
||||
divider.setAttribute('role', 'separator');
|
||||
menuEl.append(divider);
|
||||
return;
|
||||
}
|
||||
|
||||
const button = document.createElement('button');
|
||||
button.type = 'button';
|
||||
button.className = `dropdown-menu__item${item.selected ? ' is-selected' : ''}${item.danger ? ' is-danger' : ''}${item.className ? ` ${item.className}` : ''}`;
|
||||
button.setAttribute('role', 'menuitem');
|
||||
button.disabled = Boolean(item.disabled);
|
||||
|
||||
if (item.iconHtml) {
|
||||
const icon = document.createElement('span');
|
||||
icon.className = 'dropdown-menu__icon';
|
||||
icon.innerHTML = item.iconHtml;
|
||||
button.append(icon);
|
||||
} else if (item.iconSrc) {
|
||||
const icon = document.createElement('img');
|
||||
icon.className = 'dropdown-menu__icon';
|
||||
icon.src = item.iconSrc;
|
||||
icon.alt = '';
|
||||
icon.setAttribute('aria-hidden', 'true');
|
||||
button.append(icon);
|
||||
}
|
||||
|
||||
const label = document.createElement('span');
|
||||
label.textContent = String(item.label || '');
|
||||
if (item.hint) {
|
||||
const text = document.createElement('span');
|
||||
text.className = 'dropdown-menu__text';
|
||||
const hint = document.createElement('small');
|
||||
hint.className = 'dropdown-menu__hint';
|
||||
hint.textContent = String(item.hint);
|
||||
text.append(label, hint);
|
||||
button.append(text);
|
||||
} else {
|
||||
button.append(label);
|
||||
}
|
||||
if (item.submenu) {
|
||||
button.setAttribute('aria-haspopup', 'menu');
|
||||
const chevron = document.createElement('span');
|
||||
chevron.className = 'dropdown-menu__chevron';
|
||||
chevron.setAttribute('aria-hidden', 'true');
|
||||
chevron.innerHTML = iconHtml('chevron');
|
||||
button.append(chevron);
|
||||
}
|
||||
button.addEventListener('click', async (event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
if (button.disabled) return;
|
||||
if (item.submenu) {
|
||||
showLevel(item.submenu, String(item.submenuTitle || item.label || ''));
|
||||
return;
|
||||
}
|
||||
close({ focusAnchor: true });
|
||||
await item.action?.();
|
||||
});
|
||||
menuEl.append(button);
|
||||
});
|
||||
};
|
||||
|
||||
const showLevel = (levelItems, parentTitle) => {
|
||||
if (!menuEl) return;
|
||||
menuEl.replaceChildren();
|
||||
appendItems(levelItems, parentTitle);
|
||||
position();
|
||||
// Во вложенном списке фокус – на первый вариант, а не на «назад».
|
||||
(menuEl.querySelector('button:not(:disabled):not(.dropdown-menu__back)')
|
||||
|| menuEl.querySelector('button:not(:disabled)'))?.focus();
|
||||
};
|
||||
|
||||
const open = () => {
|
||||
if (destroyed || !anchorEl || portal) return;
|
||||
if (activeDropdown && activeDropdown !== api) activeDropdown.close();
|
||||
|
||||
portal = document.createElement('div');
|
||||
portal.className = `dropdown-portal${dimBackground ? ' dropdown-portal--dim' : ''}`;
|
||||
|
||||
if (dimBackground) {
|
||||
const backdrop = document.createElement('div');
|
||||
backdrop.className = 'dropdown-backdrop';
|
||||
backdrop.setAttribute('aria-hidden', 'true');
|
||||
backdrop.addEventListener('pointerdown', (event) => {
|
||||
if (event.target === backdrop) close();
|
||||
});
|
||||
portal.append(backdrop);
|
||||
}
|
||||
|
||||
menuEl = document.createElement('div');
|
||||
menuEl.className = `dropdown-menu${transparent ? ' dropdown-menu--transparent' : ''}${className ? ` ${className}` : ''}`;
|
||||
menuEl.setAttribute('role', 'menu');
|
||||
menuEl.style.minWidth = `${minWidth}px`;
|
||||
|
||||
if (typeof renderContent === 'function') {
|
||||
const content = renderContent({ close, menuEl });
|
||||
if (content instanceof Node) menuEl.append(content);
|
||||
} else {
|
||||
appendItems();
|
||||
}
|
||||
|
||||
menuEl.addEventListener('pointerdown', (event) => event.stopPropagation());
|
||||
menuEl.addEventListener('click', (event) => event.stopPropagation());
|
||||
portal.append(menuEl);
|
||||
document.body.append(portal);
|
||||
activeDropdown = api;
|
||||
setAnchorOpen(true);
|
||||
onOpen?.();
|
||||
position();
|
||||
menuEl.querySelector('button:not(:disabled)')?.focus();
|
||||
};
|
||||
|
||||
const toggle = () => {
|
||||
if (portal) close();
|
||||
else open();
|
||||
};
|
||||
|
||||
const onAnchorClick = (event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
toggle();
|
||||
};
|
||||
const onOutsidePointerDown = (event) => {
|
||||
if (!portal) return;
|
||||
if (menuEl?.contains(event.target) || anchorEl?.contains(event.target)) return;
|
||||
close();
|
||||
};
|
||||
const onKeydown = (event) => {
|
||||
if (!portal) return;
|
||||
if (event.key === 'Escape' || event.key === 'Tab') {
|
||||
if (event.key === 'Escape') event.preventDefault();
|
||||
close({ focusAnchor: true });
|
||||
return;
|
||||
}
|
||||
if (!['ArrowDown', 'ArrowUp', 'Home', 'End'].includes(event.key)) return;
|
||||
const buttons = [...menuEl.querySelectorAll('button:not(:disabled)')];
|
||||
if (!buttons.length) return;
|
||||
event.preventDefault();
|
||||
const index = buttons.indexOf(document.activeElement);
|
||||
const next = event.key === 'Home' ? 0 : event.key === 'End' ? buttons.length - 1 : (index + (event.key === 'ArrowUp' ? -1 : 1) + buttons.length) % buttons.length;
|
||||
buttons[next].focus();
|
||||
};
|
||||
const onNavigation = () => close();
|
||||
const onViewportChange = () => position();
|
||||
|
||||
setAnchorOpen(false);
|
||||
anchorEl?.addEventListener('click', onAnchorClick);
|
||||
document.addEventListener('pointerdown', onOutsidePointerDown, true);
|
||||
document.addEventListener('keydown', onKeydown);
|
||||
window.addEventListener('popstate', onNavigation);
|
||||
window.addEventListener('hashchange', onNavigation);
|
||||
window.addEventListener('resize', onViewportChange, { passive: true });
|
||||
window.addEventListener('scroll', onViewportChange, { passive: true, capture: true });
|
||||
|
||||
const api = {
|
||||
open,
|
||||
close,
|
||||
toggle,
|
||||
position,
|
||||
get isOpen() {
|
||||
return Boolean(portal);
|
||||
},
|
||||
destroy() {
|
||||
if (destroyed) return;
|
||||
destroyed = true;
|
||||
close();
|
||||
anchorEl?.removeEventListener('click', onAnchorClick);
|
||||
document.removeEventListener('pointerdown', onOutsidePointerDown, true);
|
||||
document.removeEventListener('keydown', onKeydown);
|
||||
window.removeEventListener('popstate', onNavigation);
|
||||
window.removeEventListener('hashchange', onNavigation);
|
||||
window.removeEventListener('resize', onViewportChange);
|
||||
window.removeEventListener('scroll', onViewportChange, true);
|
||||
setAnchorOpen(false);
|
||||
},
|
||||
};
|
||||
|
||||
return api;
|
||||
}
|
||||
@@ -0,0 +1,276 @@
|
||||
import {
|
||||
TWEMOJI_GROUPS,
|
||||
getTwemojiAssetUrl,
|
||||
getTwemojiPreviewUrl,
|
||||
} from './twemoji-catalog.js?v=202607151545';
|
||||
|
||||
const RECENT_STORAGE_KEY = 'shine-ui-recent-emojis-v1';
|
||||
const MAX_RECENT = 28;
|
||||
const ALL_EMOJI_ITEMS = TWEMOJI_GROUPS.flatMap((group) => group.items);
|
||||
const EMOJI_ASSET_BY_CHAR = new Map(ALL_EMOJI_ITEMS.map((item) => [item.emoji, item]));
|
||||
const TWEMOJI_MATCHER = new RegExp(
|
||||
[...EMOJI_ASSET_BY_CHAR.keys()]
|
||||
.sort((left, right) => right.length - left.length)
|
||||
.map((emoji) => emoji.replace(/[\\^$.*+?()[\]{}|]/g, '\\$&'))
|
||||
.join('|'),
|
||||
'gu',
|
||||
);
|
||||
const DEFAULT_RECENT = ALL_EMOJI_ITEMS.slice(0, 7).map((item) => item.emoji);
|
||||
let activeAnimation = null;
|
||||
|
||||
function loadRecent() {
|
||||
try {
|
||||
const parsed = JSON.parse(localStorage.getItem(RECENT_STORAGE_KEY) || '[]');
|
||||
return Array.isArray(parsed)
|
||||
? parsed.filter((item) => typeof item === 'string' && item).slice(0, MAX_RECENT)
|
||||
: [];
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
function saveRecent(items) {
|
||||
try {
|
||||
localStorage.setItem(RECENT_STORAGE_KEY, JSON.stringify(items.slice(0, MAX_RECENT)));
|
||||
} catch {
|
||||
// Selection remains usable when browser storage is unavailable.
|
||||
}
|
||||
}
|
||||
|
||||
function appendAnimatedAsset(root, item) {
|
||||
const previewUrl = item.previewUrl || getTwemojiPreviewUrl(item.emoji);
|
||||
const animatedUrl = item.animatedUrl || getTwemojiAssetUrl(item.emoji);
|
||||
const hasAnimation = animatedUrl && animatedUrl !== previewUrl;
|
||||
const image = document.createElement('img');
|
||||
image.className = 'twemoji-image';
|
||||
image.alt = '';
|
||||
image.decoding = 'async';
|
||||
image.setAttribute('aria-hidden', 'true');
|
||||
|
||||
// Без отдельного анимационного ассета — просто статичная картинка,
|
||||
// без hover/tap-подмены src и pointer capture (лишние запросы и «моргание»).
|
||||
if (!hasAnimation) {
|
||||
image.src = previewUrl;
|
||||
image.onerror = () => {
|
||||
root.classList.add('is-error');
|
||||
image.removeAttribute('src');
|
||||
};
|
||||
root.append(image);
|
||||
return;
|
||||
}
|
||||
|
||||
let isActive = false;
|
||||
let sourceVersion = 0;
|
||||
|
||||
const setSource = (source) => {
|
||||
const requestedVersion = sourceVersion + 1;
|
||||
sourceVersion = requestedVersion;
|
||||
root.classList.remove('is-error');
|
||||
image.onload = () => {
|
||||
if (requestedVersion !== sourceVersion) return;
|
||||
if (isActive) root.classList.remove('is-loading');
|
||||
};
|
||||
image.onerror = () => {
|
||||
if (requestedVersion !== sourceVersion) return;
|
||||
if (isActive) {
|
||||
isActive = false;
|
||||
root.classList.remove('is-active', 'is-loading');
|
||||
if (activeAnimation?.root === root) activeAnimation = null;
|
||||
setSource(previewUrl);
|
||||
return;
|
||||
}
|
||||
root.classList.add('is-error');
|
||||
image.removeAttribute('src');
|
||||
};
|
||||
image.src = source;
|
||||
};
|
||||
|
||||
const deactivate = () => {
|
||||
isActive = false;
|
||||
root.classList.remove('is-active', 'is-loading', 'is-error');
|
||||
if (activeAnimation?.root === root) activeAnimation = null;
|
||||
setSource(previewUrl);
|
||||
};
|
||||
|
||||
const activate = () => {
|
||||
if (activeAnimation?.root && activeAnimation.root !== root) {
|
||||
activeAnimation.deactivate();
|
||||
}
|
||||
activeAnimation = { root, deactivate };
|
||||
isActive = true;
|
||||
root.classList.add('is-active', 'is-loading');
|
||||
setSource(animatedUrl);
|
||||
};
|
||||
|
||||
const onPointerOver = (event) => {
|
||||
if (event.relatedTarget && root.contains(event.relatedTarget)) return;
|
||||
if (event.pointerType === 'mouse') activate();
|
||||
};
|
||||
|
||||
const onPointerOut = (event) => {
|
||||
if (event.relatedTarget && root.contains(event.relatedTarget)) return;
|
||||
if (event.pointerType === 'mouse') deactivate();
|
||||
};
|
||||
|
||||
const onPointerDown = (event) => {
|
||||
if (event.pointerType === 'mouse') return;
|
||||
root.setPointerCapture?.(event.pointerId);
|
||||
activate();
|
||||
};
|
||||
|
||||
const onPointerEnd = (event) => {
|
||||
if (event.pointerType === 'mouse') return;
|
||||
if (root.hasPointerCapture?.(event.pointerId)) root.releasePointerCapture?.(event.pointerId);
|
||||
deactivate();
|
||||
};
|
||||
|
||||
root.addEventListener('pointerover', onPointerOver);
|
||||
root.addEventListener('pointerout', onPointerOut);
|
||||
root.addEventListener('pointerdown', onPointerDown);
|
||||
root.addEventListener('pointerup', onPointerEnd);
|
||||
root.addEventListener('pointercancel', onPointerEnd);
|
||||
root.addEventListener('lostpointercapture', deactivate);
|
||||
setSource(previewUrl);
|
||||
root.append(image);
|
||||
}
|
||||
|
||||
export function stopAllTwemojiAnimations() {
|
||||
activeAnimation?.deactivate();
|
||||
activeAnimation = null;
|
||||
}
|
||||
|
||||
function createEmojiButton(item, onSelect) {
|
||||
const button = document.createElement('button');
|
||||
button.type = 'button';
|
||||
button.className = 'emoji-picker-item';
|
||||
button.setAttribute('aria-label', `Add ${item.emoji}`);
|
||||
button.title = item.emoji;
|
||||
button.addEventListener('pointerdown', (event) => event.preventDefault());
|
||||
button.addEventListener('click', () => onSelect(item.emoji));
|
||||
|
||||
const preview = document.createElement('span');
|
||||
preview.className = 'emoji-picker-preview';
|
||||
appendAnimatedAsset(preview, item);
|
||||
button.append(preview);
|
||||
return button;
|
||||
}
|
||||
|
||||
export function hasTwemojiAsset(emoji) {
|
||||
return EMOJI_ASSET_BY_CHAR.has(emoji);
|
||||
}
|
||||
|
||||
export function createTwemojiAsset(emoji, { className = '' } = {}) {
|
||||
const item = EMOJI_ASSET_BY_CHAR.get(emoji);
|
||||
const root = document.createElement('span');
|
||||
root.className = `twemoji ${className}`.trim();
|
||||
root.setAttribute('aria-label', emoji);
|
||||
root.setAttribute('role', 'img');
|
||||
|
||||
if (!item) {
|
||||
root.textContent = emoji;
|
||||
return root;
|
||||
}
|
||||
|
||||
appendAnimatedAsset(root, item);
|
||||
return root;
|
||||
}
|
||||
|
||||
export function appendTwemojiText(root, text, { className = '' } = {}) {
|
||||
const source = String(text || '');
|
||||
let cursor = 0;
|
||||
let found = false;
|
||||
|
||||
TWEMOJI_MATCHER.lastIndex = 0;
|
||||
for (const match of source.matchAll(TWEMOJI_MATCHER)) {
|
||||
const index = Number(match.index || 0);
|
||||
if (index > cursor) root.append(document.createTextNode(source.slice(cursor, index)));
|
||||
root.append(createTwemojiAsset(match[0], { className }));
|
||||
cursor = index + match[0].length;
|
||||
found = true;
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
root.textContent = source;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cursor < source.length) root.append(document.createTextNode(source.slice(cursor)));
|
||||
return true;
|
||||
}
|
||||
|
||||
export function createEmojiPicker({ onSelect }) {
|
||||
const root = document.createElement('section');
|
||||
root.className = 'emoji-picker';
|
||||
root.setAttribute('aria-label', 'Emoji picker');
|
||||
|
||||
const recentSection = document.createElement('section');
|
||||
recentSection.className = 'emoji-picker-section emoji-picker-recent';
|
||||
const recentTitle = document.createElement('strong');
|
||||
recentTitle.className = 'emoji-picker-section-title';
|
||||
recentTitle.textContent = 'Recent';
|
||||
const recentGrid = document.createElement('div');
|
||||
recentGrid.className = 'emoji-picker-grid';
|
||||
recentSection.append(recentTitle, recentGrid);
|
||||
|
||||
const categoryTabs = document.createElement('div');
|
||||
categoryTabs.className = 'emoji-picker-tabs';
|
||||
categoryTabs.setAttribute('role', 'tablist');
|
||||
|
||||
const categorySection = document.createElement('section');
|
||||
categorySection.className = 'emoji-picker-section';
|
||||
const categoryTitle = document.createElement('strong');
|
||||
categoryTitle.className = 'emoji-picker-section-title';
|
||||
const categoryGrid = document.createElement('div');
|
||||
categoryGrid.className = 'emoji-picker-grid';
|
||||
categorySection.append(categoryTitle, categoryGrid);
|
||||
|
||||
let activeGroup = TWEMOJI_GROUPS[0];
|
||||
const tabs = new Map();
|
||||
|
||||
const rememberAndSelect = (emoji) => {
|
||||
const recent = [emoji, ...loadRecent().filter((item) => item !== emoji)];
|
||||
saveRecent(recent);
|
||||
renderRecent();
|
||||
onSelect?.(emoji);
|
||||
};
|
||||
|
||||
const renderRecent = () => {
|
||||
const recentItems = (loadRecent().length ? loadRecent() : DEFAULT_RECENT)
|
||||
.map((emoji) => EMOJI_ASSET_BY_CHAR.get(emoji))
|
||||
.filter(Boolean);
|
||||
stopAllTwemojiAnimations();
|
||||
recentGrid.replaceChildren(...recentItems.map((item) => createEmojiButton(item, rememberAndSelect)));
|
||||
};
|
||||
|
||||
const renderGroup = () => {
|
||||
categoryTitle.textContent = activeGroup.label;
|
||||
stopAllTwemojiAnimations();
|
||||
categoryGrid.replaceChildren(...activeGroup.items.map((item) => createEmojiButton(item, rememberAndSelect)));
|
||||
tabs.forEach((tab, groupId) => {
|
||||
const active = groupId === activeGroup.id;
|
||||
tab.classList.toggle('is-active', active);
|
||||
tab.setAttribute('aria-selected', String(active));
|
||||
});
|
||||
};
|
||||
|
||||
TWEMOJI_GROUPS.forEach((group) => {
|
||||
const tab = document.createElement('button');
|
||||
tab.type = 'button';
|
||||
tab.className = 'emoji-picker-tab';
|
||||
tab.textContent = group.icon;
|
||||
tab.title = group.label;
|
||||
tab.setAttribute('aria-label', group.label);
|
||||
tab.setAttribute('role', 'tab');
|
||||
tab.addEventListener('click', () => {
|
||||
activeGroup = group;
|
||||
renderGroup();
|
||||
});
|
||||
tabs.set(group.id, tab);
|
||||
categoryTabs.append(tab);
|
||||
});
|
||||
|
||||
root.append(recentSection, categoryTabs, categorySection);
|
||||
renderRecent();
|
||||
renderGroup();
|
||||
return root;
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
// Общие состояния экрана: загрузка, «пусто» и ошибка – один вид на всё приложение.
|
||||
// Индикатор загрузки появляется с задержкой (CSS): если данные пришли быстро, его не видно
|
||||
// вовсе, и экран не мелькает.
|
||||
import { iconHtml } from './ui-icon.js';
|
||||
|
||||
export function createSpinner({ size = 'md', label = t('remaining.feedback.loading') } = {}) {
|
||||
const el = document.createElement('span');
|
||||
el.className = `spinner spinner--${size}`;
|
||||
el.setAttribute('role', 'status');
|
||||
el.setAttribute('aria-label', label);
|
||||
return el;
|
||||
}
|
||||
|
||||
export function createLoadingState({ label = t('remaining.feedback.loading'), delayMs = 350, className = '' } = {}) {
|
||||
const el = document.createElement('div');
|
||||
el.className = `loading-state${className ? ` ${className}` : ''}`;
|
||||
el.style.setProperty('--loading-delay', `${Math.max(0, Number(delayMs) || 0)}ms`);
|
||||
el.append(createSpinner({ label }));
|
||||
return el;
|
||||
}
|
||||
|
||||
/**
|
||||
* Сообщение вместо содержимого: пусто или ошибка, с необязательным действием.
|
||||
* @param {{ kind?: 'empty'|'error', icon?: string, title?: string, text?: string,
|
||||
* actionLabel?: string, onAction?: Function, className?: string }} opts
|
||||
*/
|
||||
export function createStateMessage({
|
||||
kind = 'empty', icon = '', title = '', text = '', actionLabel = '', onAction = null, className = '',
|
||||
} = {}) {
|
||||
const el = document.createElement('div');
|
||||
el.className = `state-message state-message--${kind}${className ? ` ${className}` : ''}`;
|
||||
if (kind === 'error') el.setAttribute('role', 'alert');
|
||||
if (icon) {
|
||||
const badge = document.createElement('span');
|
||||
badge.className = 'state-message__icon';
|
||||
badge.innerHTML = iconHtml(icon);
|
||||
el.append(badge);
|
||||
}
|
||||
if (title) {
|
||||
const heading = document.createElement('p');
|
||||
heading.className = 'state-message__title';
|
||||
heading.textContent = title;
|
||||
el.append(heading);
|
||||
}
|
||||
if (text) {
|
||||
const body = document.createElement('p');
|
||||
body.className = 'state-message__text';
|
||||
body.textContent = text;
|
||||
el.append(body);
|
||||
}
|
||||
if (actionLabel && typeof onAction === 'function') {
|
||||
const button = document.createElement('button');
|
||||
button.type = 'button';
|
||||
button.className = `${kind === 'error' ? 'secondary-btn' : 'primary-btn'} state-message__action`;
|
||||
button.textContent = actionLabel;
|
||||
button.addEventListener('click', onAction);
|
||||
el.append(button);
|
||||
}
|
||||
return el;
|
||||
}
|
||||
|
||||
export function createErrorState({
|
||||
title = t('remaining.feedback.could_not_load'),
|
||||
text = t('remaining.feedback.check_your_connection_and_try_again'),
|
||||
onRetry = null,
|
||||
className = '',
|
||||
} = {}) {
|
||||
return createStateMessage({
|
||||
kind: 'error', icon: 'alert', title, text, actionLabel: onRetry ? t('screens.feedback.text_001') : '', onAction: onRetry, className,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
import { getShowPublicHistoryWarning, setShowPublicHistoryWarning, getPublicHistoryRememberLabel } from '../services/public-history-consent.js';
|
||||
import { openSheet } from './sheet.js';
|
||||
|
||||
function safeCount(raw, maximum = Infinity) {
|
||||
const count = Number(raw);
|
||||
return Number.isFinite(count) ? Math.max(0, Math.min(maximum, Math.trunc(count))) : 0;
|
||||
}
|
||||
|
||||
// Значения счётчиков получены от сервера, это не криптографическая аттестация личности.
|
||||
export function confirmLikeAction(options = {}) {
|
||||
if (!getShowPublicHistoryWarning()) return Promise.resolve(true);
|
||||
return openLikeSheet(options);
|
||||
}
|
||||
|
||||
// Просмотр счётчиков не является действием в блокчейне и не спрашивает согласие.
|
||||
export function showLikeStatistics({ counts = {}, onViewList = null } = {}) {
|
||||
return openLikeSheet({ counts, onViewList, readOnly: true });
|
||||
}
|
||||
|
||||
function openLikeSheet({ liked = false, counts = {}, onViewList = null, readOnly = false } = {}) {
|
||||
return new Promise((resolve) => {
|
||||
let accepted = false;
|
||||
const all = safeCount(counts.all ?? counts.likesCount);
|
||||
const official = safeCount(counts.official ?? counts.primaryLikesCount, all);
|
||||
const shining = safeCount(counts.shining ?? counts.shiningLikesCount, official);
|
||||
const body = document.createElement('div');
|
||||
body.className = 'stack like-consent';
|
||||
const intro = document.createElement('p');
|
||||
intro.textContent = t('dialogs.modals.like_action_sheet.label_001');
|
||||
const grid = document.createElement('div');
|
||||
grid.className = 'like-consent-counters';
|
||||
const categories = [
|
||||
{ label: t('dialogs.remaining.components.like_action_sheet.openlikesheet.ofitsialnye_siyayuschie'), count: shining, type: 'shining' },
|
||||
{ label: t('dialogs.remaining.components.like_action_sheet.openlikesheet.vse_ofitsialnye'), count: official, type: 'official' },
|
||||
{ label: t('dialogs.remaining.components.like_action_sheet.openlikesheet.vse_akkaunty'), count: all, type: 'all' },
|
||||
];
|
||||
categories.forEach(({ label, count, type }) => {
|
||||
const item = document.createElement(onViewList ? 'button' : 'div');
|
||||
item.className = 'like-consent-count';
|
||||
if (onViewList) {
|
||||
item.type = 'button';
|
||||
item.addEventListener('click', () => {
|
||||
sheet.close();
|
||||
onViewList(type);
|
||||
});
|
||||
}
|
||||
const number = document.createElement('strong');
|
||||
number.textContent = String(count);
|
||||
const name = document.createElement('span');
|
||||
name.textContent = label;
|
||||
item.append(number, name);
|
||||
grid.append(item);
|
||||
});
|
||||
const warning = document.createElement('p');
|
||||
warning.className = 'meta-muted';
|
||||
warning.textContent = t('dialogs.modals.like_action_sheet.label_002');
|
||||
const rememberLabel = document.createElement('label');
|
||||
rememberLabel.className = 'confirm-dialog__remember';
|
||||
const remember = document.createElement('input');
|
||||
remember.type = 'checkbox';
|
||||
const rememberText = document.createElement('span');
|
||||
rememberText.textContent = getPublicHistoryRememberLabel();
|
||||
rememberLabel.append(remember, rememberText);
|
||||
const actions = document.createElement('div');
|
||||
actions.className = 'form-actions-grid';
|
||||
const cancel = document.createElement('button');
|
||||
cancel.type = 'button';
|
||||
cancel.className = 'secondary-btn';
|
||||
cancel.textContent = readOnly ? t('dialogs.modals.like_action_sheet.label_003') : t('dialogs.remaining.components.like_action_sheet.openlikesheet.ne_menyat');
|
||||
const confirm = document.createElement('button');
|
||||
confirm.type = 'button';
|
||||
confirm.className = 'primary-btn';
|
||||
confirm.textContent = liked ? t('dialogs.modals.like_action_sheet.label_004') : t('dialogs.remaining.components.like_action_sheet.openlikesheet.dobavit_moy_layk');
|
||||
if (readOnly) actions.append(cancel);
|
||||
else actions.append(cancel, confirm);
|
||||
body.append(intro, grid);
|
||||
if (!readOnly) body.append(warning, rememberLabel);
|
||||
body.append(actions);
|
||||
const sheet = openSheet({ title: t('dialogs.modals.like_action_sheet.label_005'), className: 'like-consent-sheet', content: body, onClose: () => resolve(accepted) });
|
||||
cancel.addEventListener('click', () => sheet.close());
|
||||
confirm.addEventListener('click', () => { if (remember.checked) setShowPublicHistoryWarning(false); accepted = true; sheet.close(); });
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
import { t, th } from '../i18n/index.js';
|
||||
// Полноэкранный просмотр фото и видео из вложений: листание, «Скачать».
|
||||
// Закрывается крестиком, Esc, смахиванием вниз или переходом назад.
|
||||
import { iconHtml } from './ui-icon.js';
|
||||
|
||||
let activeClose = null;
|
||||
|
||||
function safeFileName(name, kind) {
|
||||
const clean = String(name || '').trim().replace(/[\\/:*?"<>|]+/g, '_');
|
||||
if (clean) return clean;
|
||||
return kind === 'video' ? 'video.mp4' : 'image.jpg';
|
||||
}
|
||||
|
||||
// Arweave отдаёт файл с другого адреса: атрибут download там не работает, поэтому скачиваем через blob.
|
||||
async function downloadMedia(item) {
|
||||
const name = safeFileName(item.name, item.kind);
|
||||
try {
|
||||
const response = await fetch(item.url);
|
||||
if (!response.ok) throw new Error(String(response.status));
|
||||
const blobUrl = URL.createObjectURL(await response.blob());
|
||||
const link = document.createElement('a');
|
||||
link.href = blobUrl;
|
||||
link.download = name;
|
||||
document.body.append(link);
|
||||
link.click();
|
||||
link.remove();
|
||||
window.setTimeout(() => URL.revokeObjectURL(blobUrl), 30000);
|
||||
} catch {
|
||||
window.open(item.url, '_blank', 'noopener');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* items: [{ url, kind: 'image' | 'video', name }], index – с какого начать.
|
||||
*/
|
||||
export function openMediaViewer(items = [], index = 0) {
|
||||
const list = items.filter((item) => item?.url && (item.kind === 'image' || item.kind === 'video'));
|
||||
if (!list.length) return;
|
||||
activeClose?.();
|
||||
|
||||
let current = Math.max(0, Math.min(list.length - 1, index));
|
||||
const root = document.getElementById('modal-root') || document.body;
|
||||
const overlay = document.createElement('div');
|
||||
overlay.className = 'media-viewer';
|
||||
overlay.setAttribute('role', 'dialog');
|
||||
overlay.setAttribute('aria-modal', 'true');
|
||||
overlay.setAttribute('aria-label', t('screens.media_viewer.text_006'));
|
||||
// Сверху – только «закрыть»; счётчик и «Скачать» – сразу под фото, по центру.
|
||||
overlay.innerHTML = `
|
||||
<div class="media-viewer__bar">
|
||||
<button class="media-viewer__btn" type="button" data-action="close" aria-label="${th('screens.media_viewer.text_001')}">${iconHtml('close')}</button>
|
||||
</div>
|
||||
<div class="media-viewer__stage">
|
||||
<div class="media-viewer__frame"></div>
|
||||
<div class="media-viewer__controls">
|
||||
<span class="media-viewer__counter"></span>
|
||||
<button class="media-viewer__btn media-viewer__btn--round" type="button" data-action="download" aria-label="${th('screens.media_viewer.text_002')}" title="${th('screens.media_viewer.text_003')}">${iconHtml('download')}</button>
|
||||
</div>
|
||||
</div>
|
||||
<button class="media-viewer__nav media-viewer__nav--prev" type="button" data-action="prev" aria-label="${th('screens.media_viewer.text_004')}">${iconHtml('back')}</button>
|
||||
<button class="media-viewer__nav media-viewer__nav--next" type="button" data-action="next" aria-label="${th('screens.media_viewer.text_005')}">${iconHtml('open')}</button>
|
||||
`;
|
||||
const stage = overlay.querySelector('.media-viewer__stage');
|
||||
const frame = overlay.querySelector('.media-viewer__frame');
|
||||
const counter = overlay.querySelector('.media-viewer__counter');
|
||||
const prevBtn = overlay.querySelector('[data-action="prev"]');
|
||||
const nextBtn = overlay.querySelector('[data-action="next"]');
|
||||
|
||||
const render = () => {
|
||||
stage.querySelectorAll('video').forEach((video) => video.pause());
|
||||
const item = list[current];
|
||||
let media;
|
||||
if (item.kind === 'video') {
|
||||
media = document.createElement('video');
|
||||
media.controls = true;
|
||||
media.autoplay = true;
|
||||
media.playsInline = true;
|
||||
} else {
|
||||
media = document.createElement('img');
|
||||
media.alt = item.name || '';
|
||||
media.decoding = 'async';
|
||||
}
|
||||
media.className = 'media-viewer__media';
|
||||
media.src = item.url;
|
||||
frame.replaceChildren(media);
|
||||
counter.textContent = list.length > 1 ? `${current + 1}/${list.length}` : '';
|
||||
counter.hidden = list.length <= 1;
|
||||
prevBtn.hidden = current <= 0;
|
||||
nextBtn.hidden = current >= list.length - 1;
|
||||
};
|
||||
|
||||
const go = (delta) => {
|
||||
const next = current + delta;
|
||||
if (next < 0 || next >= list.length) return;
|
||||
current = next;
|
||||
render();
|
||||
};
|
||||
|
||||
const onKey = (event) => {
|
||||
if (event.key === 'Escape') close();
|
||||
else if (event.key === 'ArrowLeft') go(-1);
|
||||
else if (event.key === 'ArrowRight') go(1);
|
||||
};
|
||||
const onPopState = () => close();
|
||||
|
||||
const close = () => {
|
||||
if (activeClose !== close) return;
|
||||
activeClose = null;
|
||||
document.removeEventListener('keydown', onKey);
|
||||
window.removeEventListener('popstate', onPopState);
|
||||
stage.querySelectorAll('video').forEach((video) => video.pause());
|
||||
overlay.remove();
|
||||
};
|
||||
|
||||
let swiped = false;
|
||||
overlay.addEventListener('click', (event) => {
|
||||
// Клик, который браузер присылает после смахивания, не должен прятать панель или закрывать просмотр.
|
||||
if (swiped) { swiped = false; return; }
|
||||
const action = event.target.closest('[data-action]')?.dataset.action;
|
||||
if (action === 'close') close();
|
||||
else if (action === 'prev') go(-1);
|
||||
else if (action === 'next') go(1);
|
||||
else if (action === 'download') void downloadMedia(list[current]);
|
||||
else if (event.target.closest('.media-viewer__media')?.tagName === 'IMG') overlay.classList.toggle('is-bare');
|
||||
else if (event.target === stage || event.target === frame || event.target === overlay) close();
|
||||
});
|
||||
|
||||
// Смахивание: вбок – листать, вниз – закрыть.
|
||||
let startX = 0;
|
||||
let startY = 0;
|
||||
let tracking = false;
|
||||
stage.addEventListener('pointerdown', (event) => {
|
||||
if (event.target.tagName === 'VIDEO') return;
|
||||
tracking = true;
|
||||
startX = event.clientX;
|
||||
startY = event.clientY;
|
||||
});
|
||||
stage.addEventListener('pointermove', (event) => {
|
||||
if (!tracking) return;
|
||||
const dy = event.clientY - startY;
|
||||
if (dy > 0 && Math.abs(dy) > Math.abs(event.clientX - startX)) {
|
||||
stage.style.transform = `translateY(${dy}px)`;
|
||||
overlay.style.setProperty('--viewer-dim', String(Math.max(0.4, 1 - dy / 400)));
|
||||
}
|
||||
});
|
||||
const endSwipe = (event) => {
|
||||
if (!tracking) return;
|
||||
tracking = false;
|
||||
const dx = event.clientX - startX;
|
||||
const dy = event.clientY - startY;
|
||||
swiped = Math.hypot(dx, dy) > 10;
|
||||
stage.style.transform = '';
|
||||
overlay.style.removeProperty('--viewer-dim');
|
||||
if (dy > 90 && dy > Math.abs(dx)) close();
|
||||
else if (Math.abs(dx) > 50 && Math.abs(dx) > Math.abs(dy)) go(dx < 0 ? 1 : -1);
|
||||
};
|
||||
stage.addEventListener('pointerup', endSwipe);
|
||||
stage.addEventListener('pointercancel', endSwipe);
|
||||
|
||||
document.addEventListener('keydown', onKey);
|
||||
window.addEventListener('popstate', onPopState);
|
||||
activeClose = close;
|
||||
render();
|
||||
root.append(overlay);
|
||||
overlay.querySelector('[data-action="close"]')?.focus({ preventScroll: true });
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
import { createDropdownMenu } from './dropdown-menu.js';
|
||||
import { iconHtml } from './ui-icon.js';
|
||||
|
||||
export function attachMessageMenu(card, head, items) {
|
||||
const trigger = document.createElement('button');
|
||||
trigger.type = 'button';
|
||||
trigger.className = 'icon-btn channel-message-more';
|
||||
trigger.innerHTML = iconHtml('more');
|
||||
trigger.setAttribute('aria-label', t('screens.message_menu.text_001'));
|
||||
head.append(trigger);
|
||||
const menu = createDropdownMenu({ anchorEl: trigger, items });
|
||||
const previousCleanup = card.cleanup;
|
||||
card.cleanup = () => {
|
||||
previousCleanup?.();
|
||||
menu.destroy();
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
export function createOverflowDots({ className = '' } = {}) {
|
||||
const dots = document.createElement('span');
|
||||
const extra = String(className || '').trim();
|
||||
dots.className = `app-overflow-dots${extra ? ` ${extra}` : ''}`;
|
||||
dots.setAttribute('aria-hidden', 'true');
|
||||
for (let i = 0; i < 3; i += 1) {
|
||||
dots.append(document.createElement('i'));
|
||||
}
|
||||
return dots;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
export function renderPageLabel(titleRu, pageId, collapsed, onToggle) {
|
||||
const label = document.createElement('div');
|
||||
label.className = `page-label${collapsed ? ' is-collapsed' : ''}`;
|
||||
|
||||
const toggle = document.createElement('button');
|
||||
toggle.type = 'button';
|
||||
toggle.className = 'page-label-toggle';
|
||||
toggle.title = collapsed ? t('screens.page_label.text_002') : t('screens.page_label.text_003');
|
||||
toggle.setAttribute(
|
||||
'aria-label',
|
||||
collapsed ? t('screens.page_label.text_004') : t('screens.page_label.text_005'),
|
||||
);
|
||||
toggle.addEventListener('click', onToggle);
|
||||
|
||||
if (!collapsed) {
|
||||
label.append(toggle);
|
||||
|
||||
const content = document.createElement('div');
|
||||
content.className = 'page-label-content';
|
||||
|
||||
const hint = document.createElement('div');
|
||||
hint.className = 'page-label-hint';
|
||||
hint.textContent = t('screens.page_label.text_001');
|
||||
|
||||
const caption = document.createElement('div');
|
||||
caption.className = 'page-label-caption';
|
||||
caption.textContent = `${titleRu} (${pageId})`;
|
||||
|
||||
content.append(hint, caption);
|
||||
label.append(content);
|
||||
} else {
|
||||
label.append(toggle);
|
||||
}
|
||||
|
||||
return label;
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
import { t, th } from '../i18n/index.js';
|
||||
// Редактор точной настройки палитры.
|
||||
import {
|
||||
PALETTE_PRESETS,
|
||||
PALETTE_ROLES,
|
||||
exportPalette,
|
||||
getPaletteSettings,
|
||||
importPalette,
|
||||
resolvePalette,
|
||||
resolveThemeMode,
|
||||
setPaletteSettings,
|
||||
} from '../services/theme-service.js';
|
||||
|
||||
export function openPaletteEditor({ theme = resolveThemeMode(), onClose } = {}) {
|
||||
let editTheme = theme === 'light' ? 'light' : 'dark';
|
||||
const opener = document.activeElement;
|
||||
|
||||
const modal = document.createElement('div');
|
||||
modal.className = 'modal palette-editor';
|
||||
modal.innerHTML = `
|
||||
<div class="modal-card palette-editor__card" role="dialog" aria-modal="true" aria-labelledby="palette-editor-title">
|
||||
<div class="palette-editor__head">
|
||||
<h2 class="modal-title" id="palette-editor-title">${th('screens.palette_editor.text_003')}</h2>
|
||||
<button class="icon-btn palette-editor__close" type="button" aria-label="${th('screens.palette_editor.text_004')}">✕</button>
|
||||
</div>
|
||||
<div class="palette-editor__section">
|
||||
<span class="palette-editor__label">${th('screens.palette_editor.text_005')}</span>
|
||||
<select class="input palette-editor__presets" aria-label="${th('screens.palette_editor.text_006')}"></select>
|
||||
<div class="palette-editor__preview" aria-hidden="true"><span></span><span></span><span></span><span></span></div>
|
||||
</div>
|
||||
<div class="palette-editor__section">
|
||||
<span class="palette-editor__label">${th('screens.palette_editor.text_007')}</span>
|
||||
<div class="tabs tabs--auto" role="radiogroup" aria-label="${th('screens.palette_editor.text_008')}">
|
||||
<button type="button" class="tab-btn" role="radio" data-edit-theme="light">${th('screens.palette_editor.text_009')}</button>
|
||||
<button type="button" class="tab-btn" role="radio" data-edit-theme="dark">${th('screens.palette_editor.text_010')}</button>
|
||||
</div>
|
||||
<p class="palette-editor__hint">${th('screens.palette_editor.text_011')}</p>
|
||||
</div>
|
||||
<div class="palette-editor__roles"></div>
|
||||
<details class="palette-editor__share">
|
||||
<summary>${th('screens.palette_editor.text_012')}</summary>
|
||||
<p class="palette-editor__hint">${th('screens.palette_editor.text_013')}</p>
|
||||
<textarea class="input palette-editor__json" rows="8" spellcheck="false"></textarea>
|
||||
<p class="palette-editor__error" role="alert" hidden></p>
|
||||
<div class="palette-editor__actions">
|
||||
<button type="button" class="secondary-btn" data-action="copy">${th('screens.palette_editor.text_014')}</button>
|
||||
<button type="button" class="secondary-btn" data-action="import">${th('screens.palette_editor.text_015')}</button>
|
||||
</div>
|
||||
</details>
|
||||
<div class="palette-editor__actions">
|
||||
<button type="button" class="secondary-btn" data-action="reset-theme">${th('screens.palette_editor.text_016')}</button>
|
||||
<button type="button" class="primary-btn" data-action="done">${th('screens.palette_editor.text_017')}</button>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
const card = modal.querySelector('.palette-editor__card');
|
||||
const presetsEl = modal.querySelector('.palette-editor__presets');
|
||||
const rolesEl = modal.querySelector('.palette-editor__roles');
|
||||
const jsonEl = modal.querySelector('.palette-editor__json');
|
||||
const errorEl = modal.querySelector('.palette-editor__error');
|
||||
|
||||
for (const [id, preset] of Object.entries(PALETTE_PRESETS)) {
|
||||
const option = document.createElement('option');
|
||||
option.value = id;
|
||||
option.textContent = preset.label;
|
||||
presetsEl.append(option);
|
||||
}
|
||||
|
||||
const update = (mutate) => {
|
||||
const settings = getPaletteSettings();
|
||||
const next = { preset: settings.preset, custom: { dark: { ...settings.custom.dark }, light: { ...settings.custom.light } } };
|
||||
mutate(next);
|
||||
setPaletteSettings(next);
|
||||
render();
|
||||
};
|
||||
|
||||
function render() {
|
||||
const settings = getPaletteSettings();
|
||||
const colors = resolvePalette(editTheme, settings);
|
||||
const custom = settings.custom[editTheme];
|
||||
presetsEl.value = settings.preset;
|
||||
modal.querySelectorAll('.palette-editor__preview span').forEach((swatch, index) => {
|
||||
swatch.style.backgroundColor = [colors.background, colors.surface, colors.accent, colors['surface-selected']][index];
|
||||
});
|
||||
modal.querySelectorAll('[data-edit-theme]').forEach((btn) => {
|
||||
btn.setAttribute('aria-checked', String(btn.dataset.editTheme === editTheme));
|
||||
});
|
||||
rolesEl.replaceChildren(...PALETTE_ROLES.map((role) => {
|
||||
const row = document.createElement('label');
|
||||
row.className = 'palette-editor__role';
|
||||
const changed = Boolean(custom[role.id]);
|
||||
row.innerHTML = `
|
||||
<input type="color" value="${colors[role.id]}" aria-label="${role.label}">
|
||||
<span class="palette-editor__role-name">${role.label}${changed ? t('screens.palette_editor.text_002') : ''}</span>
|
||||
<code class="palette-editor__role-value">${colors[role.id]}</code>
|
||||
`;
|
||||
const input = row.querySelector('input');
|
||||
input.addEventListener('input', () => {
|
||||
document.documentElement.style.setProperty(`--${role.id}`, input.value);
|
||||
row.querySelector('code').textContent = input.value;
|
||||
});
|
||||
input.addEventListener('change', () => update((next) => { next.custom[editTheme][role.id] = input.value; }));
|
||||
return row;
|
||||
}));
|
||||
jsonEl.value = exportPalette();
|
||||
errorEl.hidden = true;
|
||||
}
|
||||
|
||||
const close = () => {
|
||||
document.removeEventListener('keydown', onKeydown);
|
||||
modal.remove();
|
||||
opener?.focus?.();
|
||||
onClose?.();
|
||||
};
|
||||
const onKeydown = (event) => { if (event.key === 'Escape') close(); };
|
||||
|
||||
modal.addEventListener('click', async (event) => {
|
||||
if (event.target === modal) { close(); return; }
|
||||
// data-edit-theme, а не data-theme: data-theme стоит на <html>, и closest() находил бы его при любом клике.
|
||||
const themeBtn = event.target.closest('[data-edit-theme]');
|
||||
if (themeBtn) { editTheme = themeBtn.dataset.editTheme; render(); return; }
|
||||
if (event.target.closest('.palette-editor__close')) { close(); return; }
|
||||
const action = event.target.closest('[data-action]')?.dataset.action;
|
||||
if (action === 'done') close();
|
||||
if (action === 'reset-theme') update((next) => { next.custom[editTheme] = {}; });
|
||||
if (action === 'copy') {
|
||||
try {
|
||||
await navigator.clipboard.writeText(jsonEl.value);
|
||||
} catch {
|
||||
jsonEl.select();
|
||||
}
|
||||
}
|
||||
if (action === 'import') {
|
||||
try {
|
||||
importPalette(jsonEl.value);
|
||||
render();
|
||||
} catch {
|
||||
errorEl.textContent = t('screens.palette_editor.text_001');
|
||||
errorEl.hidden = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
presetsEl.addEventListener('change', () => update((next) => {
|
||||
next.preset = presetsEl.value;
|
||||
next.custom = { dark: {}, light: {} };
|
||||
}));
|
||||
document.addEventListener('keydown', onKeydown);
|
||||
|
||||
render();
|
||||
document.body.append(modal);
|
||||
card.querySelector('.palette-editor__close').focus();
|
||||
return close;
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
// Шторка «Заметка о человеке»: текст и цветная метка, видны только владельцу аккаунта.
|
||||
// Открывается с карты связей и из профиля человека; хранение – services/people-notes.js.
|
||||
import { openSheet } from './sheet.js';
|
||||
import { NOTE_MARKS, PERSON_NOTE_MAX_TEXT, getPersonNote, setPersonNote } from '../services/people-notes.js';
|
||||
|
||||
export function openPersonNoteSheet({ login, name = '', onClose = null } = {}) {
|
||||
const current = getPersonNote(login);
|
||||
let mark = current?.mark || '';
|
||||
return openSheet({
|
||||
title: t('dialogs.remaining.components.person_note_sheet.openpersonnotesheet.zametka_value1', { value1: name || login }),
|
||||
className: 'person-note-sheet',
|
||||
onClose,
|
||||
content: (sheet) => {
|
||||
const wrap = document.createElement('div');
|
||||
wrap.className = 'stack person-note';
|
||||
const hint = document.createElement('p');
|
||||
hint.className = 'meta-muted person-note__hint';
|
||||
hint.textContent = t('dialogs.modals.person_note_sheet.label_001');
|
||||
const textarea = document.createElement('textarea');
|
||||
textarea.className = 'input person-note__text';
|
||||
textarea.rows = 5;
|
||||
textarea.maxLength = PERSON_NOTE_MAX_TEXT;
|
||||
textarea.placeholder = t('dialogs.modals.person_note_sheet.label_002');
|
||||
textarea.value = current?.text || '';
|
||||
textarea.setAttribute('aria-label', t('dialogs.modals.person_note_sheet.label_003'));
|
||||
textarea.autofocus = true;
|
||||
|
||||
const marksLabel = document.createElement('div');
|
||||
marksLabel.className = 'person-note__label';
|
||||
marksLabel.id = `person-note-marks-${Math.random().toString(36).slice(2, 8)}`;
|
||||
marksLabel.textContent = t('dialogs.modals.person_note_sheet.label_004');
|
||||
const marks = document.createElement('div');
|
||||
marks.className = 'person-note__marks';
|
||||
marks.setAttribute('role', 'radiogroup');
|
||||
marks.setAttribute('aria-labelledby', marksLabel.id);
|
||||
const markButtons = [];
|
||||
const syncMarks = () => markButtons.forEach((button) => button.setAttribute('aria-checked', String(button.dataset.mark === mark)));
|
||||
for (const option of [{ id: '', label: t('dialogs.remaining.components.person_note_sheet.openpersonnotesheet.bez_metki') }, ...NOTE_MARKS]) {
|
||||
const button = document.createElement('button');
|
||||
button.type = 'button';
|
||||
button.className = 'person-note__mark';
|
||||
button.dataset.mark = option.id;
|
||||
button.setAttribute('role', 'radio');
|
||||
button.setAttribute('aria-label', option.label);
|
||||
button.title = option.label;
|
||||
button.addEventListener('click', () => { mark = option.id; syncMarks(); });
|
||||
markButtons.push(button);
|
||||
marks.append(button);
|
||||
}
|
||||
syncMarks();
|
||||
wrap.append(hint, textarea, marksLabel, marks);
|
||||
|
||||
if (current) {
|
||||
const remove = document.createElement('button');
|
||||
remove.type = 'button';
|
||||
remove.className = 'ghost-btn person-note__remove';
|
||||
remove.textContent = t('dialogs.modals.person_note_sheet.label_005');
|
||||
remove.addEventListener('click', () => {
|
||||
setPersonNote(login, { text: '', mark: '' });
|
||||
sheet.close();
|
||||
});
|
||||
sheet.footer.append(remove);
|
||||
}
|
||||
const save = document.createElement('button');
|
||||
save.type = 'button';
|
||||
save.className = 'primary-btn person-note__save';
|
||||
save.textContent = t('dialogs.modals.person_note_sheet.label_006');
|
||||
save.addEventListener('click', () => {
|
||||
setPersonNote(login, { text: textarea.value, mark });
|
||||
sheet.close();
|
||||
});
|
||||
sheet.footer.append(save);
|
||||
return wrap;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// Готовый блок заметки (для карточки на карте и профиля); null, если заметки нет.
|
||||
export function createPersonNotePreview(note, { className = '', onClick = null } = {}) {
|
||||
if (!note) return null;
|
||||
const el = document.createElement(onClick ? 'button' : 'div');
|
||||
if (onClick) {
|
||||
el.type = 'button';
|
||||
el.title = t('screens.person_note_sheet.text_001');
|
||||
el.addEventListener('click', onClick);
|
||||
}
|
||||
el.className = `person-note-preview${className ? ` ${className}` : ''}`;
|
||||
if (note.mark) el.dataset.mark = note.mark;
|
||||
el.textContent = note.text.trim() || t('dialogs.modals.person_note_sheet.label_007');
|
||||
return el;
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
// Строка человека в списках (связи, поиск людей, списки профиля): аватар, имя, строка под
|
||||
// ним и действия справа. Вид совпадает со строками списка чатов.
|
||||
import { renderUserAvatar } from './avatar-image.js';
|
||||
import { iconHtml } from './ui-icon.js';
|
||||
import { createSpinner } from './feedback.js';
|
||||
|
||||
/**
|
||||
* @param {Object} opts
|
||||
* @param {string} opts.login
|
||||
* @param {string} [opts.name] – как показывать (по умолчанию логин)
|
||||
* @param {string} [opts.firstName] [opts.lastName] – для инициалов
|
||||
* @param {Object|null} [opts.avatar]
|
||||
* @param {string} [opts.sub] – строка под именем
|
||||
* @param {string} [opts.note] – личная заметка (третья строка, курсивом)
|
||||
* @param {string} [opts.markColor] – метка заметки: green/yellow/red/blue/violet, 'note' – без цвета, '' – нет
|
||||
* @param {'close'|'shining'|''} [opts.ring] – цветное кольцо вокруг аватара
|
||||
* @param {boolean} [opts.official]
|
||||
* @param {string} [opts.tag] – короткая пометка цветом в начале второй строки («ждёт ответа»)
|
||||
* @param {Function} [opts.onClick]
|
||||
* @param {Array<{icon:string,label:string,onClick:Function,primary?:boolean,busy?:boolean}>} [opts.actions]
|
||||
* primary – главное действие строки (цветом), busy – идёт сохранение (спиннер, кнопка неактивна)
|
||||
*/
|
||||
export function createPersonRow({
|
||||
login, name = '', firstName = '', lastName = '', avatar = null, sub = '', note = '', markColor = '',
|
||||
ring = '', official = false, tag = '', onClick = null, actions = [],
|
||||
} = {}) {
|
||||
const row = document.createElement('div');
|
||||
row.className = `person-row${ring ? ` person-row--${ring}` : ''}`;
|
||||
row.dataset.login = String(login || '');
|
||||
|
||||
const main = document.createElement('button');
|
||||
main.type = 'button';
|
||||
main.className = 'person-row__main';
|
||||
const avatarWrap = document.createElement('span');
|
||||
avatarWrap.className = 'person-row__avatar';
|
||||
// Имя и фамилию отдельно знают не все источники (поиск по сети отдаёт одно «displayName») –
|
||||
// тогда инициалы берутся из показанного имени, а не из логина.
|
||||
const nameParts = name && name !== login ? String(name).trim().split(/\s+/) : [];
|
||||
const initialsFirst = firstName || nameParts[0] || '';
|
||||
const initialsLast = lastName || (nameParts.length > 1 ? nameParts[nameParts.length - 1] : '');
|
||||
avatarWrap.append(renderUserAvatar({ login, firstName: initialsFirst, lastName: initialsLast, avatar, size: 'md', official }));
|
||||
if (markColor) {
|
||||
// Метка заметки – та же цветная точка, что на карте связей; 'note' – заметка без цвета.
|
||||
const mark = document.createElement('span');
|
||||
mark.className = 'person-row__mark';
|
||||
mark.dataset.mark = markColor;
|
||||
mark.setAttribute('aria-hidden', 'true');
|
||||
avatarWrap.append(mark);
|
||||
}
|
||||
const text = document.createElement('span');
|
||||
text.className = 'person-row__text';
|
||||
const title = document.createElement('span');
|
||||
title.className = 'person-row__name';
|
||||
const titleText = document.createElement('span');
|
||||
titleText.className = 'person-row__name-text';
|
||||
titleText.textContent = name || login;
|
||||
title.append(titleText);
|
||||
text.append(title);
|
||||
if (sub || tag) {
|
||||
// Пометка («ждёт ответа») – в начале второй строки, чтобы не съедать место у имени.
|
||||
const subEl = document.createElement('span');
|
||||
subEl.className = 'person-row__sub';
|
||||
if (tag) {
|
||||
const tagEl = document.createElement('span');
|
||||
tagEl.className = 'person-row__tag';
|
||||
tagEl.textContent = tag;
|
||||
subEl.append(tagEl);
|
||||
if (sub) subEl.append(' · ');
|
||||
}
|
||||
if (sub) subEl.append(sub);
|
||||
text.append(subEl);
|
||||
}
|
||||
if (note) {
|
||||
const noteEl = document.createElement('span');
|
||||
noteEl.className = 'person-row__note';
|
||||
noteEl.textContent = note;
|
||||
text.append(noteEl);
|
||||
}
|
||||
main.append(avatarWrap, text);
|
||||
if (typeof onClick === 'function') main.addEventListener('click', onClick);
|
||||
row.append(main);
|
||||
|
||||
for (const action of actions) {
|
||||
if (!action) continue;
|
||||
const button = document.createElement('button');
|
||||
button.type = 'button';
|
||||
button.className = `icon-btn person-row__action${action.primary ? ' person-row__action--primary' : ''}`;
|
||||
if (action.busy) {
|
||||
button.disabled = true;
|
||||
button.append(createSpinner({ size: 'sm', label: action.label }));
|
||||
} else {
|
||||
button.innerHTML = iconHtml(action.icon);
|
||||
}
|
||||
button.setAttribute('aria-label', action.label);
|
||||
button.title = action.label;
|
||||
button.addEventListener('click', (event) => action.onClick?.(event, button));
|
||||
row.append(button);
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
||||
// Заголовок группы в списке («Друзья · 58», «А»).
|
||||
export function createListSection(text) {
|
||||
const el = document.createElement('div');
|
||||
el.className = 'person-list-section';
|
||||
el.textContent = text;
|
||||
return el;
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
import { renderUserAvatar } from './avatar-image.js';
|
||||
|
||||
let activeClose = null;
|
||||
|
||||
/**
|
||||
* Тот же экземпляр Avatar переносится во всплывающее окно, а затем обратно.
|
||||
* Так сохраняются уже загруженная фотография и blob URL, который может быть
|
||||
* отозван загрузчиком после onload; клонировать img/src здесь нельзя.
|
||||
*/
|
||||
export function attachProfileAvatarPreview(slot, card) {
|
||||
if (!slot || !card) return { cleanup() {} };
|
||||
const trigger = document.createElement('button');
|
||||
trigger.type = 'button';
|
||||
trigger.className = 'user-profile-avatar-trigger';
|
||||
trigger.setAttribute('aria-label', t('screens.profile_avatar_preview.open'));
|
||||
|
||||
const avatar = renderUserAvatar({
|
||||
login: card.login,
|
||||
firstName: card.firstName,
|
||||
lastName: card.lastName,
|
||||
avatar: card.avatar,
|
||||
size: 'xl',
|
||||
className: 'user-profile-hero-avatar',
|
||||
official: card.accountRole === 'primary',
|
||||
});
|
||||
trigger.append(avatar);
|
||||
slot.append(trigger);
|
||||
|
||||
let closePreview = null;
|
||||
trigger.addEventListener('click', () => {
|
||||
if (closePreview) return;
|
||||
activeClose?.({ restoreFocus: false });
|
||||
const overlay = document.createElement('div');
|
||||
overlay.className = 'profile-avatar-preview';
|
||||
overlay.setAttribute('role', 'dialog');
|
||||
overlay.setAttribute('aria-modal', 'true');
|
||||
overlay.setAttribute('aria-label', t('screens.profile_avatar_preview.dialog'));
|
||||
|
||||
const largeButton = document.createElement('button');
|
||||
largeButton.type = 'button';
|
||||
largeButton.className = 'profile-avatar-preview__image';
|
||||
largeButton.setAttribute('aria-label', t('screens.profile_avatar_preview.close'));
|
||||
largeButton.append(avatar);
|
||||
overlay.append(largeButton);
|
||||
|
||||
const onKey = (event) => {
|
||||
if (event.key === 'Escape') close();
|
||||
};
|
||||
const onPopState = () => close({ restoreFocus: false });
|
||||
const close = ({ restoreFocus = true } = {}) => {
|
||||
if (closePreview !== close) return;
|
||||
closePreview = null;
|
||||
if (activeClose === close) activeClose = null;
|
||||
document.removeEventListener('keydown', onKey);
|
||||
window.removeEventListener('popstate', onPopState);
|
||||
// При обновлении карточки или уходе со страницы прежний trigger уже может быть удалён.
|
||||
if (trigger.isConnected) trigger.append(avatar);
|
||||
overlay.remove();
|
||||
if (restoreFocus && trigger.isConnected) trigger.focus({ preventScroll: true });
|
||||
};
|
||||
closePreview = close;
|
||||
activeClose = close;
|
||||
overlay.addEventListener('click', (event) => {
|
||||
if (event.target === overlay || event.target.closest('.profile-avatar-preview__image')) close();
|
||||
});
|
||||
document.addEventListener('keydown', onKey);
|
||||
window.addEventListener('popstate', onPopState);
|
||||
(document.getElementById('modal-root') || document.body).append(overlay);
|
||||
largeButton.focus({ preventScroll: true });
|
||||
});
|
||||
|
||||
return {
|
||||
cleanup() { closePreview?.({ restoreFocus: false }); },
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
import { t, th } from '../i18n/index.js';
|
||||
// data-profile-list / data-self-profile-action / data-profile-action обрабатывают profile-view.js и user-profile-view.js.
|
||||
import { iconHtml } from './ui-icon.js';
|
||||
import { displayCity } from '../services/cities.js';
|
||||
|
||||
export function escapeProfileHtml(text) {
|
||||
return String(text || '')
|
||||
.replaceAll('&', '&')
|
||||
.replaceAll('<', '<')
|
||||
.replaceAll('>', '>')
|
||||
.replaceAll('"', '"')
|
||||
.replaceAll("'", ''');
|
||||
}
|
||||
|
||||
const esc = escapeProfileHtml;
|
||||
|
||||
// Карточка статуса у аватара: кто подтвердил этот аккаунт и кого подтвердил он сам.
|
||||
function statusSideHtml({ kind, title, active, received, given, verb }) {
|
||||
const isOfficial = kind === 'primary';
|
||||
const receivedKind = isOfficial ? 'primary_received' : 'shine_received';
|
||||
const givenKind = isOfficial ? 'primary_given' : 'shine_given';
|
||||
return `
|
||||
<section class="pf-sc pf-sc--${esc(kind)}${active ? ' is-active' : ' is-empty'}" aria-label="${esc(title)}">
|
||||
<div class="pf-sc__title">${esc(title)}</div>
|
||||
<button type="button" class="pf-sc__row" data-profile-list="${receivedKind}" aria-label="${esc(title)}${th('remaining.html_profile_card.confirmed_by')}${Number(received || 0)}">
|
||||
<strong>${Number(received || 0)}</strong><span>${th('screens.profile_card.text_017')}</span>
|
||||
</button>
|
||||
<button type="button" class="pf-sc__row" data-profile-list="${givenKind}" aria-label="${esc(title)}: ${esc(verb)} ${Number(given || 0)}">
|
||||
<strong>${Number(given || 0)}</strong><span>${esc(verb)}</span>
|
||||
</button>
|
||||
</section>`;
|
||||
}
|
||||
|
||||
function statHtml({ kind, label, valueHtml, ariaLabel }) {
|
||||
return `
|
||||
<button type="button" class="pf-stat" data-profile-list="${esc(kind)}" aria-label="${esc(ariaLabel)}">
|
||||
<span class="pf-stat-value">${valueHtml}</span>
|
||||
<span class="pf-stat-label">${esc(label)}</span>
|
||||
</button>`;
|
||||
}
|
||||
|
||||
function contactRows(card) {
|
||||
return [
|
||||
[t('screens.profile_card.text_006'), card?.web],
|
||||
[t('screens.profile_card.text_007'), card?.phone],
|
||||
[t('screens.profile_card.text_008'), card?.address],
|
||||
]
|
||||
.filter(([, value]) => String(value || '').trim())
|
||||
.map(([label, value]) => `
|
||||
<div class="pf-row">
|
||||
<span class="pf-row-label">${esc(label)}</span>
|
||||
<span class="pf-row-value">${esc(value)}</span>
|
||||
</div>`)
|
||||
.join('');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {object} opts
|
||||
* @param {object} opts.card карточка профиля (loadUserProfileCard)
|
||||
* @param {string} opts.login логин на случай, если в карточке его нет
|
||||
* @param {string} opts.tilesHtml плитки действий (свои/чужие)
|
||||
* @param {string} [opts.tilesWrapClass] доп. класс обёртки плиток (для меню «Добавить»)
|
||||
* @param {string} [opts.beforeTilesHtml] разметка внутри обёртки перед плитками
|
||||
*/
|
||||
export function profileCardHtml({ card, login = '', tilesHtml = '', tilesWrapClass = '', beforeTilesHtml = '', isSelf = true }) {
|
||||
const stats = card?.stats || {};
|
||||
const official = card?.accountRole === 'primary';
|
||||
const shining = card?.shineStatus === 'shining';
|
||||
const cardLogin = String(card?.login || login || '').trim().replace(/^@+/, '');
|
||||
const city = displayCity(card?.city);
|
||||
const fullName = [card?.firstName, card?.lastName].map((v) => String(v || '').trim()).filter(Boolean).join(' ');
|
||||
const displayName = fullName || cardLogin || t('screens.profile_card.text_012');
|
||||
const about = String(card?.about || '').trim();
|
||||
const spiritualPath = String(card?.spiritualPath || '').trim();
|
||||
const contacts = contactRows(card);
|
||||
const aboutRow = (about || isSelf) ? `
|
||||
<div class="pf-row pf-row--block">
|
||||
<span class="pf-row-label">${th('screens.profile_card.text_018')}</span>
|
||||
<p class="pf-row-text${about ? '' : ' is-empty'}">${esc(about || t('screens.profile_card.text_013'))}</p>
|
||||
</div>` : '';
|
||||
const pathRow = spiritualPath ? `
|
||||
<div class="pf-row pf-row--block">
|
||||
<span class="pf-row-label">${th('screens.profile_card.text_019')}</span>
|
||||
<p class="pf-row-text">${esc(spiritualPath)}</p>
|
||||
</div>` : '';
|
||||
const listInner = aboutRow + contacts + pathRow;
|
||||
const listHtml = listInner.trim() ? `<div class="pf-list">${listInner}</div>` : '';
|
||||
const friends = Number(stats.friendsCount || 0);
|
||||
const closeFriends = Number(stats.closeFriendsCount || 0);
|
||||
|
||||
const shineReceived = Number(stats.shineReceivedCount || 0);
|
||||
const shineGiven = Number(stats.shineGivenCount || 0);
|
||||
const primaryReceived = Number(stats.primaryReceivedCount || 0);
|
||||
const primaryGiven = Number(stats.primaryGivenCount || 0);
|
||||
// Статусы по бокам аватара: слева «Официальный», справа «Сияние». На своём профиле – всегда
|
||||
// (пустая сторона бледнее), на чужом – если статус есть или уже есть подтверждения.
|
||||
const verb = card?.gender === 'female' ? t('screens.profile_card.text_009') : card?.gender === 'male' ? t('screens.profile_card.text_010') : t('screens.profile_card.text_011');
|
||||
const officialSide = (isSelf || official || primaryReceived || primaryGiven)
|
||||
? statusSideHtml({ kind: 'primary', title: t('screens.profile_card.text_001'), active: official, received: primaryReceived, given: primaryGiven, verb })
|
||||
: '';
|
||||
const shineSide = (isSelf || shining || shineReceived || shineGiven)
|
||||
? statusSideHtml({ kind: 'shine', title: t('screens.profile_card.text_002'), active: shining, received: shineReceived, given: shineGiven, verb })
|
||||
: '';
|
||||
|
||||
return `
|
||||
<div class="pf-hero" aria-label="${th('remaining.html_profile_card.profile')}${esc(cardLogin)}">
|
||||
<div class="pf-identity">
|
||||
<div class="pf-side pf-side--left">${officialSide}</div>
|
||||
<div class="pf-avatar user-profile-avatar-slot${shining ? ' is-shining' : ''}"></div>
|
||||
<div class="pf-side pf-side--right">${shineSide}</div>
|
||||
</div>
|
||||
<h2 class="pf-name">${esc(displayName)}</h2>
|
||||
<div class="pf-login">${esc(cardLogin)}</div>
|
||||
${city ? `<div class="pf-city">${iconHtml('place')}<span>${esc(city)}</span></div>` : ''}
|
||||
</div>
|
||||
|
||||
<div class="pf-stats">
|
||||
${statHtml({ kind: 'friends', label: t('screens.profile_card.text_003'), valueHtml: closeFriends ? `${friends}<small> · ${closeFriends}${th('remaining.html_profile_card.close')}</small>` : String(friends), ariaLabel: t('screens.profile_card.text_014', { value1: friends, value2: closeFriends }) })}
|
||||
${statHtml({ kind: 'channels_owned', label: t('screens.profile_card.text_004'), valueHtml: String(Number(stats.ownedPublicChannelsCount || 0)), ariaLabel: t('screens.profile_card.text_015', { value1: Number(stats.ownedPublicChannelsCount || 0) }) })}
|
||||
${statHtml({ kind: 'channels_following', label: t('screens.profile_card.text_005'), valueHtml: String(Number(stats.followingChannelsCount || 0)), ariaLabel: t('screens.profile_card.text_016', { value1: Number(stats.followingChannelsCount || 0) }) })}
|
||||
</div>
|
||||
|
||||
${tilesHtml ? `
|
||||
<div class="pf-tiles-wrap user-profile-actions-wrap ${esc(tilesWrapClass)}">
|
||||
${beforeTilesHtml}
|
||||
<div class="pf-tiles user-profile-actions">${tilesHtml}</div>
|
||||
</div>` : ''}
|
||||
|
||||
${listHtml}`;
|
||||
}
|
||||
|
||||
export function profileTileHtml({ icon, label, attrs = '', iconMarkup = '' }) {
|
||||
return `<button type="button" class="pf-tile user-profile-action-btn" ${attrs}>${iconMarkup || iconHtml(icon)}<span>${esc(label)}</span></button>`;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
/** В выборе тарифа счётчик не показываем: он начинается с логина. */
|
||||
export function createRegistrationStepper(step) {
|
||||
const current = Math.max(1, Math.min(3, Number(step) || 1));
|
||||
const wrapper = document.createElement('div');
|
||||
wrapper.className = 'signup-stepper';
|
||||
wrapper.setAttribute('aria-label', t('screens.registration_stepper.text_001', { value1: current }));
|
||||
const dots = document.createElement('div');
|
||||
dots.className = 'signup-stepper__dots';
|
||||
for (let i = 1; i <= 3; i += 1) {
|
||||
const dot = document.createElement('span');
|
||||
dot.className = `signup-stepper__dot${i === current ? ' is-active' : ''}${i < current ? ' is-complete' : ''}`;
|
||||
dots.append(dot);
|
||||
}
|
||||
const label = document.createElement('span');
|
||||
label.className = 'signup-stepper__label';
|
||||
label.textContent = t('screens.registration_stepper.text_002', { value1: current });
|
||||
wrapper.append(dots, label);
|
||||
return wrapper;
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
import { iconHtml } from './ui-icon.js';
|
||||
function resolveElement(value) {
|
||||
return typeof value === 'function' ? value() : value;
|
||||
}
|
||||
|
||||
function buildArrowIcon() {
|
||||
const icon = document.createElement('span');
|
||||
icon.className = 'scroll-to-bottom-btn__icon';
|
||||
icon.setAttribute('aria-hidden', 'true');
|
||||
icon.innerHTML = iconHtml('down');
|
||||
return icon;
|
||||
}
|
||||
|
||||
export function attachScrollToBottomButton({
|
||||
scrollContainer,
|
||||
mountTarget = document.querySelector('.app-shell'),
|
||||
thresholdPx = 160,
|
||||
title = t('remaining.scroll.scroll_down'),
|
||||
} = {}) {
|
||||
const target = resolveElement(mountTarget);
|
||||
if (!(target instanceof Element)) {
|
||||
return {
|
||||
button: null,
|
||||
refresh() {},
|
||||
cleanup() {},
|
||||
};
|
||||
}
|
||||
|
||||
const button = document.createElement('button');
|
||||
button.type = 'button';
|
||||
button.className = 'scroll-to-bottom-btn';
|
||||
button.title = title;
|
||||
button.setAttribute('aria-label', t('screens.scroll_to_bottom_button.text_001'));
|
||||
button.tabIndex = -1;
|
||||
button.append(buildArrowIcon());
|
||||
target.append(button);
|
||||
|
||||
let disposed = false;
|
||||
let boundContainer = null;
|
||||
let resizeObserver = null;
|
||||
let mutationObserver = null;
|
||||
let refreshFrame = 0;
|
||||
|
||||
const hide = () => {
|
||||
button.classList.remove('is-visible');
|
||||
button.setAttribute('aria-hidden', 'true');
|
||||
button.tabIndex = -1;
|
||||
};
|
||||
|
||||
const scheduleRefresh = () => {
|
||||
if (disposed || refreshFrame) return;
|
||||
refreshFrame = window.requestAnimationFrame(() => {
|
||||
refreshFrame = 0;
|
||||
refresh();
|
||||
});
|
||||
};
|
||||
|
||||
const unbindContainer = () => {
|
||||
boundContainer?.removeEventListener('scroll', scheduleRefresh);
|
||||
resizeObserver?.disconnect();
|
||||
mutationObserver?.disconnect();
|
||||
resizeObserver = null;
|
||||
mutationObserver = null;
|
||||
boundContainer = null;
|
||||
};
|
||||
|
||||
const bindContainer = () => {
|
||||
const nextContainer = resolveElement(scrollContainer);
|
||||
if (!(nextContainer instanceof Element)) {
|
||||
if (boundContainer) unbindContainer();
|
||||
return null;
|
||||
}
|
||||
if (nextContainer === boundContainer) return boundContainer;
|
||||
|
||||
unbindContainer();
|
||||
boundContainer = nextContainer;
|
||||
boundContainer.addEventListener('scroll', scheduleRefresh, { passive: true });
|
||||
|
||||
if (typeof ResizeObserver === 'function') {
|
||||
resizeObserver = new ResizeObserver(scheduleRefresh);
|
||||
resizeObserver.observe(boundContainer);
|
||||
}
|
||||
|
||||
if (typeof MutationObserver === 'function') {
|
||||
mutationObserver = new MutationObserver(scheduleRefresh);
|
||||
mutationObserver.observe(boundContainer, { childList: true, subtree: true });
|
||||
}
|
||||
|
||||
return boundContainer;
|
||||
};
|
||||
|
||||
function refresh() {
|
||||
if (disposed) return;
|
||||
const container = bindContainer();
|
||||
if (!container) {
|
||||
hide();
|
||||
return;
|
||||
}
|
||||
|
||||
const scrollHeight = Number(container.scrollHeight || 0);
|
||||
const clientHeight = Number(container.clientHeight || 0);
|
||||
const scrollTop = Number(container.scrollTop || 0);
|
||||
const maxScrollTop = Math.max(0, scrollHeight - clientHeight);
|
||||
const distanceToBottom = Math.max(0, maxScrollTop - scrollTop);
|
||||
const shouldShow = maxScrollTop > 8 && distanceToBottom > Math.max(24, Number(thresholdPx || 0));
|
||||
|
||||
button.classList.toggle('is-visible', shouldShow);
|
||||
button.setAttribute('aria-hidden', shouldShow ? 'false' : 'true');
|
||||
button.tabIndex = shouldShow ? 0 : -1;
|
||||
}
|
||||
|
||||
const scrollToBottom = () => {
|
||||
const container = bindContainer();
|
||||
if (!container) return;
|
||||
if (typeof container.scrollTo === 'function') {
|
||||
container.scrollTo({ top: container.scrollHeight, behavior: 'smooth' });
|
||||
} else {
|
||||
container.scrollTop = container.scrollHeight;
|
||||
}
|
||||
scheduleRefresh();
|
||||
};
|
||||
|
||||
button.addEventListener('click', scrollToBottom);
|
||||
window.addEventListener('resize', scheduleRefresh);
|
||||
window.visualViewport?.addEventListener('resize', scheduleRefresh);
|
||||
window.requestAnimationFrame(refresh);
|
||||
|
||||
return {
|
||||
button,
|
||||
refresh: scheduleRefresh,
|
||||
cleanup() {
|
||||
if (disposed) return;
|
||||
disposed = true;
|
||||
if (refreshFrame) {
|
||||
window.cancelAnimationFrame(refreshFrame);
|
||||
refreshFrame = 0;
|
||||
}
|
||||
unbindContainer();
|
||||
window.removeEventListener('resize', scheduleRefresh);
|
||||
window.visualViewport?.removeEventListener('resize', scheduleRefresh);
|
||||
button.removeEventListener('click', scrollToBottom);
|
||||
button.remove();
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
|
||||
/** Общий экран ожидания локальной генерации ключей. Без ложного процента выполнения. */
|
||||
export function createSecretGenerationOverlay() {
|
||||
const overlay = document.createElement('div');
|
||||
overlay.className = 'secret-generation-overlay';
|
||||
overlay.hidden = true;
|
||||
overlay.setAttribute('role', 'status');
|
||||
overlay.setAttribute('aria-live', 'polite');
|
||||
|
||||
const card = document.createElement('div');
|
||||
card.className = 'secret-generation-card stack';
|
||||
|
||||
const spinner = document.createElement('div');
|
||||
spinner.className = 'secret-generation-spinner';
|
||||
spinner.setAttribute('aria-hidden', 'true');
|
||||
|
||||
const title = document.createElement('div');
|
||||
title.className = 'secret-generation-title';
|
||||
title.textContent = t('components.secret_generation_overlay.title');
|
||||
|
||||
const description = document.createElement('p');
|
||||
description.className = 'secret-generation-description';
|
||||
description.textContent = t('components.secret_generation_overlay.description');
|
||||
|
||||
card.append(spinner, title, description);
|
||||
overlay.append(card);
|
||||
return {
|
||||
overlay,
|
||||
show() { overlay.hidden = false; },
|
||||
hide() { overlay.hidden = true; },
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
import { openSheet } from './sheet.js';
|
||||
import { iconHtml } from './ui-icon.js';
|
||||
import { showToast } from '../services/channels-ux.js';
|
||||
|
||||
// «Поделиться записью / комментарием»: что именно отправляется, ссылка и «Скопировать ссылку».
|
||||
// Системное меню «Поделиться» — вторым действием, если браузер его умеет.
|
||||
export function openShareSheet({ title = t('dialogs.remaining.components.share_sheet.opensharesheet.podelitsya'), kicker = '', text = '', url = '' } = {}) {
|
||||
return openSheet({
|
||||
title,
|
||||
className: 'share-sheet',
|
||||
content: (sheet) => {
|
||||
const wrap = document.createElement('div');
|
||||
wrap.className = 'share-sheet__content';
|
||||
|
||||
const preview = document.createElement('div');
|
||||
preview.className = 'share-sheet__preview';
|
||||
const k = document.createElement('strong');
|
||||
k.textContent = kicker;
|
||||
const previewText = document.createElement('p');
|
||||
previewText.textContent = text;
|
||||
preview.append(k, previewText);
|
||||
|
||||
const label = document.createElement('label');
|
||||
label.className = 'share-sheet__label';
|
||||
label.textContent = t('dialogs.modals.share_sheet.label_001');
|
||||
const field = document.createElement('input');
|
||||
field.className = 'share-sheet__link';
|
||||
field.readOnly = true;
|
||||
field.value = url;
|
||||
field.addEventListener('focus', () => field.select());
|
||||
label.append(field);
|
||||
|
||||
const copy = document.createElement('button');
|
||||
copy.type = 'button';
|
||||
copy.className = 'primary-btn share-sheet__copy';
|
||||
copy.innerHTML = `${iconHtml('copy')}<span>${t('dialogs.remaining.components.share_sheet.markup.skopirovat_ssylku')}</span>`;
|
||||
copy.addEventListener('click', async () => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(url);
|
||||
showToast(t('dialogs.remaining.components.share_sheet.opensharesheet.ssylka_skopirovana'));
|
||||
sheet.close();
|
||||
} catch {
|
||||
field.focus();
|
||||
field.select();
|
||||
showToast(t('dialogs.remaining.components.share_sheet.opensharesheet.ssylka_vydelena_skopiruyte_eyo_vruchnuyu'), { kind: 'info' });
|
||||
}
|
||||
});
|
||||
wrap.append(preview, label, copy);
|
||||
|
||||
if (navigator.share) {
|
||||
const system = document.createElement('button');
|
||||
system.type = 'button';
|
||||
system.className = 'secondary-btn share-sheet__system';
|
||||
system.innerHTML = `${iconHtml('share')}<span>${t('dialogs.remaining.components.share_sheet.markup.drugoe_prilozhenie')}</span>`;
|
||||
system.addEventListener('click', async () => {
|
||||
try { await navigator.share({ title: kicker, text, url }); sheet.close(); } catch { /* отменили */ }
|
||||
});
|
||||
wrap.append(system);
|
||||
}
|
||||
return wrap;
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
import { iconHtml } from './ui-icon.js';
|
||||
|
||||
// Шторка снизу (на широком экране — окно по центру) с заголовком и «✕».
|
||||
// Закрывается по «✕», Escape и тапу мимо; фокус возвращается туда, откуда открыли.
|
||||
// Возвращает { root, body, footer, close }. content — Node или функция (sheet) => Node.
|
||||
export function openSheet({ title = '', content = null, className = '', onClose = null } = {}) {
|
||||
const opener = document.activeElement;
|
||||
const modal = document.createElement('div');
|
||||
modal.className = `modal sheet${className ? ` ${className}` : ''}`;
|
||||
const card = document.createElement('div');
|
||||
card.className = 'modal-card sheet__card';
|
||||
card.setAttribute('role', 'dialog');
|
||||
card.setAttribute('aria-modal', 'true');
|
||||
|
||||
const head = document.createElement('div');
|
||||
head.className = 'sheet__head';
|
||||
const heading = document.createElement('h2');
|
||||
heading.className = 'modal-title sheet__title';
|
||||
heading.textContent = title;
|
||||
heading.id = `sheet-title-${Math.random().toString(36).slice(2, 8)}`;
|
||||
card.setAttribute('aria-labelledby', heading.id);
|
||||
const closeBtn = document.createElement('button');
|
||||
closeBtn.type = 'button';
|
||||
closeBtn.className = 'icon-btn sheet__close';
|
||||
closeBtn.setAttribute('aria-label', t('screens.sheet.text_001'));
|
||||
closeBtn.innerHTML = iconHtml('close');
|
||||
head.append(heading, closeBtn);
|
||||
|
||||
const body = document.createElement('div');
|
||||
body.className = 'sheet__body';
|
||||
const footer = document.createElement('div');
|
||||
footer.className = 'sheet__footer';
|
||||
footer.hidden = true;
|
||||
card.append(head, body, footer);
|
||||
modal.append(card);
|
||||
|
||||
let closed = false;
|
||||
const close = () => {
|
||||
if (closed) return;
|
||||
closed = true;
|
||||
document.removeEventListener('keydown', onKeydown, true);
|
||||
modal.remove();
|
||||
opener?.focus?.();
|
||||
onClose?.();
|
||||
};
|
||||
const onKeydown = (event) => {
|
||||
if (event.key === 'Escape') { event.stopPropagation(); close(); }
|
||||
};
|
||||
modal.addEventListener('click', (event) => { if (event.target === modal) close(); });
|
||||
closeBtn.addEventListener('click', close);
|
||||
document.addEventListener('keydown', onKeydown, true);
|
||||
|
||||
const sheet = { root: modal, body, footer, close };
|
||||
const node = typeof content === 'function' ? content(sheet) : content;
|
||||
if (node instanceof Node) body.append(node);
|
||||
if (footer.childElementCount) footer.hidden = false;
|
||||
document.body.append(modal);
|
||||
(card.querySelector('[autofocus]') || closeBtn).focus();
|
||||
return sheet;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
export const SHINE_CONNECTIONS_LOGO_SRC = '/assets/SHiNE_connections_blue.svg?v=2026082601';
|
||||
|
||||
export function createShineConnectionsLogo({ className = '' } = {}) {
|
||||
const img = document.createElement('img');
|
||||
img.src = SHINE_CONNECTIONS_LOGO_SRC;
|
||||
img.alt = '';
|
||||
img.setAttribute('aria-hidden', 'true');
|
||||
img.className = String(className || '').trim();
|
||||
return img;
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
import { authService, state } from '../state.js';
|
||||
import { readShineUserPda, supportShineUserOnSolana, supportShineDaoOnSolana } from '../services/shine-user-pda-service.js';
|
||||
import { loadEncryptedUserSecrets } from '../services/key-vault.js';
|
||||
import { getWalletFromStoredBlockchainKey, transferSolLamports, solanaAddressFromPublicKeyBase64 } from '../services/solana-wallet-service.js';
|
||||
import { bytesToBase58 } from '../services/crypto-utils.js';
|
||||
import { parseStarCents, formatStars, splitStarCents, starCentsToLamports, formatLamportsSol } from '../services/shine-support-amount.js';
|
||||
import { toUserMessage } from '../services/ui-error-texts.js';
|
||||
import { getStarsQuoteFromRpc } from '../services/shine-stars-pyth.js';
|
||||
|
||||
/** One shared payment dialog for profiles, posts and donations to the SHiNE economy. */
|
||||
export function openShineSupportDialog({ recipientLogin = '', target = { type: 0 }, onSuccess = () => {} } = {}) {
|
||||
const dao = !recipientLogin;
|
||||
const login = String(state.session.login || '').trim();
|
||||
if (!login) { window.alert(t('screens.support_phase2.login_required')); return; }
|
||||
if (!dao && login.toLowerCase() === String(recipientLogin).trim().toLowerCase()) {
|
||||
window.alert(t('screens.support_phase2.self_support')); return;
|
||||
}
|
||||
const overlay = document.createElement('div');
|
||||
overlay.className = 'shine-support-dialog-overlay';
|
||||
overlay.style.cssText = 'position:fixed;inset:0;z-index:9999;background:rgba(0,0,0,.66);display:flex;align-items:center;justify-content:center;padding:16px;';
|
||||
const panel = document.createElement('section');
|
||||
panel.className = 'card stack shine-support-dialog';
|
||||
panel.style.cssText = 'width:min(100%,440px);max-height:90vh;overflow:auto;padding:20px;gap:12px;';
|
||||
const header = document.createElement('h2');
|
||||
header.textContent = dao ? t('screens.support_phase2.donate_shine') : t('screens.support_phase2.donate');
|
||||
const description = document.createElement('p');
|
||||
description.className = 'meta-muted';
|
||||
description.textContent = dao ? t('screens.support_phase2.dao_info') : `${t('screens.support_phase2.to')} ${recipientLogin}`;
|
||||
const amountLabel = document.createElement('label');
|
||||
amountLabel.textContent = t('screens.support_phase2.amount');
|
||||
const input = document.createElement('input');
|
||||
input.className = 'input';
|
||||
input.type = 'text';
|
||||
input.inputMode = 'decimal';
|
||||
input.autocomplete = 'off';
|
||||
input.placeholder = '0.10';
|
||||
const details = document.createElement('p');
|
||||
details.className = 'meta-muted';
|
||||
const status = document.createElement('p');
|
||||
status.setAttribute('role', 'status');
|
||||
status.className = 'meta-muted';
|
||||
const donate = document.createElement('button');
|
||||
donate.type = 'button';
|
||||
donate.className = 'primary-btn';
|
||||
donate.textContent = t('screens.support_phase2.donate');
|
||||
const direct = document.createElement('button');
|
||||
direct.type = 'button';
|
||||
direct.className = 'secondary-btn';
|
||||
direct.textContent = t('screens.support_phase2.direct');
|
||||
const cancel = document.createElement('button');
|
||||
cancel.type = 'button';
|
||||
cancel.className = 'text-btn';
|
||||
cancel.textContent = t('screens.support_phase2.close');
|
||||
panel.append(header, description, amountLabel, input, details, status, donate);
|
||||
// Direct transfers bypass Stars accounting and must not appear in the support dialog.
|
||||
panel.append(cancel);
|
||||
overlay.append(panel);
|
||||
document.body.append(overlay);
|
||||
let quote = null;
|
||||
let busy = false;
|
||||
let closed = false;
|
||||
const close = () => { if (busy) return; closed = true; overlay.remove(); };
|
||||
cancel.addEventListener('click', close);
|
||||
overlay.addEventListener('click', (event) => { if (event.target === overlay) close(); });
|
||||
const update = () => {
|
||||
try {
|
||||
const cents = parseStarCents(input.value);
|
||||
const split = splitStarCents(cents);
|
||||
const sol = quote ? ` · ≈ ${formatLamportsSol(starCentsToLamports(cents, quote.solUsdE8, quote.usdtUsdE8))} SOL` : '';
|
||||
details.textContent = dao ? `${formatStars(cents)}${sol}` :
|
||||
`${t('screens.support_phase2.recipient')}: ${formatStars(split.author)} · ${t('screens.support_phase2.fund')}: ${formatStars(split.dao)}${sol}`;
|
||||
} catch { details.textContent = 'Минимум 0,10 ⭐'; }
|
||||
};
|
||||
input.addEventListener('input', update);
|
||||
amountLabel.textContent = 'Сумма поддержки, ⭐';
|
||||
update();
|
||||
void getStarsQuoteFromRpc({ solanaEndpoint: state.entrySettings.solanaServer }).then((value) => { quote = value; if (!closed) update(); })
|
||||
.catch(() => { if (!closed) details.textContent = 'Курс недоступен. Повторите попытку позднее.'; });
|
||||
const send = async (isDirect) => {
|
||||
if (busy || closed) return;
|
||||
let amount, cents;
|
||||
try {
|
||||
cents = parseStarCents(input.value);
|
||||
if (isDirect) throw new Error('Прямой перевод не учитывается в Stars');
|
||||
} catch (error) { status.textContent = error.message; return; }
|
||||
if (isDirect && !window.confirm(t('screens.support_phase2.direct_warning'))) return;
|
||||
busy = true;
|
||||
donate.disabled = direct.disabled = cancel.disabled = input.disabled = true;
|
||||
status.textContent = t('screens.support_phase2.sending');
|
||||
try {
|
||||
// Fetch a fresh quote immediately before signing; Pyth on-chain check is authoritative.
|
||||
quote = await getStarsQuoteFromRpc({ solanaEndpoint: state.entrySettings.solanaServer });
|
||||
amount = starCentsToLamports(cents, quote.solUsdE8, quote.usdtUsdE8);
|
||||
const { storagePwdInMemory: password } = state.session;
|
||||
const endpoint = state.entrySettings.solanaServer;
|
||||
let result;
|
||||
if (isDirect) {
|
||||
let address = '';
|
||||
try {
|
||||
const pda = await readShineUserPda({ login: recipientLogin, solanaEndpoint: endpoint });
|
||||
address = bytesToBase58(pda.forks.at(-1).blockchainKey);
|
||||
} catch {
|
||||
const recipient = await authService.getUser(recipientLogin);
|
||||
if (!recipient?.exists) throw new Error(t('screens.support_phase2.unavailable'));
|
||||
address = solanaAddressFromPublicKeyBase64(recipient.blockchainKey);
|
||||
}
|
||||
const wallet = await getWalletFromStoredBlockchainKey({ login, storagePwd: password });
|
||||
result = await transferSolLamports({ endpoint, fromKeypair: wallet.keypair, toAddress: address, amountLamports: amount });
|
||||
} else {
|
||||
const secrets = await loadEncryptedUserSecrets(login, password);
|
||||
if (!secrets?.blockchainKey || !secrets?.clientKey) throw new Error(t('screens.support_phase2.keys_required'));
|
||||
const args = { senderLogin: login, amountLamports: amount, starCents: cents,
|
||||
oracleAccounts: { solUsd: quote.solOracleAccount, usdtUsd: quote.usdtOracleAccount },
|
||||
solanaEndpoint: endpoint, blockchainPrivatePkcs8B64: secrets.blockchainKey, clientPrivatePkcs8B64: secrets.clientKey };
|
||||
result = dao ? await supportShineDaoOnSolana(args) : await supportShineUserOnSolana({ ...args, recipientLogin, target });
|
||||
}
|
||||
status.textContent = `${t('screens.support_phase2.success')} ${result.signature || ''}`;
|
||||
try { onSuccess(result); } catch { /* page may have been closed */ }
|
||||
donate.hidden = true;
|
||||
direct.hidden = true;
|
||||
cancel.disabled = false;
|
||||
cancel.textContent = t('screens.support_phase2.close');
|
||||
} catch (error) {
|
||||
status.textContent = toUserMessage(error, t('screens.support_phase2.failed'));
|
||||
} finally {
|
||||
busy = false;
|
||||
donate.disabled = direct.disabled = cancel.disabled = input.disabled = false;
|
||||
}
|
||||
};
|
||||
donate.addEventListener('click', () => void send(false));
|
||||
direct.addEventListener('click', () => void send(true));
|
||||
input.focus();
|
||||
return overlay;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
// Надпись «СИЯНИЕ» вразрядку: Tenor Sans (OFL) в контурах — шрифт не скачивается.
|
||||
// Цвет — currentColor, поэтому надпись берёт цвет текста темы.
|
||||
const NS = 'http://www.w3.org/2000/svg';
|
||||
const WIDTH = 7336;
|
||||
const PATH = 'M721 -129Q619 -33 479 -33Q401 -33 341 -60Q281 -87 241 -132Q201 -177 180.5 -236Q160 -295 160 -359Q160 -427 181.5 -483.5Q203 -540 242 -581Q281 -622 334.5 -645Q388 -668 451 -668Q494 -668 529.5 -658Q565 -648 592.5 -632Q620 -616 637.5 -595.5Q655 -575 662 -554H736Q721 -588 697.5 -617Q674 -646 639 -667Q604 -688 557 -700Q510 -712 450 -712Q363 -712 291.5 -687Q220 -662 169 -615.5Q118 -569 90 -503.5Q62 -438 62 -357Q62 -287 84.5 -220.5Q107 -154 154 -102.5Q201 -51 274 -19.5Q347 12 448 12Q512 12 562.5 0Q613 -12 650.5 -29.5Q688 -47 713 -67Q738 -87 751 -102ZM1542 -82V-700H1451V0H1542L1957 -625V0H2048V-700H1957ZM3316 -700V0H3225V-309H3181Q3153 -309 3134.5 -304Q3116 -299 3101 -287Q3086 -275 3073 -256Q3060 -237 3042 -209L2963 -92Q2948 -69 2933.5 -50Q2919 -31 2902 -17.5Q2885 -4 2863.5 4Q2842 12 2812 12Q2790 12 2776 10Q2762 8 2748 0V-37Q2753 -36 2758 -35.5Q2763 -35 2768 -35Q2789 -35 2805 -41Q2821 -47 2835 -58.5Q2849 -70 2862 -86.5Q2875 -103 2889 -124Q2931 -185 2954 -221.5Q2977 -258 2990.5 -278Q3004 -298 3012.5 -307Q3021 -316 3033 -322L3043 -327V-331Q2995 -334 2960.5 -352Q2926 -370 2904 -397Q2882 -424 2872 -455.5Q2862 -487 2862 -517Q2862 -544 2872.5 -576Q2883 -608 2908.5 -635.5Q2934 -663 2978 -681.5Q3022 -700 3089 -700ZM3225 -656H3124Q3086 -656 3055.5 -645Q3025 -634 3003 -614.5Q2981 -595 2969.5 -568Q2958 -541 2958 -509Q2958 -482 2968.5 -454.5Q2979 -427 3000 -404.5Q3021 -382 3051.5 -368Q3082 -354 3122 -354H3225ZM4197 -348H4616V0H4707V-700H4616V-394H4197V-700H4106V0H4197ZM5588 -82V-700H5497V0H5588L6003 -625V0H6094V-700H6003ZM6884 -700V0H7336V-55H6975V-346H7285V-394H6975V-645H7336V-700Z';
|
||||
|
||||
export function createShineWordmark({ className = '' } = {}) {
|
||||
const svg = document.createElementNS(NS, 'svg');
|
||||
svg.setAttribute('viewBox', `52 -722 ${WIDTH - 42} 744`);
|
||||
svg.setAttribute('class', `shine-wordmark ${className}`.trim());
|
||||
svg.setAttribute('role', 'img');
|
||||
svg.setAttribute('aria-label', t('screens.shine_wordmark.text_001'));
|
||||
const path = document.createElementNS(NS, 'path');
|
||||
path.setAttribute('d', PATH);
|
||||
path.setAttribute('fill', 'currentColor');
|
||||
svg.append(path);
|
||||
return svg;
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
import { authService } from '../state.js';
|
||||
import { getSolanaCluster } from '../services/solana-rpc-gateway.js';
|
||||
import { formatStars } from '../services/shine-support-amount.js';
|
||||
|
||||
export function supportStatsValues(stats = {}) {
|
||||
const sent = BigInt(stats.supportSent ?? 0);
|
||||
const received = BigInt(stats.supportReceived ?? 0);
|
||||
const daoDirect = BigInt(stats.daoDirect ?? 0);
|
||||
return [sent, received, daoDirect];
|
||||
}
|
||||
|
||||
/** Adds an independent asynchronous block; failure/Free accounts do not get fictitious statistics. */
|
||||
export function attachSupportStats(parent, { login, isActive = () => true }) {
|
||||
const section = document.createElement('section');
|
||||
section.className = 'card stack profile-support-stats';
|
||||
section.style.cssText = 'margin-top:12px;gap:8px;';
|
||||
const title = document.createElement('strong');
|
||||
title.textContent = t('screens.support_phase2.statistics');
|
||||
const content = document.createElement('div');
|
||||
content.className = 'meta-muted';
|
||||
content.textContent = t('screens.support_phase2.loading');
|
||||
section.append(title, content);
|
||||
const history = document.createElement('details');
|
||||
history.className = 'profile-support-history';
|
||||
const historySummary = document.createElement('summary');
|
||||
historySummary.textContent = t('screens.support_phase2.history');
|
||||
const historyRows = document.createElement('div');
|
||||
historyRows.className = 'stack';
|
||||
historyRows.style.cssText = 'gap:8px;margin-top:10px;';
|
||||
history.append(historySummary, historyRows);
|
||||
section.append(history);
|
||||
parent.append(section);
|
||||
let historyOffset = 0;
|
||||
let loadingHistory = false;
|
||||
let historyLoaded = false;
|
||||
const historyLogin = String(login || '').trim().toLowerCase();
|
||||
const loadHistory = async () => {
|
||||
if (loadingHistory || !isActive() || !section.isConnected) return;
|
||||
loadingHistory = true;
|
||||
const note = document.createElement('div');
|
||||
note.className = 'meta-muted';
|
||||
note.textContent = t('screens.support_phase2.loading');
|
||||
historyRows.append(note);
|
||||
try {
|
||||
const result = await authService.getSupportHistory(login, 20, historyOffset);
|
||||
if (!isActive() || !section.isConnected) return;
|
||||
note.remove();
|
||||
if (!result.ready) {
|
||||
historyRows.textContent = t('screens.support_phase2.loading');
|
||||
return;
|
||||
}
|
||||
if (!historyOffset && !result.transfers?.length) {
|
||||
historyRows.textContent = t('screens.support_phase2.no_history');
|
||||
}
|
||||
const more = historyRows.querySelector('[data-stars-more]');
|
||||
more?.remove();
|
||||
for (const transfer of result.transfers || []) {
|
||||
const outgoing = transfer.senderLogin?.trim().toLowerCase() === historyLogin;
|
||||
const cents = transfer.kind === 'DAO' || outgoing
|
||||
? transfer.amountStarCents : transfer.recipientStarCents;
|
||||
const row = document.createElement('div');
|
||||
row.className = 'row';
|
||||
row.style.cssText = 'display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:6px;';
|
||||
const info = document.createElement('span');
|
||||
info.textContent = transfer.kind === 'DAO'
|
||||
? t('screens.support_phase2.history_dao')
|
||||
: `${outgoing ? '→' : '←'} ${outgoing ? transfer.recipientLogin : transfer.senderLogin}`;
|
||||
const value = document.createElement('strong');
|
||||
value.textContent = `${outgoing ? '−' : '+'}${formatStars(cents)}`;
|
||||
const detail = document.createElement('small');
|
||||
detail.className = 'meta-muted';
|
||||
const date = transfer.blockTime ? new Date(Number(transfer.blockTime) * 1000).toLocaleString() : '';
|
||||
const lamports = BigInt(transfer.amountLamports || '0');
|
||||
const sol = `${lamports / 1_000_000_000n}.${String(lamports % 1_000_000_000n).padStart(9, '0').replace(/0+$/, '') || '0'} SOL`;
|
||||
detail.textContent = `${date} · ${sol}`;
|
||||
const explorer = document.createElement('a');
|
||||
const sig = String(transfer.signature || '');
|
||||
if (/^[1-9A-HJ-NP-Za-km-z]{64,90}$/.test(sig)) {
|
||||
const network = getSolanaCluster();
|
||||
explorer.href = `https://explorer.solana.com/tx/${sig}${network && network !== 'mainnet-beta' ? `?cluster=${encodeURIComponent(network)}` : ''}`;
|
||||
explorer.target = '_blank'; explorer.rel = 'noopener noreferrer';
|
||||
explorer.textContent = t('screens.support_phase2.transaction');
|
||||
row.append(info, value, detail, explorer);
|
||||
} else row.append(info, value, detail);
|
||||
historyRows.append(row);
|
||||
}
|
||||
historyOffset += (result.transfers || []).length;
|
||||
if (result.hasMore) {
|
||||
const btn = document.createElement('button');
|
||||
btn.className = 'text-btn'; btn.type = 'button';
|
||||
btn.dataset.starsMore = '1';
|
||||
btn.textContent = t('screens.support_phase2.more');
|
||||
btn.addEventListener('click', () => void loadHistory());
|
||||
historyRows.append(btn);
|
||||
}
|
||||
historyLoaded = true;
|
||||
} catch {
|
||||
if (isActive() && section.isConnected) note.textContent = t('screens.support_phase2.history_unavailable');
|
||||
} finally { loadingHistory = false; }
|
||||
};
|
||||
history.addEventListener('toggle', () => {
|
||||
if (history.open && !historyLoaded) void loadHistory();
|
||||
});
|
||||
let pendingRefresh = null;
|
||||
const scheduleRetry = () => {
|
||||
if (pendingRefresh !== null) return;
|
||||
pendingRefresh = window.setTimeout(() => {
|
||||
pendingRefresh = null;
|
||||
if (isActive() && section.isConnected) void refresh();
|
||||
}, 10_000);
|
||||
};
|
||||
const refresh = async () => {
|
||||
try {
|
||||
const stats = await authService.getSupportStats(login);
|
||||
if (!isActive() || !section.isConnected) return;
|
||||
if (!stats.ready) {
|
||||
// Первичная индексация ещё идёт. Повторим запрос к кешу без RPC Solana.
|
||||
content.textContent = t('screens.support_phase2.loading');
|
||||
scheduleRetry();
|
||||
return;
|
||||
}
|
||||
if (!stats.available) {
|
||||
// Free-аккаунты не имеют Paid PDA, поэтому блок статистики не показываем.
|
||||
section.remove();
|
||||
return;
|
||||
}
|
||||
const values = supportStatsValues({
|
||||
supportSent: stats.supportSentStarCents,
|
||||
supportReceived: stats.supportReceivedStarCents,
|
||||
daoDirect: stats.daoDirectStarCents,
|
||||
});
|
||||
content.replaceChildren();
|
||||
content.className = 'stack';
|
||||
[t('screens.support_phase2.sent'), t('screens.support_phase2.received'), t('screens.support_phase2.shine')].forEach((label, idx) => {
|
||||
const row = document.createElement('div');
|
||||
row.className = 'row';
|
||||
row.style.cssText = 'display:flex;justify-content:space-between;gap:8px;';
|
||||
const name = document.createElement('span');
|
||||
const amount = document.createElement('strong');
|
||||
name.textContent = label;
|
||||
amount.textContent = formatStars(values[idx]);
|
||||
row.append(name, amount);
|
||||
content.append(row);
|
||||
});
|
||||
} catch {
|
||||
if (!isActive() || !section.isConnected) return;
|
||||
// A missing Paid PDA means Free, but network errors must not be displayed as zero.
|
||||
content.textContent = t('screens.support_phase2.unavailable');
|
||||
}
|
||||
};
|
||||
void refresh();
|
||||
return { element: section, refresh };
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
import { resolveToolbarActive } from '../router.js';
|
||||
import { state, authService } from '../state.js';
|
||||
import { openAuthRequiredModal } from '../services/auth-required-modal.js';
|
||||
import { SHINE_CONNECTIONS_LOGO_SRC } from './shine-logo.js';
|
||||
|
||||
const TOOLBAR_ICONS = {
|
||||
'messages-list': '<g transform="translate(12 12) scale(.88) translate(-11.5 -13)"><path d="M21 11.5a8.5 8.5 0 0 1-8.5 8.5H4l-2 2v-9.5A8.5 8.5 0 0 1 10.5 4H13a8 8 0 0 1 8 7.5Z"/><circle cx="8" cy="12" r="1.05" class="toolbar-svg-dot"/><circle cx="11.7" cy="12" r="1.05" class="toolbar-svg-dot"/><circle cx="15.4" cy="12" r="1.05" class="toolbar-svg-dot"/></g>',
|
||||
'channels-list': '<rect x="4" y="3" width="16" height="18" rx="3"/><path d="M8 8h8M8 12h8M8 16h5"/>',
|
||||
'notifications-view': '<path d="M6.2 16.8V11a5.8 5.8 0 0 1 11.6 0v5.8l1.7 1.7h-15Z"/><path d="M10.2 21a2 2 0 0 0 3.6 0"/>',
|
||||
'profile-view': '<circle cx="12" cy="6.8" r="3.6"/><path d="M4.4 21v-2.1a5.6 5.6 0 0 1 5.6-5.6h4a5.6 5.6 0 0 1 5.6 5.6V21Z"/>',
|
||||
};
|
||||
|
||||
const ITEMS = [
|
||||
{ pageId: 'messages-list', get label() { return t('screens.toolbar.text_001'); } },
|
||||
{ pageId: 'channels-list', get label() { return t('screens.toolbar.text_002'); } },
|
||||
{ pageId: 'network-view', get label() { return t('screens.toolbar.text_003'); }, mandala: true },
|
||||
{ pageId: 'notifications-view', get label() { return t('screens.toolbar.text_004'); } },
|
||||
{ pageId: 'profile-view', get label() { return t('screens.toolbar.text_005'); } },
|
||||
];
|
||||
|
||||
function iconHtml(item, extra = '') {
|
||||
const glyph = item.mandala
|
||||
? `<img class="toolbar-mandala" src="${SHINE_CONNECTIONS_LOGO_SRC}" alt="" aria-hidden="true" />`
|
||||
: `<svg class="toolbar-svg" viewBox="0 0 24 24" aria-hidden="true">${TOOLBAR_ICONS[item.pageId]}</svg>`;
|
||||
return `<span class="toolbar-icon${item.mandala ? ' toolbar-icon--mandala' : ''}">${glyph}${extra}</span>`;
|
||||
}
|
||||
|
||||
function normalizeCounters(payload = {}) {
|
||||
const notifications = payload?.notifications || {};
|
||||
const notificationTotal = Math.max(0, Number(payload?.notificationsUnreadCount ?? (
|
||||
Number(notifications.replies || 0) + Number(notifications.connections || 0) + Number(notifications.events || 0)
|
||||
)) || 0);
|
||||
return {
|
||||
dmUnreadCount: Math.max(0, Number(payload?.dmUnreadCount || 0) || 0),
|
||||
channelsUnreadCount: Math.max(0, Number(payload?.channelsUnreadCount || 0) || 0),
|
||||
notificationsUnreadCount: notificationTotal,
|
||||
notifications: {
|
||||
replies: Math.max(0, Number(notifications.replies ?? payload?.notificationRepliesUnreadCount ?? 0) || 0),
|
||||
connections: Math.max(0, Number(notifications.connections ?? payload?.notificationConnectionsUnreadCount ?? 0) || 0),
|
||||
events: Math.max(0, Number(notifications.events ?? payload?.notificationEventsUnreadCount ?? 0) || 0),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function setCounterState(payload = {}) {
|
||||
state.userCounters = normalizeCounters(payload);
|
||||
state.notificationUnreadTotal = state.userCounters.notificationsUnreadCount;
|
||||
}
|
||||
|
||||
function renderBadge(btn, count, ariaLabel, extraClass = '') {
|
||||
if (!btn) return;
|
||||
let badge = btn.querySelector('.toolbar-unread-badge');
|
||||
if (count <= 0) { badge?.remove(); return; }
|
||||
if (!badge) {
|
||||
badge = document.createElement('span');
|
||||
badge.className = `toolbar-unread-badge${extraClass ? ` ${extraClass}` : ''}`;
|
||||
(btn.querySelector('.toolbar-icon') || btn).append(badge);
|
||||
}
|
||||
badge.textContent = count > 99 ? '99+' : String(count);
|
||||
badge.setAttribute('aria-label', `${ariaLabel}: ${count}`);
|
||||
}
|
||||
|
||||
function applyCountersToMountedToolbars() {
|
||||
const c = normalizeCounters(state.userCounters);
|
||||
document.querySelectorAll('.toolbar').forEach((toolbar) => {
|
||||
renderBadge(toolbar.querySelector('[data-toolbar-page="messages-list"]'), c.dmUnreadCount, t('screens.toolbar.text_009'));
|
||||
renderBadge(toolbar.querySelector('[data-toolbar-page="channels-list"]'), c.channelsUnreadCount, t('screens.toolbar.text_010'));
|
||||
renderBadge(toolbar.querySelector('[data-toolbar-page="notifications-view"]'), c.notificationsUnreadCount, t('screens.toolbar.text_011'), 'notification-toolbar-badge');
|
||||
});
|
||||
}
|
||||
|
||||
let countersPushBound = false;
|
||||
function ensureCountersPushBound() {
|
||||
if (countersPushBound) return;
|
||||
countersPushBound = true;
|
||||
authService.onEvent('UserCountersChanged', (event) => {
|
||||
setCounterState(event?.payload || {});
|
||||
applyCountersToMountedToolbars();
|
||||
});
|
||||
}
|
||||
|
||||
async function refreshUserCounters() {
|
||||
if (!state.session.isAuthorized) return;
|
||||
try {
|
||||
setCounterState(await authService.getUserCounters());
|
||||
applyCountersToMountedToolbars();
|
||||
} catch {
|
||||
// Keep the last known counters; realtime push or the next refresh can recover.
|
||||
}
|
||||
}
|
||||
|
||||
function navigateWithGuestRules(pageId, navigate) {
|
||||
if (state.session.isAuthorized) {
|
||||
navigate(pageId);
|
||||
return;
|
||||
}
|
||||
if (pageId === 'messages-list') {
|
||||
openAuthRequiredModal({
|
||||
title: t('screens.toolbar.text_006'),
|
||||
text: t('screens.toolbar.text_015'),
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (pageId === 'profile-view') {
|
||||
openAuthRequiredModal({
|
||||
title: t('screens.toolbar.text_007'),
|
||||
text: t('screens.toolbar.text_016'),
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (pageId === 'notifications-view') {
|
||||
openAuthRequiredModal({
|
||||
title: t('screens.toolbar.text_008'),
|
||||
text: t('screens.toolbar.text_017'),
|
||||
});
|
||||
return;
|
||||
}
|
||||
navigate(pageId);
|
||||
}
|
||||
|
||||
export function renderToolbar(currentPageId, navigate) {
|
||||
const root = document.createElement('nav');
|
||||
root.className = 'toolbar';
|
||||
const active = resolveToolbarActive(currentPageId);
|
||||
ensureCountersPushBound();
|
||||
const counters = normalizeCounters(state.userCounters);
|
||||
|
||||
ITEMS.forEach((item) => {
|
||||
const btn = document.createElement('button');
|
||||
const isProfile = item.pageId === 'profile-view';
|
||||
const isMessages = item.pageId === 'messages-list';
|
||||
const isNetwork = item.pageId === 'network-view';
|
||||
const isNotifications = item.pageId === 'notifications-view';
|
||||
btn.type = 'button';
|
||||
if (item.pageId === active) btn.setAttribute('aria-current', 'page');
|
||||
btn.dataset.toolbarPage = item.pageId;
|
||||
btn.className = `toolbar-btn${item.pageId === active ? ' active' : ''}${isProfile ? ' toolbar-btn-profile' : ''}${isMessages ? ' toolbar-btn-messages' : ''}${isNetwork ? ' toolbar-btn-network' : ''}${item.hero ? ' toolbar-btn-hero' : ''}`;
|
||||
if (isProfile) {
|
||||
btn.innerHTML = `
|
||||
${iconHtml(item, `<span id="toolbar-connection-indicator" class="toolbar-connection-indicator is-unknown">
|
||||
<span class="toolbar-connection-dot" aria-hidden="true"></span>
|
||||
</span>`)}
|
||||
<span class="sr-only">${item.label}</span>
|
||||
`;
|
||||
} else if (isNetwork) {
|
||||
btn.innerHTML = `${iconHtml(item)}<span class="sr-only">${item.label}</span>`;
|
||||
} else {
|
||||
btn.innerHTML = `${iconHtml(item)}<span class="sr-only">${item.label}</span>`;
|
||||
}
|
||||
btn.title = item.label;
|
||||
if (isMessages) renderBadge(btn, counters.dmUnreadCount, t('screens.toolbar.text_012'));
|
||||
if (item.pageId === 'channels-list') renderBadge(btn, counters.channelsUnreadCount, t('screens.toolbar.text_013'));
|
||||
if (isNotifications) renderBadge(btn, counters.notificationsUnreadCount, t('screens.toolbar.text_014'), 'notification-toolbar-badge');
|
||||
if (item.pageId === 'channels-list') {
|
||||
btn.addEventListener('click', () => navigate('channels-list'));
|
||||
} else if (isNetwork) {
|
||||
btn.addEventListener('click', () => {
|
||||
// Каждый вход через основную вкладку начинает новое исследование сети.
|
||||
// Переключение между V1–V4 внутри вкладки этот сброс не вызывает.
|
||||
if (state.session.isAuthorized) window.dispatchEvent(new Event('shine:network-tab-enter'));
|
||||
navigateWithGuestRules(item.pageId, navigate);
|
||||
});
|
||||
} else {
|
||||
btn.addEventListener('click', () => navigateWithGuestRules(item.pageId, navigate));
|
||||
}
|
||||
root.append(btn);
|
||||
});
|
||||
|
||||
if (state.session.isAuthorized) void refreshUserCounters();
|
||||
|
||||
return root;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
import { createDropdownMenu } from './dropdown-menu.js';
|
||||
import { iconHtml } from './ui-icon.js';
|
||||
|
||||
/** Заголовок-переключатель для списков; не создаёт собственный TopBar или меню. */
|
||||
export function createTopBarFilterTitle({ section, choices, value, onSelect, minWidth = 210 } = {}) {
|
||||
const button = document.createElement('button');
|
||||
button.type = 'button';
|
||||
button.className = 'topbar-filter-title';
|
||||
button.title = t('screens.topbar_filter_title.text_001', { value1: section });
|
||||
|
||||
const caption = document.createElement('span');
|
||||
caption.className = 'topbar-filter-title__caption';
|
||||
const chevron = document.createElement('span');
|
||||
chevron.className = 'topbar-filter-title__chevron';
|
||||
chevron.setAttribute('aria-hidden', 'true');
|
||||
chevron.innerHTML = iconHtml('chevron-down');
|
||||
button.append(caption, chevron);
|
||||
|
||||
let selected = value;
|
||||
const setValue = (nextValue) => {
|
||||
selected = nextValue;
|
||||
const label = choices.find(([key]) => key === selected)?.[1] || '';
|
||||
caption.textContent = `${section}: ${label}`;
|
||||
button.setAttribute('aria-label', t('screens.topbar_filter_title.text_002', { value1: section, value2: label }));
|
||||
};
|
||||
setValue(value);
|
||||
|
||||
const menu = createDropdownMenu({
|
||||
anchorEl: button,
|
||||
placement: 'bottom-start',
|
||||
minWidth,
|
||||
transparent: true,
|
||||
items: () => choices.map(([key, label]) => ({
|
||||
label,
|
||||
selected: key === selected,
|
||||
action: () => onSelect?.(key),
|
||||
})),
|
||||
});
|
||||
|
||||
return { element: button, setValue, close: () => menu.close(), destroy: () => menu.destroy() };
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
import { iconHtml } from './ui-icon.js';
|
||||
import { createDropdownMenu } from './dropdown-menu.js';
|
||||
|
||||
function appendNode(target, node) {
|
||||
if (!target || !(node instanceof Node)) return;
|
||||
target.append(node);
|
||||
}
|
||||
|
||||
function createActionButton(action = {}, cleanupFns) {
|
||||
const button = document.createElement('button');
|
||||
button.type = 'button';
|
||||
button.className = `icon-btn topbar__action${action.className ? ` ${action.className}` : ''}`;
|
||||
if (action.title) button.title = action.title;
|
||||
if (action.ariaLabel) button.setAttribute('aria-label', action.ariaLabel);
|
||||
if (action.id) button.dataset.action = action.id;
|
||||
|
||||
if (action.iconNode instanceof Node) {
|
||||
button.append(action.iconNode);
|
||||
} else if (action.icon) {
|
||||
button.innerHTML = iconHtml(action.icon);
|
||||
} else if (action.label === '⋮' || action.label === '⋯') {
|
||||
// Меню экрана везде рисуется одной иконкой «⋯»
|
||||
button.innerHTML = iconHtml('more');
|
||||
} else {
|
||||
button.textContent = String(action.label ?? '');
|
||||
}
|
||||
|
||||
if (action.menu) {
|
||||
const menu = createDropdownMenu({
|
||||
anchorEl: button,
|
||||
transparent: true,
|
||||
dimBackground: true,
|
||||
keepAnchorPressed: true,
|
||||
...(typeof action.menu === 'object' ? action.menu : {}),
|
||||
});
|
||||
cleanupFns.add(() => menu.destroy());
|
||||
} else if (typeof action.onClick === 'function') {
|
||||
button.addEventListener('click', action.onClick);
|
||||
}
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
export function createTopBar({
|
||||
title = '',
|
||||
className = '',
|
||||
left = null,
|
||||
center = null,
|
||||
back = null,
|
||||
leftLabel = '',
|
||||
actions = [],
|
||||
} = {}) {
|
||||
const cleanupFns = new Set();
|
||||
const topbar = document.createElement('header');
|
||||
topbar.className = `topbar${className ? ` ${className}` : ''}`;
|
||||
|
||||
const leftSlot = document.createElement('div');
|
||||
leftSlot.className = 'topbar__left';
|
||||
|
||||
const backAction = back;
|
||||
if (backAction?.visible !== false && typeof backAction?.onClick === 'function') {
|
||||
const button = document.createElement('button');
|
||||
button.type = 'button';
|
||||
button.className = `icon-btn topbar__back${backAction.className ? ` ${backAction.className}` : ''}`;
|
||||
button.innerHTML = iconHtml('back');
|
||||
button.setAttribute('aria-label', backAction.ariaLabel || t('screens.topbar.text_004'));
|
||||
button.title = backAction.title || t('screens.topbar.text_005');
|
||||
button.addEventListener('click', backAction.onClick);
|
||||
leftSlot.append(button);
|
||||
}
|
||||
|
||||
appendNode(leftSlot, left);
|
||||
|
||||
if (leftLabel) {
|
||||
const label = document.createElement('span');
|
||||
label.className = 'topbar__left-label';
|
||||
label.textContent = leftLabel;
|
||||
leftSlot.append(label);
|
||||
}
|
||||
|
||||
const centerSlot = document.createElement('div');
|
||||
centerSlot.className = 'topbar__center';
|
||||
const resolvedCenter = center;
|
||||
if (resolvedCenter instanceof Node) {
|
||||
centerSlot.append(resolvedCenter);
|
||||
} else {
|
||||
const heading = document.createElement('h1');
|
||||
heading.className = 'topbar__title';
|
||||
heading.textContent = String(title || '');
|
||||
centerSlot.append(heading);
|
||||
}
|
||||
|
||||
const rightSlot = document.createElement('div');
|
||||
rightSlot.className = 'topbar__right';
|
||||
const normalizedActions = actions;
|
||||
normalizedActions.forEach((action) => {
|
||||
rightSlot.append(createActionButton(action, cleanupFns));
|
||||
});
|
||||
|
||||
topbar.append(leftSlot, centerSlot, rightSlot);
|
||||
|
||||
topbar.addCleanup = (cleanup) => {
|
||||
if (typeof cleanup === 'function') cleanupFns.add(cleanup);
|
||||
return cleanup;
|
||||
};
|
||||
topbar.cleanup = () => {
|
||||
for (const cleanup of cleanupFns) {
|
||||
try {
|
||||
cleanup();
|
||||
} catch (error) {
|
||||
console.warn('[TopBar] cleanup failed', error);
|
||||
}
|
||||
}
|
||||
cleanupFns.clear();
|
||||
};
|
||||
|
||||
return topbar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Шапка-строка поиска (поиск по переписке, по связям и т. п.): «назад» закрывает поиск,
|
||||
* крестик очищает поле, Enter – onSubmit, Escape – onClose.
|
||||
* trailing – узел справа внутри поля (например, счётчик «3 из 12»).
|
||||
*/
|
||||
export function createSearchTopBar({
|
||||
placeholder = t('remaining.navigation.search'),
|
||||
value = '',
|
||||
onInput = null,
|
||||
onSubmit = null,
|
||||
onClose = null,
|
||||
trailing = null,
|
||||
actions = [],
|
||||
className = '',
|
||||
} = {}) {
|
||||
const field = document.createElement('label');
|
||||
field.className = 'topbar-search';
|
||||
field.innerHTML = `
|
||||
<span class="topbar-search__icon" aria-hidden="true">${iconHtml('search')}</span>
|
||||
<input class="topbar-search__input" type="search" autocomplete="off" autocapitalize="off" spellcheck="false" enterkeyhint="search" />
|
||||
`;
|
||||
const input = field.querySelector('input');
|
||||
input.placeholder = placeholder;
|
||||
input.setAttribute('aria-label', placeholder);
|
||||
input.value = value;
|
||||
if (trailing instanceof Node) field.append(trailing);
|
||||
const clear = document.createElement('button');
|
||||
clear.type = 'button';
|
||||
clear.className = 'topbar-search__clear';
|
||||
clear.innerHTML = iconHtml('close');
|
||||
clear.setAttribute('aria-label', t('screens.topbar.text_006'));
|
||||
clear.title = t('screens.topbar.text_001');
|
||||
clear.hidden = !value;
|
||||
clear.addEventListener('click', (event) => {
|
||||
event.preventDefault();
|
||||
input.value = '';
|
||||
clear.hidden = true;
|
||||
input.focus();
|
||||
onInput?.('');
|
||||
});
|
||||
field.append(clear);
|
||||
input.addEventListener('input', () => {
|
||||
clear.hidden = !input.value;
|
||||
onInput?.(input.value);
|
||||
});
|
||||
input.addEventListener('keydown', (event) => {
|
||||
if (event.key === 'Enter') {
|
||||
event.preventDefault();
|
||||
onSubmit?.(input.value, event);
|
||||
} else if (event.key === 'Escape') {
|
||||
event.preventDefault();
|
||||
onClose?.();
|
||||
}
|
||||
});
|
||||
const topbar = createTopBar({
|
||||
center: field,
|
||||
className: `topbar--search${className ? ` ${className}` : ''}`,
|
||||
back: { onClick: () => onClose?.(), ariaLabel: t('screens.topbar.text_002'), title: t('screens.topbar.text_003') },
|
||||
actions,
|
||||
});
|
||||
topbar.searchInput = input;
|
||||
return topbar;
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
export const TWEMOJI_GROUP_ACTIVITY = {
|
||||
"id": "activity",
|
||||
get "label"() { return t('screens.twemoji_activity.text_002'); },
|
||||
"icon": "🎉",
|
||||
"items": [
|
||||
{
|
||||
"file": "Activity/1st Place Medal.webp",
|
||||
"emoji": "🥇"
|
||||
},
|
||||
{
|
||||
"file": "Activity/2nd Place Medal.webp",
|
||||
"emoji": "🥈"
|
||||
},
|
||||
{
|
||||
"file": "Activity/3rd Place Medal.webp",
|
||||
"emoji": "🥉"
|
||||
},
|
||||
{
|
||||
"file": "Activity/Admission Tickets.webp",
|
||||
"emoji": "🎟️"
|
||||
},
|
||||
{
|
||||
"file": "Activity/Artist Palette.webp",
|
||||
"emoji": "🎨"
|
||||
},
|
||||
{
|
||||
"file": "Activity/Balloon.webp",
|
||||
"emoji": "🎈"
|
||||
},
|
||||
{
|
||||
"file": "Activity/Basketball.webp",
|
||||
"emoji": "🏀"
|
||||
},
|
||||
{
|
||||
"file": "Activity/Christmas Tree.webp",
|
||||
"emoji": "🎄"
|
||||
},
|
||||
{
|
||||
"file": "Activity/Confetti Ball.webp",
|
||||
"emoji": "🎊"
|
||||
},
|
||||
{
|
||||
"file": "Activity/Crystal Ball.webp",
|
||||
"emoji": "🔮"
|
||||
},
|
||||
{
|
||||
"file": "Activity/Firecracker.webp",
|
||||
"emoji": "🧨"
|
||||
},
|
||||
{
|
||||
"file": "Activity/Fireworks.webp",
|
||||
"emoji": "🎆"
|
||||
},
|
||||
{
|
||||
"file": "Activity/Jack O Lantern.webp",
|
||||
"emoji": "🎃"
|
||||
},
|
||||
{
|
||||
"file": "Activity/Magic Wand.webp",
|
||||
"emoji": "🪄"
|
||||
},
|
||||
{
|
||||
"file": "Activity/Military Medal.webp",
|
||||
"emoji": "🎖️"
|
||||
},
|
||||
{
|
||||
"file": "Activity/Mirror Ball.webp",
|
||||
"emoji": "🪩"
|
||||
},
|
||||
{
|
||||
"file": "Activity/Party Popper.webp",
|
||||
"emoji": "🎉"
|
||||
},
|
||||
{
|
||||
"file": "Activity/Performing Arts.webp",
|
||||
"emoji": "🎭"
|
||||
},
|
||||
{
|
||||
"file": "Activity/Soccer Ball.webp",
|
||||
"emoji": "⚽"
|
||||
},
|
||||
{
|
||||
"file": "Activity/Sparkler.webp",
|
||||
"emoji": "🎇"
|
||||
},
|
||||
{
|
||||
"file": "Activity/Sparkles.webp",
|
||||
"emoji": "✨"
|
||||
},
|
||||
{
|
||||
"file": "Activity/Sports Medal.webp",
|
||||
"emoji": "🏅"
|
||||
},
|
||||
{
|
||||
"file": "Activity/Ticket.webp",
|
||||
"emoji": "🎫"
|
||||
},
|
||||
{
|
||||
"file": "Activity/Trophy.webp",
|
||||
"emoji": "🏆"
|
||||
},
|
||||
{
|
||||
"file": "Activity/Video Game.webp",
|
||||
"emoji": "🎮"
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
@@ -0,0 +1,489 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
export const TWEMOJI_GROUP_ANIMALS_NATURE = {
|
||||
"id": "animals-and-nature",
|
||||
get "label"() { return t('screens.twemoji_animals_nature.text_002'); },
|
||||
"icon": "🌿",
|
||||
"items": [
|
||||
{
|
||||
"file": "Animals and Nature/Ant.webp",
|
||||
"emoji": "🐜"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Baby Chick.webp",
|
||||
"emoji": "🐤"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Bat.webp",
|
||||
"emoji": "🦇"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Bear.webp",
|
||||
"emoji": "🐻"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Beetle.webp",
|
||||
"emoji": "🪲"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Bird.webp",
|
||||
"emoji": "🐦"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Bison.webp",
|
||||
"emoji": "🦬"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Black Cat.webp",
|
||||
"emoji": "🐈⬛"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Blossom.webp",
|
||||
"emoji": "🌼"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Bouquet.webp",
|
||||
"emoji": "💐"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Bug.webp",
|
||||
"emoji": "🐛"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Butterfly.webp",
|
||||
"emoji": "🦋"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Cactus.webp",
|
||||
"emoji": "🌵"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Cat Face.webp",
|
||||
"emoji": "🐱"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Cat.webp",
|
||||
"emoji": "🐈"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Cherry Blossom.webp",
|
||||
"emoji": "🌸"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Chicken.webp",
|
||||
"emoji": "🐔"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Cloud With Lightning And Rain.webp",
|
||||
"emoji": "⛈️"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Cloud With Lightning.webp",
|
||||
"emoji": "🌩️"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Cloud With Rain.webp",
|
||||
"emoji": "🌧️"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Cloud With Snow.webp",
|
||||
"emoji": "🌨️"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Cloud.webp",
|
||||
"emoji": "☁️"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Cockroach.webp",
|
||||
"emoji": "🪳"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Cow.webp",
|
||||
"emoji": "🐄"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Cricket.webp",
|
||||
"emoji": "🦗"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Deciduous Tree.webp",
|
||||
"emoji": "🌳"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Deer.webp",
|
||||
"emoji": "🦌"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Dog Face.webp",
|
||||
"emoji": "🐶"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Dove.webp",
|
||||
"emoji": "🕊️"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Duck.webp",
|
||||
"emoji": "🦆"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Evergreen Tree.webp",
|
||||
"emoji": "🌲"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Fire.webp",
|
||||
"emoji": "🔥"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/First Quarter Moon Face.webp",
|
||||
"emoji": "🌛"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/First Quarter Moon.webp",
|
||||
"emoji": "🌓"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Fish.webp",
|
||||
"emoji": "🐟"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Flamingo.webp",
|
||||
"emoji": "🦩"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Four Leaf Clover.webp",
|
||||
"emoji": "🍀"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Fox.webp",
|
||||
"emoji": "🦊"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Frog.webp",
|
||||
"emoji": "🐸"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Front Facing Baby Chick.webp",
|
||||
"emoji": "🐥"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Full Moon Face.webp",
|
||||
"emoji": "🌝"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Full Moon.webp",
|
||||
"emoji": "🌕"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Giraffe.webp",
|
||||
"emoji": "🦒"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Glowing Star.webp",
|
||||
"emoji": "🌟"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Gorilla.webp",
|
||||
"emoji": "🦍"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Hamster.webp",
|
||||
"emoji": "🐹"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Hatching Chick.webp",
|
||||
"emoji": "🐣"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Hedgehog.webp",
|
||||
"emoji": "🦔"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Herb.webp",
|
||||
"emoji": "🌿"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Hibiscus.webp",
|
||||
"emoji": "🌺"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/High Voltage.webp",
|
||||
"emoji": "⚡"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Honeybee.webp",
|
||||
"emoji": "🐝"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Horse Face.webp",
|
||||
"emoji": "🐴"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Horse.webp",
|
||||
"emoji": "🐎"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Kangaroo.webp",
|
||||
"emoji": "🦘"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Koala.webp",
|
||||
"emoji": "🐨"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Lady Beetle.webp",
|
||||
"emoji": "🐞"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Last Quarter Moon Face.webp",
|
||||
"emoji": "🌜"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Last Quarter Moon.webp",
|
||||
"emoji": "🌗"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Leopard.webp",
|
||||
"emoji": "🐆"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Lion.webp",
|
||||
"emoji": "🦁"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Llama.webp",
|
||||
"emoji": "🦙"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Lobster.webp",
|
||||
"emoji": "🦞"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Microbe.webp",
|
||||
"emoji": "🦠"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Monkey Face.webp",
|
||||
"emoji": "🐵"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Mosquito.webp",
|
||||
"emoji": "🦟"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Mouse Face.webp",
|
||||
"emoji": "🐭"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/New Moon Face.webp",
|
||||
"emoji": "🌚"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/New Moon.webp",
|
||||
"emoji": "🌑"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Octopus.webp",
|
||||
"emoji": "🐙"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Owl.webp",
|
||||
"emoji": "🦉"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Ox.webp",
|
||||
"emoji": "🐂"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Palm Tree.webp",
|
||||
"emoji": "🌴"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Panda.webp",
|
||||
"emoji": "🐼"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Parrot.webp",
|
||||
"emoji": "🦜"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Paw Prints.webp",
|
||||
"emoji": "🐾"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Penguin.webp",
|
||||
"emoji": "🐧"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Pig Face.webp",
|
||||
"emoji": "🐷"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Pig Nose.webp",
|
||||
"emoji": "🐽"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Polar Bear.webp",
|
||||
"emoji": "🐻❄️"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Rabbit Face.webp",
|
||||
"emoji": "🐰"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Rabbit.webp",
|
||||
"emoji": "🐇"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Raccoon.webp",
|
||||
"emoji": "🦝"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Rainbow.webp",
|
||||
"emoji": "🌈"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Rose.webp",
|
||||
"emoji": "🌹"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Rosette.webp",
|
||||
"emoji": "🏵️"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Sauropod.webp",
|
||||
"emoji": "🦕"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Seal.webp",
|
||||
"emoji": "🦭"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Seedling.webp",
|
||||
"emoji": "🌱"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Shamrock.webp",
|
||||
"emoji": "☘️"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Shrimp.webp",
|
||||
"emoji": "🦐"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Snail.webp",
|
||||
"emoji": "🐌"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Snake.webp",
|
||||
"emoji": "🐍"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Snowflake.webp",
|
||||
"emoji": "❄️"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Snowman Without Snow.webp",
|
||||
"emoji": "⛄"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Snowman.webp",
|
||||
"emoji": "☃️"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Spider Web.webp",
|
||||
"emoji": "🕸️"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Spider.webp",
|
||||
"emoji": "🕷️"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Spouting Whale.webp",
|
||||
"emoji": "🐳"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Squid.webp",
|
||||
"emoji": "🦑"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Star.webp",
|
||||
"emoji": "⭐"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Sun Behind Cloud.webp",
|
||||
"emoji": "⛅"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Sun Behind Large Cloud.webp",
|
||||
"emoji": "🌥️"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Sun Behind Rain Cloud.webp",
|
||||
"emoji": "🌦️"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Sun Behind Small Cloud.webp",
|
||||
"emoji": "🌤️"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Sun With Face.webp",
|
||||
"emoji": "🌞"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Sun.webp",
|
||||
"emoji": "☀️"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Swan.webp",
|
||||
"emoji": "🦢"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/T Rex.webp",
|
||||
"emoji": "🦖"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Tiger Face.webp",
|
||||
"emoji": "🐯"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Tiger.webp",
|
||||
"emoji": "🐅"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Tropical Fish.webp",
|
||||
"emoji": "🐠"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Tulip.webp",
|
||||
"emoji": "🌷"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Turkey.webp",
|
||||
"emoji": "🦃"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Turtle.webp",
|
||||
"emoji": "🐢"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Unicorn.webp",
|
||||
"emoji": "🦄"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Waning Crescent Moon.webp",
|
||||
"emoji": "🌘"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Waxing Crescent Moon.webp",
|
||||
"emoji": "🌒"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Waxing Gibbous Moon.webp",
|
||||
"emoji": "🌔"
|
||||
},
|
||||
{
|
||||
"file": "Animals and Nature/Zebra.webp",
|
||||
"emoji": "🦓"
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
import { TWEMOJI_GROUP_ACTIVITY } from './twemoji-activity.js?v=202607151545';
|
||||
import { TWEMOJI_GROUP_ANIMALS_NATURE } from './twemoji-animals_nature.js?v=202607151545';
|
||||
import { TWEMOJI_GROUP_FLAGS } from './twemoji-flags.js?v=202607151545';
|
||||
import { TWEMOJI_GROUP_FOOD_DRINK } from './twemoji-food_drink.js?v=202607151545';
|
||||
import { TWEMOJI_GROUP_OBJECTS } from './twemoji-objects.js?v=202607151545';
|
||||
import { TWEMOJI_GROUP_PEOPLE } from './twemoji-people.js?v=202607151545';
|
||||
import { TWEMOJI_GROUP_SMILEYS } from './twemoji-smileys.js?v=202607151545';
|
||||
import { TWEMOJI_GROUP_SYMBOLS } from './twemoji-symbols.js?v=202607151545';
|
||||
import { TWEMOJI_GROUP_TRAVEL_PLACES } from './twemoji-travel_places.js?v=202607151545';
|
||||
|
||||
const TWEMOJI_SVG_BASE_URL = 'https://cdn.jsdelivr.net/gh/twitter/twemoji@14.0.2/assets/svg/';
|
||||
|
||||
function getTwemojiCodepoint(emoji) {
|
||||
return Array.from(String(emoji || ''))
|
||||
.map((char) => char.codePointAt(0))
|
||||
.filter((codepoint) => codepoint && codepoint !== 0xfe0f)
|
||||
.map((codepoint) => codepoint.toString(16))
|
||||
.join('-');
|
||||
}
|
||||
|
||||
function withPreviewUrls(group) {
|
||||
return {
|
||||
...group,
|
||||
items: group.items.map((item) => ({
|
||||
...item,
|
||||
name: item.name || String(item.emoji || ''),
|
||||
previewUrl: getTwemojiPreviewUrl(item.emoji),
|
||||
animatedUrl: getTwemojiAssetUrl(item.emoji),
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
export const TWEMOJI_GROUPS = [
|
||||
TWEMOJI_GROUP_SMILEYS,
|
||||
TWEMOJI_GROUP_PEOPLE,
|
||||
TWEMOJI_GROUP_ANIMALS_NATURE,
|
||||
TWEMOJI_GROUP_FOOD_DRINK,
|
||||
TWEMOJI_GROUP_TRAVEL_PLACES,
|
||||
TWEMOJI_GROUP_ACTIVITY,
|
||||
TWEMOJI_GROUP_OBJECTS,
|
||||
TWEMOJI_GROUP_SYMBOLS,
|
||||
TWEMOJI_GROUP_FLAGS,
|
||||
].map(withPreviewUrls);
|
||||
|
||||
export function getTwemojiAssetUrl(emoji) {
|
||||
return getTwemojiPreviewUrl(emoji);
|
||||
}
|
||||
|
||||
export function getTwemojiPreviewUrl(emoji) {
|
||||
const codepoint = getTwemojiCodepoint(emoji);
|
||||
return codepoint ? `${TWEMOJI_SVG_BASE_URL}${codepoint}.svg` : '';
|
||||
}
|
||||
@@ -0,0 +1,296 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
export const TWEMOJI_GROUP_FLAGS = {
|
||||
"id": "flags",
|
||||
get "label"() { return t('screens.twemoji_flags.text_002'); },
|
||||
"icon": "🏳️",
|
||||
"items": [
|
||||
{
|
||||
"file": "Flags/Black Flag.webp",
|
||||
"emoji": "🏴"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Chequered Flag.webp",
|
||||
"emoji": "🏁"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Argentina.webp",
|
||||
"emoji": "🇦🇷"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Armenia.webp",
|
||||
"emoji": "🇦🇲"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Austria.webp",
|
||||
"emoji": "🇦🇹"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Bahamas.webp",
|
||||
"emoji": "🇧🇸"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Belarus.webp",
|
||||
"emoji": "🇧🇾"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Belgium.webp",
|
||||
"emoji": "🇧🇪"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Benin.webp",
|
||||
"emoji": "🇧🇯"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Brazil.webp",
|
||||
"emoji": "🇧🇷"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Bulgaria.webp",
|
||||
"emoji": "🇧🇬"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Burkina Faso.webp",
|
||||
"emoji": "🇧🇫"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Cameroon.webp",
|
||||
"emoji": "🇨🇲"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Chad.webp",
|
||||
"emoji": "🇹🇩"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag China.webp",
|
||||
"emoji": "🇨🇳"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Cote Divoire.webp",
|
||||
"emoji": "🇨🇮"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Croatia.webp",
|
||||
"emoji": "🇭🇷"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Czechia.webp",
|
||||
"emoji": "🇨🇿"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Djibouti.webp",
|
||||
"emoji": "🇩🇯"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Equatorial Guinea.webp",
|
||||
"emoji": "🇬🇶"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Estonia.webp",
|
||||
"emoji": "🇪🇪"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag France.webp",
|
||||
"emoji": "🇫🇷"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Gabon.webp",
|
||||
"emoji": "🇬🇦"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Germany.webp",
|
||||
"emoji": "🇩🇪"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Ghana.webp",
|
||||
"emoji": "🇬🇭"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Guinea Bissau.webp",
|
||||
"emoji": "🇬🇼"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Guinea.webp",
|
||||
"emoji": "🇬🇳"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Hungary.webp",
|
||||
"emoji": "🇭🇺"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag India.webp",
|
||||
"emoji": "🇮🇳"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Indonesia.webp",
|
||||
"emoji": "🇮🇩"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Ireland.webp",
|
||||
"emoji": "🇮🇪"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Italy.webp",
|
||||
"emoji": "🇮🇹"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Japan.webp",
|
||||
"emoji": "🇯🇵"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Jordan.webp",
|
||||
"emoji": "🇯🇴"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Lithuania.webp",
|
||||
"emoji": "🇱🇹"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Luxembourg.webp",
|
||||
"emoji": "🇱🇺"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Madagascar.webp",
|
||||
"emoji": "🇲🇬"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Mali.webp",
|
||||
"emoji": "🇲🇱"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Monaco.webp",
|
||||
"emoji": "🇲🇨"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Morocco.webp",
|
||||
"emoji": "🇲🇦"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Mozambique.webp",
|
||||
"emoji": "🇲🇿"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Myanmar Burma.webp",
|
||||
"emoji": "🇲🇲"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Netherlands.webp",
|
||||
"emoji": "🇳🇱"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Nigeria.webp",
|
||||
"emoji": "🇳🇬"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Palestinian Territories.webp",
|
||||
"emoji": "🇵🇸"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Peru.webp",
|
||||
"emoji": "🇵🇪"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Philippines.webp",
|
||||
"emoji": "🇵🇭"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Poland.webp",
|
||||
"emoji": "🇵🇱"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Romania.webp",
|
||||
"emoji": "🇷🇴"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Russia.webp",
|
||||
"emoji": "🇷🇺"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Sao Tome Principe.webp",
|
||||
"emoji": "🇸🇹"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Saudi Arabia.webp",
|
||||
"emoji": "🇸🇦"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Senegal.webp",
|
||||
"emoji": "🇸🇳"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Sierra Leone.webp",
|
||||
"emoji": "🇸🇱"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Singapore.webp",
|
||||
"emoji": "🇸🇬"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Sint Maarten.webp",
|
||||
"emoji": "🇸🇽"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Somalia.webp",
|
||||
"emoji": "🇸🇴"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag South Korea.webp",
|
||||
"emoji": "🇰🇷"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag South Sudan.webp",
|
||||
"emoji": "🇸🇸"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Spain.webp",
|
||||
"emoji": "🇪🇸"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Sudan.webp",
|
||||
"emoji": "🇸🇩"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Ukraine.webp",
|
||||
"emoji": "🇺🇦"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag United Arab Emirates.webp",
|
||||
"emoji": "🇦🇪"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag United Kingdom.webp",
|
||||
"emoji": "🇬🇧"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag United States.webp",
|
||||
"emoji": "🇺🇸"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Uzbekistan.webp",
|
||||
"emoji": "🇺🇿"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Vietnam.webp",
|
||||
"emoji": "🇻🇳"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Western Sahara.webp",
|
||||
"emoji": "🇪🇭"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Flag Yemen.webp",
|
||||
"emoji": "🇾🇪"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Pirate Flag.webp",
|
||||
"emoji": "🏴☠️"
|
||||
},
|
||||
{
|
||||
"file": "Flags/Triangular Flag.webp",
|
||||
"emoji": "🚩"
|
||||
},
|
||||
{
|
||||
"file": "Flags/White Flag.webp",
|
||||
"emoji": "🏳️"
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -0,0 +1,201 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
export const TWEMOJI_GROUP_FOOD_DRINK = {
|
||||
"id": "food-and-drink",
|
||||
get "label"() { return t('screens.twemoji_food_drink.text_002'); },
|
||||
"icon": "🍓",
|
||||
"items": [
|
||||
{
|
||||
"file": "Food and Drink/Baby Bottle.webp",
|
||||
"emoji": "🍼"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Banana.webp",
|
||||
"emoji": "🍌"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Bento Box.webp",
|
||||
"emoji": "🍱"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Beverage Box.webp",
|
||||
"emoji": "🧃"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Birthday Cake.webp",
|
||||
"emoji": "🎂"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Bottle With Popping Cork.webp",
|
||||
"emoji": "🍾"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Bubble Tea.webp",
|
||||
"emoji": "🧋"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Canned Food.webp",
|
||||
"emoji": "🥫"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Chocolate Bar.webp",
|
||||
"emoji": "🍫"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Clinking Glasses.webp",
|
||||
"emoji": "🥂"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Cocktail Glass.webp",
|
||||
"emoji": "🍸"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Cookie.webp",
|
||||
"emoji": "🍪"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Cooking.webp",
|
||||
"emoji": "🍳"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Cup With Straw.webp",
|
||||
"emoji": "🥤"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Cupcake.webp",
|
||||
"emoji": "🧁"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Custard.webp",
|
||||
"emoji": "🍮"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Dango.webp",
|
||||
"emoji": "🍡"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Doughnut.webp",
|
||||
"emoji": "🍩"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Fish Cake With Swirl.webp",
|
||||
"emoji": "🍥"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Fork And Knife With Plate.webp",
|
||||
"emoji": "🍽️"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/French Fries.webp",
|
||||
"emoji": "🍟"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Glass Of Milk.webp",
|
||||
"emoji": "🥛"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Hamburger.webp",
|
||||
"emoji": "🍔"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Hot Beverage.webp",
|
||||
"emoji": "☕"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Hot Dog.webp",
|
||||
"emoji": "🌭"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Lollipop.webp",
|
||||
"emoji": "🍭"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Mate.webp",
|
||||
"emoji": "🧉"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Meat On Bone.webp",
|
||||
"emoji": "🍖"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Oden.webp",
|
||||
"emoji": "🍢"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Pancakes.webp",
|
||||
"emoji": "🥞"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Pie.webp",
|
||||
"emoji": "🥧"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Pizza.webp",
|
||||
"emoji": "🍕"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Popcorn.webp",
|
||||
"emoji": "🍿"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Poultry Leg.webp",
|
||||
"emoji": "🍗"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Pouring Liquid.webp",
|
||||
"emoji": "🫗"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Pretzel.webp",
|
||||
"emoji": "🥨"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Rice Ball.webp",
|
||||
"emoji": "🍙"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Rice Cracker.webp",
|
||||
"emoji": "🍘"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Sandwich.webp",
|
||||
"emoji": "🥪"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Shortcake.webp",
|
||||
"emoji": "🍰"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Soft Ice Cream.webp",
|
||||
"emoji": "🍦"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Strawberry.webp",
|
||||
"emoji": "🍓"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Stuffed Flatbread.webp",
|
||||
"emoji": "🥙"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Sushi.webp",
|
||||
"emoji": "🍣"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Taco.webp",
|
||||
"emoji": "🌮"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Tropical Drink.webp",
|
||||
"emoji": "🍹"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Tumbler Glass.webp",
|
||||
"emoji": "🥃"
|
||||
},
|
||||
{
|
||||
"file": "Food and Drink/Wine Glass.webp",
|
||||
"emoji": "🍷"
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
@@ -0,0 +1,281 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
export const TWEMOJI_GROUP_OBJECTS = {
|
||||
"id": "objects",
|
||||
get "label"() { return t('screens.twemoji_objects.text_002'); },
|
||||
"icon": "💡",
|
||||
"items": [
|
||||
{
|
||||
"file": "Objects/Abacus.webp",
|
||||
"emoji": "🧮"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Ballot Box With Ballot.webp",
|
||||
"emoji": "🗳️"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Bar Chart.webp",
|
||||
"emoji": "📊"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Bomb.webp",
|
||||
"emoji": "💣"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Books.webp",
|
||||
"emoji": "📚"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Briefcase.webp",
|
||||
"emoji": "💼"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Card Index Dividers.webp",
|
||||
"emoji": "🗂️"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Chart Decreasing.webp",
|
||||
"emoji": "📉"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Chart Increasing.webp",
|
||||
"emoji": "📈"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Clapper Board.webp",
|
||||
"emoji": "🎬"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Coffin.webp",
|
||||
"emoji": "⚰️"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Coin.webp",
|
||||
"emoji": "🪙"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Crown.webp",
|
||||
"emoji": "👑"
|
||||
},
|
||||
{
|
||||
"file": "Objects/File Folder.webp",
|
||||
"emoji": "📁"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Gem Stone.webp",
|
||||
"emoji": "💎"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Graduation Cap.webp",
|
||||
"emoji": "🎓"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Handbag.webp",
|
||||
"emoji": "👜"
|
||||
},
|
||||
{
|
||||
"file": "Objects/High Heeled Shoe.webp",
|
||||
"emoji": "👠"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Hourglass Done.webp",
|
||||
"emoji": "⌛"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Hourglass Not Done.webp",
|
||||
"emoji": "⏳"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Identification Card.webp",
|
||||
"emoji": "🪪"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Inbox Tray.webp",
|
||||
"emoji": "📥"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Incoming Envelope.webp",
|
||||
"emoji": "📨"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Key.webp",
|
||||
"emoji": "🔑"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Keyboard.webp",
|
||||
"emoji": "⌨️"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Laptop.webp",
|
||||
"emoji": "💻"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Light Bulb.webp",
|
||||
"emoji": "💡"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Locked With Key.webp",
|
||||
"emoji": "🔐"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Luggage.webp",
|
||||
"emoji": "🧳"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Magnifying Glass Tilted Left.webp",
|
||||
"emoji": "🔍"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Magnifying Glass Tilted Right.webp",
|
||||
"emoji": "🔎"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Megaphone.webp",
|
||||
"emoji": "📣"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Memo.webp",
|
||||
"emoji": "📝"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Microphone.webp",
|
||||
"emoji": "🎤"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Microscope.webp",
|
||||
"emoji": "🔬"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Military Helmet.webp",
|
||||
"emoji": "🪖"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Mobile Phone With Arrow.webp",
|
||||
"emoji": "📲"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Mobile Phone.webp",
|
||||
"emoji": "📱"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Money Bag.webp",
|
||||
"emoji": "💰"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Money With Wings.webp",
|
||||
"emoji": "💸"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Musical Note.webp",
|
||||
"emoji": "🎵"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Musical Notes.webp",
|
||||
"emoji": "🎶"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Newspaper.webp",
|
||||
"emoji": "📰"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Old Key.webp",
|
||||
"emoji": "🗝️"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Open Book.webp",
|
||||
"emoji": "📖"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Outbox Tray.webp",
|
||||
"emoji": "📤"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Pencil.webp",
|
||||
"emoji": "✏️"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Pill.webp",
|
||||
"emoji": "💊"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Printer.webp",
|
||||
"emoji": "🖨️"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Purse.webp",
|
||||
"emoji": "👛"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Reminder Ribbon.webp",
|
||||
"emoji": "🎗️"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Roll Of Paper.webp",
|
||||
"emoji": "🧻"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Shopping Bags.webp",
|
||||
"emoji": "🛍️"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Shopping Cart.webp",
|
||||
"emoji": "🛒"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Soap.webp",
|
||||
"emoji": "🧼"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Sponge.webp",
|
||||
"emoji": "🧽"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Stethoscope.webp",
|
||||
"emoji": "🩺"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Studio Microphone.webp",
|
||||
"emoji": "🎙️"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Syringe.webp",
|
||||
"emoji": "💉"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Tear Off Calendar.webp",
|
||||
"emoji": "📆"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Telephone Receiver.webp",
|
||||
"emoji": "📞"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Telephone.webp",
|
||||
"emoji": "☎️"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Telescope.webp",
|
||||
"emoji": "🔭"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Television.webp",
|
||||
"emoji": "📺"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Test Tube.webp",
|
||||
"emoji": "🧪"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Thermometer.webp",
|
||||
"emoji": "🌡️"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Toolbox.webp",
|
||||
"emoji": "🧰"
|
||||
},
|
||||
{
|
||||
"file": "Objects/Top Hat.webp",
|
||||
"emoji": "🎩"
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
@@ -0,0 +1,361 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
export const TWEMOJI_GROUP_PEOPLE = {
|
||||
"id": "people",
|
||||
get "label"() { return t('screens.twemoji_people.text_002'); },
|
||||
"icon": "🧑",
|
||||
"items": [
|
||||
{
|
||||
"file": "People/Baby.webp",
|
||||
"emoji": "👶"
|
||||
},
|
||||
{
|
||||
"file": "People/Backhand Index Pointing Down.webp",
|
||||
"emoji": "👇"
|
||||
},
|
||||
{
|
||||
"file": "People/Backhand Index Pointing Left.webp",
|
||||
"emoji": "👈"
|
||||
},
|
||||
{
|
||||
"file": "People/Backhand Index Pointing Right.webp",
|
||||
"emoji": "👉"
|
||||
},
|
||||
{
|
||||
"file": "People/Backhand Index Pointing Up.webp",
|
||||
"emoji": "👆"
|
||||
},
|
||||
{
|
||||
"file": "People/Biting Lip.webp",
|
||||
"emoji": "🫦"
|
||||
},
|
||||
{
|
||||
"file": "People/Bone.webp",
|
||||
"emoji": "🦴"
|
||||
},
|
||||
{
|
||||
"file": "People/Bust In Silhouette.webp",
|
||||
"emoji": "👤"
|
||||
},
|
||||
{
|
||||
"file": "People/Busts In Silhouette.webp",
|
||||
"emoji": "👥"
|
||||
},
|
||||
{
|
||||
"file": "People/Call Me Hand.webp",
|
||||
"emoji": "🤙"
|
||||
},
|
||||
{
|
||||
"file": "People/Clapping Hands.webp",
|
||||
"emoji": "👏"
|
||||
},
|
||||
{
|
||||
"file": "People/Crossed Fingers.webp",
|
||||
"emoji": "🤞"
|
||||
},
|
||||
{
|
||||
"file": "People/Ear With Hearing Aid.webp",
|
||||
"emoji": "🦻"
|
||||
},
|
||||
{
|
||||
"file": "People/Ear.webp",
|
||||
"emoji": "👂"
|
||||
},
|
||||
{
|
||||
"file": "People/Eyes.webp",
|
||||
"emoji": "👀"
|
||||
},
|
||||
{
|
||||
"file": "People/Family Man Woman Girl Boy.webp",
|
||||
"emoji": "👨👩👧👦"
|
||||
},
|
||||
{
|
||||
"file": "People/Flexed Biceps.webp",
|
||||
"emoji": "💪"
|
||||
},
|
||||
{
|
||||
"file": "People/Folded Hands.webp",
|
||||
"emoji": "🙏"
|
||||
},
|
||||
{
|
||||
"file": "People/Foot.webp",
|
||||
"emoji": "🦶"
|
||||
},
|
||||
{
|
||||
"file": "People/Footprints.webp",
|
||||
"emoji": "👣"
|
||||
},
|
||||
{
|
||||
"file": "People/Hand With Fingers Splayed.webp",
|
||||
"emoji": "🖐️"
|
||||
},
|
||||
{
|
||||
"file": "People/Hand With Index Finger And Thumb Crossed.webp",
|
||||
"emoji": "🫰"
|
||||
},
|
||||
{
|
||||
"file": "People/Handshake.webp",
|
||||
"emoji": "🤝"
|
||||
},
|
||||
{
|
||||
"file": "People/Heart Hands.webp",
|
||||
"emoji": "🫶"
|
||||
},
|
||||
{
|
||||
"file": "People/Index Pointing At The Viewer.webp",
|
||||
"emoji": "🫵"
|
||||
},
|
||||
{
|
||||
"file": "People/Index Pointing Up.webp",
|
||||
"emoji": "☝️"
|
||||
},
|
||||
{
|
||||
"file": "People/Left Facing Fist.webp",
|
||||
"emoji": "🤛"
|
||||
},
|
||||
{
|
||||
"file": "People/Leftwards Hand.webp",
|
||||
"emoji": "🫲"
|
||||
},
|
||||
{
|
||||
"file": "People/Leg.webp",
|
||||
"emoji": "🦵"
|
||||
},
|
||||
{
|
||||
"file": "People/Love You Gesture.webp",
|
||||
"emoji": "🤟"
|
||||
},
|
||||
{
|
||||
"file": "People/Man Dancing.webp",
|
||||
"emoji": "🕺"
|
||||
},
|
||||
{
|
||||
"file": "People/Man Facepalming.webp",
|
||||
"emoji": "🤦♂️"
|
||||
},
|
||||
{
|
||||
"file": "People/Man Health Worker.webp",
|
||||
"emoji": "👨⚕️"
|
||||
},
|
||||
{
|
||||
"file": "People/Man Police Officer.webp",
|
||||
"emoji": "👮♂️"
|
||||
},
|
||||
{
|
||||
"file": "People/Man Shrugging.webp",
|
||||
"emoji": "🤷♂️"
|
||||
},
|
||||
{
|
||||
"file": "People/Man Teacher.webp",
|
||||
"emoji": "👨🏫"
|
||||
},
|
||||
{
|
||||
"file": "People/Man Technologist.webp",
|
||||
"emoji": "👨💻"
|
||||
},
|
||||
{
|
||||
"file": "People/Man Vampire.webp",
|
||||
"emoji": "🧛♂️"
|
||||
},
|
||||
{
|
||||
"file": "People/Man Zombie.webp",
|
||||
"emoji": "🧟♂️"
|
||||
},
|
||||
{
|
||||
"file": "People/Mechanical Arm.webp",
|
||||
"emoji": "🦾"
|
||||
},
|
||||
{
|
||||
"file": "People/Mechanical Leg.webp",
|
||||
"emoji": "🦿"
|
||||
},
|
||||
{
|
||||
"file": "People/Middle Finger.webp",
|
||||
"emoji": "🖕"
|
||||
},
|
||||
{
|
||||
"file": "People/Mouth.webp",
|
||||
"emoji": "👄"
|
||||
},
|
||||
{
|
||||
"file": "People/Mrs Claus.webp",
|
||||
"emoji": "🤶"
|
||||
},
|
||||
{
|
||||
"file": "People/Mx Claus.webp",
|
||||
"emoji": "🧑🎄"
|
||||
},
|
||||
{
|
||||
"file": "People/Nail Polish.webp",
|
||||
"emoji": "💅"
|
||||
},
|
||||
{
|
||||
"file": "People/Nose.webp",
|
||||
"emoji": "👃"
|
||||
},
|
||||
{
|
||||
"file": "People/Ok Hand.webp",
|
||||
"emoji": "👌"
|
||||
},
|
||||
{
|
||||
"file": "People/Old Woman.webp",
|
||||
"emoji": "👵"
|
||||
},
|
||||
{
|
||||
"file": "People/Oncoming Fist.webp",
|
||||
"emoji": "👊"
|
||||
},
|
||||
{
|
||||
"file": "People/Open Hands.webp",
|
||||
"emoji": "👐"
|
||||
},
|
||||
{
|
||||
"file": "People/Palm Down Hand.webp",
|
||||
"emoji": "🫳"
|
||||
},
|
||||
{
|
||||
"file": "People/Palm Up Hand.webp",
|
||||
"emoji": "🫴"
|
||||
},
|
||||
{
|
||||
"file": "People/Palms Up Together.webp",
|
||||
"emoji": "🤲"
|
||||
},
|
||||
{
|
||||
"file": "People/People Hugging.webp",
|
||||
"emoji": "🫂"
|
||||
},
|
||||
{
|
||||
"file": "People/Person Facepalming.webp",
|
||||
"emoji": "🤦"
|
||||
},
|
||||
{
|
||||
"file": "People/Person Shrugging.webp",
|
||||
"emoji": "🤷"
|
||||
},
|
||||
{
|
||||
"file": "People/Pinched Fingers.webp",
|
||||
"emoji": "🤌"
|
||||
},
|
||||
{
|
||||
"file": "People/Pinching Hand.webp",
|
||||
"emoji": "🤏"
|
||||
},
|
||||
{
|
||||
"file": "People/Pregnant Woman.webp",
|
||||
"emoji": "🤰"
|
||||
},
|
||||
{
|
||||
"file": "People/Raised Back Of Hand.webp",
|
||||
"emoji": "🤚"
|
||||
},
|
||||
{
|
||||
"file": "People/Raised Fist.webp",
|
||||
"emoji": "✊"
|
||||
},
|
||||
{
|
||||
"file": "People/Raised Hand.webp",
|
||||
"emoji": "✋"
|
||||
},
|
||||
{
|
||||
"file": "People/Raising Hands.webp",
|
||||
"emoji": "🙌"
|
||||
},
|
||||
{
|
||||
"file": "People/Right Facing Fist.webp",
|
||||
"emoji": "🤜"
|
||||
},
|
||||
{
|
||||
"file": "People/Rightwards Hand.webp",
|
||||
"emoji": "🫱"
|
||||
},
|
||||
{
|
||||
"file": "People/Santa Claus.webp",
|
||||
"emoji": "🎅"
|
||||
},
|
||||
{
|
||||
"file": "People/Sign Of The Horns.webp",
|
||||
"emoji": "🤘"
|
||||
},
|
||||
{
|
||||
"file": "People/Speaking Head.webp",
|
||||
"emoji": "🗣️"
|
||||
},
|
||||
{
|
||||
"file": "People/Technologist.webp",
|
||||
"emoji": "🧑💻"
|
||||
},
|
||||
{
|
||||
"file": "People/Thumbs Down.webp",
|
||||
"emoji": "👎"
|
||||
},
|
||||
{
|
||||
"file": "People/Thumbs Up.webp",
|
||||
"emoji": "👍"
|
||||
},
|
||||
{
|
||||
"file": "People/Tongue.webp",
|
||||
"emoji": "👅"
|
||||
},
|
||||
{
|
||||
"file": "People/Tooth.webp",
|
||||
"emoji": "🦷"
|
||||
},
|
||||
{
|
||||
"file": "People/Vampire.webp",
|
||||
"emoji": "🧛"
|
||||
},
|
||||
{
|
||||
"file": "People/Victory Hand.webp",
|
||||
"emoji": "✌️"
|
||||
},
|
||||
{
|
||||
"file": "People/Vulcan Salute.webp",
|
||||
"emoji": "🖖"
|
||||
},
|
||||
{
|
||||
"file": "People/Waving Hand.webp",
|
||||
"emoji": "👋"
|
||||
},
|
||||
{
|
||||
"file": "People/Woman Dancing.webp",
|
||||
"emoji": "💃"
|
||||
},
|
||||
{
|
||||
"file": "People/Woman Facepalming.webp",
|
||||
"emoji": "🤦♀️"
|
||||
},
|
||||
{
|
||||
"file": "People/Woman Health Worker.webp",
|
||||
"emoji": "👩⚕️"
|
||||
},
|
||||
{
|
||||
"file": "People/Woman Police Officer.webp",
|
||||
"emoji": "👮♀️"
|
||||
},
|
||||
{
|
||||
"file": "People/Woman Shrugging.webp",
|
||||
"emoji": "🤷♀️"
|
||||
},
|
||||
{
|
||||
"file": "People/Woman Technologist.webp",
|
||||
"emoji": "👩💻"
|
||||
},
|
||||
{
|
||||
"file": "People/Woman Vampire.webp",
|
||||
"emoji": "🧛♀️"
|
||||
},
|
||||
{
|
||||
"file": "People/Woman Zombie.webp",
|
||||
"emoji": "🧟♀️"
|
||||
},
|
||||
{
|
||||
"file": "People/Writing Hand.webp",
|
||||
"emoji": "✍️"
|
||||
},
|
||||
{
|
||||
"file": "People/Zombie.webp",
|
||||
"emoji": "🧟"
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
@@ -0,0 +1,504 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
export const TWEMOJI_GROUP_SMILEYS = {
|
||||
"id": "smileys",
|
||||
get "label"() { return t('screens.twemoji_smileys.text_001'); },
|
||||
"icon": "🙂",
|
||||
"items": [
|
||||
{
|
||||
"file": "Smileys/Alien Monster.webp",
|
||||
"emoji": "👾"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Alien.webp",
|
||||
"emoji": "👽"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Angry Face With Horns.webp",
|
||||
"emoji": "👿"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Angry Face.webp",
|
||||
"emoji": "😠"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Anguished Face.webp",
|
||||
"emoji": "😧"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Anxious Face With Sweat.webp",
|
||||
"emoji": "😰"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Astonished Face.webp",
|
||||
"emoji": "😲"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Beaming Face With Smiling Eyes.webp",
|
||||
"emoji": "😁"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Cat With Tears Of Joy.webp",
|
||||
"emoji": "😹"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Cat With Wry Smile.webp",
|
||||
"emoji": "😼"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Clown Face.webp",
|
||||
"emoji": "🤡"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Cold Face.webp",
|
||||
"emoji": "🥶"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Confounded Face.webp",
|
||||
"emoji": "😖"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Confused Face.webp",
|
||||
"emoji": "😕"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Cowboy Hat Face.webp",
|
||||
"emoji": "🤠"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Crying Cat.webp",
|
||||
"emoji": "😿"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Crying Face.webp",
|
||||
"emoji": "😢"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Disappointed Face.webp",
|
||||
"emoji": "😞"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Disguised Face.webp",
|
||||
"emoji": "🥸"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Dizzy Face.webp",
|
||||
"emoji": "😵"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Dotted Line Face.webp",
|
||||
"emoji": "🫥"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Downcast Face With Sweat.webp",
|
||||
"emoji": "😓"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Drooling Face.webp",
|
||||
"emoji": "🤤"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Exploding Head.webp",
|
||||
"emoji": "🤯"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Expressionless Face.webp",
|
||||
"emoji": "😑"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Face Blowing A Kiss.webp",
|
||||
"emoji": "😘"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Face Exhaling.webp",
|
||||
"emoji": "😮💨"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Face Holding Back Tears.webp",
|
||||
"emoji": "🥹"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Face In Clouds.webp",
|
||||
"emoji": "😶🌫️"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Face Savoring Food.webp",
|
||||
"emoji": "😋"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Face Screaming In Fear.webp",
|
||||
"emoji": "😱"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Face Vomiting.webp",
|
||||
"emoji": "🤮"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Face With Diagonal Mouth.webp",
|
||||
"emoji": "🫤"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Face With Hand Over Mouth.webp",
|
||||
"emoji": "🤭"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Face With Head Bandage.webp",
|
||||
"emoji": "🤕"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Face With Medical Mask.webp",
|
||||
"emoji": "😷"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Face With Monocle.webp",
|
||||
"emoji": "🧐"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Face With Open Eyes And Hand Over Mouth.webp",
|
||||
"emoji": "🫢"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Face With Open Mouth.webp",
|
||||
"emoji": "😮"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Face With Peeking Eye.webp",
|
||||
"emoji": "🫣"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Face With Raised Eyebrow.webp",
|
||||
"emoji": "🤨"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Face With Rolling Eyes.webp",
|
||||
"emoji": "🙄"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Face With Spiral Eyes.webp",
|
||||
"emoji": "😵💫"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Face With Steam From Nose.webp",
|
||||
"emoji": "😤"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Face With Symbols On Mouth.webp",
|
||||
"emoji": "🤬"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Face With Tears Of Joy.webp",
|
||||
"emoji": "😂"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Face With Thermometer.webp",
|
||||
"emoji": "🤒"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Face With Tongue.webp",
|
||||
"emoji": "😛"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Face Without Mouth.webp",
|
||||
"emoji": "😶"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Fearful Face.webp",
|
||||
"emoji": "😨"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Flushed Face.webp",
|
||||
"emoji": "😳"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Frowning Face With Open Mouth.webp",
|
||||
"emoji": "😦"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Frowning Face.webp",
|
||||
"emoji": "☹️"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Ghost.webp",
|
||||
"emoji": "👻"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Goblin.webp",
|
||||
"emoji": "👺"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Grimacing Face.webp",
|
||||
"emoji": "😬"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Grinning Cat With Smiling Eyes.webp",
|
||||
"emoji": "😸"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Grinning Cat.webp",
|
||||
"emoji": "😺"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Grinning Face With Big Eyes.webp",
|
||||
"emoji": "😃"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Grinning Face With Smiling Eyes.webp",
|
||||
"emoji": "😄"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Grinning Face With Sweat.webp",
|
||||
"emoji": "😅"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Grinning Face.webp",
|
||||
"emoji": "😀"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Grinning Squinting Face.webp",
|
||||
"emoji": "😆"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Hear No Evil Monkey.webp",
|
||||
"emoji": "🙉"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Hot Face.webp",
|
||||
"emoji": "🥵"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Hugging Face.webp",
|
||||
"emoji": "🤗"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Hushed Face.webp",
|
||||
"emoji": "😯"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Kissing Cat.webp",
|
||||
"emoji": "😽"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Kissing Face With Closed Eyes.webp",
|
||||
"emoji": "😚"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Kissing Face.webp",
|
||||
"emoji": "😗"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Loudly Crying Face.webp",
|
||||
"emoji": "😭"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Lying Face.webp",
|
||||
"emoji": "🤥"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Melting Face.webp",
|
||||
"emoji": "🫠"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Money Mouth Face.webp",
|
||||
"emoji": "🤑"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Nauseated Face.webp",
|
||||
"emoji": "🤢"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Nerd Face.webp",
|
||||
"emoji": "🤓"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Neutral Face.webp",
|
||||
"emoji": "😐"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Ogre.webp",
|
||||
"emoji": "👹"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Partying Face.webp",
|
||||
"emoji": "🥳"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Pensive Face.webp",
|
||||
"emoji": "😔"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Persevering Face.webp",
|
||||
"emoji": "😣"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Pile Of Poo.webp",
|
||||
"emoji": "💩"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Pleading Face.webp",
|
||||
"emoji": "🥺"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Pouting Cat.webp",
|
||||
"emoji": "😾"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Pouting Face.webp",
|
||||
"emoji": "😡"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Relieved Face.webp",
|
||||
"emoji": "😌"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Robot.webp",
|
||||
"emoji": "🤖"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Rolling On The Floor Laughing.webp",
|
||||
"emoji": "🤣"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Sad But Relieved Face.webp",
|
||||
"emoji": "😥"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Saluting Face.webp",
|
||||
"emoji": "🫡"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/See No Evil Monkey.webp",
|
||||
"emoji": "🙈"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Shushing Face.webp",
|
||||
"emoji": "🤫"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Skull And Crossbones.webp",
|
||||
"emoji": "☠️"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Skull.webp",
|
||||
"emoji": "💀"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Sleeping Face.webp",
|
||||
"emoji": "😴"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Sleepy Face.webp",
|
||||
"emoji": "😪"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Slightly Frowning Face.webp",
|
||||
"emoji": "🙁"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Slightly Smiling Face.webp",
|
||||
"emoji": "🙂"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Smiling Cat With Heart Eyes.webp",
|
||||
"emoji": "😻"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Smiling Face With Halo.webp",
|
||||
"emoji": "😇"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Smiling Face With Hearts.webp",
|
||||
"emoji": "🥰"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Smiling Face With Horns.webp",
|
||||
"emoji": "😈"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Smiling Face With Smiling Eyes.webp",
|
||||
"emoji": "😊"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Smiling Face With Sunglasses.webp",
|
||||
"emoji": "😎"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Smiling Face With Tear.webp",
|
||||
"emoji": "🥲"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Smiling Face.webp",
|
||||
"emoji": "☺️"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Smirking Face.webp",
|
||||
"emoji": "😏"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Sneezing Face.webp",
|
||||
"emoji": "🤧"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Speak No Evil Monkey.webp",
|
||||
"emoji": "🙊"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Squinting Face With Tongue.webp",
|
||||
"emoji": "😝"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Star Struck.webp",
|
||||
"emoji": "🤩"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Thinking Face.webp",
|
||||
"emoji": "🤔"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Tired Face.webp",
|
||||
"emoji": "😫"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Unamused Face.webp",
|
||||
"emoji": "😒"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Upside Down Face.webp",
|
||||
"emoji": "🙃"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Weary Cat.webp",
|
||||
"emoji": "🙀"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Weary Face.webp",
|
||||
"emoji": "😩"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Winking Face With Tongue.webp",
|
||||
"emoji": "😜"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Winking Face.webp",
|
||||
"emoji": "😉"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Woozy Face.webp",
|
||||
"emoji": "🥴"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Worried Face.webp",
|
||||
"emoji": "😟"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Yawning Face.webp",
|
||||
"emoji": "🥱"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Zany Face.webp",
|
||||
"emoji": "🤪"
|
||||
},
|
||||
{
|
||||
"file": "Smileys/Zipper Mouth Face.webp",
|
||||
"emoji": "🤐"
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -0,0 +1,284 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
export const TWEMOJI_GROUP_SYMBOLS = {
|
||||
"id": "symbols",
|
||||
get "label"() { return t('screens.twemoji_symbols.text_002'); },
|
||||
"icon": "❤️",
|
||||
"items": [
|
||||
{
|
||||
"file": "Symbols/Anger Symbol.webp",
|
||||
"emoji": "💢"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Aquarius.webp",
|
||||
"emoji": "♒"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Aries.webp",
|
||||
"emoji": "♈"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Baby Symbol.webp",
|
||||
"emoji": "🚼"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Baggage Claim.webp",
|
||||
"emoji": "🛄"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Beating Heart.webp",
|
||||
"emoji": "💓"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Black Heart.webp",
|
||||
"emoji": "🖤"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Blue Heart.webp",
|
||||
"emoji": "💙"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Broken Heart.webp",
|
||||
"emoji": "💔"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Brown Heart.webp",
|
||||
"emoji": "🤎"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Cancer.webp",
|
||||
"emoji": "♋"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Capricorn.webp",
|
||||
"emoji": "♑"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Check Box With Check.webp",
|
||||
"emoji": "☑️"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Check Mark Button.webp",
|
||||
"emoji": "✅"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Check Mark.webp",
|
||||
"emoji": "✔️"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Collision.webp",
|
||||
"emoji": "💥"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Cool Button.webp",
|
||||
"emoji": "🆒"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Cross Mark.webp",
|
||||
"emoji": "❌"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Currency Exchange.webp",
|
||||
"emoji": "💱"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Customs.webp",
|
||||
"emoji": "🛃"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Dizzy.webp",
|
||||
"emoji": "💫"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Double Exclamation Mark.webp",
|
||||
"emoji": "‼️"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Exclamation Mark.webp",
|
||||
"emoji": "❗"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Exclamation Question Mark.webp",
|
||||
"emoji": "⁉️"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Free Button.webp",
|
||||
"emoji": "🆓"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Gemini.webp",
|
||||
"emoji": "♊"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Green Heart.webp",
|
||||
"emoji": "💚"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Growing Heart.webp",
|
||||
"emoji": "💗"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Heart Decoration.webp",
|
||||
"emoji": "💟"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Heart Exclamation.webp",
|
||||
"emoji": "❣️"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Heart On Fire.webp",
|
||||
"emoji": "❤️🔥"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Heart With Arrow.webp",
|
||||
"emoji": "💘"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Heart With Ribbon.webp",
|
||||
"emoji": "💝"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Hundred Points.webp",
|
||||
"emoji": "💯"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Kiss Mark.webp",
|
||||
"emoji": "💋"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Left Luggage.webp",
|
||||
"emoji": "🛅"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Leo.webp",
|
||||
"emoji": "♌"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Libra.webp",
|
||||
"emoji": "♎"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Love Letter.webp",
|
||||
"emoji": "💌"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Mending Heart.webp",
|
||||
"emoji": "❤️🩹"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Mens Room.webp",
|
||||
"emoji": "🚹"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/New Button.webp",
|
||||
"emoji": "🆕"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/No One Under Eighteen.webp",
|
||||
"emoji": "🔞"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Ok Button.webp",
|
||||
"emoji": "🆗"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Ophiuchus.webp",
|
||||
"emoji": "⛎"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Orange Heart.webp",
|
||||
"emoji": "🧡"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Passport Control.webp",
|
||||
"emoji": "🛂"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Pisces.webp",
|
||||
"emoji": "♓"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Purple Heart.webp",
|
||||
"emoji": "💜"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Question Mark.webp",
|
||||
"emoji": "❓"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Red Heart.webp",
|
||||
"emoji": "❤️"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Revolving Hearts.webp",
|
||||
"emoji": "💞"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Right Anger Bubble.webp",
|
||||
"emoji": "🗯️"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Sagittarius.webp",
|
||||
"emoji": "♐"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Scorpio.webp",
|
||||
"emoji": "♏"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Sparkling Heart.webp",
|
||||
"emoji": "💖"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Speech Balloon.webp",
|
||||
"emoji": "💬"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Taurus.webp",
|
||||
"emoji": "♉"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Thought Balloon.webp",
|
||||
"emoji": "💭"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Top Arrow.webp",
|
||||
"emoji": "🔝"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Two Hearts.webp",
|
||||
"emoji": "💕"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Up Button.webp",
|
||||
"emoji": "🆙"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Virgo.webp",
|
||||
"emoji": "♍"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/White Exclamation Mark.webp",
|
||||
"emoji": "❕"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/White Heart.webp",
|
||||
"emoji": "🤍"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/White Question Mark.webp",
|
||||
"emoji": "❔"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Womens Room.webp",
|
||||
"emoji": "🚺"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Yellow Heart.webp",
|
||||
"emoji": "💛"
|
||||
},
|
||||
{
|
||||
"file": "Symbols/Zzz.webp",
|
||||
"emoji": "💤"
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -0,0 +1,77 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
export const TWEMOJI_GROUP_TRAVEL_PLACES = {
|
||||
"id": "travel-and-places",
|
||||
get "label"() { return t('screens.twemoji_travel_places.text_002'); },
|
||||
"icon": "✈️",
|
||||
"items": [
|
||||
{
|
||||
"file": "Travel and Places/Airplane.webp",
|
||||
"emoji": "✈️"
|
||||
},
|
||||
{
|
||||
"file": "Travel and Places/Ambulance.webp",
|
||||
"emoji": "🚑"
|
||||
},
|
||||
{
|
||||
"file": "Travel and Places/Automobile.webp",
|
||||
"emoji": "🚗"
|
||||
},
|
||||
{
|
||||
"file": "Travel and Places/Beach With Umbrella.webp",
|
||||
"emoji": "🏖️"
|
||||
},
|
||||
{
|
||||
"file": "Travel and Places/Camping.webp",
|
||||
"emoji": "🏕️"
|
||||
},
|
||||
{
|
||||
"file": "Travel and Places/Classical Building.webp",
|
||||
"emoji": "🏛️"
|
||||
},
|
||||
{
|
||||
"file": "Travel and Places/Compass.webp",
|
||||
"emoji": "🧭"
|
||||
},
|
||||
{
|
||||
"file": "Travel and Places/Desert Island.webp",
|
||||
"emoji": "🏝️"
|
||||
},
|
||||
{
|
||||
"file": "Travel and Places/Hot Springs.webp",
|
||||
"emoji": "♨️"
|
||||
},
|
||||
{
|
||||
"file": "Travel and Places/House.webp",
|
||||
"emoji": "🏠"
|
||||
},
|
||||
{
|
||||
"file": "Travel and Places/Locomotive.webp",
|
||||
"emoji": "🚂"
|
||||
},
|
||||
{
|
||||
"file": "Travel and Places/Moai.webp",
|
||||
"emoji": "🗿"
|
||||
},
|
||||
{
|
||||
"file": "Travel and Places/Motor Boat.webp",
|
||||
"emoji": "🛥️"
|
||||
},
|
||||
{
|
||||
"file": "Travel and Places/Police Car.webp",
|
||||
"emoji": "🚓"
|
||||
},
|
||||
{
|
||||
"file": "Travel and Places/Rocket.webp",
|
||||
"emoji": "🚀"
|
||||
},
|
||||
{
|
||||
"file": "Travel and Places/Roller Coaster.webp",
|
||||
"emoji": "🎢"
|
||||
},
|
||||
{
|
||||
"file": "Travel and Places/Taxi.webp",
|
||||
"emoji": "🚕"
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
const paths = {
|
||||
heart: '<path d="M12 21S2.3 15.5 2.3 8.7C2.3 3.6 8.1 1.9 12 6.5c3.9-4.6 9.7-2.9 9.7 2.2C21.7 15.5 12 21 12 21Z"/>',
|
||||
message: '<path d="M5.2 2.35h13.6a2.7 2.7 0 0 1 2.7 2.7v9.7a2.7 2.7 0 0 1-2.7 2.7h-7.1L7.2 21v-3.55h-2a2.7 2.7 0 0 1-2.7-2.7v-9.7a2.7 2.7 0 0 1 2.7-2.7Z"/>',
|
||||
more: '<circle cx="4" cy="12" r="1.6" fill="currentColor" stroke="none"/><circle cx="12" cy="12" r="1.6" fill="currentColor" stroke="none"/><circle cx="20" cy="12" r="1.6" fill="currentColor" stroke="none"/>',
|
||||
moreVertical: '<circle cx="12" cy="4" r="1.6" fill="currentColor" stroke="none"/><circle cx="12" cy="12" r="1.6" fill="currentColor" stroke="none"/><circle cx="12" cy="20" r="1.6" fill="currentColor" stroke="none"/>',
|
||||
forward: '<path d="m14.4 3.1 7.2 7.1-7.2 6.6v-4.4C8.5 12.4 5 15.1 2.4 20c.4-7.6 4.4-11.7 12-12.4Z"/>',
|
||||
download: '<path d="M12 4v11M7 10.5l5 5 5-5M5 20h14"/>',
|
||||
reply: '<path d="M9 7 4 12l5 5"/><path d="M4 12h9a7 7 0 0 1 7 7"/>',
|
||||
copy: '<rect x="8" y="8" width="12" height="12" rx="2.5"/><path d="M16 8V6.5A2.5 2.5 0 0 0 13.5 4h-7A2.5 2.5 0 0 0 4 6.5v7A2.5 2.5 0 0 0 6.5 16H8"/>',
|
||||
info: '<circle cx="12" cy="12" r="9"/><path d="M12 11v5.5M12 7.6v.1"/>',
|
||||
trash: '<path d="M4 7h16M9.5 7V4.8h5V7M6.5 7l.9 12.2a1.9 1.9 0 0 0 1.9 1.8h5.4a1.9 1.9 0 0 0 1.9-1.8L17.5 7M10 11v6M14 11v6"/>',
|
||||
'bell-off': '<path d="M8.5 4.2A6 6 0 0 1 18 9c0 4.3 1.1 6.2 2 7.2M18 17H3c0-2 3-2 3-9M10 21h4M3 3l18 18"/>',
|
||||
phone: '<path d="M5 3.5h3.2l1.6 4.2-2.1 1.4a11 11 0 0 0 5.2 5.2l1.4-2.1 4.2 1.6V17a2.5 2.5 0 0 1-2.7 2.5A16 16 0 0 1 2.5 6.2 2.5 2.5 0 0 1 5 3.5Z"/>',
|
||||
video: '<rect x="2.5" y="6" width="13" height="12" rx="2.5"/><path d="m15.5 10.5 6-3.5v10l-6-3.5"/>',
|
||||
emoji: '<circle cx="12" cy="12" r="9"/><path d="M8.3 14.2a4.6 4.6 0 0 0 7.4 0"/><circle cx="9" cy="9.8" r=".9" fill="currentColor" stroke="none"/><circle cx="15" cy="9.8" r=".9" fill="currentColor" stroke="none"/>',
|
||||
send: '<path d="M12 19V5M5.5 11.5 12 5l6.5 6.5"/>',
|
||||
mic: '<rect x="9" y="3" width="6" height="11" rx="3"/><path d="M5.5 11a6.5 6.5 0 0 0 13 0M12 17.5V21"/>',
|
||||
camera: '<path d="M4.5 7.5h2.8l1.7-2.5h6l1.7 2.5h2.8A1.5 1.5 0 0 1 21 9v9a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 3 18V9a1.5 1.5 0 0 1 1.5-1.5Z"/><circle cx="12" cy="13" r="3.5"/>',
|
||||
image: '<rect x="3" y="4.5" width="18" height="15" rx="2.5"/><circle cx="8.5" cy="9.5" r="1.6"/><path d="m21 16-4.7-4.7-8.2 8.2"/>',
|
||||
list: '<path d="M9 6h11M9 12h11M9 18h11"/><circle cx="4.5" cy="6" r=".9" fill="currentColor" stroke="none"/><circle cx="4.5" cy="12" r=".9" fill="currentColor" stroke="none"/><circle cx="4.5" cy="18" r=".9" fill="currentColor" stroke="none"/>',
|
||||
doc: '<path d="M6.5 3h7.5L19 8v11.5a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 5 19.5v-15A1.5 1.5 0 0 1 6.5 3Z"/><path d="M14 3v5h5M8.5 13h7M8.5 16.5h5"/>',
|
||||
close: '<path d="M6 6l12 12M18 6 6 18"/>',
|
||||
clock: '<circle cx="12" cy="12" r="8.5"/><path d="M12 7.5V12l3 2"/>',
|
||||
alert: '<circle cx="12" cy="12" r="9"/><path d="M12 7.5v5.5M12 16.4v.1"/>',
|
||||
'check-double': '<path d="m2.5 12.5 4 4L15 8"/><path d="m10.5 16 1 .5L21 8"/>',
|
||||
compose: '<path d="M13 4H6.5A2.5 2.5 0 0 0 4 6.5v11A2.5 2.5 0 0 0 6.5 20h11a2.5 2.5 0 0 0 2.5-2.5V11"/><path d="m18.5 3.8 1.7 1.7a1.3 1.3 0 0 1 0 1.8L12.4 15H9v-3.4l7.7-7.8a1.3 1.3 0 0 1 1.8 0Z"/>',
|
||||
channels: '<rect x="4" y="3" width="16" height="18" rx="3"/><path d="M8 8h8M8 12h8M8 16h5"/>',
|
||||
network: '<circle cx="12" cy="5" r="3"/><circle cx="5" cy="18" r="3"/><circle cx="19" cy="18" r="3"/><path d="m10 8-4 7m8-7 4 7M8 18h8"/>',
|
||||
bell: '<path d="M18 8a6 6 0 0 0-12 0c0 7-3 7-3 9h18c0-2-3-2-3-9ZM10 21h4"/>',
|
||||
profile: '<circle cx="12" cy="7" r="4"/><path d="M4 21v-2a8 8 0 0 1 16 0v2"/>',
|
||||
share: '<path d="m14.4 3.1 7.2 7.1-7.2 6.6v-4.4C8.5 12.4 5 15.1 2.4 20c.4-7.6 4.4-11.7 12-12.4Z"/>',
|
||||
search: '<circle cx="10.5" cy="10.5" r="6.5"/><path d="m16 16 5 5"/>',
|
||||
link: '<path d="M10 14a4.5 4.5 0 0 0 6.4 0l3.2-3.2a4.5 4.5 0 0 0-6.4-6.4L12 5.6"/><path d="M14 10a4.5 4.5 0 0 0-6.4 0l-3.2 3.2a4.5 4.5 0 0 0 6.4 6.4l1.2-1.2"/>',
|
||||
gift: '<rect x="3" y="8" width="18" height="5" rx="1"/><path d="M5 13v7a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-7M12 8v13M12 8S10.5 3 8 3.5 7 8 12 8Zm0 0s1.5-5 4-4.5S17 8 12 8Z"/>',
|
||||
plus: '<path d="M12 5v14M5 12h14"/>',
|
||||
check: '<path d="m5 12.5 4.5 4.5L19 7.5"/>',
|
||||
open: '<path d="M5 12h14M13 6l6 6-6 6"/>',
|
||||
chevron: '<path d="m9 6 6 6-6 6"/>',
|
||||
'chevron-up': '<path d="m6 15 6-6 6 6"/>',
|
||||
'chevron-down': '<path d="m6 9 6 6 6-6"/>',
|
||||
calendar: '<rect x="3.5" y="5" width="17" height="15.5" rx="2.5"/><path d="M3.5 10h17M8 3v4M16 3v4"/>',
|
||||
pin: '<path d="M9 3.5h6M10 3.5v6.2L6.5 14h11L14 9.7V3.5M12 14v6.5"/>',
|
||||
back: '<path d="M19 12H5M11 5l-7 7 7 7"/>',
|
||||
down: '<path d="M12 5v14M5 12l7 7 7-7"/>',
|
||||
edit: '<path d="M4 20h4L19 9a2.8 2.8 0 0 0-4-4L4 16v4Z"/><path d="m13.5 6.5 4 4"/>',
|
||||
wallet: '<path d="M4 7.5A2.5 2.5 0 0 1 6.5 5H18v3"/><rect x="4" y="8" width="16" height="11" rx="2.5"/><circle cx="16" cy="13.5" r="1.2" fill="currentColor" stroke="none"/>',
|
||||
settings: '<circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1.1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1.1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9a1.7 1.7 0 0 0 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1Z"/>',
|
||||
'user-plus': '<circle cx="10" cy="8" r="3.5"/><path d="M3.5 20a6.5 6.5 0 0 1 13 0M19 8v6M16 11h6"/>',
|
||||
refresh: '<path d="M20 12a8 8 0 1 1-2.3-5.6"/><path d="M20 4v4.4h-4.4"/>',
|
||||
sparkle: '<path d="M11 4c.6 4.4 2.6 6.4 7 7-4.4.6-6.4 2.6-7 7-.6-4.4-2.6-6.4-7-7 4.4-.6 6.4-2.6 7-7Z"/><path d="M19 2.5v3M17.5 4h3"/>',
|
||||
rings: '<circle cx="12" cy="12" r="2"/><circle cx="12" cy="12" r="5.5"/><circle cx="12" cy="12" r="9"/>',
|
||||
place: '<path d="M12 21s-6.5-5.6-6.5-11a6.5 6.5 0 0 1 13 0c0 5.4-6.5 11-6.5 11Z"/><circle cx="12" cy="10" r="2.4"/>',
|
||||
groups: '<circle cx="9" cy="8" r="3"/><path d="M3.5 19a5.5 5.5 0 0 1 11 0"/><circle cx="17" cy="9.5" r="2.5"/><path d="M15.6 14.1A4.6 4.6 0 0 1 21 18.5"/>',
|
||||
eye: '<path d="M2.5 12S6 5.5 12 5.5 21.5 12 21.5 12 18 18.5 12 18.5 2.5 12 2.5 12Z"/><circle cx="12" cy="12" r="3"/>',
|
||||
eyeOff: '<path d="M10.2 5.7A9.6 9.6 0 0 1 12 5.5c6 0 9.5 6.5 9.5 6.5a16.4 16.4 0 0 1-2.6 3.4M6.4 7A16.2 16.2 0 0 0 2.5 12S6 18.5 12 18.5a9 9 0 0 0 4.9-1.4"/><path d="M9.9 9.9a3 3 0 0 0 4.2 4.2M3.5 3.5l17 17"/>',
|
||||
repost: '<path d="M17 2.5 20.5 6 17 9.5"/><path d="M3.5 11.5V9a3 3 0 0 1 3-3h14"/><path d="M7 21.5 3.5 18 7 14.5"/><path d="M20.5 12.5V15a3 3 0 0 1-3 3h-14"/>',
|
||||
expand: '<path d="M14 4h6v6M10 20H4v-6M20 4l-6.5 6.5M4 20l6.5-6.5"/>',
|
||||
clip: '<path d="m20.5 11.5-8.2 8.2a5 5 0 0 1-7.1-7.1l8.5-8.5a3.3 3.3 0 0 1 4.7 4.7l-8.5 8.5a1.7 1.7 0 0 1-2.4-2.4l7.8-7.8"/>',
|
||||
minus: '<path d="M5 12h14"/>',
|
||||
fit: '<path d="M4 9V5.5A1.5 1.5 0 0 1 5.5 4H9M15 4h3.5A1.5 1.5 0 0 1 20 5.5V9M20 15v3.5a1.5 1.5 0 0 1-1.5 1.5H15M9 20H5.5A1.5 1.5 0 0 1 4 18.5V15"/><circle cx="12" cy="12" r="2.5"/>',
|
||||
focus: '<circle cx="12" cy="12" r="7.5"/><circle cx="12" cy="12" r="2.2" fill="currentColor" stroke="none"/><path d="M12 2v2.5M12 19.5V22M2 12h2.5M19.5 12H22"/>',
|
||||
};
|
||||
|
||||
export function iconHtml(name, filled = false, className = '') {
|
||||
return `<svg${className ? ` class="${className}"` : ''} viewBox="0 0 24 24" fill="${filled ? 'currentColor' : 'none'}" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${paths[name] || paths.message}</svg>`;
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
import { iconHtml } from './ui-icon.js';
|
||||
|
||||
/**
|
||||
* Native password inputs are single-line only. A textarea allows long phrases to
|
||||
* wrap across up to three lines. Masking uses a non-interactive bullet mirror so
|
||||
* it also works in browsers without CSS text-security support.
|
||||
*/
|
||||
export function createExpandablePasswordTextarea() {
|
||||
const input = document.createElement('textarea');
|
||||
input.className = 'input auth-password-field__textarea';
|
||||
input.rows = 1;
|
||||
// 32 visible monospace characters per line on screens wide enough.
|
||||
// Soft wrap only: never add newline characters to the actual password.
|
||||
input.cols = 32;
|
||||
input.wrap = 'soft';
|
||||
input.autocapitalize = 'off';
|
||||
input.spellcheck = false;
|
||||
input.setAttribute('autocorrect', 'off');
|
||||
|
||||
const resize = () => {
|
||||
const computed = window.getComputedStyle(input);
|
||||
const lineHeight = Number.parseFloat(computed.lineHeight) || 24;
|
||||
const extras = (Number.parseFloat(computed.paddingTop) || 0)
|
||||
+ (Number.parseFloat(computed.paddingBottom) || 0)
|
||||
+ (Number.parseFloat(computed.borderTopWidth) || 0)
|
||||
+ (Number.parseFloat(computed.borderBottomWidth) || 0);
|
||||
input.style.height = `${lineHeight + extras}px`;
|
||||
input.style.height = `${Math.min(input.scrollHeight, 3 * lineHeight + extras)}px`;
|
||||
};
|
||||
input.addEventListener('input', resize);
|
||||
// Initial value may be restored from a registration draft before mounting.
|
||||
input.resizePasswordField = resize;
|
||||
input.clearPasswordField = () => {
|
||||
input.value = '';
|
||||
input.updatePasswordMask?.();
|
||||
resize();
|
||||
};
|
||||
return input;
|
||||
}
|
||||
|
||||
/** Passwords are deliberately visible initially on registration and sign-in. */
|
||||
export function createVisiblePasswordField(input) {
|
||||
const multiline = input.tagName === 'TEXTAREA';
|
||||
if (!multiline) input.type = 'text';
|
||||
const wrap = document.createElement('div');
|
||||
wrap.className = multiline ? 'auth-password-field auth-password-field--multiline' : 'auth-password-field';
|
||||
|
||||
let mask = null;
|
||||
let visible = true;
|
||||
if (multiline) {
|
||||
mask = document.createElement('div');
|
||||
mask.className = 'auth-password-field__mask';
|
||||
mask.setAttribute('aria-hidden', 'true');
|
||||
mask.hidden = true;
|
||||
const updateMask = () => {
|
||||
// Preserve explicit line breaks while not copying actual password text.
|
||||
mask.textContent = Array.from(input.value, char => char === '\n' ? '\n' : '•').join('');
|
||||
mask.scrollTop = input.scrollTop;
|
||||
mask.scrollLeft = input.scrollLeft;
|
||||
};
|
||||
input.addEventListener('input', updateMask);
|
||||
input.addEventListener('scroll', () => {
|
||||
mask.scrollTop = input.scrollTop;
|
||||
mask.scrollLeft = input.scrollLeft;
|
||||
});
|
||||
input.updatePasswordMask = updateMask;
|
||||
}
|
||||
|
||||
const toggle = document.createElement('button');
|
||||
toggle.type = 'button';
|
||||
toggle.className = 'auth-password-field__toggle';
|
||||
function updateToggle() {
|
||||
const isVisible = multiline ? visible : input.type !== 'password';
|
||||
toggle.innerHTML = iconHtml(isVisible ? 'eyeOff' : 'eye', false, 'key-toggle-icon');
|
||||
toggle.setAttribute('aria-label', isVisible ? t('screens.visible_password_field.text_001') : t('screens.visible_password_field.text_002'));
|
||||
toggle.setAttribute('title', isVisible ? t('screens.visible_password_field.text_003') : t('screens.visible_password_field.text_004'));
|
||||
toggle.setAttribute('aria-pressed', String(!isVisible));
|
||||
}
|
||||
toggle.addEventListener('click', () => {
|
||||
const start = input.selectionStart;
|
||||
const end = input.selectionEnd;
|
||||
if (multiline) {
|
||||
visible = !visible;
|
||||
wrap.classList.toggle('auth-password-field--masked', !visible);
|
||||
mask.hidden = visible;
|
||||
input.updatePasswordMask();
|
||||
input.resizePasswordField();
|
||||
} else {
|
||||
input.type = input.type === 'password' ? 'text' : 'password';
|
||||
}
|
||||
updateToggle();
|
||||
input.focus();
|
||||
try { if (start !== null && end !== null) input.setSelectionRange(start, end); } catch { /* unsupported input method */ }
|
||||
});
|
||||
updateToggle();
|
||||
wrap.append(input);
|
||||
if (mask) wrap.append(mask);
|
||||
wrap.append(toggle);
|
||||
return wrap;
|
||||
}
|
||||
Reference in New Issue
Block a user