Gebruiker:MakiBoy/Gadget-Sidebar.js: verschil tussen versies
		
		
		
		
		
		Naar navigatie springen
		Naar zoeken springen
		
				
		
		
	
| Regel 18: | Regel 18: | ||
| } | } | ||
| − | function  | + | function addSidebar(pages) { | 
|      var div = document.createElement('div'); |      var div = document.createElement('div'); | ||
| Regel 27: | Regel 27: | ||
|          </h3> |          </h3> | ||
|          <div class="body vector-menu-content" style="border-bottom: 1px solid #80bfff"> |          <div class="body vector-menu-content" style="border-bottom: 1px solid #80bfff"> | ||
| − |              <ul class="vector-menu-content-list" id=" | + |              <ul class="vector-menu-content-list"> | 
| − | + |                 ${pages.map(function (page, index) { | |
| + |         return `<li id="makiboy-n-${index}"> | ||
| + |                     <a href="/${page.url}" title="${page.tooltip}">${page.label}</a> | ||
| + |                  </li>`; | ||
| + |     }).join('')} | ||
|              </ul> |              </ul> | ||
|          </div> |          </div> | ||
| Regel 36: | Regel 40: | ||
| } | } | ||
| − | function  | + | (function (mw, $) { | 
| − | + |     $(function () { | |
| − | + |         getEditCount(mw) | |
| − | + |             .then(function (editCount) { | |
| − | } | + |                 var pages = [{ | 
| + |                     url: 'Wikikids:Moderatorwerk', | ||
| + |                     label: 'Moderatorwerk', | ||
| + |                     tooltip: 'Naar moderatorwerk', | ||
| + |                 }, | ||
| + |                 { | ||
| + |                     url: 'Gebruiker:MakiBoy/aantal/bewerkingen', | ||
| + |                     label: 'Aantal bewerkingen: ' + editCount || 0, | ||
| + |                     tooltip: 'Naar mijn aantal bewerkingen', | ||
| + |                 }, | ||
| + |                 { | ||
| + |                     url: 'Speciaal:Logboeken/newusers', | ||
| + |                     label: 'Logboek gebruikers', | ||
| + |                     tooltip: 'Naar het logboek nieuwe gebruikers', | ||
| + |                 }, | ||
| + |                 { | ||
| + |                     url: 'Wikikids:Blokverzoek', | ||
| + |                     label: 'Blokverzoek', | ||
| + |                     tooltip: 'Naar blokverzoeken', | ||
| + |                 }, | ||
| + |                 { | ||
| + |                     url: 'Speciaal:Opschonen', | ||
| + |                     label: 'Opschonen', | ||
| + |                     tooltip: 'Naar opschoon pagina', | ||
| + |                 }, | ||
| + |                 { | ||
| + |                     url: 'Wikikids:Clubhuis', | ||
| + |                     label: 'Clubhuis', | ||
| + |                     tooltip: 'Naar het clubhuis' | ||
| + |                 }, | ||
| + |                 { | ||
| + |                     url: 'Speciaal:LogCounter', | ||
| + |                     label: 'LogCounter', | ||
| + |                     tooltip: 'Naar LogCounter' | ||
| + |                 }]; | ||
| − | + |                 addSidebar(pages); | |
| − | + |              }); | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
|      }); |      }); | ||
| − | + | }(mediaWiki, jQuery)); | |
| − | |||
Versie van 13 jan 2023 14:36
/**
 * Gebruiker:MakiBoy/Gadget-Sidebar.js
 * Made by [[User:MakiBoy]]
 */
function getEditCount(mw) {
    var username = 'MakiBoy';
    var api = new mw.Api();
    return api.get({
        action: 'query',
        list: 'users',
        usprop: 'editcount',
        ususers: username,
    }).then(function (data) {
        return data.query.users[0].editcount;
    });
}
function addSidebar(pages) {
    var div = document.createElement('div');
    div.innerHTML = `<nav id="p-makiboy" style="background-color: #80bfff" class="vector-menu vector-menu-portal portal"
        aria-labelledby="p-makiboy-label" role="navigation">
        <h3 id="p-makiboy-label">
            <span>Persoonlijk</span>
        </h3>
        <div class="body vector-menu-content" style="border-bottom: 1px solid #80bfff">
            <ul class="vector-menu-content-list">
                ${pages.map(function (page, index) {
        return `<li id="makiboy-n-${index}">
                    <a href="/${page.url}" title="${page.tooltip}">${page.label}</a>
                </li>`;
    }).join('')}
            </ul>
        </div>
    </nav>`;
    document.getElementById('p-Kids').parentNode.insertBefore(div, document.getElementById('p-Kids'));
}
(function (mw, $) {
    $(function () {
        getEditCount(mw)
            .then(function (editCount) {
                var pages = [{
                    url: 'Wikikids:Moderatorwerk',
                    label: 'Moderatorwerk',
                    tooltip: 'Naar moderatorwerk',
                },
                {
                    url: 'Gebruiker:MakiBoy/aantal/bewerkingen',
                    label: 'Aantal bewerkingen: ' + editCount || 0,
                    tooltip: 'Naar mijn aantal bewerkingen',
                },
                {
                    url: 'Speciaal:Logboeken/newusers',
                    label: 'Logboek gebruikers',
                    tooltip: 'Naar het logboek nieuwe gebruikers',
                },
                {
                    url: 'Wikikids:Blokverzoek',
                    label: 'Blokverzoek',
                    tooltip: 'Naar blokverzoeken',
                },
                {
                    url: 'Speciaal:Opschonen',
                    label: 'Opschonen',
                    tooltip: 'Naar opschoon pagina',
                },
                {
                    url: 'Wikikids:Clubhuis',
                    label: 'Clubhuis',
                    tooltip: 'Naar het clubhuis'
                },
                {
                    url: 'Speciaal:LogCounter',
                    label: 'LogCounter',
                    tooltip: 'Naar LogCounter'
                }];
                addSidebar(pages);
            });
    });
}(mediaWiki, jQuery));