MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
(Convert to ECMAScript 5) |
No edit summary |
||
Line 10: | Line 10: | ||
<script> \ | <script> \ | ||
function submit(){ \ | function submit(){ \ | ||
const resultDiv = document.getElementById(\ | const resultDiv = document.getElementById(\"result\"); \ | ||
const api = new mw.Api(); \ | const api = new mw.Api(); \ | ||
api.get({ \ | api.get({ \ | ||
action: \'expandtemplates\, \ | action: \'expandtemplates\, \ | ||
prop: \'wikitext\', \ | prop: \'wikitext\', \ | ||
text:\'{{#invoke:Roman Date|document.getElementById(\ | text:\'{{#invoke:Roman Date|document.getElementById(\"date\").value}}\' \ | ||
}).done( function ( data ) { \ | }).done( function ( data ) { \ | ||
console.log( data ); \ | console.log( data ); \ |
Revision as of 09:35, 29 June 2022
/* Any JavaScript here will be loaded for all users on every page load. */
$(function() {
$('#ir-roman-date-converter').html('<div class=\"mw-inputbox-centered\"> \
<form name=\"Convert Date\" onSubmit="JavaScript:submit()"> \
<input id=\'date\' type=\"date\" class=\"mw-ui-input mw-ui-input-inline mw-inputbox-createbox webfonts-changed\" placeholder=\"\" required=\"\" size=\"50\" dir=\"ltr\"> \
<input type=\"submit\" class=\"mw-ui-button mw-ui-progressive webfonts-changed\" value=\"Convert Date\"> \
</form> \
<div id=\"result\"></div> \
<script> \
function submit(){ \
const resultDiv = document.getElementById(\"result\"); \
const api = new mw.Api(); \
api.get({ \
action: \'expandtemplates\, \
prop: \'wikitext\', \
text:\'{{#invoke:Roman Date|document.getElementById(\"date\").value}}\' \
}).done( function ( data ) { \
console.log( data ); \
} ); \
resultDiv.innerHTML(); \
} \
</script> \
</div>');
});