Wikipedia:WikiProject User scripts/Scripts/Force edit summary alternative

From Wikipedia, the free encyclopedia

/*

 importScript('Wikipedia:WikiProject User scripts/Scripts/Force edit summary alternative'); 
// (script starts here) */
 
function addForceSummary()
{
    if(!/&action=edit/.test(window.location.href) && !/&action=submit/.test(window.location.href)) return;
    if(/&section=new/.test(window.location.href)) return;
    if(!document.forms.editform) return;
    document.forms.editform.wpSave.onclick = forceSummary;
}
 
function forceSummary()
{
    if(!document.forms.editform.wpSummary.value.replace(/^(?:\/\\*.*\\*\/)? *(.*) *$/,'$1'))
    {
        flashcolour(7);
        document.forms.editform.wpSave.onclick = "";
        return false;
    }
    return true;
}
 
var flashcolour_timer;
function flashcolour(count) {
    if (count%2 == 1)
        document.forms.editform.wpSummary.style.backgroundColor = "#FF8000";
    else
        document.forms.editform.wpSummary.style.backgroundColor = "#FFFFFF";
 
    if (flashcolour_timer != null) {
        clearTimeout(flashcolour_timer);
        flashcolour_timer = null;
    }
 
    if (count > 0)
        flashcolour_timer = window.setTimeout("flashcolour(" + (count-1) + ")",350);
}
 
 
addOnloadHook(addForceSummary);
 
// (end of script)