<commit_before>import i18n from '../../i18n';
import popupWidget from '../shared/popup';
import backbutton from '../../backbutton';
import gameApi from '../../lichess/game';
import settings from '../../settings';
import helper from '../helper';
import formWidgets from '../shared/form';
import m from 'mithril';

export default {

  controller: function(root) {
    let isOpen = false;

    function open() {
      backbutton.stack.push(close);
      isOpen = true;
    }

    function close(fromBB) {
      if (fromBB !== 'backbutton' && isOpen) backbutton.stack.pop();
      isOpen = false;
    }

    return {
      open: open,
      close: close,
      isOpen: function() {
        return isOpen;
      },
      root
    };
  },

  view: function(ctrl) {
    return popupWidget(
      'analyse_menu',
      null,
      renderAnalyseMenu.bind(undefined, ctrl.root),
      ctrl.isOpen(),
      ctrl.close
    );
  }
};

function renderAnalyseMenu(ctrl) {

  return m('div.analyseMenu', [
    m('button', {
      key: 'startNewAnalysis',
      config: helper.ontouch(ctrl.startNewAnalysis)
    }, [m('span[data-icon=A]'), i18n('startNewAnalysis')]),
    ctrl.source === 'offline' || !gameApi.playable(ctrl.data) ? m('button[data-icon=U]', {
      key: 'continueFromHere',
      config: helper.ontouch(() => ctrl.continuePopup.open(ctrl.vm.step.fen))
    }, i18n('continueFromHere')) : null,
    ctrl.source === 'offline' || !gameApi.playable(ctrl.data) ? m('button', {
      key: 'boardEditor',
      config: helper.ontouch(() => m.route(`/editor/${encodeURIComponent(ctrl.vm.step.fen)}`))
    }, [m('span.fa.fa-pencil'), i18n('boardEditor')]) : null,
    m('button', {
      key: 'importPGN',
      config: helper.ontouch(() => {
        ctrl.menu.close();
        ctrl.importPgnPopup.open();
      })
    }, [m('span.fa.fa-upload'), i18n('importGame')]),
    ctrl.ceval.allowed() ? m('div.action', {
      key: 'enableCeval'
    }, [
      formWidgets.renderCheckbox(
        i18n('enableLocalComputerEvaluation'), 'allowCeval', settings.analyse.enableCeval,
        v => {
          ctrl.ceval.toggle();
          if (v) ctrl.initCeval();
          else ctrl.ceval.destroy();
        }
      ),
      m('small.caution', i18n('localEvalCaution'))
    ]) : null,
    ctrl.ceval.allowed() && settings.analyse.enableCeval() ? m('div.action', {
      key: 'showBestMove'
    }, [
      formWidgets.renderCheckbox(
        i18n('showBestMove'), 'showBestMove', settings.analyse.showBestMove,
        ctrl.toggleBestMove
      )
    ]) : null
  ]);
}

<commit_msg>Tweak button<commit_after>import i18n from '../../i18n';
import popupWidget from '../shared/popup';
import backbutton from '../../backbutton';
import gameApi from '../../lichess/game';
import settings from '../../settings';
import helper from '../helper';
import formWidgets from '../shared/form';
import m from 'mithril';

export default {

  controller: function(root) {
    let isOpen = false;

    function open() {
      backbutton.stack.push(close);
      isOpen = true;
    }

    function close(fromBB) {
      if (fromBB !== 'backbutton' && isOpen) backbutton.stack.pop();
      isOpen = false;
    }

    return {
      open: open,
      close: close,
      isOpen: function() {
        return isOpen;
      },
      root
    };
  },

  view: function(ctrl) {
    return popupWidget(
      'analyse_menu',
      null,
      renderAnalyseMenu.bind(undefined, ctrl.root),
      ctrl.isOpen(),
      ctrl.close
    );
  }
};

function renderAnalyseMenu(ctrl) {

  return m('div.analyseMenu', [
    m('button', {
      key: 'startNewAnalysis',
      config: helper.ontouch(ctrl.startNewAnalysis)
    }, [m('span[data-icon=A].withIcon'), i18n('startNewAnalysis')]),
    ctrl.source === 'offline' || !gameApi.playable(ctrl.data) ? m('button[data-icon=U]', {
      key: 'continueFromHere',
      config: helper.ontouch(() => ctrl.continuePopup.open(ctrl.vm.step.fen))
    }, i18n('continueFromHere')) : null,
    ctrl.source === 'offline' || !gameApi.playable(ctrl.data) ? m('button', {
      key: 'boardEditor',
      config: helper.ontouch(() => m.route(`/editor/${encodeURIComponent(ctrl.vm.step.fen)}`))
    }, [m('span.fa.fa-pencil'), i18n('boardEditor')]) : null,
    m('button', {
      key: 'importPGN',
      config: helper.ontouch(() => {
        ctrl.menu.close();
        ctrl.importPgnPopup.open();
      })
    }, [m('span.fa.fa-upload'), i18n('importGame')]),
    ctrl.ceval.allowed() ? m('div.action', {
      key: 'enableCeval'
    }, [
      formWidgets.renderCheckbox(
        i18n('enableLocalComputerEvaluation'), 'allowCeval', settings.analyse.enableCeval,
        v => {
          ctrl.ceval.toggle();
          if (v) ctrl.initCeval();
          else ctrl.ceval.destroy();
        }
      ),
      m('small.caution', i18n('localEvalCaution'))
    ]) : null,
    ctrl.ceval.allowed() && settings.analyse.enableCeval() ? m('div.action', {
      key: 'showBestMove'
    }, [
      formWidgets.renderCheckbox(
        i18n('showBestMove'), 'showBestMove', settings.analyse.showBestMove,
        ctrl.toggleBestMove
      )
    ]) : null
  ]);
}


{'fraction_non_alphanumeric': 0.1787524366471735, 'fraction_numerical': 0.007017543859649123, 'mean_word_length': 2.6834170854271355, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '2116329', 'n_tokens_mistral': 1703, 'n_tokens_neox': 1675, 'n_words': 291}