<commit_before>/*
 * theminesweeper
 * https://github.com/leosartaj/jquery.minesweeper.js
 *
 * Copyright (c) 2014 <NAME>
 * Licensed under the MIT license.
 */

(function($) {

    var levels = [
        { height: 8 , width: 8 }
    ];

    // Defines the widget
    $.widget('ss.theminesweeper', {

        
        // widget currrent version
        version: '0.1.0',

        options: {
            levels: levels
        },

        _create: function() {
            this.element.addClass('ss-minesweeper');
            this._createWrapper();
            this._createButtons();
            this._renderMarkup();
        },
        
        _createWrapper: function() {
            var el = $('<div/>'), display;

            this.shell = el.clone().addClass('ss-minesweeper-shell');
            display = el.clone().addClass('ss-minesweeper-display').appendTo(this.shell);
        },

        _createButtons: function() {
            var el = $('<button/>'), container = $('<div/>').addClass('ss-minesweeper-buttons'), i = 0, j, level = this.options.levels[0], height = level.height, width = level.width, buttons = [];

            for(i = 0; i < width; i++) {
                for(j = 0; j < height; j++) {
                    if( j === 0) {
                        buttons.push({label: '', classname: 'ss-minesweeper-left'});
                    }
                    else {
                        buttons.push({label: ''})
                    }
                }
            }

            $.each(buttons, function(i, button) {
                var btn = el.clone().text(button.label).appendTo(container).button();
                if(!!button.classname) {
                    btn.addClass(button.classname);
                }

                if(!!button.classname) {
                    btn.addClass(button.classname);
                }

            });

                container.appendTo(this.shell);
        },

        _renderMarkup: function() {
            this.shell.appendTo(this.element);
        }

    });

}(jQuery));<commit_msg>random mine generation<commit_after>/*
 * theminesweeper
 * https://github.com/leosartaj/jquery.minesweeper.js
 *
 * Copyright (c) 2014 <NAME>
 * Licensed under the MIT license.
 */

(function($) {

    var levels = [
        { height: 8 , width: 8, mines: 10 }
    ];

    // Defines the widget
    $.widget('ss.theminesweeper', {

        
        // widget currrent version
        version: '0.1.0',

        options: {
            levels: levels
        },

        _create: function() {
            this.element.addClass('ss-minesweeper');
            this._createWrapper();
            this._createButtons();
            this._generateMines();
            this._renderMarkup();

            this._on({
                'click button': this._clickHandler
            });
        },
        
        _createWrapper: function() {
            var el = $('<div/>'), display;

            this.shell = el.clone().addClass('ss-minesweeper-shell');
            display = el.clone().addClass('ss-minesweeper-display').appendTo(this.shell);
        },

        _createButtons: function() {
            var el = $('<button/>'), container = $('<div/>').addClass('ss-minesweeper-buttons'), i = 0, j, level = this.options.levels[0], height = level.height, width = level.width, buttons = [];

            for(i = 0; i < width; i++) {
                buttons[i] = [];
                for(j = 0; j < height; j++) {
                    if( j === 0) {
                        buttons[i][j] = {label: '', mine: 'n', classname: 'ss-minesweeper-left'};
                    }
                    else {
                        buttons[i][j] = {label: '', mine: 'n'};
                    }
                }
            }

            $.each(buttons, function(i, button) {
                $.each(button, function(i, but) {
                    var btn = el.clone().text(but.label).appendTo(container).button();
                    if(!!but.classname) {
                        btn.addClass(but.classname);
                    }

                    if(!!but.classname) {
                        btn.addClass(but.classname);
                    }
                });
            });
            level.buttons = buttons;
            container.appendTo(this.shell);
        },

        _renderMarkup: function() {
            this.shell.appendTo(this.element);
        },

        _setOptions: function() {
            this._superApply(arguments);
        },

        _setOption: function(key, val) {
            this._super(key, val);

            if(key === 'levels') {
                this.shell.find('button').remove();
                this._createButtons();
                this._renderMarkup();
            }
            else if(key === 'disable') {
                this.shell.find('button').button('option', key, val);
            }
        },

        _generateMines: function() {
            var level = this.options.levels[0],mines = level.mines, width = level.width, height = level.height, x, y;

            while(mines !== 0) {
                x = Math.floor(width * Math.random());
                y = Math.floor(height * Math.random());
                level.buttons[x][y].mine = 'y';
                mines--;
            }


        },

        _clickHandler: function() {

        }

    });

}(jQuery));
{'fraction_non_alphanumeric': 0.1518608565550776, 'fraction_numerical': 0.005984664297737049, 'mean_word_length': 1.3559471365638767, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 11, 'https://': 2, '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': '3308162', 'n_tokens_mistral': 1538, 'n_tokens_neox': 1437, 'n_words': 258}