@@ -31,15 +31,15 @@ var app = app || {};
3131 componentDidMount : function ( ) {
3232 var setState = this . setState ;
3333 var router = Router ( {
34- '/' : setState . bind ( this , { nowShowing : app . ALL_TODOS } ) ,
35- '/active' : setState . bind ( this , { nowShowing : app . ACTIVE_TODOS } ) ,
36- '/completed' : setState . bind ( this , { nowShowing : app . COMPLETED_TODOS } )
34+ '/' : setState . bind ( this , { nowShowing : app . ALL_TODOS } ) ,
35+ '/active' : setState . bind ( this , { nowShowing : app . ACTIVE_TODOS } ) ,
36+ '/completed' : setState . bind ( this , { nowShowing : app . COMPLETED_TODOS } )
3737 } ) ;
3838 router . init ( '/' ) ;
3939 } ,
4040
4141 handleChange : function ( event ) {
42- this . setState ( { newTodo : event . target . value } ) ;
42+ this . setState ( { newTodo : event . target . value } ) ;
4343 } ,
4444
4545 handleNewTodoKeyDown : async function ( event ) {
@@ -53,7 +53,7 @@ var app = app || {};
5353
5454 if ( val ) {
5555 await this . props . model . addTodo ( val ) ;
56- this . setState ( { newTodo : '' } ) ;
56+ this . setState ( { newTodo : '' } ) ;
5757 }
5858 } ,
5959
@@ -71,16 +71,16 @@ var app = app || {};
7171 } ,
7272
7373 edit : function ( todo ) {
74- this . setState ( { editing : todo . id } ) ;
74+ this . setState ( { editing : todo . id } ) ;
7575 } ,
7676
7777 save : async function ( todoToSave , text ) {
7878 await this . props . model . save ( todoToSave , text ) ;
79- this . setState ( { editing : null } ) ;
79+ this . setState ( { editing : null } ) ;
8080 } ,
8181
8282 cancel : function ( ) {
83- this . setState ( { editing : null } ) ;
83+ this . setState ( { editing : null } ) ;
8484 } ,
8585
8686 clearCompleted : function ( ) {
@@ -94,12 +94,12 @@ var app = app || {};
9494
9595 var shownTodos = todos . filter ( function ( todo ) {
9696 switch ( this . state . nowShowing ) {
97- case app . ACTIVE_TODOS :
98- return ! todo . completed ;
99- case app . COMPLETED_TODOS :
100- return todo . completed ;
101- default :
102- return true ;
97+ case app . ACTIVE_TODOS :
98+ return ! todo . completed ;
99+ case app . COMPLETED_TODOS :
100+ return todo . completed ;
101+ default :
102+ return true ;
103103 }
104104 } , this ) ;
105105
@@ -150,30 +150,30 @@ var app = app || {};
150150 ) ;
151151 }
152152
153- const loadPercentage = Math . round ( this . props . model . status . loaded / this . props . model . status . total * 100 )
153+ const loadPercentage = Math . round ( this . props . model . status . loaded / this . props . model . status . total * 100 )
154154
155155 return (
156156 < div >
157157 < header className = "header" >
158158 < h1 > todos</ h1 >
159159 { ! this . props . model . ready
160160 ? < p className = "loadingText" >
161- { this . props . model . ready
162- ? null
163- : 'Loading... ' + loadPercentage + '%'
164- }
165- </ p >
161+ { this . props . model . ready
162+ ? null
163+ : 'Loading... ' + loadPercentage + '%'
164+ }
165+ </ p >
166166 : null
167167 }
168168 { this . props . model . ready
169169 ? < input
170- className = "new-todo"
171- placeholder = "What needs to be done?"
172- value = { this . state . newTodo }
173- onKeyDown = { this . handleNewTodoKeyDown }
174- onChange = { this . handleChange }
175- autoFocus = { true }
176- />
170+ className = "new-todo"
171+ placeholder = "What needs to be done?"
172+ value = { this . state . newTodo }
173+ onKeyDown = { this . handleNewTodoKeyDown }
174+ onChange = { this . handleChange }
175+ autoFocus = { true }
176+ />
177177 : null
178178 }
179179 </ header >
@@ -185,37 +185,14 @@ var app = app || {};
185185 } ) ;
186186
187187 // Create the store (storage backend), namespace is our database name/id
188- // ToDo: add url query parsing here
189- const match = document . location . href . match ( / q u e r y = ( [ ^ & ] + ) / ) ;
190- if ( match ) {
191- const address = atob ( match [ 1 ] )
192- OrbitDB . isValidAddress ( address ) ? namespace = address : null ;
193- }
194188 var db = await store ( namespace ) ;
195189
196- swal ( {
197- title : "Share your session" ,
198- text : 'Share the Url with your friends!' ,
199- buttons : [ "No thanks" , "Cool, copy it!" ]
200- } ) . then ( ( value ) => {
201- if ( ! value ) {
202- return ;
203- }
204- navigator . clipboard . writeText ( document . location . href )
205- swal (
206- "Copied!" ,
207- "The text has been copied." ,
208- "success" ,
209- ) ;
210- } )
211-
212-
213190 // Create the data model
214191 var model = new app . TodoModel ( db , namespace ) ;
215192
216193 function render ( ) {
217- ReactDOM . render (
218- < TodoApp model = { model } /> ,
194+ React . render (
195+ < TodoApp model = { model } /> ,
219196 document . getElementsByClassName ( 'todoapp' ) [ 0 ]
220197 ) ;
221198 }
@@ -224,11 +201,6 @@ var app = app || {};
224201 model . subscribe ( render ) ;
225202 render ( ) ;
226203
227- if ( ! match ) {
228- const query = btoa ( db . address . toString ( ) ) ;
229- document . location . href = document . location . href . replace ( / \? .+ $ / , "" ) ;
230- document . location . href = document . location . href + `?query=${ query } ` ;
231- }
232- // Load the database from locally persisted data
233- await db . load ( )
204+ // Load the database from locally persisted data
205+ await db . load ( )
234206} ) ( ) ;
0 commit comments