Gebruiker:MakiBoy/Gadget-TestGadget.js: verschil tussen versies
Naar navigatie springen
Naar zoeken springen
Regel 1: | Regel 1: | ||
− | + | function process() { | |
− | + | if (mw.config.get('wgArticleId') === 1) { | |
− | + | var x = document.getElementById("newpagessection").innerHTML; | |
− | + | x = x.replaceAll('\" title=', '?x=h\" title='); | |
+ | document.getElementById("newpagessection").innerHTML = x; | ||
+ | } | ||
− | + | var date = new Date(); | |
− | + | var dateString = date.getDate() + "-" + (date.getMonth() + 1) + "-" + date.getFullYear() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds(); | |
− | |||
− | + | var object = { | |
− | + | title: mw.config.get('wgPageName'), | |
− | + | date: dateString, | |
− | + | fromMainPage: false | |
− | + | }; | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | } | ||
− | |||
− | |||
− | + | if (mw.util.getParamValue('x') === "h") { | |
− | + | object.fromMainPage = true; | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
} | } | ||
− | + | fetch("https://wikikids.martvanweeghel.nl/pages", | |
− | + | { | |
− | + | headers: { | |
− | + | 'Accept': 'application/json', | |
− | + | 'Content-Type': 'application/json' | |
− | + | }, | |
− | + | method: "POST", | |
+ | body: JSON.stringify(object) | ||
+ | }) | ||
+ | .then(function (res) { }) | ||
+ | .catch(function (res) { }); | ||
} | } | ||
+ | $.when($.ready, mw.loader.using(['mediawiki.util'])).done(process); |
Versie van 13 jan 2023 15:46
function process() {
if (mw.config.get('wgArticleId') === 1) {
var x = document.getElementById("newpagessection").innerHTML;
x = x.replaceAll('\" title=', '?x=h\" title=');
document.getElementById("newpagessection").innerHTML = x;
}
var date = new Date();
var dateString = date.getDate() + "-" + (date.getMonth() + 1) + "-" + date.getFullYear() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
var object = {
title: mw.config.get('wgPageName'),
date: dateString,
fromMainPage: false
};
if (mw.util.getParamValue('x') === "h") {
object.fromMainPage = true;
}
fetch("https://wikikids.martvanweeghel.nl/pages",
{
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
method: "POST",
body: JSON.stringify(object)
})
.then(function (res) { })
.catch(function (res) { });
}
$.when($.ready, mw.loader.using(['mediawiki.util'])).done(process);