{"payload":{"allShortcutsEnabled":false,"fileTree":{"src":{"items":[{"name":"admin.opa","path":"src/admin.opa","contentType":"file"},{"name":"main.opa","path":"src/main.opa","contentType":"file"},{"name":"todo.opa","path":"src/todo.opa","contentType":"file"},{"name":"ui.opa","path":"src/ui.opa","contentType":"file"},{"name":"user.opa","path":"src/user.opa","contentType":"file"}],"totalCount":5},"":{"items":[{"name":"resources","path":"resources","contentType":"directory"},{"name":"src","path":"src","contentType":"directory"},{"name":"Makefile","path":"Makefile","contentType":"file"},{"name":"README.md","path":"README.md","contentType":"file"},{"name":"dotcloud.yml","path":"dotcloud.yml","contentType":"file"}],"totalCount":5}},"fileTreeProcessingTime":10.456455,"foldersToFetch":[],"repo":{"id":3629594,"defaultBranch":"master","name":"OpaDo","ownerLogin":"cedricss","currentUserCanPush":false,"isFork":true,"isEmpty":false,"createdAt":"2012-03-05T17:38:38.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/802010?v=4","public":true,"private":false,"isOrgOwned":false},"symbolsExpanded":false,"treeExpanded":true,"refInfo":{"name":"0.4.0","listCacheKey":"v0:1613535078.845356","canEdit":false,"refType":"tag","currentOid":"83a0435026cd9582f104f23ddc6affcd1a6882f6"},"path":"src/todo.opa","currentUser":null,"blob":{"rawLines":["package opado.todo","","import opado.user","import opado.ui","import stdlib.web.client","","type todo_item = {"," string value,"," bool done,"," string created_at","}","","database stringmap(stringmap(todo_item)) /todo_items","database /todo_items[_][_]/done = false","","module Todo {"," function update_counts() {"," num_done = Dom.length(Dom.select_class(\"done\"));"," total = Dom.length(Dom.select_class(\"todo\"));"," Dom.set_text(#number_done, Int.to_string(num_done));"," Dom.set_text(#number_left, Int.to_string(total - num_done))"," }",""," function make_done(string id) {"," if(Dom.is_checked(Dom.select_inside(#{id}, Dom.select_raw(\"input\")))) {"," db_make_done(id);"," Dom.add_class(#{id}, \"done\")"," } else {"," Dom.remove_class(#{id}, \"done\")"," };"," update_counts()"," }",""," exposed @async function db_make_done(string id) {"," username = User.get_username();"," items = /todo_items[username];"," item = Option.get(StringMap.get(id, items));"," @/todo_items[username] <-"," StringMap.add(id, {item with done : true}, items)"," }",""," function remove_item(string id) {"," db_remove_item(id);"," Dom.remove(Dom.select_parent_one(#{id}));"," update_counts()"," }",""," exposed @async function db_remove_item(string id) {"," username = User.get_username();"," items = /todo_items[username];"," @/todo_items[username] <- StringMap.remove(id, items)"," }",""," @async function remove_all_done() {"," Dom.iter((function(x){remove_item(Dom.get_id(x))}),"," Dom.select_class(\"done\"))"," }",""," function add_todo(string x) {"," id = Dom.fresh_id();"," db_add_todo(id, x);"," add_todo_to_page(id, x, false)"," }",""," exposed @async function db_add_todo(string id, string x) {"," username = User.get_username();"," items = /todo_items[username];"," @/todo_items[username] <-"," StringMap.add(id, { value : x, done : false, created_at : \"\" }, items)"," }",""," exposed function add_todos() {"," username = User.get_username();"," items = /todo_items[username];"," StringMap.iter((function(x,y){add_todo_to_page(x, y.value, y.done)}), items)"," }",""," function update_todo(string id, string value) {"," db_add_todo(id, value);"," update_todo_on_page(id, value);"," Dom.void_style(#{id^\"_destroy\"});"," }",""," function update_todo_on_page(string id, string value) {"," line =
"," "," Clear"," 0"," completed items"," ","
",""," 0"," items left","
","