Jump to content

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

From Wikipedia, the free encyclopedia
/*

* A modified version of [[Wikipedia:WikiProject User scripts/Scripts/Force edit summary]].
* Flashes summary box instead of displaying message.
* Place this line into your monobook.js

<pre> importScript('Wikipedia:WikiProject User scripts/Scripts/Force edit summary alternative'); </pre>

<syntaxhighlight lang=javascript>
// (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);
}


$(addForceSummary);

// (end of script) </syntaxhighlight>