<commit_before>Projects = {
  organizationsWithProjects: function() {
    var projects = [];
    for(var i in my_projects) {
      if(!isNaN(i) && my_projects[i]) {
        var p = my_projects[i];
        p.id = parseInt(i);
        p.my_role = Projects.roles[p.role];
        p.admin = p.role == 3;
        projects.push(p);
      }
    }
    return my_external_organizations.collect(function(org) {
      org.projects = projects.
        select(function(p) {
          return p.organization_id == org.id; }).
        sortBy(function(p) {
          return p.name.toLowerCase(); });
      org.active_projects = org.projects.
        reject(function(p) {
          return p.archived; });
      org.archived_projects = org.projects.
        select(function(p) {
          return p.archived; });
      org.has_archived_projects =
        (org.archived_projects.length > 0) ?
        { count: org.archived_projects.length,
          name: org.name,
          projects: org.archived_projects } :
        false;
      return org;
    }).compact();
  },
  showAllProjects: function() {
    var html = Mustache.to_html(Templates.projects.index, {
      organizations: Projects.organizationsWithProjects()
    });
    Pane.replace(html);
  },
  roles: [
    I18n.translations.roles.observer,
    I18n.translations.roles.commenter,
    I18n.translations.roles.participant,
    I18n.translations.roles.admin
  ],
  fastCommentForm: function() {
    if (!$('project_id')) {
      return;
    }
    var projects_in_orgs = {};
    (new Hash(my_projects)).each(function(p) {
      var org_id = p[1].organization_id;
      if (projects_in_orgs[org_id]) {
        projects_in_orgs[org_id].push(p[0]);
      }
      else {
        projects_in_orgs[org_id] = [p[0]];
      }
    });
    var groups = [];
    my_organizations.each(function(o) {
      var group = new Element('optgroup', { label: o.name });
      projects_in_orgs[o.id].each(function(p) {
        if (!my_projects[p].archived) {
          var project = new Element('option', { value: p }).insert(my_projects[p].name);
          group.insert(project);
        }
      });
      groups.push(group);
      $('project_id').insert(group);
    });

  }
}

document.on('click', 'a.show_archived', function(e,el) {
  e.stop()
  el.hide()
  el.up().next('.archived_projects').appear({duration: 0.2})
})

document.on('click', 'a.delete_project', function(e, el){
	e.preventDefault()
	Prototype.Facebox.open($('delete_project_html').innerHTML, 'html delete_project_box', {
		buttons: [
			{className: 'close', href:'#close', description: I18n.translations.common.cancel},
			{className: 'confirm', href:el.readAttribute('href'), description: I18n.translations.projects.fields.delete_this_project,
			 extra:"data-method='delete'"}
		]
	})
})

document.on("dom:loaded", function () {
  Projects.fastCommentForm();
})

<commit_msg>fix quick comment box, alphabetical order<commit_after>Projects = {
  organizationsWithProjects: function() {
    var projects = [];
    for(var i in my_projects) {
      if(!isNaN(i) && my_projects[i]) {
        var p = my_projects[i];
        p.id = parseInt(i);
        p.my_role = Projects.roles[p.role];
        p.admin = p.role == 3;
        projects.push(p);
      }
    }
    return my_external_organizations.collect(function(org) {
      org.projects = projects.
        select(function(p) {
          return p.organization_id == org.id; }).
        sortBy(function(p) {
          return p.name.toLowerCase(); });
      org.active_projects = org.projects.
        reject(function(p) {
          return p.archived; });
      org.archived_projects = org.projects.
        select(function(p) {
          return p.archived; });
      org.has_archived_projects =
        (org.archived_projects.length > 0) ?
        { count: org.archived_projects.length,
          name: org.name,
          projects: org.archived_projects } :
        false;
      return org;
    }).compact();
  },
  showAllProjects: function() {
    var html = Mustache.to_html(Templates.projects.index, {
      organizations: Projects.organizationsWithProjects()
    });
    Pane.replace(html);
  },
  roles: [
    I18n.translations.roles.observer,
    I18n.translations.roles.commenter,
    I18n.translations.roles.participant,
    I18n.translations.roles.admin
  ],
  fastCommentForm: function() {
    if (!$('project_id')) {
      return;
    }
    var projects_in_orgs = {};
    (new Hash(my_projects)).each(function(p) {
      var org_id = p[1].organization_id;
      if (projects_in_orgs[org_id]) {
        projects_in_orgs[org_id].push([p[0], p[1].name]);
      }
      else {
        projects_in_orgs[org_id] = [[p[0], p[1].name]];
      }
    });
    var groups = [];
    my_organizations.each(function(o) {
      var group = new Element('optgroup', { label: o.name });
      projects_in_orgs[o.id].sortBy(function(p) {return p[1]}).collect(function(p) {return p[0]}).each(function(p) {
        if (!my_projects[p].archived) {
          var project = new Element('option', { value: p }).insert(my_projects[p].name);
          group.insert(project);
        }
      });
      groups.push(group);
      $('project_id').insert(group);
    });

  }
}

document.on('click', 'a.show_archived', function(e,el) {
  e.stop()
  el.hide()
  el.up().next('.archived_projects').appear({duration: 0.2})
})

document.on('click', 'a.delete_project', function(e, el){
	e.preventDefault()
	Prototype.Facebox.open($('delete_project_html').innerHTML, 'html delete_project_box', {
		buttons: [
			{className: 'close', href:'#close', description: I18n.translations.common.cancel},
			{className: 'confirm', href:el.readAttribute('href'), description: I18n.translations.projects.fields.delete_this_project,
			 extra:"data-method='delete'"}
		]
	})
})

document.on("dom:loaded", function () {
  Projects.fastCommentForm();
})


{'fraction_non_alphanumeric': 0.16014356520252948, 'fraction_numerical': 0.007178260126474107, 'mean_word_length': 2.8398950131233596, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1046471', 'n_tokens_mistral': 1998, 'n_tokens_neox': 1957, 'n_words': 289}