Permalink
Browse files

Works offline with json feed

  • Loading branch information...
1 parent 4d74b39 commit a391c4ca43a1a108b2d395ec4c5e89f926db9cff @HalfdanJ HalfdanJ committed Oct 10, 2011
View
1 html/.bash_profile
@@ -0,0 +1 @@
+EDITOR=mate
View
1 static/api/members/1
@@ -0,0 +1 @@
+{"image": "http://media.illutron.johan.cc/images/profiles/profile.jpg", "latest_checkin_time": "2011-10-09T22:31:21", "name": "Johan", "on_illutron": true, "log": [{"latitude": null, "description": "", "on_illutron": true, "longitude": null, "time": "2011-10-09T22:31:21"}, {"latitude": null, "description": "", "on_illutron": true, "longitude": null, "time": "2011-10-10T10:06:00"}]}
View
1 static/api/members/2
@@ -0,0 +1 @@
+{"image": null, "latest_checkin_time": "2011-10-10T00:20:31", "name": "Jonas Jongejan", "on_illutron": true, "log": [{"latitude": null, "description": "", "on_illutron": false, "longitude": null, "time": "2011-10-10T00:20:31"}]}
View
1 static/api/members/list
@@ -0,0 +1 @@
+[{"username": "johan", "id": 1}, {"username": "halfdanj", "id": 2}]
View
25 static/coffee/main.coffee
@@ -1,11 +1,16 @@
+$.ajaxSetup({ cache: false });
+
$ ()->
- jsonUrl = "http://illutron.johan.cc/api/"
+ jsonUrl = "api/"
window.Person = Backbone.Model.extend({
- initialize: -> alert "asd"
+ initialize: ->
+ this
defaults: ->
{
"username": "-"
+ "on_illutron" : false
+ "image" : ""
}
url: ->
@@ -17,12 +22,12 @@ $ ()->
window.PeopleList = Backbone.Collection.extend({
model: Person
#url: "http://jive.local:8000/api/latest/"
- url: jsonUrl+ "members/"
+ url: jsonUrl+ "members/list"
- sync: (method, model, options) ->
- options.timeout = 10000
- options.dataType = "jsonp"
- Backbone.sync(method, model, options)
+ # sync: (method, model, options) ->
+ # options.timeout = 10000
+ # options.dataType = "jsonp"
+ # Backbone.sync(method, model, options)
# initialize: ->
# this.bind("add", this.changed)
@@ -59,22 +64,20 @@ $ ()->
People.fetch()
- setInterval( (-> window.People.each( (person) -> person.fetch() )) , 5000);
+ setInterval( (-> window.People.each( (person) -> person.fetch() )) , 3000);
this
render: -> this
addAll: ->
- alert "asd"
People.each(this.addPerson);
addPerson: (person) ->
- alert person.url()
view = new PersonView(model: person)
@$("#people-list").append view.render().el
-
+ person.fetch()
)
window.App = new AppView;
View
25 static/javascripts/main.js
@@ -1,14 +1,19 @@
(function() {
+ $.ajaxSetup({
+ cache: false
+ });
$(function() {
var jsonUrl;
- jsonUrl = "http://illutron.johan.cc/api/";
+ jsonUrl = "api/";
window.Person = Backbone.Model.extend({
initialize: function() {
- return alert("asd");
+ return this;
},
defaults: function() {
return {
- "username": "-"
+ "username": "-",
+ "on_illutron": false,
+ "image": ""
};
},
url: function() {
@@ -20,12 +25,7 @@
});
window.PeopleList = Backbone.Collection.extend({
model: Person,
- url: jsonUrl + "members/",
- sync: function(method, model, options) {
- options.timeout = 10000;
- options.dataType = "jsonp";
- return Backbone.sync(method, model, options);
- }
+ url: jsonUrl + "members/list"
});
window.People = new PeopleList;
window.PersonView = Backbone.View.extend({
@@ -51,23 +51,22 @@
return window.People.each(function(person) {
return person.fetch();
});
- }), 5000);
+ }), 3000);
return this;
},
render: function() {
return this;
},
addAll: function() {
- alert("asd");
return People.each(this.addPerson);
},
addPerson: function(person) {
var view;
- alert(person.url());
view = new PersonView({
model: person
});
- return this.$("#people-list").append(view.render().el);
+ this.$("#people-list").append(view.render().el);
+ return person.fetch();
}
});
return window.App = new AppView;
View
51 static/offline.html
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Illutron Dashboard</title>
+ <link href="../stylesheets/screen.css" media="all" rel="stylesheet" type="text/css"/>
+ <script src="../vendor/json/json2.js"></script>
+ <script src="../vendor/jquery-1.6.4.min.js"></script>
+ <script src="../vendor/underscore-min.js"></script>
+ <script src="../vendor/backbone-min.js"></script>
+ <!-- <script src="{{ STATIC_URL }}vendor/backbone-localstorage.js"></script> -->
+ <script src="../javascripts/main.js"></script>
+</head>
+
+<body>
+ <div class="mainarea" id="app">
+ <div id="people-list">
+ </div>
+ </div>
+
+
+
+
+
+ <!-- Templates -->
+
+ <script type="text/template" id="person-template">
+ <div class="personbox <%= on_illutron == 1 ? 'activeperson' : '' %>">
+ <img src="<%= image %>">
+ <p class="person-name"><%= name %></p>
+ </div>
+ </script>
+
+ <script type="text/template" id="stats-template">
+ <% if (total) { %>
+ <span class="todo-count">
+ <span class="number"><%= remaining %></span>
+ <span class="word"><%= remaining == 1 ? 'item' : 'items' %></span> left.
+ </span>
+ <% } %>
+ <% if (done) { %>
+ <span class="todo-clear">
+ <a href="#">
+ Clear <span class="number-done"><%= done %></span>
+ completed <span class="word-done"><%= done == 1 ? 'item' : 'items' %></span>
+ </a>
+ </span>
+ <% } %>
+ </script>
+
+ </body>
+ </html>
View
20 templates/dashboard.html
@@ -1,15 +1,14 @@
<!DOCTYPE html>
<html>
-
<head>
<title>Illutron Dashboard</title>
- <link href="stylesheets/screen.css" media="all" rel="stylesheet" type="text/css"/>
- <script src="vendor/json/json2.js"></script>
- <script src="vendor/jquery-1.6.4.min.js"></script>
- <script src="vendor/underscore-min.js"></script>
- <script src="vendor/backbone-min.js"></script>
- <!-- <script src="vendor/backbone-localstorage.js"></script> -->
- <script src="javascripts/main.js"></script>
+ <link href="{{ STATIC_URL }}stylesheets/screen.css" media="all" rel="stylesheet" type="text/css"/>
+ <script src="{{ STATIC_URL }}vendor/json/json2.js"></script>
+ <script src="{{ STATIC_URL }}vendor/jquery-1.6.4.min.js"></script>
+ <script src="{{ STATIC_URL }}vendor/underscore-min.js"></script>
+ <script src="{{ STATIC_URL }}vendor/backbone-min.js"></script>
+ <!-- <script src="{{ STATIC_URL }}vendor/backbone-localstorage.js"></script> -->
+ <script src="{{ STATIC_URL }}javascripts/main.js"></script>
</head>
<body>
@@ -26,11 +25,12 @@
<script type="text/template" id="person-template">
<div class="personbox <%= on_illutron == 1 ? 'activeperson' : '' %>">
- <img src="http://illutron.johan.cc<%= image %>">
- <p class="person-name"><%= id %> - <%= username %></p>
+ <img src="<%= image %>">
+ <p class="person-name"><%= name %></p>
</div>
</script>
+
<script type="text/template" id="stats-template">
<% if (total) { %>
<span class="todo-count">

0 comments on commit a391c4c

Please sign in to comment.