<commit_before>class GUI {

  constructor(game) {

    this.game = game;

    this.componentElementMap = {
      'raw': ['commandInput', 'runInTerminalDiv']
    };

    this.selections = {};

    this.selectStart = new CoordForm(
      document.getElementById('selectStartX'),
      document.getElementById('selectStartY'),
      document.getElementById('selectStartZ')
    );

    this.selectEnd = new CoordForm(
      document.getElementById('selectEndX'),
      document.getElementById('selectEndY'),
      document.getElementById('selectEndZ')
    );

    this.cutawayForm = new CutawayForm(
      document.getElementById('axisButton'),
      document.getElementById('operationButton'),
      document.getElementById('cutawayValue')
    );

    this.container = document.createElement('div');
    document.body.appendChild( this.container );
    this.container.appendChild(this.game.mapRender.renderer.domElement);

    document.addEventListener('keydown', (e)=>{
      const questionMarkCode = 191;      
      if (e.keyCode == questionMarkCode && e.shiftKey) {e.preventDefault(); $('#controlsDisplay').modal('toggle');}
    });

    // stop key events triggering inside text fields
    Array.from(document.querySelectorAll('input[type=text]')).map((elem)=>{
      elem.addEventListener('keydown', (e)=>{e.stopPropagation();});
    });

    this.selectStart.addEventListener('input', ()=>{this.game.mapRender.removeSelectBox(); this.game.mapRender.requestRender()});
    this.selectEnd.addEventListener('input', ()=>{this.game.mapRender.removeSelectBox(); this.game.mapRender.requestRender()});
  
    let toolButtonListeners = [
      {buttonID: 'moveTool', eventListener: this.clearSelection.bind(this)},
      {buttonID: 'interactTool', eventListener: this.clearSelection.bind(this)},
      {buttonID: 'inspectTool', eventListener: this.clearSelection.bind(this)},
      {buttonID: 'digTool', eventListener: ()=>{this.clearSelection(); this.slowRender(this);}},
      {buttonID: 'placeTool', eventListener: ()=>{this.clearSelection(); this.slowRender(this);}}
    ];
  
    for (let toolButtonInfo of toolButtonListeners) {
      let button = document.getElementById(toolButtonInfo.buttonID).parentElement;
      button.addEventListener('click', toolButtonInfo.eventListener);
    }
  <commit_msg>beginning to move element references to GUI<commit_after>class GUI {

  constructor(game) {

    this.game = game;

    this.componentElementMap = {
      'raw': ['commandInput', 'runInTerminalDiv']
    };

    this.selections = {};

    this.selectStart = new CoordForm(
      document.getElementById('selectStartX'),
      document.getElementById('selectStartY'),
      document.getElementById('selectStartZ')
    );

    this.selectEnd = new CoordForm(
      document.getElementById('selectEndX'),
      document.getElementById('selectEndY'),
      document.getElementById('selectEndZ')
    );

    this.cutawayForm = new CutawayForm(
      document.getElementById('axisButton'),
      document.getElementById('operationButton'),
      document.getElementById('cutawayValue')
    );

    // Lots of UI elements gathered here so they can all be referenced from one place.
    let propertyToIdMap = {
      'moveToolButton': 'moveTool',
      'interactToolButton': 'interactTool',
      'inspectToolButton': 'inspectTool',
      'digToolButton': 'digTool',
      'placeToolButton': 'placeTool',
    }
    
    for (let propertyName in propertyToIdMap) {
      this[propertyName] = document.getElementById(propertyToIdMap[propertyName]);
    }
    

    this.container = document.createElement('div');
    document.body.appendChild( this.container );
    this.container.appendChild(this.game.mapRender.renderer.domElement);

    document.addEventListener('keydown', (e)=>{
      const questionMarkCode = 191;      
      if (e.keyCode == questionMarkCode && e.shiftKey) {e.preventDefault(); $('#controlsDisplay').modal('toggle');}
    });

    // stop key events triggering inside text fields
    Array.from(document.querySelectorAll('input[type=text]')).map((elem)=>{
      elem.addEventListener('keydown', (e)=>{e.stopPropagation();});
    });

    this.selectStart.addEventListener('input', ()=>{this.game.mapRender.removeSelectBox(); this.game.mapRender.requestRender()});
    this.selectEnd.addEventListener('input', ()=>{this.game.mapRender.removeSelectBox(); this.game.mapRender.requestRender()});

    let toolButtonListeners = {
      [this.moveToolButton]: this.clearSelection.bind(this),
      [this.interactToolButton]: this.clearSelection.bind(this),
      [this.inspectToolButton]: this.clearSelection.bind(this),
      [this.digToolButton]: ()=>{this.clearSelection(); this.slowRender(this);},
      [this.placeToolButton]: ()=>{this.clearSelection(); this.slowRender(this);}
    }
  
    for (let toolButton of toolButtonListeners) {
      toolButton.addEventListener('click', toolButtonListeners[toolButton]);
    }
  
{'fraction_non_alphanumeric': 0.1479757085020243, 'fraction_numerical': 0.0012145748987854252, 'mean_word_length': 4.114906832298137, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '1842549', 'n_tokens_mistral': 1381, 'n_tokens_neox': 1348, 'n_words': 215}