<commit_before>(function(app) {
  'use strict';
  var m = require('mithril');

  var sidePanelView = function(ctrl) {
    var state = ctrl.state();
    var searchKeyword = ctrl.searchKeyword();
    var pieceList = ctrl.searchPieceList(searchKeyword);

    return m('#side_panel', {
      className: state
    }, [
      m('input#search_input', {
        type: 'search',
        autocapitalize: 'off',
        autocorrect: 'off',
        value: searchKeyword,
        config: function(element, isInitialized) {
          if (isInitialized)
            return;

          var isFocus = false;
          if (dom.supportsTouch()) {
            document.addEventListener('touchstart', function(event) {
              if (event.target !== element)
                element.blur();
            });
          } else {
            element.addEventListener('blur', function() {
              isFocus = false;
            });
            element.addEventListener('click', function() {
              if (isFocus)
                return;
              isFocus = true;
              if (element.selectionStart === element.selectionEnd)
                element.select();
            });
          }

          var changeListener = function(event) {
            var cache = ctrl.searchKeyword();
            var value = event.target.value;

            if (value === cache)
              return;

            ctrl.dispatchEvent({
              type: 'searchkeywordchange',
              value: value
            });
          };
          element.addEventListener('change', changeListener);
          element.addEventListener('input', changeListener);
        }
      }),
      m('#piece_list', {
        config: function(element, isInitialized) {
          if (isInitialized)
            return;
          setListItemDragEvent(ctrl, element, function(event) {
            ctrl.dispatchEvent(event);
          });
        }
      }, [
        m('#piece_list_content', pieceList.map(function(item) {
          return m('.piece-list-item', [
            m('.piece-list-item-container', {
              className: dom.supportsTouch() ? '' : 'hoverable',
              'data-piece-src': item.src
            }, [
              m('.piece-list-item-header', item.label),
              m('.piece-list-item-content', item.description)
            ])
          ]);
        }))
      ]),
      m('#divider', [
        m('#divider_icon', {
          config: function(element, isInitialized) {
            if (isInitialized)
              return;

            dom.pointerEvent('#divider_icon', {
              ontap: function() {
                ctrl.dispatchEvent({type: 'toggle'});
                dom.setCursor('default');
                dom.removeClass(element, 'tap');
              },
              onstart: function() {
                dom.addClass(element, 'tap');
                dom.removeKeyboardFocus();
                dom.setCursor('pointer');
              },
              onout: function() {
                dom.removeClass(element, 'tap');
              },
              onover: function() {
                dom.addClass(element, 'tap');
              }
            });
          }
        })
      ])
    ]);
  };

  var setListItemDragEvent = (function() {
    var isTouchEnabled = dom.supportsTouch();
    var START = isTouchEnabled ? 'touchstart' : 'mousedown';
    var MOVE = isTouchEnabled ? 'touchmove' : 'mousemove';<commit_msg>Fix cursor style when the divider tapped<commit_after>(function(app) {
  'use strict';
  var m = require('mithril');

  var sidePanelView = function(ctrl) {
    var state = ctrl.state();
    var searchKeyword = ctrl.searchKeyword();
    var pieceList = ctrl.searchPieceList(searchKeyword);

    return m('#side_panel', {
      className: state
    }, [
      m('input#search_input', {
        type: 'search',
        autocapitalize: 'off',
        autocorrect: 'off',
        value: searchKeyword,
        config: function(element, isInitialized) {
          if (isInitialized)
            return;

          var isFocus = false;
          if (dom.supportsTouch()) {
            document.addEventListener('touchstart', function(event) {
              if (event.target !== element)
                element.blur();
            });
          } else {
            element.addEventListener('blur', function() {
              isFocus = false;
            });
            element.addEventListener('click', function() {
              if (isFocus)
                return;
              isFocus = true;
              if (element.selectionStart === element.selectionEnd)
                element.select();
            });
          }

          var changeListener = function(event) {
            var cache = ctrl.searchKeyword();
            var value = event.target.value;

            if (value === cache)
              return;

            ctrl.dispatchEvent({
              type: 'searchkeywordchange',
              value: value
            });
          };
          element.addEventListener('change', changeListener);
          element.addEventListener('input', changeListener);
        }
      }),
      m('#piece_list', {
        config: function(element, isInitialized) {
          if (isInitialized)
            return;
          setListItemDragEvent(ctrl, element, function(event) {
            ctrl.dispatchEvent(event);
          });
        }
      }, [
        m('#piece_list_content', pieceList.map(function(item) {
          return m('.piece-list-item', [
            m('.piece-list-item-container', {
              className: dom.supportsTouch() ? '' : 'hoverable',
              'data-piece-src': item.src
            }, [
              m('.piece-list-item-header', item.label),
              m('.piece-list-item-content', item.description)
            ])
          ]);
        }))
      ]),
      m('#divider', [
        m('#divider_icon', {
          config: function(element, isInitialized) {
            if (isInitialized)
              return;

            dom.pointerEvent('#divider_icon', {
              ontap: function() {
                ctrl.dispatchEvent({type: 'toggle'});
                dom.setCursor('default');
                dom.removeClass(element, 'tap');
              },
              onstart: function() {
                dom.addClass(element, 'tap');
                dom.removeKeyboardFocus();
                dom.setCursor('pointer');
              },
              onout: function() {
                dom.removeClass(element, 'tap');
                dom.setCursor('default');
              },
              onover: function() {
                dom.addClass(element, 'tap');
                dom.setCursor('pointer');
              }
            });
          }
        })
      ])
    ]);
  };

  var setListItemDragEvent = (function() {
    var isTouchEnabled = dom.supportsTouch();
    var START = isTouchEnabled ? 'touchstart' : 'mousedown';
    var MOVE = isTouchEnabled ? 'touchmove' : 'mousemove';
{'fraction_non_alphanumeric': 0.13011632916846186, 'fraction_numerical': 0.0, 'mean_word_length': 1.5259339862169023, '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': '2459399', 'n_tokens_mistral': 1789, 'n_tokens_neox': 1753, 'n_words': 321}