Widget:Autorenbox: Unterschied zwischen den Versionen
Aus ZUM-Unterrichten
KKeine Bearbeitungszusammenfassung Markierung: 2017-Quelltext-Bearbeitung |
KKeine Bearbeitungszusammenfassung Markierung: 2017-Quelltext-Bearbeitung |
||
(3 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
Zeile 1: | Zeile 1: | ||
<includeonly> | <includeonly> | ||
< | <div class="uk-panel uk-panel-box uk-panel-box-primary zum-hintergrund-links zum-farbe-xx-heller"> | ||
<strong>Autoren</strong> | |||
<small class="uk-align-right" data-zum-hook="last-modified">aktualisiert am: </small> | |||
<div class="uk-flex uk-flex-wrap uk-width-1-1" data-zum-hook="userlist"> | |||
</div> | |||
</div> | |||
<script type="text/javascript"> | <script type="text/javascript"> | ||
const element = document.currentScript && document.currentScript.previousElementSibling; | const element = document.currentScript && document.currentScript.previousElementSibling; | ||
Zeile 6: | Zeile 12: | ||
window.RLQ.push(function(){ | window.RLQ.push(function(){ | ||
mw.loader.enqueue(['mediawiki.api'], function(){ | mw.loader.enqueue(['mediawiki.api'], function(){ | ||
const userlistEl = $(element).children('[data-zum-hook="userlist"]'); | |||
const lastModifiedEl = $(element).children('[data-zum-hook="last-modified"]'); | |||
const pageid = 19515 /*mw.config.get('wgArticleId')*/; | const pageid = 19515 /*mw.config.get('wgArticleId')*/; | ||
const api = new mw.Api(); | const api = new mw.Api(); | ||
api.get({ | api.get({ | ||
action:'query', | action:'query', | ||
prop:['revisions', 'contributors'], | prop:['revisions', 'contributors', 'info'], | ||
pageids:[pageid], | pageids:[pageid], | ||
rvlimit:1000 | rvlimit:1000 | ||
}).then((data) => data | }); | ||
response.then((data) => data.query.pages[pageid].touched) | |||
.then((dateS)=>new Date(dateS).toLocalString()) | |||
.then((dateLS) => $lastModifiedEl.append(dateLS)); | |||
response.then((data) => data | |||
.query | .query | ||
.pages[pageid] | .pages[pageid] | ||
Zeile 25: | Zeile 39: | ||
.map((user) => api.parse(`{{Nutzerkarte|${user}}}`) | .map((user) => api.parse(`{{Nutzerkarte|${user}}}`) | ||
.fail((ignored) => null)); | .fail((ignored) => null)); | ||
$.when(...textsP) | $.when(...textsP) | ||
.then((...texts)=> texts.filter((t) => t!==null)) | .then((...texts)=> texts.filter((t) => t!==null)) | ||
.then((texts)=> $( | .then((texts)=> $(userlistEl).append(texts)); | ||
}); | }); | ||
}); | }); |