Widget:NewsLanding/LatestNews/LoadMore

From TwogPedia

<script> function loadMore() {

 var parameters = ;
 
 var list = document.querySelector(".news-latest")
 if ( !list ) return
 var offset = parseInt(list.dataset.offset);
 var category = list.dataset.category;
 // Use the selected template as a parameter in the parser function
 var parserFunction = "Lua error: Error: operator for the hierarchy field 'News.category' must be 'HOLDS', 'HOLDS NOT', 'HOLDS WITHIN', 'HOLDS LIKE' or 'HOLDS NOT LIKE'..";
 
 // Replace the content in the dynamic content container with the parsed template
 $.get(mw.util.wikiScript('api'), { action: 'parse', format: 'json', text: parserFunction }, function(data) {
   var parsedContent = data.parse.text['*'];
   
   var content = document.createElement('div')
   content.innerHTML = parsedContent
   if ( content.querySelector('.mw-parser-output div') ) {
      list.innerHTML += content.querySelector('.mw-parser-output').innerHTML;
      list.dataset.offset = offset + 4
   } else {
     var newDiv = document.createElement('div')
     newDiv.textContent = 'No more entries'
     document.getElementById("loadMore").replaceWith(newDiv)
   } 
 });

} </script> <button id="loadMore" onclick="loadMore()">Load more</button>