630
edits
No edit summary |
(Convert to ECMAScript 5) |
||
Line 2: | Line 2: | ||
$(function() { | $(function() { | ||
$('#ir-roman-date-converter').html('<div class=\"mw-inputbox-centered\"> \ | |||
$('#ir-roman-date-converter').html( | <form name=\"Convert Date\" onSubmit="JavaScript:submit()"> \ | ||
<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 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\"> \ | ||
<input type=\"submit\" class=\"mw-ui-button mw-ui-progressive webfonts-changed\" value=\"Convert Date\"> | </form> \ | ||
</form> | <div id=\"result\"></div> \ | ||
<div id=\"result\"></div> | <script> \ | ||
<script> | function submit(){ \ | ||
function submit(){ | const resultDiv = document.getElementById(\'result\'); \ | ||
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(\'date\').value}}\' \ | ||
text:\'{{#invoke:Roman Date|document.getElementById('date').value}}\' | }).done( function ( data ) { \ | ||
}).done( function ( data ) { | console.log( data ); \ | ||
console.log( data ); | } ); \ | ||
} ); | resultDiv.innerHTML(); \ | ||
resultDiv.innerHTML(); | } \ | ||
} | </script> \ | ||
</script> | </div>'); | ||
</div> | |||
}); | }); |