<commit_before>DP.RealTime = function() {
    this.setup();
};

DP.RealTime.prototype = {
    
    setup: function() {
        this.pusher = new Pusher(DP.PUSHER_KEY);
        this.channel = this.pusher.subscribe(DP.Round.url);
        this.channel.bind('new:charge', _.bind(this.newCharge, this));
        console.log(["Subscribing to real-time", this.pusher, this.channel]);
        
        this.secondsLeft = DP.Round.secondsLeft;
        this.reloader = setInterval(_.bind(this.reloadDonations, this), 1000*60);
        this.timer = setInterval(_.bind(this.renderTimer, this), 1000*1);
    },
    
    newCharge: function() {
        console.log(["REAL-TIME: New Charge", arguments]);
        this.reloadDonations();
    },
    
    reloadDonations: function(data) {
        if (!data) {
            $.get('/round_status/' + DP.Round.url, {}, this.renderDonations);
        } else {
            this.renderDonations(data);
        }
    },
    
    renderDonations: function(data) {
        console.log(["Round status", data]);
        $('.donations').html(data.donations_template);
        $('.payment-info').html(data.payment_info_template);
        this.secondsLeft = data.seconds_left;
    },
    
    renderTimer: function() {
        var $timer = $('.timer');
        var minutes = Math.floor(this.secondsLeft / 60);
        var seconds = this.secondsLeft % 60;
        $timer.html(minutes + ":" + seconds + " left");
        this.secondsLeft -= 1;
    }
    
};


$(document).ready(function() {
    
    if (!DP.Round.closed) {
        DP.realtime = new DP.RealTime();
        DP.paymentform = new DP.PaymentForm();
    }

});<commit_msg>Padding timer and reloading page on closed round.<commit_after>DP.RealTime = function() {
    this.setup();
};

DP.RealTime.prototype = {
    
    setup: function() {
        this.pusher = new Pusher(DP.PUSHER_KEY);
        this.channel = this.pusher.subscribe(DP.Round.url);
        this.channel.bind('new:charge', _.bind(this.newCharge, this));
        console.log(["Subscribing to real-time", this.pusher, this.channel]);
        
        this.secondsLeft = DP.Round.secondsLeft;
        this.reloader = setInterval(_.bind(this.reloadDonations, this), 1000*60);
        this.timer = setInterval(_.bind(this.renderTimer, this), 1000*1);
    },
    
    newCharge: function() {
        console.log(["REAL-TIME: New Charge", arguments]);
        this.reloadDonations();
    },
    
    reloadDonations: function(data) {
        if (!data) {
            $.get('/round_status/' + DP.Round.url, {}, this.renderDonations);
        } else {
            this.renderDonations(data);
        }
    },
    
    renderDonations: function(data) {
        console.log(["Round status", data]);
        $('.donations').html(data.donations_template);
        $('.payment-info').html(data.payment_info_template);
        this.secondsLeft = data.seconds_left;
        if (data.closed) {
            window.location.href = window.location.href;
        }
    },
    
    renderTimer: function() {
        var $timer = $('.timer');
        var minutes = Math.floor(this.secondsLeft / 60);
        var seconds = this.secondsLeft % 60;
        if (seconds <= 9) seconds = "0" + seconds;
        $timer.html(minutes + ":" + seconds + " left");
        this.secondsLeft -= 1;
    }
    
};


$(document).ready(function() {
    
    if (!DP.Round.closed) {
        DP.realtime = new DP.RealTime();
        DP.paymentform = new DP.PaymentForm();
    }

});
{'fraction_non_alphanumeric': 0.15886239586325768, 'fraction_numerical': 0.009767308244757253, 'mean_word_length': 2.291115311909263, 'pattern_counts': {'":': 2, '<': 4, '<?xml version=': 0, '>': 3, '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': '3603027', 'n_tokens_mistral': 1118, 'n_tokens_neox': 1074, 'n_words': 179}