<commit_before>console.log('Loaded main.js');
var app = app || {};

Salak = (function() {
    'use strict';

    return Class.extend({
	init: function() {
	    console.log('new salak');

	    this.paper = new Raphael(0, 0, window.screen.width, window.screen.height);

	    this.salaks = [];
	    
	},

	add: function() {
	    var addedSalak = new Snake(this.paper);

            this.salaks.push(addedSalak);
           
            return addedSalak;
	}
    });

}());

Snake = (function() {
    'use strict';
    
    return Class.extend({
        init: function(paper) {
            console.log('  new snake');

            this.paper = paper;

            this.colour = this.randColor();
            this.opacity = 0.5;

            this.createSectionWide(this.colour, 80);
            this.createSectionNarrow(this.colour, 80);
            this.createSectionNarrow(this.colour, 80);            

            return this;
        },

        getPosition: function(inc, x, y) {
            var x = this.lastOptions ? this.lastOptions.x3 : Math.floor(Math.random() * window.screen.width);
            var y = this.lastOptions ? this.lastOptions.y3 : Math.floor(Math.random() * window.screen.height);
            var options = [
                  {x1: x, y1: y, x2: x,       y2: y + inc, x3: x + inc, y3: y + inc},
                  {x1: x, y1: y, x2: x + inc, y2: y,       x3: x + inc, y3: y + inc},
                  {x1: x, y1: y, x2: x + inc, y2: y      , x3: x + inc, y3: y - inc},
                  {x1: x, y1: y, x2: x      , y2: y - inc, x3: x + inc, y3: y - inc},
                  {x1: x, y1: y, x2: x,       y2: y - inc, x3: x - inc, y3: y - inc},
                  {x1: x, y1: y, x2: x - inc, y2: y      , x3: x - inc, y3: y - inc},
                  {x1: x, y1: y, x2: x - inc, y2: y,       x3: x - inc, y3: y + inc},
                  {x1: x, y1: y, x2: x,       y2: y + inc, x3: x - inc, y3: y + inc},
                ]
              , chosen = /*this.lastChosen ? (Math.floor(Math.random()) ? this.lastChosen + 1 : this.lastChosen - 1) :*/ Math.floor(Math.random() * options.length);

            chosen = chosen == 4 ? 0 : chosen;
            console.log(chosen);
            this.lastChosen = chosen;
            this.lastOptions = options[chosen];

            return options[chosen];
        },

        getPositionNarrow: function(x, y) {
            return this.getPosition(100, x, y);
        },

        getPositionWide: function(x, y) {
            return this.getPosition(200, x, y);
        },

        createSectionNarrow: function(colour, size) {
            this.createSection(this.getPositionNarrow(), colour, size);
        },

        createSectionWide: function(colour, size) {
            this.createSection(this.getPositionWide(), colour, size);
        },

        createSection: function(positions, colour, size) {
            var x1 = positions.x1, y1 = positions.y1
              , x2 = positions.x2, y2 = positions.y2
              , x3 = positions.x3, y3 = positions.y3;
            var line, circle;
            this.paper.circle(x1,y1,size)
                .attr("fill", colour)
                .attr("stroke-width", 0)
                .attr("fill-opacity", this.opacity);
            circle = this.paper.circle(x1, y1, size)
                .attr("fill", colour)
                .attr("stroke-width", 0)
                .attr("fill-opacity", this.opacity);
            line = this.paper.path("M" + x1 + "," + y1 + 
                                   "C" + x1 + "," + y1 + 
                                   "," + x1 + "," + y1 + 
                                   "," + x1 + "," + y1)
                .attr("stroke", colour)
                .attr("stroke-width", size * 2)
                .attr("stroke-opacity", this.opacity);

            line.animate({path: "M" + x1 + "," + y1 + 
                         "C" + x1 + "," + y1 + 
                         "," + x2 + "," + y2 + 
                         "," + x3 + "," + y3}, 1000);
            circle.animate({transform: "T" + (x3 - x1) + "," + (y3 - y1)}, 1000);

            return this; 
            
        },

        randColor: function() {
            var colors = ["00b196", "797e89", "3a3f56", "c9cc38", "32baec", "aa519a", "4058a4"]
              , rand = Math.floor(Math.random() * colors.length);
            return "#" + colors[rand];
        }
    });

}());

(function() {<commit_msg>Adds snakes on click<commit_after>console.log('Loaded main.js');
var app = app || {};

Salak = (function() {
    'use strict';

    return Class.extend({
	init: function() {
	    console.log('new salak');

	    this.paper = new Raphael(0, 0, window.screen.height, window.screen.width);

	    this.salaks = [];
	    
//            this.createDots();// OH GOD, THE HUGE MANATEE!

            Salak = this;

            document.onclick = function(event) {
                Salak.add(event.x, event.y);
            }
	},

	add: function(x, y) {
	    var addedSalak = new Snake(this.paper, x, y);

            this.salaks.push(addedSalak);
           
            return addedSalak;
	},

        createDots: function() {
            var x, y;
            for( x = 0; x < window.screen.width; x+=5) {
                for ( y = 0; y < window.screen.height; y+=5) {
                    this.paper.circle(x, y, 1)
                        .attr("stroke-width", 0)
                        .attr("fill", "#797e89")
                        .attr("fill-opacity", 0.5);
                }
            }
        }
    });

}());

Snake = (function() {
    'use strict';
    
    return Class.extend({
        init: function(paper, x, y) {
            console.log('  new snake');

            this.paper = paper;

            this.colour = this.randColor();
            this.opacity = 0.99;

            if (x && y) {
                this.lastOptions = {
                    x3: x,
                    y3: y
                }
            }

            this.createSectionWide(this.colour, 80);// TODO: Randomise this
            this.createSectionNarrow(this.colour, 80);
            this.createSectionNarrow(this.colour, 80);            

            return this;
        },

        getPosition: function(inc) {
            var x = this.lastOptions ? this.lastOptions.x3 : Math.floor(Math.random() * window.screen.width);
            var y = this.lastOptions ? this.lastOptions.y3 : Math.floor(Math.random() * window.screen.height);
            var options = [
                  {x1: x, y1: y, x2: x,       y2: y + inc, x3: x + inc, y3: y + inc},
                  {x1: x, y1: y, x2: x + inc, y2: y,       x3: x + inc, y3: y + inc},
                  {x1: x, y1: y, x2: x + inc, y2: y      , x3: x + inc, y3: y - inc},
                  {x1: x, y1: y, x2: x      , y2: y - inc, x3: x + inc, y3: y - inc},
                  {x1: x, y1: y, x2: x,       y2: y - inc, x3: x - inc, y3: y - inc},
                  {x1: x, y1: y, x2: x - inc, y2: y      , x3: x - inc, y3: y - inc},
                  {x1: x, y1: y, x2: x - inc, y2: y,       x3: x - inc, y3: y + inc},
                  {x1: x, y1: y, x2: x,       y2: y + inc, x3: x - inc, y3: y + inc},
                ]
              , chosen = /*this.lastChosen ? (Math.floor(Math.random()) ? this.lastChosen + 1 : this.lastChosen - 1) :*/ Math.floor(Math.random() * options.length);

            chosen = chosen == 4 ? 0 : chosen;
            this.lastChosen = chosen;
            this.lastOptions = options[chosen];

            return options[chosen];
        },

        getPositionNarrow: function(x, y) {
            return this.getPosition(100, x, y);
        },

        getPositionWide: function(x, y) {
            return this.getPosition(200, x, y);
        },

        createSectionNarrow: function(colour, size) {
            this.createSection(this.getPositionNarrow(), colour, size);
        },

        createSectionWide: function(colour, size) {
            this.createSection(this.getPositionWide(), colour, size);
        },

        createSection: function(positions, colour, size) {
            var x1 = positions.x1, y1 = positions.y1
              , x2 = positions.x2, y2 = positions.y2
              , x3 = positions.x3, y3 = positions.y3;
            var line, circle1, circle2;
            circle1 = this.paper.circle(x1,y1,size)
                .attr("fill", colour)
                .attr("stroke-width", 0)
                .attr("fill-opacity", this.opacity)
                .toBack();
            circle2 = this.paper.circle(x1, y1, size)
                .attr("fill", colour)
                .attr("stroke-width", 0)
                .attr("fill-opacity", this.opacity)
                .toBack();
            line = this.paper.path("M" + x1 + "," + y1 + 
                                   "C" + x1 + "," + y1 + 
                                   "," + x1 + "," + y1 + 
                                   "," + x1 + "," + y1)
                .attr("stroke", colour)
                .attr("stroke-width", size * 2)
                .attr("stroke-opacity", this.opacity)
                .toBack();

            line.animate({path: "M" + x1 + "," + y1 + 
                         "C" + x1 + "," + y1 + 
                         "," + x2 + "," + y2 + 
                         "," + x3 + "," + y3}, 1000);
            circle2.animate({transform: "T" + (x3 - x1) + "," + (y3 - y1)}, 1000);

            return this; 
            
        },

        randColor: function() {
            var colors = ["00b196", "797e89", "3a3f56", "c9cc38", "32baec", "aa519a", "4058a4"]
              , rand = Math.floor(Math.random() * colors.length);
            return "#" + colors[rand];
        }
    });

}());

(function() {
{'fraction_non_alphanumeric': 0.15677352637021716, 'fraction_numerical': 0.03195449844881076, 'mean_word_length': 1.3393807450411224, 'pattern_counts': {'":': 0, '<': 5, '<?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': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7014925', 'n_tokens_mistral': 3291, 'n_tokens_neox': 3048, 'n_words': 727}