Untitled
unknown
plain_text
a year ago
1.5 kB
5
Indexable
document.addEventListener('DOMContentLoaded', function() { const fetchButton = document.getElementById('fetch-table-button'); const displayElement = document.getElementById('display-table'); fetchButton.addEventListener('click', fetchAndDisplayTable); function fetchAndDisplayTable() { // Define the Page IDs const sourcePageId = 'page1'; // Replace with the actual Page ID of the source page const targetPageId = 'page2'; // Replace with the actual Page ID of the target page // Define the Confluence REST API URLs for the source and target pages const sourcePageUrl = `https://your-confluence-instance/wiki/rest/api/content/${sourcePageId}`; const targetPageUrl = `https://your-confluence-instance/wiki/rest/api/content/${targetPageId}`; // Function to fetch the content from the source page fetch(sourcePageUrl) .then(response => response.json()) .then(data => { const sourceContent = data.body.view.value; // Parse the content to find the table with ID "table1" const regex = /<table[^>]*id="table1"[^>]*>[\s\S]*?<\/table>/; const match = sourceContent.match(regex); if (match) { // Display the table on the target page displayElement.innerHTML = match[0]; } else { displayElement.textContent = 'Table not found on the source page.'; } }) .catch(error => { console.error('Error fetching Confluence page content:', error); }); } });
Editor is loading...