Gebruiker:Rots61/JS-HandtekeninginBoomhut.js: verschil tussen versies
Naar navigatie springen
Naar zoeken springen
(Nieuwe pagina aangemaakt met '→jshint sub:true maxerr:100000: //<nowiki> // Script geschreven door User:Rots61 // Voegt automatisch een var api = new mw.Api(); var samenvatting, bericht...') |
|||
Regel 4: | Regel 4: | ||
// Voegt automatisch een | // Voegt automatisch een | ||
var api = new mw.Api(); | var api = new mw.Api(); | ||
− | var | + | var kopje, bericht, volgpagina, volg, edit_token; |
− | |||
function editpage() { | function editpage() { | ||
Regel 21: | Regel 20: | ||
'title': "WikiKids:Boomhut", | 'title': "WikiKids:Boomhut", | ||
'section': 'new', | 'section': 'new', | ||
− | 'sectiontitle': | + | 'sectiontitle': kopje, |
'text': bericht, | 'text': bericht, | ||
− | 'summary': "Nieuwe vraag: " + | + | 'summary': "Nieuwe vraag: " + kopje, |
'watchlist': volg, | 'watchlist': volg, | ||
'token': edit_token, | 'token': edit_token, | ||
Regel 33: | Regel 32: | ||
mw.notify("Opslaan mislukt"); | mw.notify("Opslaan mislukt"); | ||
} | } | ||
− | |||
window.location.href = 'https://wikikids.nl/Wikikids:Boomhut'; | window.location.href = 'https://wikikids.nl/Wikikids:Boomhut'; | ||
}); | }); | ||
Regel 40: | Regel 38: | ||
function voeghandtekeningtoe () { | function voeghandtekeningtoe () { | ||
− | + | kopje = document.getElementById('wpSummary').value; | |
bericht = document.getElementById('wpTextbox1').value; | bericht = document.getElementById('wpTextbox1').value; | ||
+ | document.getElementById('wpTextbox1').value = ''; | ||
+ | document.getElementById('wpSummary').value = ''; | ||
volgpagina = document.getElementById('wpWatchthis').checked; | volgpagina = document.getElementById('wpWatchthis').checked; | ||
if (!bericht.includes("~~~~")) { | if (!bericht.includes("~~~~")) { | ||
bericht += '~~~~'; | bericht += '~~~~'; | ||
} | } | ||
− | |||
if (volgpagina === "true") { | if (volgpagina === "true") { | ||
volg = 'watch'; | volg = 'watch'; | ||
Regel 52: | Regel 51: | ||
volg = 'unwatch'; | volg = 'unwatch'; | ||
} | } | ||
− | |||
editpage(); | editpage(); | ||
} | } | ||
− | |||
if ((mw.config.get('wgArticleId') === 61839) && mw.util.getParamValue('action') === 'edit' && mw.util.getParamValue('section') === 'new' ) { | if ((mw.config.get('wgArticleId') === 61839) && mw.util.getParamValue('action') === 'edit' && mw.util.getParamValue('section') === 'new' ) { | ||
var opslaknop ='<span id="WKslaopknop" class="oo-ui-widget oo-ui-widget-enabled oo-ui-inputWidget oo-ui-buttonElement oo-ui-buttonElement-framed oo-ui-labelElement oo-ui-flaggedElement-progressive oo-ui-flaggedElement-primary oo-ui-buttonInputWidget">' | var opslaknop ='<span id="WKslaopknop" class="oo-ui-widget oo-ui-widget-enabled oo-ui-inputWidget oo-ui-buttonElement oo-ui-buttonElement-framed oo-ui-labelElement oo-ui-flaggedElement-progressive oo-ui-flaggedElement-primary oo-ui-buttonInputWidget">' |
Versie van 6 jan 2023 00:35
/* jshint sub:true maxerr:100000 */
//<nowiki>
// Script geschreven door [[User:Rots61]]
// Voegt automatisch een
var api = new mw.Api();
var kopje, bericht, volgpagina, volg, edit_token;
function editpage() {
api.get({
action: 'query',
prop: 'info',
intoken: 'edit',
titles: 'kassdfalv', //Pagina moet niet bestaan.
}).done(
function(data) {
edit_token = data.query.pages['-1'].edittoken;
}).done(function(data) {
api.post({
'action': 'edit',
'title': "WikiKids:Boomhut",
'section': 'new',
'sectiontitle': kopje,
'text': bericht,
'summary': "Nieuwe vraag: " + kopje,
'watchlist': volg,
'token': edit_token,
}).done(
function(data) {
if (data.edit.result == "Success") {
mw.notify("Opgeslagen!");
} else {
mw.notify("Opslaan mislukt");
}
window.location.href = 'https://wikikids.nl/Wikikids:Boomhut';
});
});
}
function voeghandtekeningtoe () {
kopje = document.getElementById('wpSummary').value;
bericht = document.getElementById('wpTextbox1').value;
document.getElementById('wpTextbox1').value = '';
document.getElementById('wpSummary').value = '';
volgpagina = document.getElementById('wpWatchthis').checked;
if (!bericht.includes("~~~~")) {
bericht += '~~~~';
}
if (volgpagina === "true") {
volg = 'watch';
} else if (volgpagina === "false") {
volg = 'unwatch';
}
editpage();
}
if ((mw.config.get('wgArticleId') === 61839) && mw.util.getParamValue('action') === 'edit' && mw.util.getParamValue('section') === 'new' ) {
var opslaknop ='<span id="WKslaopknop" class="oo-ui-widget oo-ui-widget-enabled oo-ui-inputWidget oo-ui-buttonElement oo-ui-buttonElement-framed oo-ui-labelElement oo-ui-flaggedElement-progressive oo-ui-flaggedElement-primary oo-ui-buttonInputWidget">'
+ '<input type="button" onClick="voeghandtekeningtoe();" tabindex="4" aria-disabled="false" title="Sla jouw wijzigingen op [Alt+Shift+s]" accesskey="s" name="wpSave" id="wpSave" value="Wijzigingen opslaan*" class="oo-ui-inputWidget-input oo-ui-buttonElement-button"></span>';
$('#wpSaveWidget').after(opslaknop);
document.getElementById('wpSaveWidget').innerHTML = '';
}
//</nowiki>