annotate service/wallscreen/gui.js @ 454:ccde9f432e4e

WIP speechmusic to load from http, but pulseaudio out is broken Ignore-this: 28a41741b1f33114348f5ec6e7b4bef9
author drewp@bigasterisk.com
date Fri, 19 Apr 2019 13:51:54 -0700
parents 66f8897b74ea
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
61
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
1 var reloadData;
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
2 $(function () {
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
3
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
4 setTimeout(function () {
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
5 window.resizeTo(702,480);
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
6 }, 10000);
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
7
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
8 var model = {
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
9 requestedF: ko.observable(),
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
10 tasks: ko.observableArray([]),
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
11 events: ko.observableArray([]),
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
12 isToday: function (ev) {
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
13 var today = moment().format("YYYY-MM-DD");
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
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
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
17 };
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
18 reloadData = function() {
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
19 $.getJSON("content", function (data) {
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
20 model.tasks(data.tasks);
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
21 model.events(data.events);
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
22 });
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
23 }
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
24 setInterval(reloadData, 30*60*1000);
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
25 reloadData();
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
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
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
43 function onMessage(d) {
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
44 if (d.tempF) {
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
45 model.requestedF(d.tempF);
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
46 }
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
47 }
68
85d12376b415 wallscreen hostname and size
drewp@bigasterisk.com
parents: 61
diff changeset
48 reconnectingWebSocket("ws://bang.bigasterisk.com:9102/live", onMessage);
61
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
49
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
50 ko.applyBindings(model);
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
51
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
52 if (navigator.userAgent == "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:18.0) Gecko/18.0 Firefox/18.0") {
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
53 $(".rot").removeClass("rot");
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
54 }
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
55
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
56 function updateClock() {
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
57 var now = moment();
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
58 var s = (new Date()).toLocaleTimeString();
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
59 $("#clock").html(
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
60 "<div>"+now.format("dddd")+"</div>"+
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
61 "<div>"+now.format("MMM Do")+"</div>"+
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
62 "<div>"+now.format("HH:mm")+"</div>"
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
63 )
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
64 }
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
65 setInterval(updateClock, 20000)
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
66 updateClock();
1afb0564636d use websockets for temperature update
drewp@bigasterisk.com
parents:
diff changeset
67 });