사용자:Zlzleking/common.js: 두 판 사이의 차이

편집 요약 없음
(문서를 비움)
태그: 비우기
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;
}));
});
}
});
}

2019년 10월 17일 (목) 07:26 판