<commit_before>
// import Divmod
// import Divmod.Runtime

// import Nevow
// import Nevow.Athena

// import Mantissa

Mantissa.LiveForm.FormWidget = Nevow.Athena.Widget.subclass('Mantissa.LiveForm.FormWidget');
Mantissa.LiveForm.FormWidget.DOM_DESCEND = Divmod.Runtime.Platform.DOM_DESCEND;
Mantissa.LiveForm.FormWidget.DOM_CONTINUE = Divmod.Runtime.Platform.DOM_CONTINUE;

Mantissa.LiveForm.MessageFader = Divmod.Class.subclass("Divmod.Class.MessageFader");

/**
   Fade a node in, then out again.
 */
Mantissa.LiveForm.MessageFader.methods(
    function __init__(self, node) {
        self.node = node;
        self.timer = null;
        self.inRate = 1.0;      // in opacity / second
        self.outRate = 0.5;
        self.messageDelay = 5.0; // number of seconds message is left on-screen
    },

    /*
     * Cause the referenced Node to become fully opaque.  It must currently be
     * fully transparent.  Returns a Deferred which fires when this has been
     * done.
     */
    function fadeIn(self) {
        var currentOpacity = 0.0;
        var TICKS_PER_SECOND = 30.0;
        var fadedInDeferred = Divmod.Defer.Deferred();
        var inStep = function () {
            currentOpacity += (self.inRate / TICKS_PER_SECOND)
            if (currentOpacity > 1.0) {
                self.node.style.opacity = '1.0';
                self.timer = null;
                fadedInDeferred.callback(null);
            } else {
                self.node.style.opacity = currentOpacity;
                self.timer = setTimeout(inStep, 1000 * 1.0 / TICKS_PER_SECOND);
            }
        };

        /* XXX TODO - "block" is not the right thing to do here. The wrapped
         * node might be a table cell or something.
         */
        self.node.style.display = 'block';
        inStep();
        return fadedInDeferred;
    },

    /*
     * Cause the referenced Node to become fully transparent.  It must
     * currently be fully opaque.  Returns a Deferred which fires when this
     * has been done.
     */
    function fadeOut(self) {
        var fadedOutDeferred = Divmod.Defer.Deferred();
        var currentOpacity = 0.0;
        var TICKS_PER_SECOND = 30.0;

        var outStep = function () {
            currentOpacity -= (self.outRate / TICKS_PER_SECOND);
            if (currentOpacity < 0.0) {
                self.node.style.display = 'none';
                self.timer = null;
                fadedOutDeferred.callback(null);
            } else {
                self.node.style.opacity = currentOpacity;
                self.timer = setTimeout(outStep, 1000 * 1.0 / TICKS_PER_SECOND);
            }
        };

        outStep();
        return fadedOutDeferred;
    },

    /*
     * Go through one fade-in/fade-out cycle.  Return a Deferred which fires
     * when both steps have finished.
     */
    function start(self) {
        // kick off the timer loop
        self.fadeIn().addCallback(function() { return self.fadeOut(); });
    });


Mantissa.LiveForm.FormWidget.methods(<commit_msg>make MessageFader.start() return the deferred<commit_after>
// import Divmod
// import Divmod.Runtime

// import Nevow
// import Nevow.Athena

// import Mantissa

Mantissa.LiveForm.FormWidget = Nevow.Athena.Widget.subclass('Mantissa.LiveForm.FormWidget');
Mantissa.LiveForm.FormWidget.DOM_DESCEND = Divmod.Runtime.Platform.DOM_DESCEND;
Mantissa.LiveForm.FormWidget.DOM_CONTINUE = Divmod.Runtime.Platform.DOM_CONTINUE;

Mantissa.LiveForm.MessageFader = Divmod.Class.subclass("Divmod.Class.MessageFader");

/**
   Fade a node in, then out again.
 */
Mantissa.LiveForm.MessageFader.methods(
    function __init__(self, node) {
        self.node = node;
        self.timer = null;
        self.inRate = 1.0;      // in opacity / second
        self.outRate = 0.5;
        self.messageDelay = 5.0; // number of seconds message is left on-screen
    },

    /*
     * Cause the referenced Node to become fully opaque.  It must currently be
     * fully transparent.  Returns a Deferred which fires when this has been
     * done.
     */
    function fadeIn(self) {
        var currentOpacity = 0.0;
        var TICKS_PER_SECOND = 30.0;
        var fadedInDeferred = Divmod.Defer.Deferred();
        var inStep = function () {
            currentOpacity += (self.inRate / TICKS_PER_SECOND)
            if (currentOpacity > 1.0) {
                self.node.style.opacity = '1.0';
                self.timer = null;
                fadedInDeferred.callback(null);
            } else {
                self.node.style.opacity = currentOpacity;
                self.timer = setTimeout(inStep, 1000 * 1.0 / TICKS_PER_SECOND);
            }
        };

        /* XXX TODO - "block" is not the right thing to do here. The wrapped
         * node might be a table cell or something.
         */
        self.node.style.display = 'block';
        inStep();
        return fadedInDeferred;
    },

    /*
     * Cause the referenced Node to become fully transparent.  It must
     * currently be fully opaque.  Returns a Deferred which fires when this
     * has been done.
     */
    function fadeOut(self) {
        var fadedOutDeferred = Divmod.Defer.Deferred();
        var currentOpacity = 0.0;
        var TICKS_PER_SECOND = 30.0;

        var outStep = function () {
            currentOpacity -= (self.outRate / TICKS_PER_SECOND);
            if (currentOpacity < 0.0) {
                self.node.style.display = 'none';
                self.timer = null;
                fadedOutDeferred.callback(null);
            } else {
                self.node.style.opacity = currentOpacity;
                self.timer = setTimeout(outStep, 1000 * 1.0 / TICKS_PER_SECOND);
            }
        };

        outStep();
        return fadedOutDeferred;
    },

    /*
     * Go through one fade-in/fade-out cycle.  Return a Deferred which fires
     * when both steps have finished.
     */
    function start(self) {
        // kick off the timer loop
        return self.fadeIn().addCallback(function() { return self.fadeOut(); });
    });


Mantissa.LiveForm.FormWidget.methods(
{'fraction_non_alphanumeric': 0.10293876210802824, 'fraction_numerical': 0.01116401247742571, 'mean_word_length': 1.9789731051344743, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7371181', 'n_tokens_mistral': 1894, 'n_tokens_neox': 1815, 'n_words': 442}