|
|
1번째 줄: |
1번째 줄: |
| if(window.location.href.search('action=edit') !== -1) {
| | |
| $('#wpTextbox1').on('input propertychange paste', function() {
| |
| var textboxValue = $(this).val();
| |
| var toCursorPosition = textboxValue.substring(0, $(this).prop('selectionStart'));
| |
| var linkStart = toCursorPosition.match(/\[\[(.*?)$/);
| |
| var templateStart = toCursorPosition.match(/\{\{(.*?)$/);
| |
| if(linkStart && linkStart.length === 2 && linkStart.length && !linkStart[1].match(/[\|\]]/)) {
| |
| (new mw.Api()).ajax({
| |
| action: 'query',
| |
| list: 'search',
| |
| srsearch: linkStart[1],
| |
| srlimit: 5
| |
| }).then(function(r) {
| |
| console.log(r.query.search.map(function(e) {
| |
| return e.title;
| |
| }));
| |
| });
| |
| }
| |
| if(templateStart && templateStart.length === 2 && templateStart[1].length && !templateStart[1].match(/[\|\}]/)) {
| |
| (new mw.Api()).ajax({
| |
| action: 'query',
| |
| list: 'search',
| |
| srsearch: 'Template:' + templateStart[1],
| |
| srlimit: 5
| |
| }).then(function(r) {
| |
| console.log(r.query.search.map(function(e) {
| |
| return e.title;
| |
| }));
| |
| });
| |
| }
| |
| });
| |
| }
| |