MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
m (Use DateInput) |
No edit summary |
||
(14 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
$(function() { | $(function() { | ||
mw.loader.using( [ | |||
'mediawiki.widgets.DateInputWidget' | |||
] ).done( function () { | |||
var dateInput = new mw.widgets.DateInputWidget({id: 'date'}); | |||
$('#ir-roman-date-converter').append('<div class=\"mw-inputbox-centered\"> ', dateInput.$element, ' \ | |||
<input type=\"submit\" onclick=\"submit()\" class=\"mw-ui-button mw-ui-progressive webfonts-changed\" value=\"Convert Date\"> \ | |||
<div id=\"result\"></div> \ | <div id=\"result\"></div> \ | ||
<script> \ | <script> \ | ||
Line 11: | Line 13: | ||
const resultDiv = document.getElementById(\"result\"); \ | const resultDiv = document.getElementById(\"result\"); \ | ||
const api = new mw.Api(); \ | const api = new mw.Api(); \ | ||
let date = $(#date). | let date = $(\'#date input[type=hidden]\').val(); \ | ||
api.get({ \ | api.get({ \ | ||
action: \'expandtemplates\', \ | action: \'expandtemplates\', \ | ||
Line 22: | Line 24: | ||
</script> \ | </script> \ | ||
</div>'); | </div>'); | ||
}); | |||
}); | |||
$(function() { | |||
mw.loader.using( [ | |||
'oojs-ui', | |||
'oojs-ui-core', | |||
] ).done( function () { | |||
var numInput = new OO.ui.NumberInputWidget({id: 'numeral'}); | |||
$('#ir-roman-numeral-converter').append('<div class=\"mw-inputbox-centered\"> ', numInput.$element, ' \ | |||
<input type=\"submit\" onclick=\"submit()\" class=\"mw-ui-button mw-ui-progressive webfonts-changed\" value=\"Convert Number\"> \ | |||
<div id=\"result\"></div> \ | |||
<script> \ | |||
function submit(){ \ | |||
const resultDiv = document.getElementById(\"result\"); \ | |||
const api = new mw.Api(); \ | |||
let numeral = $(\'#numeral input\').val(); \ | |||
api.get({ \ | |||
action: \'expandtemplates\', \ | |||
prop: \'wikitext\', \ | |||
text:\'{{#invoke:Roman Numeral| main |\' + numeral + \' | explanation=yes }}\' \ | |||
}).done( function ( data ) { \ | |||
resultDiv.innerHTML = \'<pre>\' + data.expandtemplates.wikitext + \'</pre>\'; \ | |||
} ); \ | |||
} \ | |||
</script> \ | |||
</div>'); | |||
}); | |||
}); | }); |
Latest revision as of 12:20, 29 June 2022
/* Any JavaScript here will be loaded for all users on every page load. */
$(function() {
mw.loader.using( [
'mediawiki.widgets.DateInputWidget'
] ).done( function () {
var dateInput = new mw.widgets.DateInputWidget({id: 'date'});
$('#ir-roman-date-converter').append('<div class=\"mw-inputbox-centered\"> ', dateInput.$element, ' \
<input type=\"submit\" onclick=\"submit()\" class=\"mw-ui-button mw-ui-progressive webfonts-changed\" value=\"Convert Date\"> \
<div id=\"result\"></div> \
<script> \
function submit(){ \
const resultDiv = document.getElementById(\"result\"); \
const api = new mw.Api(); \
let date = $(\'#date input[type=hidden]\').val(); \
api.get({ \
action: \'expandtemplates\', \
prop: \'wikitext\', \
text:\'{{#invoke:Roman Date| main | \' + date + \' }}\' \
}).done( function ( data ) { \
resultDiv.innerHTML = data.expandtemplates.wikitext; \
} ); \
} \
</script> \
</div>');
});
});
$(function() {
mw.loader.using( [
'oojs-ui',
'oojs-ui-core',
] ).done( function () {
var numInput = new OO.ui.NumberInputWidget({id: 'numeral'});
$('#ir-roman-numeral-converter').append('<div class=\"mw-inputbox-centered\"> ', numInput.$element, ' \
<input type=\"submit\" onclick=\"submit()\" class=\"mw-ui-button mw-ui-progressive webfonts-changed\" value=\"Convert Number\"> \
<div id=\"result\"></div> \
<script> \
function submit(){ \
const resultDiv = document.getElementById(\"result\"); \
const api = new mw.Api(); \
let numeral = $(\'#numeral input\').val(); \
api.get({ \
action: \'expandtemplates\', \
prop: \'wikitext\', \
text:\'{{#invoke:Roman Numeral| main |\' + numeral + \' | explanation=yes }}\' \
}).done( function ( data ) { \
resultDiv.innerHTML = \'<pre>\' + data.expandtemplates.wikitext + \'</pre>\'; \
} ); \
} \
</script> \
</div>');
});
});