Commit 5d2932ac authored by rohieb's avatar rohieb

brand: integrate opening status in fancy Stratum 0 logo

The template is now only one template because we need to change the
heading on the outer template, but that is negligible. renderStatus()
has therefore been slacked down a lot.
parent 9288017b
......@@ -2,27 +2,16 @@ var httpreq = require('httpreq');
var Mustache = require('mustache');
var URL = 'https://stratum0.org/status/status.json';
var TEMPLATES = {};
var TEMPLATE = "";
require('fs').readFile('modules/brand/template.mustache', 'utf-8', function (err, data) {
TEMPLATES.template = data;
});
require('fs').readFile('modules/brand/status.mustache', 'utf-8', function (err, data) {
TEMPLATES.status = data;
TEMPLATE = data;
});
var status = {};
function renderStatus(sock, everything) {
var sendInner = function () {
status.random = ''+Math.random();
sock.emit('brand.status', Mustache.render(TEMPLATES.status, status));
}
if (everything) {
sock.emit('brand', Mustache.render(TEMPLATES.template, {}));
setTimeout(sendInner, 3000);
} else {
sendInner();
}
function renderStatus(sock) {
status.random = ''+Math.random();
sock.emit('brand', Mustache.render(TEMPLATE, status));
}
function fetchStatus(cb) {
......@@ -35,6 +24,7 @@ function fetchStatus(cb) {
cb(state);
} catch (e) {
console.log('brand: fetchStatus: ' + e);
cb({ lastchange: null });
}
});
}
......@@ -52,12 +42,11 @@ module.exports = function (io) {
}
if (firstTime && status) {
io.on('connection', function (sock) {
renderStatus(sock, true);
renderStatus(sock);
});
renderStatus(io, true);
firstTime = false;
} else {
renderStatus(io, false);
renderStatus(io);
}
});
}
......
Space is {{#open}}<span class="open">open</span> on <span class="person">{{trigger_person}}</span>{{/open}}
{{^open}}<span class="closed">closed</span>{{/open}}
<br>since {{since}}
<br>
<img style="width: 470px; height: 310px" src="http://maurudor.de/?rasd={{random}}"></img>
<img src="/modules/brand/stratum0_logo.svg"><br>
<h3 data-infodisplay-outlet="status"></h3>
{{#lastchange}}
{{#open}}
<img src="/modules/brand/stratum0_logo_open.svg" alt="Stratum 0 Logo – space is open"><br>
<h3>Space is <span class="open">open</span> on <span class="person">{{trigger_person}}</span>
{{/open}}
{{^open}}
<img src="/modules/brand/stratum0_logo_closed.svg" alt="Stratum 0 Logo – space is closed"><br>
<h3>Space is <span class="closed">closed</span>
{{/open}}
<br>since {{since}}</h3>
<br>
{{/lastchange}}
{{^lastchange}}
<img src="/modules/brand/stratum0_logo.svg" alt="Stratum 0 Logo – no SpaceAPI connection :-(" ><br>
{{! -- prevent flickering -- }}
<h3>{{! status }}&nbsp;<br>{{! since }}&nbsp;</h3><br>
{{/lastchange}}
<img style="width: 470px; height: 310px" src="http://maurudor.de/?rasd={{random}}"></img>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment