User:Lupin/summarynag.js

function perhapsSave(ev) {  var sum = document.getElementsByName('wpSummary'); var submit = true; if (sum.length > 0) { sum = sum[0]; if (isBadSummary(sum.value)) { if (!document.getElementById('jn-fillIn')) { var div = document.createElement('p'); div.appendChild(document.createTextNode('Fill in the summary!')); div.setAttribute('style', 'color: #f00; font-size: 150%;'); div.id = 'jn-fillIn'; sum.parentNode.insertBefore(div, sum.nextSibling); }        sum.focus; submit = false; }  }   if (submit) { var btn = document.getElementById('wpSave'); btn.onclick = null; btn.setAttribute('type', 'submit'); btn.click; } }

function isBadSummary(str) { var sumRe=RegExp('^ *$|^/[*].*?[*]/ *$'); return (sumRe.test(str)); }

function modifySaveButton {  // action=edit for edit pages, action=submit for previews var loc=window.location.href; if ((loc.indexOf('&action=edit') != -1 || loc.indexOf('&action=submit') != -1 ) && loc.indexOf(':Lupin') == -1 ) { var btn = document.getElementById('wpSave'); if (btn) { btn.setAttribute('type', 'button'); btn.onclick = perhapsSave; }  } }

addOnloadHook(modifySaveButton);