미디어위키:Gadget-editsummary.js: 두 판 사이의 차이

내용 삭제됨 내용 추가됨
Gapo (토론 | 기여)
(차이 없음)

2012년 8월 27일 (월) 03:01 판

function esEditSummary() {
  if (wgAction == 'edit' || wgAction == 'submit' || wgAction == 'editredlink') {
    var wpSummary = document.getElementById('wpSummary')
    if (!wpSummary || (wpSummary.form.wpSection && wpSummary.form.wpSection.value == 'new')) return
    wpSummaryButtons = document.createElement('span')
    wpSummaryButtons.id = 'esSummaryButtons'
    wpSummary.parentNode.insertBefore(wpSummaryButtons, wpSummary.nextSibling)
    esAddingButton()
  }
}
 
function esAddButton(name, text, title) {
  var btn = document.createElement('esSummaryButton')
  btn.appendChild(document.createTextNode(name))
  btn.title = title
  btn.onclick = function() { esInsertSummary(text) }
  wpSummaryButtons.appendChild(btn)
}
 
function esInsertSummary(text) {
  var wpSummary = document.getElementById('wpSummary')
  if (wpSummary.value.indexOf(text) != -1) return 
  if (wpSummary.value.match(/[^,; \/]$/)) wpSummary.value += ','
  if (wpSummary.value.match(/[^ ]$/)) wpSummary.value += ' '
  wpSummary.value += text
}
 
addOnloadHook(esEditSummary)