<commit_before>var MarkupImage = {
    HandlesType: function(type) {
        return type == 'image';
    },

    Paint: function(elementObject) {
        var fullyPainted = false;

        if (elementObject.source == null) {
            $('#' + elementObject.Handle).text('Please provide a source for the image');
        } else {
            $('#' + elementObject.Handle).html('<img>');
            var img = $('#' + elementObject.Handle).children('img')

            if (elementObject.width == null) {
                $(img).on('load', function() {
                    elementObject.width = Math.round(SizeCalculator.ToMM($(this).width()));
                    MarkupImage.Paint(elementObject);
                    $(this).trigger('painted', elementObject);
                });
            } else {
                $(img).css('width', SizeCalculator.ToPixels(elementObject.width));
                fullyPainted = true;
            }

            $(img)
                .attr('src', elementObject.source)
                .css({
                    left: SizeCalculator.ToPixels(elementObject.x) + 'px',
                    top: SizeCalculator.ToPixels(elementObject.y) + 'px'
                });
        }

        if (fullyPainted) {
            $(this).trigger('painted', elementObject);
        }
    },

    Update: function(elementObject) {
        this.Paint(elementObject);
    },

    New: function(markup, image) {
       markup.AddElement({
           type: "image",
           source: null,
           x: 10,
           y: 10,
           width: null,
           properties: {
               source: {
                   label: 'Source',
                   component: 'browse'
               },
               x: {
                   label: 'Left (mm)',
                   component: 'number'
               },
               y: {
                   label: 'Top (mm)',
                   component: 'number'
               },
               width: {
                   label: 'Width (mm)',
                   component: 'range',
                   range: {
                       from: 1,
                       to: formats[settings.format][0]
                   }
               }
           }
       });
    }
};<commit_msg>Load an image from the constructor<commit_after>var MarkupImage = {
    HandlesType: function(type) {
        return type == 'image';
    },

    Paint: function(elementObject) {
        var fullyPainted = false;

        if (elementObject.source == null) {
            $('#' + elementObject.Handle).text('Please provide a source for the image');
        } else {
            $('#' + elementObject.Handle).html('<img>');
            var img = $('#' + elementObject.Handle).children('img')

            if (elementObject.width == null) {
                $(img).on('load', function() {
                    elementObject.width = Math.round(SizeCalculator.ToMM($(this).width()));
                    MarkupImage.Paint(elementObject);
                    $(this).trigger('painted', elementObject);
                });
            } else {
                $(img).css('width', SizeCalculator.ToPixels(elementObject.width));
                fullyPainted = true;
            }

            $(img)
                .attr('src', elementObject.source)
                .css({
                    left: SizeCalculator.ToPixels(elementObject.x) + 'px',
                    top: SizeCalculator.ToPixels(elementObject.y) + 'px'
                });
        }

        if (fullyPainted) {
            $(this).trigger('painted', elementObject);
        }
    },

    Update: function(elementObject) {
        this.Paint(elementObject);
    },

    New: function(markup, image) {
       markup.AddElement({
           type: "image",
           source: image,
           x: 10,
           y: 10,
           width: null,
           properties: {
               source: {
                   label: 'Source',
                   component: 'browse'
               },
               x: {
                   label: 'Left (mm)',
                   component: 'number'
               },
               y: {
                   label: 'Top (mm)',
                   component: 'number'
               },
               width: {
                   label: 'Width (mm)',
                   component: 'range',
                   range: {
                       from: 1,
                       to: formats[settings.format][0]
                   }
               }
           }
       });
    }
};
{'fraction_non_alphanumeric': 0.1298932384341637, 'fraction_numerical': 0.0026690391459074734, 'mean_word_length': 1.1558005752636624, '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': '2190096', 'n_tokens_mistral': 1178, 'n_tokens_neox': 1097, 'n_words': 209}