Gebruiker:MakiBoy/Gadget-TestGadget.js: verschil tussen versies

Uit Wikikids
Naar navigatie springen Naar zoeken springen
Regel 8: Regel 8:
 
document.title = "LogCounter - WikiKids";
 
document.title = "LogCounter - WikiKids";
   
table = `<table class="wikitable sortable">
+
table = `<table class="sortable">
 
<thead>
 
<thead>
 
<tr>
 
<tr>

Versie van 13 jan 2023 14:27

/* 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="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) {
        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() {
    var pages = [];
    var request = new XMLHttpRequest();
    request.open('GET', 'https://wikikids.martvanweeghel.nl/pages', false);
    request.send(null);
    if (request.status === 200) {
        pages = JSON.parse(request.responseText);
    }
    return pages;
}

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);
}
Afkomstig van Wikikids , de interactieve Nederlandstalige Internet-encyclopedie voor en door kinderen. "https://wikikids.nl/index.php?title=Gebruiker:MakiBoy/Gadget-TestGadget.js&oldid=759774"