I'm trying to add a button to wikieditor that executes an API call and places the returned string at the cursor.
I can add buttons fine using the below code example, but I'm struggling to replace "XXXXX" in with the result of my API call:
$.ajax({
dataType: 'script',
cache: true,
url: 'https://meta.wikimedia.org/w/index.php?title=User:Krinkle/Scripts/InsertWikiEditorButton.js&action=raw&ctype=text/javascript'
}).then(function () {
krInsertWikiEditorButton({
id: 'mw-apiCall1',
icon: '//upload.wikimedia.org/wikipedia/commons/thumb/1/1b/Gnome-face-monkey.svg/22px-Gnome-face-monkey.svg.png',
label: 'Api Call 1',
sampleText: 'XXXXX'
});
});
The API call I'm looking to make is: /api.php?action=idprovider-increment
And its return value is of the format. { "id": "1" }
Anyone got any pointers as to how I can do this?