<commit_before>Template.contactUsMessageList.helpers({
  contactUsMessages: function() {
    return ContactUsMessages.find();
  },
});

Template.contactUs.onRendered(function () {
  // TODO make reactive based on Meteor.user(), so a logout action causes a clearing of email and other default values?
  if (Meteor.user()) {
    // Set on-screen email address to same as logged-in user
    // TODO pick an "active" email address rather than just the first email address
    $('#email').val(Meteor.user().emails[0].address);
  } else {
    $('#email').val("");
  };
});

Template.contactUs.events({
  'submit #contact-us-form': function (event) {
    event.preventDefault();
    console.log("submit contact-us-form, event: ", event);

    $('#button-submit').text("Submitting message...");
    $('#button-submit').prop( "disabled", true );

    // TODO let user know message stored.
    // TODO re-enable button once message stored.
    
    var message = {
      name: $('#name').val(),
      email: $('#email').val(),
      zip: $('#zip').val(),
      text: $('#message').val(),<commit_msg>Retrieve Contact Us from event on submit<commit_after>Template.contactUsMessageList.helpers({
  contactUsMessages: function() {
    return ContactUsMessages.find();
  },
});

Template.contactUs.onRendered(function () {
  // TODO make reactive based on Meteor.user(), so a logout action causes a clearing of email and other default values?
  if (Meteor.user()) {
    // Set on-screen email address to same as logged-in user
    // TODO pick an "active" email address rather than just the first email address
    $('#email').val(Meteor.user().emails[0].address);
  } else {
    $('#email').val("");
  };
});

Template.contactUs.events({
  'submit #contact-us-form': function (event) {
    event.preventDefault();
    console.log("submit contact-us-form, event: ", event);

    Template.contactUs.mishaEvent = event;
    
    $('#button-submit').text("Submitting message...");
    $('#button-submit').prop( "disabled", true );

    // TODO let user know message stored.
    // TODO re-enable button once message stored.
    
    var message = {
      name: event.target.name.value,  // alternative: $('#name').val()
      email: event.target.email.value,
      zip: event.target.zip.value,
      text: event.target.message.value,
{'fraction_non_alphanumeric': 0.16414686825053995, 'fraction_numerical': 0.0008639308855291577, 'mean_word_length': 3.337078651685393, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6951907', 'n_tokens_mistral': 668, 'n_tokens_neox': 669, 'n_words': 187}