<commit_before>var ViewManager = (function() {
  function setTitle(title) {
    if (!title) {
      $id('view-title').textContent = '';
    } else {
      $id('view-title').textContent = ' - ' + title;
    }
  }

  function reset() {
    $expr('#container .item').forEach(function reset_func(elem) {
      var viewId = elem.dataset.linkedView;
      if (!viewId) {
        return;
      }

      var linkedView = $id(viewId);
      if (!linkedView) {
        return;
      }

      linkedView.dataset.shown = false;
    });
  }

  function showContent(viewId, showData) {
    var viewElem = $id(viewId);
    if (!viewElem) {
      return;
    }
    var viewOldId = null;
    var contentView = $expr('#container .item');
    for (var i = 0; i < contentView.length; i++) {
      var oldId = contentView[i].dataset.linkedView;
      if (!oldId) {
        continue;
      }
      var linkedView = $id(oldId);
      if (!linkedView) {
        continue;
      }
      if (viewId == 'connect-view') {
        linkedView.dataset.firstshown = false;
      }
      if (linkedView.dataset.shown == "true") {
        viewOldId = oldId;
        continue;
      } else {
        continue;
      }
    }

    if ( !! viewOldId) {
      if (viewOldId == viewId) {
        return;
      }
      if (viewOldId == "contact-view") {
        var sub = $id('contact-edit-view');
        if (sub.hidden == false) {
          new AlertDialog(_('save-contacts-confirm'), true, function (returnBtn) {
            if(returnBtn) {
              $id(viewOldId).dataset.shown = false;
              switchContent(viewId, showData, viewElem);
            }
          });
          return;
        }
      } else if (viewOldId == "sms-view") {
        var sub = $id('sender-ctn-input');
        if (sub.hidden == false && sub.value.length > 0) {
          new AlertDialog(_('send-sms-confirm'), true, function (returnBtn) {
            if(returnBtn) {
              $id(viewOldId).dataset.shown = false;
              switchContent(viewId, showData, viewElem);
            }
          });
          return;
        }
      }
      $id(viewOldId).dataset.shown = false;
    }
    switchContent(viewId, showData, viewElem);
  }

  function switchContent(viewId, showData, viewElem) {
    viewElem.dataset.shown = true;
    if (viewId == "summary-view" || viewId == "connect-view" || viewId == "music-view" || viewId == "gallery-view" || viewId == "video-view") {
      $id('views').classList.add('hidden-views');
      $id('content').classList.remove('narrow-content');
    } else {
      $id('views').classList.remove('hidden-views');
      $id('content').classList.add('narrow-content');<commit_msg>fixed view switch<commit_after>var ViewManager = (function() {
  function setTitle(title) {
    if (!title) {
      $id('view-title').textContent = '';
    } else {
      $id('view-title').textContent = ' - ' + title;
    }
  }

  function reset() {
    $expr('#container .item').forEach(function reset_func(elem) {
      var viewId = elem.dataset.linkedView;
      if (!viewId) {
        return;
      }

      var linkedView = $id(viewId);
      if (!linkedView) {
        return;
      }

      linkedView.dataset.shown = false;
    });
  }

  function showContent(viewId, showData) {
    var viewElem = $id(viewId);
    if (!viewElem) {
      return;
    }
    var viewOldId = null;
    var contentView = $expr('#container .item');
    for (var i = 0; i < contentView.length; i++) {
      var oldId = contentView[i].dataset.linkedView;
      if (!oldId) {
        continue;
      }
      var linkedView = $id(oldId);
      if (!linkedView) {
        continue;
      }
      if (viewId == 'connect-view') {
        linkedView.dataset.firstshown = false;
      }
      if (linkedView.dataset.shown == "true") {
        viewOldId = oldId;
        continue;
      } else {
        continue;
      }
    }

    if ( !! viewOldId) {
      if (viewOldId == viewId) {
        return;
      }
      if (viewOldId == "contact-view" && viewId != 'connect-view') {
        var sub = $id('contact-edit-view');
        if (sub.hidden == false) {
          new AlertDialog(_('save-contacts-confirm'), true, function (returnBtn) {
            if(returnBtn) {
              $id(viewOldId).dataset.shown = false;
              switchContent(viewId, showData, viewElem);
            }
          });
          return;
        }
      } else if (viewOldId == "sms-view" && viewId != 'connect-view') {
        var sub = $id('sender-ctn-input');
        if (sub.hidden == false && sub.value.length > 0) {
          new AlertDialog(_('send-sms-confirm'), true, function (returnBtn) {
            if(returnBtn) {
              $id(viewOldId).dataset.shown = false;
              switchContent(viewId, showData, viewElem);
            }
          });
          return;
        }
      }
      $id(viewOldId).dataset.shown = false;
    }
    switchContent(viewId, showData, viewElem);
  }

  function switchContent(viewId, showData, viewElem) {
    viewElem.dataset.shown = true;
    if (viewId == "summary-view" || viewId == "connect-view" || viewId == "music-view" || viewId == "gallery-view" || viewId == "video-view") {
      $id('views').classList.add('hidden-views');
      $id('content').classList.remove('narrow-content');
    } else {
      $id('views').classList.remove('hidden-views');
      $id('content').classList.add('narrow-content');
{'fraction_non_alphanumeric': 0.15832406377456434, 'fraction_numerical': 0.0007415647015202076, 'mean_word_length': 2.0531975099037916, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4706663', 'n_tokens_mistral': 1709, 'n_tokens_neox': 1678, 'n_words': 317}