Open Dandandan opened 12 years ago
OpaDo loads items when ready, but faster is to load items in one time. Unfornately can't run OpaDo because my version is to new and don't have time to change the "resource" to js-like. But something like this will do ;)?
function todo_line(string id, string value, bool is_done) { <li><div class="todo {if (is_done) "done" else ""}" id={ id }> <div class="display"> <span id={id^"_destroy"} class="todo_destroy icon icon-remove" onclick={function(_){remove_item(id)}}></span> <input class="check" type="checkbox" onclick={function(_){make_done(id)}}/> <div id={id^"_todo"} class="todo_content" onclick={function(_){make_editable(id, value)}}>{ value }</div> </div> </div></li> } function add_todo_to_page(string id, string value, bool is_done) { Dom.transform([#todo_list =+ line(id, value, is_done]); Dom.scroll_to_bottom(#todo_list); Dom.set_value(#new_todo, ""); update_counts() } function todos(){ if (User.is_logged()){ mypage("Todos",todos_page()) } else { mypage("Sign Up",User.new()) } } function todos_page() { <div class="topbar"> <div class="container"> <a class="brand" href="#"></a> <a class="btn pull-right" onclick={function(_){User.logout()}}>Logout</a> </div> </div> <div class="container hero-unit"> <div id=#create_todo> <input id=#new_todo class="xlarge" placeholder="What needs to be done?" type="text" onnewline={function(_){add_todo(Dom.get_value(#new_todo))}} /> </div> </div> <div class="container" id="todoapp"> <div class="content"> <div id=#todos> <ul id=#todo_list onready={function(_){add_todos()}} class="unstyled"></ul> { username = User.get_username(); items = /todo_items[username]; StringMap.map((function(x,y){todo_line(x, y.value, y.done)}), items) } </div> <div id="todo_stats" class="well"> <p class="todo_clear pull-right"> <a class="btn" href="#" onclick={function(_){remove_all_done()}}> <span class="icon icon-white icon-trash"/> Clear <span id=#number_done class="number-done">0</span> completed <span class="word-done">items</span> </a> </p> <p class="todo_count"> <span id=#number_left class="number bold">0</span> <span class="word">items</span> left </p> </div> </div> <div class="footer">Note: This is beta version. No guarentee your data wont be lost.</div> </div> }
Thanks! I'll try working this in to the code soon.
OpaDo loads items when ready, but faster is to load items in one time. Unfornately can't run OpaDo because my version is to new and don't have time to change the "resource" to js-like. But something like this will do ;)?