<commit_before>define([
  'baseview',
  'text!templates/partials/map/MeasurePopup.html'
], function(Baseview, measurePopupTemplate){
    var private = {
        handleMeasurements: function(event) {
            var geometry = event.geometry;
            var units = event.units;
            var order = event.order;
            var measure = event.measure;
            if (measure > 0 ) {
                $("#measureContainer").append("<div>Segment " + this.numberOfSegments + ": " +  measure.toFixed(3) + " " + event.units + "</div>");
                this.numberOfSegments++;
            }
            else 
                $("#measureContainer").html("");
        }
    };

    var MeasurePopupView = Baseview.extend({
        initialize: function(args) {
            this.initArgs(args);
            this.numberOfSegments = 1;

            this.bindToControl(this.measureControl, "measure", private.handleMeasurements, this);
            this.bindToControl(this.measureControl, "measurepartial", private.handleMeasurements, this);
            this.bindTo(Backbone.globalEvents, "measureEnd", this.close);
        },

        template: _.template(measurePopupTemplate),

        render: function() {
            var view = this;

            this.$el.html(this.template(this.model));
            $("#dialog").append(this.$el);

            this.measureControl.element = $("#measureContainer");

            $("#dialog").dialog({
                title: "Measurements",
                minHeight: 70,
                close: function(evt, ui) {
                    view.close();
                },
                position: {
                    my: "right top",
                    at: "right bottom",
                    of: $(".btn-toolbar")
                }
            });

            return this;
        },

        onClose: function() {
            $("#dialog").dialog("close");
        }
    });

    return MeasurePopupView;
});


<commit_msg>Really simplified getting the segment length<commit_after>define([
  'baseview',
  'text!templates/partials/map/MeasurePopup.html'
], function(Baseview, measurePopupTemplate){
    var private = {
        handleMeasurements: function(event) {
            var geometry = event.geometry;
            var units = event.units;
            var order = event.order;
            var measure = event.measure;
            if (measure > 0 ) {
                $("#measureContainer").append("<div>Segment " + this.numberOfSegments + ": " +  (measure.toFixed(3) - this.previousTotal.toFixed(3)).toFixed(3) + " " + event.units + "</div>");
                this.numberOfSegments++;
                this.previousTotal = measure;

                if (event.type === "measure") 
                    $("#measureContainer").append("<div><b>Total</b>: " +  measure.toFixed(3) + " " + event.units + "</div>");
            }
            else 
                $("#measureContainer").html("");
        }
    };

    var MeasurePopupView = Baseview.extend({
        initialize: function(args) {
            this.initArgs(args);
            this.numberOfSegments = 1;
            this.previousTotal = 0;

            this.bindToControl(this.measureControl, "measure", private.handleMeasurements, this);
            this.bindToControl(this.measureControl, "measurepartial", private.handleMeasurements, this);
            this.bindTo(Backbone.globalEvents, "measureEnd", this.close);
        },

        template: _.template(measurePopupTemplate),

        render: function() {
            var view = this;

            this.$el.html(this.template(this.model));
            $("#dialog").append(this.$el);

            this.measureControl.element = $("#measureContainer");

            $("#dialog").dialog({
                title: "Measurements",
                minHeight: 70,
                close: function(evt, ui) {
                    view.close();
                },
                position: {
                    my: "right top",
                    at: "right bottom",
                    of: $(".btn-toolbar")
                }
            });

            return this;
        },

        onClose: function() {
            $("#dialog").dialog("close");
        }
    });

    return MeasurePopupView;
});



{'fraction_non_alphanumeric': 0.13881687485269856, 'fraction_numerical': 0.0032995522036295072, 'mean_word_length': 1.6591478696741855, 'pattern_counts': {'":': 2, '<': 11, '<?xml version=': 0, '>': 13, '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': '4422332', 'n_tokens_mistral': 1116, 'n_tokens_neox': 1069, 'n_words': 191}