Main Page: Difference between revisions

From DefacerID Encyclopedia
Replaced content with "{{RandomArticlesList}}"
No edit summary
Line 1: Line 1:
{{RandomArticlesList}}
<script>
  fetch('http://localhost/wikidef/api.php?action=query&list=random&rnnamespace=0&rnlimit=10&format=json')
    .then(response => response.json())
    .then(data => {
      const articles = data.query.random;
      const list = document.createElement('ul');
      articles.forEach(article => {
        const item = document.createElement('li');
        const link = document.createElement('a');
        link.href = `http://localhost/wikidef/${article.title}`;
        link.textContent = article.title;
        item.appendChild(link);
        list.appendChild(item);
      });
      document.getElementById('random-articles').appendChild(list);
    });
</script>
<div id="random-articles">Loading random articles...</div>

Revision as of 05:10, 4 August 2024

<script>

 fetch('http://localhost/wikidef/api.php?action=query&list=random&rnnamespace=0&rnlimit=10&format=json')
   .then(response => response.json())
   .then(data => {
     const articles = data.query.random;
     const list = document.createElement('ul');
     articles.forEach(article => {
       const item = document.createElement('li');
       const link = document.createElement('a');
       link.href = `http://localhost/wikidef/${article.title}`;
       link.textContent = article.title;
       item.appendChild(link);
       list.appendChild(item);
     });
     document.getElementById('random-articles').appendChild(list);
   });

</script>

Loading random articles...