// Инициализация Quill редактора для редактирования новостей const editorContainer =…
- User
// Инициализация Quill редактора для редактирования новостей const editorContainer = document.getElementById('editor-container'); const saveButton = document.getElementById('save-btn'); let currentEditingItem = null;
const quill = new Quill('#editor-container', { theme: 'snow' });
function enableEditing(content, feedItem) { editorContainer.classList.remove('hidden'); saveButton.classList.remove('hidden'); currentEditingItem = feedItem;
quill.setText(content); }
// Сохранение изменений в новости saveButton.addEventListener('click', () => { const updatedContent = quill.getText(); currentEditingItem.querySelector('p').textContent = updatedContent;
editorContainer.classList.add('hidden'); saveButton.classList.add('hidden'); });
// Подключение GigaChat API для обсуждения новостей const gigachatContainer = document.getElementById('gigachat-container'); const gigachatOpenButton = document.getElementById('gigachat-open-btn');
// Функция для открытия GigaChat function openGigachat(roomId) { gigachatContainer.classList.remove('hidden');
// ВСТАВЬТЕ API GIGACHAT ЗДЕСЬ // Пример использования iframe для вставки чата gigachatContainer.innerHTML =
<iframe src="YOUR_GIGACHAT_API_URL/${roomId}" width="100%" height="500"></iframe>; }// Обработчик для кнопки открытия GigaChat gigachatOpenButton.addEventListener('click', () => openGigachat('unique-room-id'));
// Функция для загрузки RSS ленты async function fetchRSS(url) { try { const response = await fetch(url); if (!response.ok) { throw new Error(
Ошибка загрузки RSS: ${response.statusText}); }codeconst rssText = await response.text(); const parser = new DOMParser(); const xmlDoc = parser.parseFromString(rssText, "application/xml"); const items = xmlDoc.querySelectorAll("item"); const parsedItems = Array.from(items).map(item => ({ title: item.querySelector("title")?.textContent || "Без названия", link: item.querySelector("link")?.textContent || "Без ссылки", description: item.querySelector("description")?.textContent || "Без описания", pubDate: item.querySelector("pubDate")?.textContent || "Без даты", })); return parsedItems;} catch (error) { document.getElementById('error').textContent = error.message; document.getElementById('error').classList.remove('hidden'); return []; } }
- Assistant