Gebruiker:MakiBoy/Gadget-TestGadget.js: verschil tussen versies
Naar navigatie springen
Naar zoeken springen
Regel 8: | Regel 8: | ||
document.title = "LogCounter - WikiKids"; | document.title = "LogCounter - WikiKids"; | ||
− | table = `<table class="wikitable"> | + | table = `<table class="wikitable sortable"> |
<thead> | <thead> | ||
<tr> | <tr> | ||
Regel 21: | Regel 21: | ||
${pages.map((function (page, index) { | ${pages.map((function (page, index) { | ||
var totalVisitors = page.normalVisitors + page.mainPageVisitors; | var totalVisitors = page.normalVisitors + page.mainPageVisitors; | ||
− | var pageTitle = page.title.replace(/ /g, ' | + | var pageTitle = page.title.replace(/_/g, ' '); |
return `<tr> | return `<tr> | ||
<td><a href="/${page.title}">${pageTitle}</a></td> | <td><a href="/${page.title}">${pageTitle}</a></td> | ||
Regel 29: | Regel 29: | ||
<td>${totalVisitors}</td> | <td>${totalVisitors}</td> | ||
</tr>`; | </tr>`; | ||
− | }))} | + | })).join('')} |
</tbody> | </tbody> | ||
</table>`; | </table>`; |
Versie van 13 jan 2023 14:23
/* jshint sub:true maxerr:100000 */
// Gadget gemaakt door [[User:MakiBoy]]
// Documentatie op [[WikiKids:LogCounter]]
var version = '1.2';
function showProject(pages) {
document.getElementsByTagName("h1")[0].textContent = "Speciaal:LogCounter";
document.title = "LogCounter - WikiKids";
table = `<table class="wikitable sortable">
<thead>
<tr>
<th>Paginatitel</th>
<th>Laatst bezocht</th>
<th>Normaal bezocht</th>
<th>Via hoofdpagina bezocht</th>
<th>Totaal aantal</th>
</tr>
</thead>
<tbody>
${pages.map((function (page, index) {
var totalVisitors = page.normalVisitors + page.mainPageVisitors;
var pageTitle = page.title.replace(/_/g, ' ');
return `<tr>
<td><a href="/${page.title}">${pageTitle}</a></td>
<td>${page.date}</td>
<td>${page.normalVisitors}</td>
<td>${page.mainPageVisitors}</td>
<td>${totalVisitors}</td>
</tr>`;
})).join('')}
</tbody>
</table>`;
document.getElementById('bodyContent').innerHTML = table;
}
function getPages() {
return [
{
"title": "Wikikids:Boomhut",
"date": "2023-01-13",
"normalVisitors": 314,
"mainPageVisitors": 0
},
{
"title": "Portaal:Kids",
"date": "2023-01-13",
"normalVisitors": 105,
"mainPageVisitors": 0
},
{
"title": "Hoofdpagina",
"date": "2023-01-13",
"normalVisitors": 3171,
"mainPageVisitors": 0
},
{
"title": "Stefanskroon",
"date": "2023-01-12",
"normalVisitors": 1,
"mainPageVisitors": 0
},
{
"title": "Wikikids:Awards",
"date": "2023-01-13",
"normalVisitors": 78,
"mainPageVisitors": 0
},
{
"title": "Federale_Republiek_Joegoslavië",
"date": "2023-01-13",
"normalVisitors": 1,
"mainPageVisitors": 0
},
{
"title": "Wikikids:Alarm",
"date": "2023-01-13",
"normalVisitors": 88,
"mainPageVisitors": 0
},
{
"title": "Bestormingen_op_het_Plein_van_de_Drie_Machten",
"date": "2023-01-13",
"normalVisitors": 0,
"mainPageVisitors": 2
},
{
"title": "Gebruiker:Rots61",
"date": "2023-01-13",
"normalVisitors": 1,
"mainPageVisitors": 0
},
{
"title": "PIM-systeem",
"date": "2023-01-13",
"normalVisitors": 1,
"mainPageVisitors": 0
},
{
"title": "Gebruiker:MakiBoy",
"date": "2023-01-13",
"normalVisitors": 3,
"mainPageVisitors": 0
},
{
"title": "Koninkrijk_Joegoslavië",
"date": "2023-01-13",
"normalVisitors": 1,
"mainPageVisitors": 0
},
{
"title": "Socialistische_Federale_Republiek_Joegoslavië",
"date": "2023-01-13",
"normalVisitors": 0,
"mainPageVisitors": 1
}
];
}
if (mw.config.get('wgNamespaceNumber') === -1 && mw.config.get('wgTitle') === "LogCounter") {
document.getElementById("footer-places").innerHTML += '<li id="footer-places-gadget-LogCounter">Script gemaakt door <a href="/User:MakiBoy" title="Gebruiker:MakiBoy">MakiBoy</a>, versie: ' + version + '</li>';
var allPages = getPages();
showProject(allPages);
}