Widget:CategoryPages: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
| Line 2: | Line 2: | ||
<script type="text/javascript"> | <script type="text/javascript"> | ||
(function() { | (function() { | ||
const url = '/api.php?action=query&list=categorymembers&cmtitle=Category:Tools and Equipment in | const url = '/api.php?action=query&list=categorymembers&cmtitle=Category:Tools and Equipment in {$area|escape:'html'}&format=json'; | ||
fetch(url).then(function(response) { | fetch(url).then(function(response) { | ||
return response.json(); | return response.json(); | ||
Revision as of 00:18, 24 January 2025
<script type="text/javascript">
(function() {
const url = '/api.php?action=query&list=categorymembers&cmtitle=Category:Tools and Equipment in {$area|escape:'html'}&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>