Как настроить вашу визитку?
Чтобы ваша NFC-карта заработала, создайте один из двух вариантов:
1. Мультиссылка — красивая страница-визитка со всей информацией, соцсетями, контактами и фото.
2. Переадресация — мгновенный переход по вашей ссылке при касании карты (сайт, файл или соц. сеть).
После создания мультиссылки или редиректа, нажмите «Добавить NFC продукт» и следуйте указаниям.
Есть вопросы? Напишите нам — TG, VK @nfsea.ru
${emptyAction}
`;
return;
}
const icons = {
multilinks: '👤',
carriers: '📱',
redirects: '↪️'
};
container.innerHTML = items.map((item, index) => `
${icons[type]}
${escapeHtml(item.name)}
${escapeHtml(item.url)}
`).join('');
}
function attachEventListeners() {
document.querySelectorAll('[data-action^="add-"]').forEach(btn => {
btn.removeEventListener('click', handleAddClick);
btn.addEventListener('click', handleAddClick);
});
document.querySelectorAll('[data-action="view"], [data-action="copy"], [data-action="edit"], [data-action="delete"]').forEach(btn => {
btn.removeEventListener('click', handleItemAction);
btn.addEventListener('click', handleItemAction);
});
document.querySelectorAll('[data-action="close-modal"]').forEach(btn => {
btn.removeEventListener('click', closeModal);
btn.addEventListener('click', closeModal);
});
modalForm.removeEventListener('submit', handleFormSubmit);
modalForm.addEventListener('submit', handleFormSubmit);
modal.removeEventListener('click', handleModalBackdropClick);
modal.addEventListener('click', handleModalBackdropClick);
}
function handleAddClick(e) {
const action = e.currentTarget.dataset.action;
const type = action.replace('add-', '');
let formType = 'multilink';
if (type === 'carrier') formType = 'carrier';
if (type === 'redirect') formType = 'redirect';
currentEditIndex = null;
currentEditType = formType;
modalForm.dataset.type = formType;
modalTitle.textContent =
formType === 'multilink' ? 'Создать мультиссылку' :
formType === 'carrier' ? 'Добавить NFC носитель' :
'Создать переадресацию';
descriptionGroup.style.display = formType === 'multilink' ? 'block' : 'none';
document.getElementById('fieldName').value = '';
document.getElementById('fieldUrl').value = '';
document.getElementById('fieldDescription').value = '';
openModal();
}
function handleItemAction(e) {
const action = e.currentTarget.dataset.action;
const type = e.currentTarget.dataset.type;
const index = parseInt(e.currentTarget.dataset.index);
if (action === 'view') {
window.open(data[type][index].url, '_blank');
} else if (action === 'copy') {
navigator.clipboard.writeText(data[type][index].url).then(() => {
alert('Ссылка скопирована!');
});
} else if (action === 'edit') {
openEditModal(type, index);
} else if (action === 'delete') {
if (confirm('Вы уверены, что хотите удалить этот элемент?')) {
data[type].splice(index, 1);
saveData();
renderSection(type);
attachEventListeners();
}
}
}
function openEditModal(type, index) {
currentEditIndex = index;
currentEditType = type;
const item = data[type][index];
let formType = 'multilink';
if (type === 'carriers') formType = 'carrier';
if (type === 'redirects') formType = 'redirect';
modalForm.dataset.type = formType;
modalTitle.textContent =
formType === 'multilink' ? 'Редактировать мультиссылку' :
formType === 'carrier' ? 'Редактировать NFC носитель' :
'Редактировать переадресацию';
descriptionGroup.style.display = formType === 'multilink' ? 'block' : 'none';
document.getElementById('fieldName').value = item.name;
document.getElementById('fieldUrl').value = item.url;
document.getElementById('fieldDescription').value = item.description || '';
openModal();
}
function handleFormSubmit(e) {
e.preventDefault();
const type = modalForm.dataset.type;
const realType =
type === 'multilink' ? 'multilinks' :
type === 'carrier' ? 'carriers' :
'redirects';
const item = {
name: document.getElementById('fieldName').value,
url: document.getElementById('fieldUrl').value,
description: document.getElementById('fieldDescription').value
};
if (currentEditIndex !== null) {
data[realType][currentEditIndex] = item;
} else {
data[realType].push(item);
}
saveData();
renderSection(realType);
attachEventListeners();
closeModal();
}
function openModal() {
modal.classList.add('active');
document.body.style.overflow = 'hidden';
}
function closeModal() {
modal.classList.remove('active');
document.body.style.overflow = '';
currentEditIndex = null;
currentEditType = null;
}
function handleModalBackdropClick(e) {
if (e.target === modal) {
closeModal();
}
}
function escapeHtml(text) {
const div = document.createElement('div');
div.textContent = text;
return div.innerHTML;
}
init();
})();