<commit_before>

/******************************************************************************************************************************
COMING SOON PAGE
*******************************************************************************************************************************/
(function($) {


    /******************************************************************************************************************************
    WEBSOCKET
    *******************************************************************************************************************************/

    var launch = new Date();

    var ws = new WebSocket("ws://" + window.location.host + "/ws/tweets")

    ws.onopen = function (event) {
//      var now = new Date()
//      setDate(now)
      setCount(0,0);
      setTweets([],0,20)
      ws.send("connected")

//    minutes.html('<h1>00:</h1>');
//    seconds.html('<h1>00</h1>');
    };
    

    ws.onmessage = function(event) { 
        data = JSON.parse(event.data); 
        if (data.payload == "connected") {
            launch = new Date(data.cycle.end);
            setDate();
            return true;
        }
        console.log(data)
        setCount(data.count, data.cycle.threshold)
        if (data.pour) {
            console.log('pour')
            setPour()
            launch = new Date(data.cycle.end);
            setDate();
            setTweets([],0,20);
        } else if (data.reset) {
            console.log('reset')
            launch = new Date(data.cycle.end);
            setDate();
            setTweets([],0,20);
        } else if (!data.pour) {
            if (data.tweets.length !=0) {
                setTweets(data.tweets, data.count, data.cycle.tweet_window);
            }
        } 
    };

    function setPour() {
        $("#pour").show();
        setTimeout(function(){
            $("#pour").hide();
        }, 2000);
    }

    function setCount(count, threshold) {
        $("#count").html(count);
        $("#threshold").html(threshold);
    }

    function setTweets(tweets, count, tweet_window) {
        $("#tweets li").each(function(idx, el) {
            index = count - tweet_window + idx;
            if (index < 0) {
                $(el).html('&nbsp;');
            } else if (count < tweet_window) {
                var tweet = tweets[index];
                $(el).css('opacity', (idx+1)/tweet_window);
                $(el).html(index+1 + '. <strong>@' + tweet.user.screen_name + '</strong> ' + tweet.text.replace(/\#water/gi, "<span style='color:red;'>#water</span>"));
            } else {
                var tweet = tweets[idx];
                $(el).css('opacity', (idx+1)/tweet_window);
                $(el).html(index+1 + '. <strong>@' + tweet.user.screen_name + '</strong> ' + tweet.text.replace(/\#water/gi, "<span style='color:red;'>#water</span>"));
            }
        });
    }<commit_msg>Garbage collection to fix memory leak<commit_after>

/******************************************************************************************************************************
COMING SOON PAGE
*******************************************************************************************************************************/
(function($) {


    /******************************************************************************************************************************
    WEBSOCKET
    *******************************************************************************************************************************/

    var launch = new Date();

    var ws = new WebSocket("ws://" + window.location.host + "/ws/tweets")

    ws.onopen = function (event) {
//      var now = new Date()
//      setDate(now)
      setCount(0,0);
      setTweets([],0,20)
      ws.send("connected")

//    minutes.html('<h1>00:</h1>');
//    seconds.html('<h1>00</h1>');
    };
    

    ws.onmessage = function(event) { 
        data = JSON.parse(event.data); 
        if (data.payload == "connected") {
            launch = new Date(data.cycle.end);
            setDate();
            return true;
        }
        console.log(data)
        setCount(data.count, data.cycle.threshold)
        if (data.pour) {
            console.log('pour')
            setPour()
            launch = new Date(data.cycle.end);
            setDate();
            setTweets([],0,20);
        } else if (data.reset) {
            console.log('reset')
            launch = new Date(data.cycle.end);
            setDate();
            setTweets([],0,20);
        } else if (!data.pour) {
            if (data.tweets.length !=0) {
                setTweets(data.tweets, data.count, data.cycle.tweet_window);
            }
        } 
        data.tweets = null;
        data = null;
    };

    function setPour() {
        $("#pour").show();
        setTimeout(function(){
            $("#pour").hide();
        }, 2000);
    }

    function setCount(count, threshold) {
        $("#count").html(count);
        $("#threshold").html(threshold);
    }

    function setTweets(tweets, count, tweet_window) {
        $("#tweets li").each(function(idx, el) {
            index = count - tweet_window + idx;
            if (index < 0) {
                $(el).html('&nbsp;');
            } else if (count < tweet_window) {
                var tweet = tweets[index];
                $(el).css('opacity', (idx+1)/tweet_window);
                $(el).html(index+1 + '. <strong>@' + tweet.user.screen_name + '</strong> ' + tweet.text.replace(/\#water/gi, "<span style='color:red;'>#water</span>"));
            } else {
                var tweet = tweets[idx];
                $(el).css('opacity', (idx+1)/tweet_window);
                $(el).html(index+1 + '. <strong>@' + tweet.user.screen_name + '</strong> ' + tweet.text.replace(/\#water/gi, "<span style='color:red;'>#water</span>"));
            }
        });
    }
{'fraction_non_alphanumeric': 0.3233644859813084, 'fraction_numerical': 0.009855564995751912, 'mean_word_length': 2.2681843420322045, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 27, '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': '794003', 'n_tokens_mistral': 1684, 'n_tokens_neox': 1571, 'n_words': 263}