|
|
| Line 2: |
Line 2: |
| | <input id="param1" value="JavaScript" /> | | <input id="param1" value="JavaScript" /> |
| | <input type="button" id="send-email" value="Send" /> | | <input type="button" id="send-email" value="Send" /> |
| − | <script type="text/javascript">
| |
| − | // <![CDATA[
| |
| − | $('#send-email').click(function() {
| |
| − | var param1 = $('#param1').val();
| |
| − | var ask = '{{#ask:[[Category:' + param1 + ']]|link=none|sep=;|limit=500}}';
| |
| − | console.log('Sending query: ' + ask);
| |
| − | var title = mw.config.get('wgPageName');
| |
| − | console.log(title);
| |
| − | $.ajax({
| |
| − | type: 'post',
| |
| − | url: mw.util.wikiScript('api'),
| |
| − | dataType: 'json',
| |
| − | data: {
| |
| − | action: 'parse',
| |
| − | text: ask,
| |
| − | contentmodel: 'wikitext',
| |
| − | format: 'json'
| |
| − | },
| |
| − | success: function(json) {
| |
| − | var page = mw.config.get('wgPageName');
| |
| − | window.location = mw.util.wikiScript() + '?title=Special:EmailPage&ea-title=' + page + '&ea-to=' + json.parse.text;
| |
| − | }
| |
| − | });
| |
| − | });
| |
| − | // ]]>
| |
| − | </script>
| |
| | </html> | | </html> |