<commit_before>// Copyright (c) 2016-19 <NAME>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the The GNU Affero General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// You should have received a copy of the GNU Affero General Public
// License along with this library; if not, write to the Free Software
// Foundation, 51 Franklin Street, Suite 500 Boston, MA 02110-1335 USA


function ModeWidget() {
    // Row and column of each halfstep: Note that span cells are
    // counted only once.
    const MODEMAP = [[2, 7], [3, 6], [5, 10], [7, 11], [9, 10], [11, 8], [12, 5], [11, 5], [9, 3], [7, 2], [5, 3], [3, 5]];
    const ROTATESPEED = 125;
    const ORANGE = '#e37a00'; // 5YR
    const BUTTONDIVWIDTH = 535;
    const BUTTONSIZE = 53;
    const ICONSIZE = 32;

    this.init = function(logo, modeBlock) {
        this._logo = logo;
        this._modeBlock = modeBlock;
        this._locked = false;
        this._pitch = this._logo.keySignature[0][0];
        this._noteValue = 0.333;
        this._undoStack = [];
        this._playing = false;
        this._cellColors = [];

        var w = window.innerWidth;
        this._cellScale = w / 1200;
        var iconSize = ICONSIZE * this._cellScale;

        var canvas = docById('myCanvas');

        // Position the widget and make it visible.
        var modeDiv = docById('modeDiv');
        modeDiv.style.visibility = 'visible';
        modeDiv.setAttribute('draggable', 'true');
        modeDiv.style.left = '200px';
        modeDiv.style.top = '150px';

        // The mode buttons
        var modeButtonsDiv = docById('modeButtonsDiv');
        modeButtonsDiv.style.display = 'inline';
        modeButtonsDiv.style.visibility = 'visible';
        modeButtonsDiv.style.width = BUTTONDIVWIDTH;
        modeButtonsDiv.innerHTML = '<table cellpadding="0px" id="modeButtonTable"></table>';

        var buttonTable = docById('modeButtonTable');
        var header = buttonTable.createTHead();
        var row = header.insertRow(0);

        // For the button callbacks
        var that = this;

        var cell = this._addButton(row, 'close-button.svg', ICONSIZE, _('Close'));

        cell.onclick=function() {
            docById('modeDiv').style.visibility = 'hidden';
            docById('modeButtonsDiv').style.visibility = 'hidden';
            docById('modeTableDiv').style.visibility = 'hidden';
            that._logo.hideMsgs();
        }


        var cell = this._addButton(row, 'play-button.svg', ICONSIZE, _('Play all'));

        cell.onclick=function() {
            that._logo.resetSynth(0);
            if (that._playingStatus()) {
                that._playing = false;

                this.innerHTML = '&nbsp;&nbsp;<img src="header-icons/play-button.svg" title="' + _('Play all') + '" alt="' + _('Play all') + '" height="' + ICONSIZE + '" width="' + ICONSIZE + '" vertical-align="middle">&nbsp;&nbsp;';
            } else {
                that._playing = true;

                this.innerHTML = '&nbsp;&nbsp;<img src="header-icons/pause-button.svg" title="' + _('Pause') + '" alt="' + _('Pause') + '" height="' + ICONSIZE + '" width="' + ICONSIZE + '" vertical-align="middle">&nbsp;&nbsp;';

                var table = docById('modeTable');
                for (var i = 0; i < 12; i++) {
                    that._cellColors.push(table.rows[MODEMAP[i][0]].cells[MODEMAP[i][1]].style.backgroundColor);
                }

                that._playAll(this);
            }
        }

        var cell = this._addButton(row, 'export-chunk.svg', ICONSIZE, _('Save'));

        cell.onclick=function() {
            that._save();
        }

        var cell = this._addButton(row, 'erase-button.svg', ICONSIZE, _('Clear'));

        cell.onclick=function() {
            that._clear();<commit_msg>should be stop instead of pause<commit_after>// Copyright (c) 2016-19 <NAME>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the The GNU Affero General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// You should have received a copy of the GNU Affero General Public
// License along with this library; if not, write to the Free Software
// Foundation, 51 Franklin Street, Suite 500 Boston, MA 02110-1335 USA


function ModeWidget() {
    // Row and column of each halfstep: Note that span cells are
    // counted only once.
    const MODEMAP = [[2, 7], [3, 6], [5, 10], [7, 11], [9, 10], [11, 8], [12, 5], [11, 5], [9, 3], [7, 2], [5, 3], [3, 5]];
    const ROTATESPEED = 125;
    const ORANGE = '#e37a00'; // 5YR
    const BUTTONDIVWIDTH = 535;
    const BUTTONSIZE = 53;
    const ICONSIZE = 32;

    this.init = function(logo, modeBlock) {
        this._logo = logo;
        this._modeBlock = modeBlock;
        this._locked = false;
        this._pitch = this._logo.keySignature[0][0];
        this._noteValue = 0.333;
        this._undoStack = [];
        this._playing = false;
        this._cellColors = [];

        var w = window.innerWidth;
        this._cellScale = w / 1200;
        var iconSize = ICONSIZE * this._cellScale;

        var canvas = docById('myCanvas');

        // Position the widget and make it visible.
        var modeDiv = docById('modeDiv');
        modeDiv.style.visibility = 'visible';
        modeDiv.setAttribute('draggable', 'true');
        modeDiv.style.left = '200px';
        modeDiv.style.top = '150px';

        // The mode buttons
        var modeButtonsDiv = docById('modeButtonsDiv');
        modeButtonsDiv.style.display = 'inline';
        modeButtonsDiv.style.visibility = 'visible';
        modeButtonsDiv.style.width = BUTTONDIVWIDTH;
        modeButtonsDiv.innerHTML = '<table cellpadding="0px" id="modeButtonTable"></table>';

        var buttonTable = docById('modeButtonTable');
        var header = buttonTable.createTHead();
        var row = header.insertRow(0);

        // For the button callbacks
        var that = this;

        var cell = this._addButton(row, 'close-button.svg', ICONSIZE, _('Close'));

        cell.onclick=function() {
            docById('modeDiv').style.visibility = 'hidden';
            docById('modeButtonsDiv').style.visibility = 'hidden';
            docById('modeTableDiv').style.visibility = 'hidden';
            that._logo.hideMsgs();
        }


        var cell = this._addButton(row, 'play-button.svg', ICONSIZE, _('Play all'));

        cell.onclick=function() {
            that._logo.resetSynth(0);
            if (that._playingStatus()) {
                that._playing = false;

                this.innerHTML = '&nbsp;&nbsp;<img src="header-icons/play-button.svg" title="' + _('Play all') + '" alt="' + _('Play all') + '" height="' + ICONSIZE + '" width="' + ICONSIZE + '" vertical-align="middle">&nbsp;&nbsp;';
            } else {
                that._playing = true;

                this.innerHTML = '&nbsp;&nbsp;<img src="header-icons/stop-button.svg" title="' + _('Stop') + '" alt="' + _('Stop') + '" height="' + ICONSIZE + '" width="' + ICONSIZE + '" vertical-align="middle">&nbsp;&nbsp;';

                var table = docById('modeTable');
                for (var i = 0; i < 12; i++) {
                    that._cellColors.push(table.rows[MODEMAP[i][0]].cells[MODEMAP[i][1]].style.backgroundColor);
                }

                that._playAll(this);
            }
        }

        var cell = this._addButton(row, 'export-chunk.svg', ICONSIZE, _('Save'));

        cell.onclick=function() {
            that._save();
        }

        var cell = this._addButton(row, 'erase-button.svg', ICONSIZE, _('Clear'));

        cell.onclick=function() {
            that._clear();
{'fraction_non_alphanumeric': 0.14872251175797635, 'fraction_numerical': 0.022880386424304056, 'mean_word_length': 2.342395921835174, 'pattern_counts': {'":': 0, '<': 15, '<?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': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4977128', 'n_tokens_mistral': 2498, 'n_tokens_neox': 2279, 'n_words': 612}