-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
316 lines (295 loc) · 10.5 KB
/
index.html
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
<!DOCTYPE html>
<html>
<head>
<title>Realizr</title>
<!-- tr '\n' '' < from > to -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/bootstrap-responsive.min.css">
<link rel="stylesheet" href="css/style.css">
<!-- jQuery adn plugins -->
<script src="scripts/lib/jquery.js"></script>
<script src="scripts/lib/moment.min.js"></script>
<!--script src="scripts/lib/serializeobject.js"></script>
<script src="scripts/lib/charcount.js"></script>
<script src="scripts/lib/jquery.countdown.js"></script>
<script src="scripts/lib/jquery.prettydate.js"></script-->
<!-- Core JS MVC -->
<script src="scripts/lib/dust-full-1.0.0.js"></script>
<script src="scripts/lib/underscore.js"></script>
<script src="scripts/lib/backbone.js"></script>
<script src="scripts/lib/backbone-localstorage.js"></script>
<!-- Router, \ views, models and collections -->
<script src="scripts/app.js" type="text/javascript"></script>
<script src="scripts/router.js" type="text/javascript"></script>
<script src="scripts/models/base.js" type="text/javascript"></script>
<script src="scripts/models/dream.js" type="text/javascript"></script>
<script src="scripts/models/product.js" type="text/javascript"></script>
<script src="scripts/models/user.js" type="text/javascript"></script>
<script src="scripts/models/comment.js" type="text/javascript"></script>
<script src="scripts/collections/dreams.js" type="text/javascript"></script>
<script src="scripts/collections/products.js" type="text/javascript"></script>
<script src="scripts/collections/users.js" type="text/javascript"></script>
<script src="scripts/collections/comments.js" type="text/javascript"></script>
<script src="scripts/collections/friends.js" type="text/javascript"></script>
<script src="scripts/views/app.js" type="text/javascript"></script>
<script src="scripts/views/dreams.js" type="text/javascript"></script>
<script src="scripts/views/profile.js" type="text/javascript"></script>
<script src="scripts/views/add.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery(function ($) {
// Compile the templates - accessible via 'id' attribute of script at bottom of index.html
$('.dust-template').each(function () {
var $this = $(this);
var compiled = dust.compile($this.html(), $this.attr('id'));
dust.loadSource(compiled);
});
// Clear local storage to prep for new data
window.localStorage.clear();
// Set up the router
window.router = new Router();
window.users = new UsersCollection();
window.products = new ProductsCollection();
window.dreams = new DreamsCollection();
window.comments = new CommentsCollection();
initCollections();
saveModels(users);
saveModels(products);
saveModels(dreams);
saveModels(comments);
// Set up application
users.fetch({success: function () {
console.log(users.length);
window.app = new AppView({
model: window.users.at(0)
});
app.render();
Backbone.history.start();
}});
// Save new models into localstorage
function saveModels(collection) {
collection.each(function (model) {
model.save();
});
}
function initCollections() {
window.users.reset(JSON.parse('[ \
{ \
"name":"jo bloggs", \
"email":"[email protected]", \
"dreams": [1,3,4,5] \
}, \
{ \
"name":"harry potter", \
"email":"[email protected]", \
"dreams": [2,5] \
}, \
{ \
"name":"jane doe", \
"email":"[email protected]", \
"dreams": [] \
} \
]'));
window.products.reset(JSON.parse('[ \
{ \
"name":"skydiving", \
"price":"500.10", \
"location":"Perth WA", \
"keywords":["skydive", "skydiving", "parachuting"], \
"supplier":"Perth Skydiving Co.", \
"availability":"all", \
"pictures":["skydiving.jpg"] \
}, \
{ \
"name":"travel to England", \
"price":"5050.00", \
"location":"Perth WA", \
"keywords":["travel", "England", "London", "Stonehenge", "Castle", "Royalty", "Queen"], \
"supplier":"Qantas", \
"availability":"all", \
"pictures":["London.jpg"] \
}, \
{ \
"name":"flute lessons", \
"price":"50.00", \
"location":"Perth WA", \
"keywords":["music", "flute"], \
"supplier":"Mrs Moonspasm", \
"availability":"Tuesday afternoons by appointment only", \
"pictures":["Flute.jpg"] \
} \
]'));
window.dreams.reset(JSON.parse('[ \
{ \
"id":1, \
"objective":"skydive", \
"due":1355241600000, \
"privacy":"public", \
"users":"jo bloggs", \
"comments":[1, 2], \
"keywords":["skydive"], \
"picture":"skydive.jpg", \
"ranking":"1" \
}, \
{ \
"id":2, \
"objective":"diving", \
"due":1363708800000, \
"privacy":"public", \
"users":"jo bloggs", \
"comments":[3, 4, 5], \
"keywords":["music", "flute"], \
"picture":"flute.jpg", \
"ranking":"2" \
}, \
{ \
"id":3, \
"objective":"grow a beard", \
"due":1377964800000, \
"privacy":"private", \
"users":"jo bloggs", \
"comments":[], \
"keywords":["beard"], \
"picture":"beard.jpg", \
"ranking":"3" \
}, \
{ \
"id":4, \
"objective":"visit stonehenge", \
"due":1364745600000, \
"privacy":"public", \
"users":"jo bloggs", \
"comments":[6], \
"keywords":["travel", "stonehenge"], \
"picture":"stonehenge.jpg", \
"ranking":"4" \
}, \
{ \
"id":5, \
"objective":"swim with whales", \
"due":1365091200000, \
"privacy":"private", \
"users":"jo bloggs", \
"comments":[], \
"keywords":["business"], \
"picture":"business.jpg", \
"ranking":"5" \
} \
]'));
window.comments.reset(JSON.parse('[ \
{ \
"id":1, \
"author":"jo bloggs", \
"text":"yeah I know everyone wants to do this, but so do I", \
"date":1347379200000, \
"dream":1 \
}, \
{ \
"id":2, \
"author":"harry potter", \
"text":"not me. Leaping out of a perfectly good airplane seems a little stupid", \
"date":1347379200000, \
"dream":2 \
}, \
{ \
"id":3, \
"author":"jo bloggs", \
"text":"the fiddle is the traditional aspiration, but I like the sound of a flute", \
"date":1347379200000, \
"dream":2 \
}, \
{ \
"id":4, \
"author":"harry potter", \
"text":"easier to learn and harder to master, I think", \
"date":1347379200000, \
"dream":2 \
}, \
{ \
"id":5, \
"author":"jo bloggs", \
"text":"what you know about the flute is remarkable in its paucity and irrelevance", \
"date":1347379200000, \
"dream":2 \
}, \
{ \
"id":6, \
"author":"jane doe", \
"text":"went there last year. Not as awesome as youd imagine", \
"date":1347379200000, \
"dream":4 \
} \
]'));
}
});
</script>
</head>
<body>
<header>
<div>
<h1>realizr - delivering your dreams</h1>
</div>
</header>
<!-- Dust.js templates -->
<script id="app-template" class="dust-template" type="text/x-dust-template">
<div class="container clearFix"></div>
</script>
<script id="right-section-template" class="dust-template" type="text/x-dust-template">
<div class="friends">
{#friends}
<div class="friend"></div>{~n}
{/friends}
</div>
<div class="products"></div>
<div class="timer"></div>
<div class="done"></div>
</script>
<script id="list-item-template" class="dust-template" type="text/x-dust-template">
{#dreams}
<div class="list-item dream-item">
<div class="left-section">
<div class="main-image"><img src="img/{picture}"></div>
<h1 class="title">{objective}</h1>
</div>
<div class="right-section">
<div class="products">
{#dream.products}
<div class="friend"></div>{~n}
{/dream.products}
<h2>Why?</h2>
<p>I want to do this because...</p>
<ul class="options">
<li>Timeframe: <span class="time">{due}</span></li>
<li class="complete">Complete</li>
</ul>
<h2>Comments</h2>
<p>Mary</p>
<p>You can do it!</p>
</div>
</div>
</div>{~n}
{/dreams}
</script>
<script id="profile-template" class="dust-template" type="text/x-dust-template">
<div id="dreams-todos" class="list"></div>
<div id="dreams-completes" class="list"></div>
<div id="profile"></div>
</script>
<script id="add-item-template" class="dust-template" type="text/x-dust-template">
<div class="list-item add-item">
<div class="left-section">
<div class="main-image">
<img src="img/dream.jpg">
</div>
</div>
</div>
</script>
<script id="add-dream-template" class="dust-template" type="text/x-dust-template">
<h1>Add your dream</h1>
<form>
<label>What’s your dream?</label>
<input type="text" class="input-large">
<span class="help-block">Example: naked skydiving</span>
</form>
</script>
</body>
</html>