(Created page with "<includeonly> <button data-page="1" id="currentPage" onclick="updateTemplate()">Load more</button> <script> function updateTemplate() { var parameters = ''; var currentPageEl = document.getElementById("currentPage") var currentPage = parseInt(currentPageEl?.dataset.page) + 1; var contentContainer = document.getElementById("<!--{$id|escape:'html'}-->"); // Loop through all the parameters given <!--{foreach from=$arg key=key item=item}--> paramete...") |
mNo edit summary |
||
Line 6: | Line 6: | ||
function updateTemplate() { | function updateTemplate() { | ||
var parameters = ''; | var parameters = ''; | ||
Line 14: | Line 13: | ||
var contentContainer = document.getElementById("<!--{$id|escape:'html'}-->"); | var contentContainer = document.getElementById("<!--{$id|escape:'html'}-->"); | ||
var sentParams = JSON.parse("<!--{$arg|escape:'javascript'}-->") | |||
for (let key in sentParams) { | |||
parameters += '|' + key + '=' + sentParams[key] | |||
} | |||
parameters += '|page=' + currentPage + '|more=true|template=' + "<!--{$template|escape:'html'}-->" | parameters += '|page=' + currentPage + '|more=true|template=' + "<!--{$template|escape:'html'}-->" | ||
Line 25: | Line 25: | ||
// Replace the content in the dynamic content container with the parsed template | // 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) { | $.get(mw.util.wikiScript('api'), { action: 'parse', format: 'json', text: parserFunction }, function(data) { | ||
var parsedContent = data.parse.text['*']; | var parsedContent = data.parse.text['*']; | ||
Line 41: | Line 40: | ||
} | } | ||
}); | }); | ||
} | } | ||
</script> | </script> | ||
</includeonly> | </includeonly> |