Widget:CategoryPages: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
| Line 11: | Line 11: | ||
const page = pages[pageIdx]; | const page = pages[pageIdx]; | ||
const pageLink = document.createElement('a'); | const pageLink = document.createElement('a'); | ||
pageLink.href = `/index.php?curid=${page.pageid}`; | pageLink.href = `/index.php?curid=${page.pageid}`; | ||
pageLink.appendChild(document.createTextNode(page.title | pageLink.appendChild(document.createTextNode(page.title)); | ||
wrapper.appendChild(pageLink); | wrapper.appendChild(pageLink); | ||
if (pageIdx < (pages.length - 1)) { | |||
wrapper.appendChild(document.createTextNode(' • '); | |||
} | |||
} | } | ||
}).catch(function(err) { | }).catch(function(err) { | ||
Revision as of 00:15, 24 January 2025
<script type="text/javascript">
(function() {
const url = '/api.php?action=query&list=categorymembers&cmtitle=Category:Tools and Equipment in Electronics Area&format=json';
fetch(url).then(function(response) {
return response.json();
}).then(function(data) {
const wrapper = document.getElementById('categoryPages');
const pages = data.query.categorymembers;
for (const pageIdx in pages) {
const page = pages[pageIdx];
const pageLink = document.createElement('a');
pageLink.href = `/index.php?curid=${page.pageid}`;
pageLink.appendChild(document.createTextNode(page.title));
wrapper.appendChild(pageLink);
if (pageIdx < (pages.length - 1)) {
wrapper.appendChild(document.createTextNode(' • ');
}
}
}).catch(function(err) {
console.log('Fetch Error :-S', err);
});
})();
</script>