|
|
(같은 사용자의 중간 판 4개는 보이지 않습니다) |
1번째 줄: |
1번째 줄: |
| if(window.location.href.search('action=edit') !== -1) {
| | var test = $('.mw-htmlform-field-Licenses > .mw-input > label > input[type="checkbox"]'); |
| $('#wpTextbox1').on('input propertychange paste', function() {
| | console.log(test.val()); |
| 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;
| |
| }));
| |
| });
| |
| }
| |
| });
| |
| }
| |