Mercurial > code > home > repos > homeauto
annotate service/wallscreen/gui.js @ 114:4cd065b97fa1
bugs in async http client. move trig helpers to rdflibtrig, which can work with rdflib 4
Ignore-this: 81dc30256f5d2658e53fce60abea66db
author | drewp@bigasterisk.com |
---|---|
date | Tue, 10 Sep 2013 00:38:52 -0700 |
parents | 66f8897b74ea |
children |
rev | line source |
---|---|
61 | 1 var reloadData; |
2 $(function () { | |
3 | |
4 setTimeout(function () { | |
5 window.resizeTo(702,480); | |
6 }, 10000); | |
7 | |
8 var model = { | |
9 requestedF: ko.observable(), | |
10 tasks: ko.observableArray([]), | |
11 events: ko.observableArray([]), | |
12 isToday: function (ev) { | |
13 var today = moment().format("YYYY-MM-DD"); | |
14 return ev.date == today; | |
113
66f8897b74ea
wallscreen show map of people and their distances from home
drewp@bigasterisk.com
parents:
68
diff
changeset
|
15 }, |
66f8897b74ea
wallscreen show map of people and their distances from home
drewp@bigasterisk.com
parents:
68
diff
changeset
|
16 mapPersonData: ko.observable(), |
61 | 17 }; |
18 reloadData = function() { | |
19 $.getJSON("content", function (data) { | |
20 model.tasks(data.tasks); | |
21 model.events(data.events); | |
22 }); | |
23 } | |
24 setInterval(reloadData, 30*60*1000); | |
25 reloadData(); | |
26 | |
113
66f8897b74ea
wallscreen show map of people and their distances from home
drewp@bigasterisk.com
parents:
68
diff
changeset
|
27 reloadMap = function () { |
66f8897b74ea
wallscreen show map of people and their distances from home
drewp@bigasterisk.com
parents:
68
diff
changeset
|
28 $.getJSON("content/map", function (data) { |
66f8897b74ea
wallscreen show map of people and their distances from home
drewp@bigasterisk.com
parents:
68
diff
changeset
|
29 var personData = []; |
66f8897b74ea
wallscreen show map of people and their distances from home
drewp@bigasterisk.com
parents:
68
diff
changeset
|
30 data.pts.forEach(function (pt) { |
66f8897b74ea
wallscreen show map of people and their distances from home
drewp@bigasterisk.com
parents:
68
diff
changeset
|
31 // this is in another config but not yet in the graph |
66f8897b74ea
wallscreen show map of people and their distances from home
drewp@bigasterisk.com
parents:
68
diff
changeset
|
32 var initial = pt.who.split("#")[1].substr(0, 1).toUpperCase(); |
66f8897b74ea
wallscreen show map of people and their distances from home
drewp@bigasterisk.com
parents:
68
diff
changeset
|
33 pt.initial = initial; |
66f8897b74ea
wallscreen show map of people and their distances from home
drewp@bigasterisk.com
parents:
68
diff
changeset
|
34 pt.topFrac = initial == 'K' ? 0 : .5; |
66f8897b74ea
wallscreen show map of people and their distances from home
drewp@bigasterisk.com
parents:
68
diff
changeset
|
35 personData.push(pt); |
66f8897b74ea
wallscreen show map of people and their distances from home
drewp@bigasterisk.com
parents:
68
diff
changeset
|
36 }); |
66f8897b74ea
wallscreen show map of people and their distances from home
drewp@bigasterisk.com
parents:
68
diff
changeset
|
37 model.mapPersonData(personData); |
66f8897b74ea
wallscreen show map of people and their distances from home
drewp@bigasterisk.com
parents:
68
diff
changeset
|
38 }); |
66f8897b74ea
wallscreen show map of people and their distances from home
drewp@bigasterisk.com
parents:
68
diff
changeset
|
39 }; |
66f8897b74ea
wallscreen show map of people and their distances from home
drewp@bigasterisk.com
parents:
68
diff
changeset
|
40 setInterval(reloadMap, 2*60*1000); |
66f8897b74ea
wallscreen show map of people and their distances from home
drewp@bigasterisk.com
parents:
68
diff
changeset
|
41 reloadMap(); |
66f8897b74ea
wallscreen show map of people and their distances from home
drewp@bigasterisk.com
parents:
68
diff
changeset
|
42 |
61 | 43 function onMessage(d) { |
44 if (d.tempF) { | |
45 model.requestedF(d.tempF); | |
46 } | |
47 } | |
68 | 48 reconnectingWebSocket("ws://bang.bigasterisk.com:9102/live", onMessage); |
61 | 49 |
50 ko.applyBindings(model); | |
51 | |
52 if (navigator.userAgent == "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:18.0) Gecko/18.0 Firefox/18.0") { | |
53 $(".rot").removeClass("rot"); | |
54 } | |
55 | |
56 function updateClock() { | |
57 var now = moment(); | |
58 var s = (new Date()).toLocaleTimeString(); | |
59 $("#clock").html( | |
60 "<div>"+now.format("dddd")+"</div>"+ | |
61 "<div>"+now.format("MMM Do")+"</div>"+ | |
62 "<div>"+now.format("HH:mm")+"</div>" | |
63 ) | |
64 } | |
65 setInterval(updateClock, 20000) | |
66 updateClock(); | |
67 }); |