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="wikitable sortable">
        <thead>
+
    //    <thead>
            <tr>  
+
    //        <tr>  
                <th>Paginatitel</th>
+
    //            <th>Paginatitel</th>
                <th>Laatst bezocht</th>
+
    //            <th>Laatst bezocht</th>
                <th>Normaal bezocht</th>
+
    //            <th>Normaal bezocht</th>
                <th>Via hoofdpagina bezocht</th>
+
    //            <th>Via hoofdpagina bezocht</th>
                <th>Totaal aantal</th>
+
    //            <th>Totaal aantal</th>
            </tr>
+
    //        </tr>
        </thead>
+
    //    </thead>
         <tbody>
+
    //    <tbody>
            ${pages.map((function (page, index) {
+
    //         ${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>`;
 +
 
 +
    table = `
 +
    {| class="wikitable sortable"
 +
    ! Paginatitel
 +
    ! Laatst bezocht
 +
    ! Normaal bezocht
 +
    ! Via hoofdpagina bezocht
 +
    ! Totaal aantal
 +
    ${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 `
                    <td><a href="/${page.title}">${pageTitle}</a></td>
+
        |-
                    <td>${page.date}</td>
+
        | [[${page.title}|${pageTitle}]]
                    <td>${page.normalVisitors}</td>
+
        | ${page.date}
                    <td>${page.mainPageVisitors}</td>
+
        | ${page.normalVisitors}
                    <td>${totalVisitors}</td>
+
        | ${page.mainPageVisitors}
                </tr>`;
+
        | ${totalVisitors}
 +
        `;
 
     })).join('')}
 
     })).join('')}
        </tbody>
+
     `;
     </table>`;
 
  
 
     document.getElementById('bodyContent').innerHTML = table;
 
     document.getElementById('bodyContent').innerHTML = table;

Versie van 13 jan 2023 14:25

/* 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>`;

    table = `
    {| class="wikitable sortable"
    ! Paginatitel	
    ! Laatst bezocht
    ! Normaal bezocht
    ! Via hoofdpagina bezocht
    ! Totaal aantal
    ${pages.map((function (page, index) {
        var totalVisitors = page.normalVisitors + page.mainPageVisitors;
        var pageTitle = page.title.replace(/_/g, ' ');
        return `
        |-
        | [[${page.title}|${pageTitle}]]
        | ${page.date}
        | ${page.normalVisitors}
        | ${page.mainPageVisitors}
        | ${totalVisitors}
        `;
    })).join('')}
    `;

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