User:DieBuche/forcesummary.js

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload

/*
*
* Derived from [[w:Wikipedia:WikiProject User scripts/Scripts/Force edit summary]] by [[w:User:Alphax]]
*
*/
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(5);
        document.forms.editform.wpSave.onclick = "";
        return false;
    }
    return true;
}
 
var flashcolour_timer;
function flashcolour(count) {

    document.forms.editform.wpSummary.focus();
    if (count%2 == 1)
        document.forms.editform.wpSummary.style.backgroundColor = "#D64F5F";
    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);