<commit_before>var crud         = require("../..")
var localStorage = require("crudlet-local-storage");
var io           = require("crudlet-socket.io");
var pc           = require("paperclip");
var _            = require("highland");
var memory         = require("crudlet-memory");

var iodb = io({
  host: "http://" + location.host,
  channel: "todos"
});

var db = crud.tailable(localStorage());
var todosDb = crud.child(db, { collection: "todos" });

// sync remote stuff with the local db
iodb(crud.op("tail")).pipe(crud.open(db));

// sync local db with remote stuff
db(crud.op("tail")).pipe(crud.open(iodb));

// the template
var tpl = pc.template(
  "<h3>Local storage + socket.io (realtime) todos</h3>" +
  "<input type='text' class='form-control' placeholder='add todo' value={{<~>todoText}} onEnter={{addTodo(todoText)}} />" +
  "<ul class='todo-items'>" +
    "<repeat each={{todos}} as='todo'>" +
      "<li><a href='#' onClick={{removeTodo(todo)}}>x</a> {{todo.text}}</li>" +
    "</repeat>" +
  "</ul>"
);

// the view controller
var view = tpl.view({
  addTodo: function(text) {
    todosDb(crud.op("insert", {
      data: { text: text, uid: Date.now() }
    }));

    this.todoText = "";
  },
  removeTodo: function(todo) {
    todosDb(crud.op("remove", {<commit_msg>change key<commit_after>var crud         = require("../..")
var localStorage = require("crudlet-local-storage");
var io           = require("crudlet-socket.io");
var pc           = require("paperclip");
var _            = require("highland");
var memory         = require("crudlet-memory");

var iodb = io({
  host: "http://" + location.host,
  channel: "todos"
});

var db = crud.tailable(localStorage({
  storageKey: "crudlet"
}));

var todosDb = crud.child(db, { collection: "todos" });

// sync remote stuff with the local db
iodb(crud.op("tail")).pipe(crud.open(db));

// sync local db with remote stuff
db(crud.op("tail")).pipe(crud.open(iodb));

// the template
var tpl = pc.template(
  "<h3>Local storage + socket.io (realtime) todos</h3>" +
  "<input type='text' class='form-control' placeholder='add todo' value={{<~>todoText}} onEnter={{addTodo(todoText)}} />" +
  "<ul class='todo-items'>" +
    "<repeat each={{todos}} as='todo'>" +
      "<li><a href='#' onClick={{removeTodo(todo)}}>x</a> {{todo.text}}</li>" +
    "</repeat>" +
  "</ul>"
);

// the view controller
var view = tpl.view({
  addTodo: function(text) {
    todosDb(crud.op("insert", {
      data: { text: text, uid: Date.now() }
    }));

    this.todoText = "";
  },
  removeTodo: function(todo) {
    todosDb(crud.op("remove", {
{'fraction_non_alphanumeric': 0.21497491316094172, 'fraction_numerical': 0.0015438054805094559, 'mean_word_length': 3.4844290657439445, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, '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': '214998', 'n_tokens_mistral': 938, 'n_tokens_neox': 957, 'n_words': 191}