<commit_before>var guiStatus;

function GuiStatus() {
  /* Using two properties:
    editingFiber -> fiber currently being edited
    editingCP -> CP of the fiber in current edition
    editingRegion -> region currently being edited.
  editingFiber and editingRegion must never be defined at the same time.

  Featuring three methods:
    editing, which recieves as input:
      element, with 'fiber', 'CP' or 'region' as string value.
      index, which specifies its index
    viewing, which removes any editing state. Constructor leaves status this way.
    retrieve, which brings back the state in which it the editor was

    *TO BE CHECKED* apply method usability.
*/
    this.previewing = false;
    document.getElementById("switchViewButton").disabled = true;

    this.editingFiber = undefined;
    this.editingCP = undefined;
    this.editingRegion = undefined;
}

GuiStatus.prototype = {
  editing: function(element, index) {
    this.previewing = false;

    switch (element) {
      case 'fiber':
        this.unediting();
        this.editingFiber = index;
        break;
      case 'CP':
        if (this.editingFiber === undefined) {
          console.error('Tried to edit CP with any fiber in edit!');
          break;
        }
        this.editingCP = index;
        break;
      case 'region':
        this.unediting();
        this.editingRegion = index;
        break;
      default: console.error('Element string in status was not correct');
    }

    document.getElementById("switchViewButton").disabled = false;
  },
  retrieve: function() {
    if (this.previewing) {
      phantom.addToScene(scene);
    } else {
      if (this.editingFiber !== undefined) {
        fiberSelectClick(this.editingFiber, true);
        if (this.editingCP !== undefined) {
          cpSelectClick(this.editingFiber, this.editingCP, true);
        }
      } else if (this.editingRegion !== undefined) {
        regionSelectClick(this.editingRegion, true)
      } else {
        phantom.addToScene(scene);
        editExit();
      }
    }
  },
  apply: function(element, index) {
    this.editing(element, index);
    this.retrieve();
  },
  unediting: function() {
    this.previewing = false;
    document.getElementById("switchViewButton").value = "Preview";
    document.getElementById("switchViewButton").disabled = true;

    this.editingFiber = undefined;
    this.editingCP = undefined;
    this.editingRegion = undefined;
  }
}
<commit_msg>Fixed a bug regarding the preview button behavior<commit_after>var guiStatus;

function GuiStatus() {
  /* Using two properties:
    editingFiber -> fiber currently being edited
    editingCP -> CP of the fiber in current edition
    editingRegion -> region currently being edited.
  editingFiber and editingRegion must never be defined at the same time.

  Featuring three methods:
    editing, which recieves as input:
      element, with 'fiber', 'CP' or 'region' as string value.
      index, which specifies its index
    viewing, which removes any editing state. Constructor leaves status this way.
    retrieve, which brings back the state in which it the editor was

    *TO BE CHECKED* apply method usability.
*/
    this.previewing = false;
    document.getElementById("switchViewButton").disabled = true;

    this.editingFiber = undefined;
    this.editingCP = undefined;
    this.editingRegion = undefined;
}

GuiStatus.prototype = {
  editing: function(element, index) {
    switch (element) {
      case 'fiber':
        this.unediting();
        this.editingFiber = index;
        break;
      case 'CP':
        if (this.editingFiber === undefined) {
          console.error('Tried to edit CP with any fiber in edit!');
          break;
        }
        this.editingCP = index;
        break;
      case 'region':
        this.unediting();
        this.editingRegion = index;
        break;
      default: console.error('Element string in status was not correct');
    }

    document.getElementById("switchViewButton").disabled = false;
  },
  retrieve: function() {
    if (this.previewing) {
      phantom.addToScene(scene);
    } else {
      if (this.editingFiber !== undefined) {
        fiberSelectClick(this.editingFiber, true);
        if (this.editingCP !== undefined) {
          cpSelectClick(this.editingFiber, this.editingCP, true);
        }
      } else if (this.editingRegion !== undefined) {
        regionSelectClick(this.editingRegion, true)
      } else {
        phantom.addToScene(scene);
        editExit();
      }
    }
  },
  apply: function(element, index) {
    this.editing(element, index);
    this.retrieve();
  },
  unediting: function() {
    this.previewing = false;
    document.getElementById("switchViewButton").value = "Preview";
    document.getElementById("switchViewButton").disabled = true;

    this.editingFiber = undefined;
    this.editingCP = undefined;
    this.editingRegion = undefined;
  }
}

{'fraction_non_alphanumeric': 0.10349735664904433, 'fraction_numerical': 0.0, 'mean_word_length': 2.75209763539283, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '2168699', 'n_tokens_mistral': 1396, 'n_tokens_neox': 1380, 'n_words': 387}