(function() {
    var todolist      = document.querySelector('#todolist');
    var todolistView  = new ToMvc.View( 'todolist', '#todolist' );
    var todolistModel = new ToMvc.Model( 'todolist' );
    var nrTodos       = 0;

    function init() {
        document.querySelector('#add-todo button').addEventListener( 'click', addTodo, false);

        todolistModel.listenTo( 'todo:added', function( data ) {
            var key = nrTodos++;
            localStorage.setItem( nrTodos, data );
        });
    }

    function addTodo() {
        var text = window.prompt('enter event');
        if (!text) return;

        var li         = document.createElement('li');
        li.textContent = text;
        todolist.appendChild(li);

        // Added todo must be send to Model
        todolistView.broadcast( 'todo:added', text);

        // Immediately ask for another todo to enter
        addTodo();
    }


    // GO!
    init();

}());

@@ -1,9 +1,10 @@
 (
+ 
 function
@@ -25,21 +25,16 @@
 odolist 
-     
 = docume
@@ -50,16 +50,17 @@
 elector(
+ 
 '#todoli
@@ -62,16 +62,17 @@
 odolist'
+ 
 );%0A    v
@@ -87,17 +87,16 @@
 istView 
- 
 = new To
@@ -191,34 +191,155 @@
  );%0A
+%0A%0A
    
+ //
  var 
-nrTodos
+todolistModel = function() %7B%0A    //         this.name = 'todolist';%0A
     
+//
    
-= 0;
+  %7D%0A        // todolistModel.prototype = new ToMvc.View;%0A
 %0A%0A  
@@ -389,16 +389,17 @@
 elector(
+ 
 '#add-to
@@ -408,16 +408,17 @@
  button'
+ 
 ).addEve
@@ -452,16 +452,221 @@
 o, false
+ );%0A%0A        // console.info( 'model', todolistModel );%0A        // var currentTodos = todolistModel.getCurrentTodos();%0A        var currentTodos = getCurrentTodos();%0A        writeCurrentTodos( currentTodos 
 );%0A%0A    
@@ -752,17 +752,38 @@
 y = 
-nrTodos++
+window.localStorage.length + 1
 ;%0A  
@@ -792,16 +792,23 @@
         
+window.
 localSto
@@ -825,15 +825,11 @@
 em( 
-nrTodos
+key
 , da
@@ -843,16 +843,17 @@
        %7D
+ 
 );%0A    %7D
@@ -862,24 +862,114 @@
     
-function add
+// model method%0A    // todolistModel.prototype.getCurrentTodos = function() %7B%0A    function getCurrent
 Todo
+s
 () %7B
@@ -985,190 +985,493 @@
 var 
-text = window.prompt('enter event');%0A        if (!text)
+list = %5B%5D;%0A        for ( var key in localStorage ) %7B%0A            list.push( window.localStorage.getItem( key ) );%0A        %7D%0A        // TODO re-index keys because of deletions%0A       
  return
+ list
 ;
-%0A
 %0A    
+%7D%0A%0A
     
-var li         = document.createElement('li');%0A        li.textContent = text;%0A        todolist.appendChild(li
+function writeCurrentTodos( list ) %7B%0A        list.forEach( function( item ) %7B%0A            writeTodo( item );%0A        %7D );%0A    %7D%0A%0A    // view method%0A    function addTodo() %7B%0A        var text = window.prompt( 'enter event' );%0A        if ( !text ) return;%0A%0A        writeTodo( text 
 );%0A%0A
@@ -1564,16 +1564,17 @@
 d', text
+ 
 );%0A%0A    
@@ -1648,16 +1648,191 @@
 %0A    %7D%0A%0A
+    // view method%0A    function writeTodo( text ) %7B%0A        var li = document.createElement( 'li' );%0A        li.textContent = text;%0A        todolist.appendChild( li );%0A    %7D%0A%0A
 %0A    // 
@@ -1851,11 +1851,12 @@
 ();%0A%0A%7D()
+ 
 );%0A

Add created todos to localStorage