Skip to content

Commit

Permalink
Works offline with json feed
Browse files Browse the repository at this point in the history
  • Loading branch information
HalfdanJ committed Oct 10, 2011
1 parent 4d74b39 commit a391c4c
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 34 deletions.
1 change: 1 addition & 0 deletions html/.bash_profile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
EDITOR=mate
1 change: 1 addition & 0 deletions static/api/members/1
Original file line number Diff line number Diff line change
@@ -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"}]}
1 change: 1 addition & 0 deletions static/api/members/2
Original file line number Diff line number Diff line change
@@ -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"}]}
1 change: 1 addition & 0 deletions static/api/members/list
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"username": "johan", "id": 1}, {"username": "halfdanj", "id": 2}]
25 changes: 14 additions & 11 deletions static/coffee/main.coffee
Original file line number Diff line number Diff line change
@@ -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: ->
Expand All @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
25 changes: 12 additions & 13 deletions static/javascripts/main.js
Original file line number Diff line number Diff line change
@@ -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() {
Expand All @@ -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({
Expand All @@ -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;
Expand Down
51 changes: 51 additions & 0 deletions static/offline.html
Original file line number Diff line number Diff line change
@@ -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>
20 changes: 10 additions & 10 deletions templates/dashboard.html
Original file line number Diff line number Diff line change
@@ -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>
Expand All @@ -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">
Expand Down

0 comments on commit a391c4c

Please sign in to comment.