<commit_before>define(function(require) {
var Backbone = require('backbone'),
    Mustache = require('mustache'),
    ContentTemplate = require('text!streamhub-backbone/templates/Content.html'),
    ContentView = require('streamhub-backbone/views/ContentView'),
    sources = require('streamhub-backbone/const/sources'),
    _ = require('underscore');

var ScorecardView = Backbone.View.extend(
{
    initialize: function (opts) {
        this._contentViewOpts = opts.contentViewOptions || {};
        this._sourceOpts = opts.sources || {};
        this.lastEventId = 0;

        this.collection.on('add', this._insertItem, this);
        this.collection.on('initialDataLoaded', this.render, this);
    }
});

ScorecardView.prototype._insertItem = function (item, opts) {
    var json = item.toJSON();
	
	if (json.event > this.lastEventId) {
	    var score1 = this.$el.find('.score1');
	    var score2 = this.$el.find('.score2');
	    var quarterEl = this.$el.find('.quarter');
	    
	    //strip html tags
	    var text = $(document.createElement('div')).html(json.bodyHtml).text().trim();
		try {
			var parts = text.split(' ');
			if (parts.length >= 3 && parts[0] == "score") {
				var s1 = parseInt(parts[1]);
				var s2 = parseInt(parts[2]);
				var self = this;
				parts.shift();
				parts.shift();
				parts.shift();
				var quarterText = parts.join(' ');
				
				this.$el.fadeOut(function() {
					score1.html(s1);
					score2.html(s2);
					
					if (quarterText.length = 0) { quarterEl.html(quarterText); }
					
					self.$el.fadeIn();
				});
				this.lastEventId = json.event;
			}
		} catch (ex) {
			return;
		}
	}	
    return;
};

return ScorecardView;
});
<commit_msg>finalized scoreboard protocol<commit_after>define(function(require) {
var Backbone = require('backbone'),
    Mustache = require('mustache'),
    ContentTemplate = require('text!streamhub-backbone/templates/Content.html'),
    ContentView = require('streamhub-backbone/views/ContentView'),
    sources = require('streamhub-backbone/const/sources'),
    _ = require('underscore');

var ScorecardView = Backbone.View.extend(
{
    initialize: function (opts) {
        this._contentViewOpts = opts.contentViewOptions || {};
        this._sourceOpts = opts.sources || {};
        this.lastEventId = 0;

        this.collection.on('add', this._insertItem, this);
        this.collection.on('initialDataLoaded', this.render, this);
    }
});

ScorecardView.prototype._insertItem = function (item, opts) {
    var json = item.toJSON();
	if (json.event > this.lastEventId) {
	    var score1 = this.$el.find('.score1');
	    var score2 = this.$el.find('.score2');
	    var quarterEl = this.$el.find('.quarter');
	    
	    //strip html tags
	    var text = $(document.createElement('div')).html(json.bodyHtml).text().trim();
		try {
			var parts = text.split(' ');
			if (parts.length >= 3 && parts.shift() == "score") {
				var s1 = parseInt(parts.shift());
				var s2 = parseInt(parts.shift());
				var self = this;
				parts.pop(); // popping "date time" from end, for cache busting
				var quarterText = parts.join(' ');
				
				this.$el.fadeOut(function() {
					score1.html(s1);
					score2.html(s2);
					
					if (quarterText.length != 0) { quarterEl.html(quarterText); }
					
					self.$el.fadeIn();
				});
				this.lastEventId = json.event;
			}
		} catch (ex) {
			return;
		}
	}	
    return;
};

return ScorecardView;
});

{'fraction_non_alphanumeric': 0.1665203394790752, 'fraction_numerical': 0.008486976880304361, 'mean_word_length': 3.0449704142011833, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '7256826', 'n_tokens_mistral': 1241, 'n_tokens_neox': 1079, 'n_words': 200}