<commit_before>define(['marionette', 'utils', 'backbone-validation'], function(Marionette, utils) {
    
    return Marionette.ItemView.extend({
        template: false,
        tagName: 'canvas',
        className: 'plate',
        
        collectionEvents: {
            'change reset': 'drawPlate',
        },
        
        events: {
            'mousemove': 'hoverDrop',
            'click': 'clickDrop',
        },
                
        hoverDrop: function(e) {
            var hover = this._xy_to_drop(utils.get_xy(e,this.$el))
            if (hover != this.hover) {
                this.hover = hover
                this.drawPlate()
            }
            
        },
            
        clickDrop: function(e) {
            e.preventDefault()
            var pos = this._xy_to_drop(utils.get_xy(e,this.$el))
            if (pos) {
                var drop = this.collection.findWhere({ LOCATION: pos.toString() })
                
                if (drop) drop.set('isSelected', true)
                this.drawPlate()
            }
        },
        
        initialize: function(options) {
            this.pt = this.getOption('type')
            this.inspectionimages = options.inspectionimages
            if (this.inspectionimages) this.listenTo(this.inspectionimages, 'sync', this.render, this)
            
            this.hover = {}
            this.showImageStatus = this.getOption('showImageStatus')
            
            Backbone.Validation.bind(this, {
                collection: this.collection
            });
        },

        setInspectionImages: function(imgs) {
            this.inspectionimages = imgs
            this.showImageStatus = true
            if (this.inspectionimages) this.listenTo(this.inspectionimages, 'sync', this.render, this)
        },
        
        
        onDomRefresh: function() {
            this.canvas = this.$el[0]
            this.ctx = this.canvas.getContext('2d')
            
            this.canvas.width = this.$el.parent().width()
            this.canvas.height = this.canvas.width*0.68
            console.log('type', this.getOption('type'), this.canvas, this.ctx)
            this.pt.setGeometry(this.canvas.width, this.canvas.height)
            this.drawPlate()
            
            //$(document).unbind('keydown', this.keyPress)<commit_msg>check if options exists before assigning<commit_after>define(['marionette', 'utils', 'backbone-validation'], function(Marionette, utils) {
    
    return Marionette.ItemView.extend({
        template: false,
        tagName: 'canvas',
        className: 'plate',
        
        collectionEvents: {
            'change reset': 'drawPlate',
        },
        
        events: {
            'mousemove': 'hoverDrop',
            'click': 'clickDrop',
        },
                
        hoverDrop: function(e) {
            var hover = this._xy_to_drop(utils.get_xy(e,this.$el))
            if (hover != this.hover) {
                this.hover = hover
                this.drawPlate()
            }
            
        },
            
        clickDrop: function(e) {
            e.preventDefault()
            var pos = this._xy_to_drop(utils.get_xy(e,this.$el))
            if (pos) {
                var drop = this.collection.findWhere({ LOCATION: pos.toString() })
                
                if (drop) drop.set('isSelected', true)
                this.drawPlate()
            }
        },
        
        initialize: function(options) {
            this.pt = this.getOption('type')
            this.inspectionimages = options && options.inspectionimages
            if (this.inspectionimages) this.listenTo(this.inspectionimages, 'sync', this.render, this)
            
            this.hover = {}
            this.showImageStatus = this.getOption('showImageStatus')
            
            Backbone.Validation.bind(this, {
                collection: this.collection
            });
        },

        setInspectionImages: function(imgs) {
            this.inspectionimages = imgs
            this.showImageStatus = true
            if (this.inspectionimages) this.listenTo(this.inspectionimages, 'sync', this.render, this)
        },
        
        
        onDomRefresh: function() {
            this.canvas = this.$el[0]
            this.ctx = this.canvas.getContext('2d')
            
            this.canvas.width = this.$el.parent().width()
            this.canvas.height = this.canvas.width*0.68
            console.log('type', this.getOption('type'), this.canvas, this.ctx)
            this.pt.setGeometry(this.canvas.width, this.canvas.height)
            this.drawPlate()
            
            //$(document).unbind('keydown', this.keyPress)
{'fraction_non_alphanumeric': 0.11979609175870858, 'fraction_numerical': 0.0021240441801189465, 'mean_word_length': 1.518181818181818, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3820020', 'n_tokens_mistral': 1273, 'n_tokens_neox': 1254, 'n_words': 205}