MediaWiki:Common.js

From Imperivm Romanvm
Jump to navigation Jump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/* 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\" method=\"post\" action=\"\"> \
            <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\" onclick=\"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(); \
                let date = document.getElementById(\"date\").value; \
                api.get({ \
                    action: \'expandtemplates\', \
                    prop: \'wikitext\', \
                    text:\'{{#invoke:Roman Date| main | \' + date + \' }}\' \
                }).done( function ( data ) { \
                    resultDiv.innerHTML = data; \
                } ); \
            } \
        </script> \
    </div>');
});