<commit_before>(function(){
  'use strict';
  var app = window.LS || (window.LS = {});
  var u = app.utils;

  // Document module
  app.document = {vm: {}};
  app.document.vm.init = function() {
    var vm = this;
    vm.id = m.prop(m.route.param("id"));
    vm.action = m.route.param("action");
    vm.readOnly = true; 
    vm.contentType = m.prop("");
    vm.updatedTags = m.prop("");
    vm.content = "";
    vm.binary = false;
    vm.image = false;
    vm.tags = [];
    try {
      vm.ext = vm.id().match(/\.(.+)$/)[1];
    } catch(e) {
      vm.ext = "";
    }
    
    // Retrieve single document & update relevant variables
    vm.getDoc = function(cb){
      vm.doc = Doc.get(vm.id());
      vm.doc.then(function(doc){
        vm.content = doc.data;
        vm.tags = doc.tags;
        vm.updatedTags(vm.tags.filter(function(t){return !/^\$/.test(t)}).join(", "));
        if (vm.tags.filter(function(t){return t === "$format:binary"}).length > 0) {
          vm.binary = true;
          if (vm.tags.filter(function(t){return t === "$type:image"}).length > 0) {
            vm.image = true;
          }
        }
      }, vm.flashError);
    };
    
    // Reset some properties based on action
    switch (vm.action) {
      case 'create':
        vm.readOnly = false;
        vm.content = "";
        break;
      case 'edit':
        vm.getDoc();
        vm.readOnly = false;
        break;
      case 'view':<commit_msg>Fixed error in determining file extension. * Closes #36.<commit_after>(function(){
  'use strict';
  var app = window.LS || (window.LS = {});
  var u = app.utils;

  // Document module
  app.document = {vm: {}};
  app.document.vm.init = function() {
    var vm = this;
    vm.id = m.prop(m.route.param("id"));
    vm.action = m.route.param("action");
    vm.readOnly = true; 
    vm.contentType = m.prop("");
    vm.updatedTags = m.prop("");
    vm.content = "";
    vm.binary = false;
    vm.image = false;
    vm.tags = [];
    try {
      vm.ext = vm.id().match(/\.([a-z0-9]+)$/i)[1];
    } catch(e) {
      vm.ext = "";
    }
    
    // Retrieve single document & update relevant variables
    vm.getDoc = function(cb){
      vm.doc = Doc.get(vm.id());
      vm.doc.then(function(doc){
        vm.content = doc.data;
        vm.tags = doc.tags;
        vm.updatedTags(vm.tags.filter(function(t){return !/^\$/.test(t)}).join(", "));
        if (vm.tags.filter(function(t){return t === "$format:binary"}).length > 0) {
          vm.binary = true;
          if (vm.tags.filter(function(t){return t === "$type:image"}).length > 0) {
            vm.image = true;
          }
        }
      }, vm.flashError);
    };
    
    // Reset some properties based on action
    switch (vm.action) {
      case 'create':
        vm.readOnly = false;
        vm.content = "";
        break;
      case 'edit':
        vm.getDoc();
        vm.readOnly = false;
        break;
      case 'view':
{'fraction_non_alphanumeric': 0.19094960575934178, 'fraction_numerical': 0.0034281796366129585, 'mean_word_length': 1.9356136820925554, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '3806293', 'n_tokens_mistral': 994, 'n_tokens_neox': 985, 'n_words': 194}