<commit_before>library client.authen;

import 'dart:html';
import 'package:StupidBirdExpress/client/parse.dart';

void main() {
  String sequence;
  InputElement receiverNameInput = querySelector('#receiverName');
  InputElement receiverEmailInput = querySelector('#receiverEmail');
  ButtonElement submitButton = querySelector('.submit-btn');
  //  is reply
  if (!window.location.search.isEmpty) {
    //protect form
    submitButton.disabled = true;
    //get sequence
    String search = window.location.search.substring(1);
    int position = search.indexOf('=');
    if (search.substring(0, position) == 'id') {
      sequence = search.substring(position);
    }
    //set receiverName, receiverEmail(not alloewd to chage)
    downloadMsg(sequence).then((Message msg) {
      receiverNameInput.value = msg.sendname;
      querySelector('#receiverEmailInfo').text = '寄件者是不公開的喔！已經幫你填好收件者郵件地址了。';
      querySelector('#receiverEmailInfoEn').text = "The sender's email is private, and we have already filled in  his/her email address.";
      receiverEmailInput.type = "hidden";
      receiverEmailInput.value = msg.sendemail;
    }).catchError((e){
      querySelector("#reply-error-alter").classes.remove('disappear');
    }).whenComplete(() {
      submitButton.disabled = false;
    });
  }
  
  querySelector('#form-alert-close').onClick.listen((_) {
    querySelector('#form-error-alert').classes.add('disappear');
  });
  
  submitButton.onClick.listen((_) {
    String receiverName = receiverNameInput.value;
    String receiverEmail = receiverEmailInput.value;
    String userName = (querySelector('#userEmail') as InputElement).value;
    String userEmail = (querySelector('#userEmail') as InputElement).value;
    //determine massage type
    InputElement messageInput= querySelector('.tab-content .active input');
    String message;
    String filename;
    File messageFile;
    bool isFile = false;
    switch(messageInput.type) {
      case 'text':
        message = messageInput.value;
        break;
      case 'file':
        isFile = true;
        if(messageInput.files.length > 0) {
          messageFile = messageInput.files[0];
          filename = Uri.decodeComponent(messageFile.name);
          print(filename);
        }
        break;
    }
    uploadMsg(userName, userEmail, receiverName, receiverEmail, isFile, message, messageFile, filename)
    .then((_) {
      window.location.href = '../authen_done';
    })
    .catchError((_) {
      querySelector('#form-error-alert').classes.remove('disappear');
    });
  });
}<commit_msg>chinese<commit_after>library client.authen;

import 'dart:html';
import 'package:StupidBirdExpress/client/parse.dart';

void main() {
  String sequence;
  InputElement receiverNameInput = querySelector('#receiverName');
  InputElement receiverEmailInput = querySelector('#receiverEmail');
  ButtonElement submitButton = querySelector('.submit-btn');
  //  is reply
  if (!window.location.search.isEmpty) {
    //protect form
    submitButton.disabled = true;
    //get sequence
    String search = window.location.search.substring(1);
    int position = search.indexOf('=');
    if (search.substring(0, position) == 'id') {
      sequence = search.substring(position);
    }
    //set receiverName, receiverEmail(not alloewd to chage)
    downloadMsg(sequence).then((Message msg) {
      receiverNameInput.value = msg.sendname;
      querySelector('#receiverEmailInfo').text = '寄件者是不公開的喔！我們會直接幫你/妳回傳給對方。';
      querySelector('#receiverEmailInfoEn').text = "The sender's email is private, and we have already filled in  his/her email address.";
      receiverEmailInput.type = "hidden";
      receiverEmailInput.value = msg.sendemail;
    }).catchError((e){
      querySelector("#reply-error-alter").classes.remove('disappear');
    }).whenComplete(() {
      submitButton.disabled = false;
    });
  }
  
  querySelector('#form-alert-close').onClick.listen((_) {
    querySelector('#form-error-alert').classes.add('disappear');
  });
  
  submitButton.onClick.listen((_) {
    String receiverName = receiverNameInput.value;
    String receiverEmail = receiverEmailInput.value;
    String userName = (querySelector('#userEmail') as InputElement).value;
    String userEmail = (querySelector('#userEmail') as InputElement).value;
    //determine massage type
    InputElement messageInput= querySelector('.tab-content .active input');
    String message;
    String filename;
    File messageFile;
    bool isFile = false;
    switch(messageInput.type) {
      case 'text':
        message = messageInput.value;
        break;
      case 'file':
        isFile = true;
        if(messageInput.files.length > 0) {
          messageFile = messageInput.files[0];
          filename = Uri.decodeComponent(messageFile.name);
          print(filename);
        }
        break;
    }
    uploadMsg(userName, userEmail, receiverName, receiverEmail, isFile, message, messageFile, filename)
    .then((_) {
      window.location.href = '../authen_done';
    })
    .catchError((_) {
      querySelector('#form-error-alert').classes.remove('disappear');
    });
  });
}
{'fraction_non_alphanumeric': 0.13451776649746192, 'fraction_numerical': 0.0015618898867629833, 'mean_word_length': 3.4859894921190895, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3670013', 'n_tokens_mistral': 1482, 'n_tokens_neox': 1486, 'n_words': 288}