File tree Expand file tree Collapse file tree 13 files changed +126
-134
lines changed
Expand file tree Collapse file tree 13 files changed +126
-134
lines changed Original file line number Diff line number Diff line change 11* .swp
2- js / mobile.js
3- js / init_plot.js
4- css / mobile.css
2+ * .pyc
3+ node_modules /
4+ js / * .js
Original file line number Diff line number Diff line change 1+ $ = $ || {}
2+
3+ habitat =
4+ db : if $ .couch then $ .couch .db " habitat" else {}
5+
6+ habitat .db .uri = " http://habitat.habhub.org/habitat/"
Original file line number Diff line number Diff line change 1+ habitat .tracker =
2+ flights :
3+ active : []
4+ upcoming : []
5+ options : {}
6+ vehicles : []
7+
8+ ### reset tracker state to pre-init state ###
9+ reset : ->
10+ delete this .flights
11+ delete this .options
12+ delete this .vehicles
13+
14+ this .flights =
15+ active : []
16+ upcoming : []
17+ this .options = {}
18+ this .vehicles = []
19+
20+ init : (options ) ->
21+ options = if options then options else {}
22+ options .filter = if options .filter then open|| null
23+ options .poll = options .poll || true
24+ this .options = options
25+
26+ """ pull flight list """
27+ this .update_flight_list ()
28+
29+ update_flight_list : ->
30+ this .db .get_flights (data) ->
31+ current_ts = habitat .util .timestamp_now ()
32+
33+ for flight in data
34+ flight_ts = habitat .util .rfc3339_to_timestamp flight .start
35+
36+ if flight_ts < current_ts
37+ habitat .tracker .flights .active .push flight
38+ else
39+ habitat .tracker .flights .upcoming .push flight
40+
41+ null
42+
43+ test : ->
44+ out = $ (' body' )
45+
46+ out .append (" Upcoming flights<br><br>" )
47+ this .append (this .flights .upcoming )
48+ out .append (" <br>Active flights<br><br>" )
49+ this .append (this .flights .active )
50+
51+ append : (list ) ->
52+ out = $ (' body' )
53+
54+ for flight in list
55+ out .append " #{ flight .start } #{ flight .name } <br />"
Original file line number Diff line number Diff line change 1+ habitat .tracker .db =
2+
3+ # pulls latest flights from habitat
4+ get_flights : (callback , selector ) ->
5+ ts = Math .floor (new Date ()).getTime () / 1000
6+
7+ habitat .db .view " flight/end_start_including_payloads" , {
8+ startkey : [ts]
9+ include_docs : true
10+ success : (data ) ->
11+ last = null
12+ list = []
13+ payloads
14+
15+ # merge payload_configs into flight docs
16+ for row in data .rows
17+ doc = row .doc
18+
19+ if doc .type is " flight" and doc .approved is true
20+ last = doc
21+ payloads = doc .payloads
22+ doc .payloads = []
23+ list .push doc
24+ else if payloads .indexOf doc ._id is not - 1
25+ last .payloads .push doc
26+
27+ # return results
28+ callback list
29+ null
30+ }
31+
32+ fetch_payloads : (flight_docs ) ->
33+ list = []
34+
35+ for doc in flight_docs
36+ list .concat (doc .payloads );
37+
38+ null
Original file line number Diff line number Diff line change 1+
2+ habitat .util =
3+ timestamp_now : ->
4+ Math .floor (new Date ()).getTime () / 1000
5+
6+ rfc3339_to_timestamp : (str ) ->
7+ Math .floor (new Date str).getTime () / 1000
8+
9+ timestamp_to_rfc3339 : (ts ) ->
10+ date = new Date ()
11+ date .setTime ts * 1000
12+ date .toISOString ()
Original file line number Diff line number Diff line change 1+ from fabric .api import *
2+
3+ def compile_coffee ():
4+ local ("/usr/lib/node_modules/coffee-script/bin/coffee -b -c -o js/ coffee/*.coffee" )
5+
6+ def build ():
7+ compile_coffee ()
8+
9+ def clean ():
10+ local ("rm -f js/*js" )
Original file line number Diff line number Diff line change 33 < head >
44 < meta http-equiv ="Content-Type " content ="text/html; charset=UTF-8 " />
55 < title > habitat api test </ title >
6- < script type ="text/javascript " language ="javascript " src ="js/jquery-1.8.3-min.js "> </ script >
7- < script type ="text/javascript " language ="javascript " src ="js/jquery.couch.js "> </ script >
6+ < script type ="text/javascript " language ="javascript " src ="js/lib/ jquery-1.8.3-min.js "> </ script >
7+ < script type ="text/javascript " language ="javascript " src ="js/lib/ jquery.couch.js "> </ script >
88 < script type ="text/javascript " language ="javascript " src ="js/habitat.js "> </ script >
99 < script type ="text/javascript " language ="javascript " src ="js/habitat.util.js "> </ script >
1010 < script type ="text/javascript " language ="javascript " src ="js/habitat.tracker.js "> </ script >
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments