Difference between revisions of "User:Vid gmail/pages.js"
Jump to navigation
Jump to search
(Created page with "// This code dynamically updates an HTML table of files with specified extensions on a MediaWiki site as it works (async function() { const extensions = ['pub', 'png', 'gif'...") |
|||
Line 4: | Line 4: | ||
const updateTable = (extension, count) => { | const updateTable = (extension, count) => { | ||
− | const tableBody = document.getElementById(' | + | const tableBody = document.getElementById('bodyContent'); |
if (tableBody) { | if (tableBody) { | ||
const row = `<tr><td>${extension}</td><td>${count}</td></tr>`; | const row = `<tr><td>${extension}</td><td>${count}</td></tr>`; |
Revision as of 09:40, 15 March 2024
// This code dynamically updates an HTML table of files with specified extensions on a MediaWiki site as it works (async function() { const extensions = ['pub', 'png', 'gif', 'jpg', 'jpeg', 'pdf', 'xls', 'docx', 'pptx', 'doc', 'ppt', 'svg', 'xml', 'mpg', 'odp', 'odt', 'wmv', 'flv', 'vsd', 'mpp', 'ai', 'zip', 'txt', 'wpd', 'rtf', 'drf', 'xlsx', 'xlsm', 'oft', 'swf', 'ppsx', 'dotx', 'potx']; const updateTable = (extension, count) => { const tableBody = document.getElementById('bodyContent'); if (tableBody) { const row = `<tr><td>${extension}</td><td>${count}</td></tr>`; tableBody.innerHTML += row; } else { console.error('Files table body element not found'); } }; for (const extension of extensions) { let continueParam = ''; let totalCount = 0; do { const response = await fetch(`https://wiki.gccollab.ca/api.php?action=query&list=allimages&aifrom=${extension}&ailimit=max&format=json${continueParam}`); const data = await response.json(); const files = data.query.allimages || []; // Filter files by extension const filteredFiles = files.filter(file => file.name.endsWith(`.${extension}`)); totalCount += filteredFiles.length; continueParam = data.continue ? `&aicontinue=${data.continue.aicontinue}` : ''; } while (continueParam); // Update the table with the extension and count updateTable(extension, totalCount); } })();