<commit_before>// Based on Firebase's JS tutorial: https://www.firebase.com/tutorial

import 'dart:html' as HTML;
import 'package:firebase/firebase.dart' as FB;

void main() {
  // create Firebase reference
  FB.Firebase fbRef = new FB.Firebase("https://l90j8hn4wau.firebaseio-demo.com");

  // get UI element references
  HTML.InputElement nameField = HTML.querySelector("#name-input");
  HTML.InputElement messageField = HTML.querySelector("#message-input");
  HTML.UListElement messageList = HTML.querySelector("#messages");

  // listen for ENTER key in message field
  messageField.onKeyPress.listen((HTML.KeyboardEvent event) {
    if (event.keyCode == HTML.KeyCode.ENTER && messageField.value.isNotEmpty) {
      fbRef.push(value: {"name": nameField.value, "text": messageField.value});
      messageField.value = "";
    }
  });

  // listen for Firebase "childAdded" events
  fbRef.limitToLast(10).onChildAdded.listen((FB.Event event) {
    // get the message data
    Map data = event.snapshot.val();

    // check for anonymous post
    data['name'] = data['name'].isNotEmpty ? data['name'] : "Anonymous";
//    data['name'] ??= "Anonymous";

    // append message to UI
    messageList.appendHtml("<li><strong class='chat-username'>${data['name']}:</strong> ${data['text']}</li>");

    // scroll to bottom of message list<commit_msg>cleanup<commit_after>// Based on Firebase's JS tutorial: https://www.firebase.com/tutorial

import 'dart:html' as HTML;
import 'package:firebase/firebase.dart' as FB;

void main() {
  // create Firebase reference
  FB.Firebase fbRef = new FB.Firebase("https://l90j8hn4wau.firebaseio-demo.com");

  // get UI element references
  HTML.InputElement nameField = HTML.querySelector("#name-input");
  HTML.InputElement messageField = HTML.querySelector("#message-input");
  HTML.UListElement messageList = HTML.querySelector("#messages");

  // listen for ENTER key in message field
  messageField.onKeyPress.listen((HTML.KeyboardEvent event) {
    if (event.keyCode == HTML.KeyCode.ENTER && messageField.value.isNotEmpty) {
      fbRef.push(value: {"name": nameField.value, "text": messageField.value});
      messageField.value = "";
    }
  });

  // listen for Firebase "childAdded" events
  fbRef.limitToLast(10).onChildAdded.listen((FB.Event event) {
    // get the message data
    Map data = event.snapshot.val();

    // check for anonymous post
    data['name'] = data['name'].isNotEmpty ? data['name'] : "Anonymous";

    // append message to UI
    messageList.appendHtml("<li><strong class='chat-username'>${data['name']}:</strong> ${data['text']}</li>");

    // scroll to bottom of message list
{'fraction_non_alphanumeric': 0.15622641509433963, 'fraction_numerical': 0.004528301886792453, 'mean_word_length': 4.059160305343512, 'pattern_counts': {'":': 4, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, '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': '1945294', 'n_tokens_mistral': 826, 'n_tokens_neox': 800, 'n_words': 183}