-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
103 lines (75 loc) · 1.74 KB
/
app.js
File metadata and controls
103 lines (75 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/**
* To-do app
* Features: multiple to-do lists
* to-do lists can have a start & end date
* tasks can have comments
*/
var console = (function(undefined) {
var m = ['log', 'error', 'info', 'warn', 'time','timeEnd', 'dir'];
if(typeof window.console === undefined) {
var c = {}, f = function() {};
for (var i=0, l = m.length; i < l; i++) {
c[m[i]] = f;
}
return c;
}
return window.console;
})();
//(function() {
var Lists = new Lists();
var Tasks = new Tasks();
Lists.fetch();
Tasks.fetch();
// Only one Lists View
var ListsView = new ListsView({
collection: Lists
});
// Only one Tasks View (this should change)
var TasksView = new TasksView({
collection: Tasks
});
var Router = Backbone.Router.extend({
routes: {
"/": "home",
"/lists/:id": "lists",
"/tasks/:id": "tasks"
},
initialize: function(){
},
home: function(){
TasksView && TasksView.el.empty();
},
lists: function(id) {
/*
TasksView && TasksView.remove();
if(!id){return;}
var list = Lists.get(id);
list && TasksView = new TasksView({
collection: new Tasks(),
list: new List()
});
*/
var list = Lists.get(id);
TasksView.render(list);
},
tasks: function(id) {
}
});
var TodoApp = new Router();
//Backbone.history.start({pushState:true});
Backbone.history.start();
/*
Tasks.add(mytask);
mytask.add_to_list(mylist);
Lists.add(mylist);
ListsView.render();
Lists.add({
'name': 'more things to do'
});
Lists.add({
'name': 'gamise ta'
});
mytask.save();
mylist.save();
*/
//})();