2014-06-24 01:26:16 +02:00
|
|
|
/**
|
|
|
|
* @provides javelin-behavior-aphlict-status
|
|
|
|
* @requires javelin-behavior
|
|
|
|
* javelin-aphlict
|
|
|
|
* phabricator-phtize
|
|
|
|
* javelin-dom
|
|
|
|
* @javelin
|
|
|
|
*/
|
|
|
|
|
|
|
|
JX.behavior('aphlict-status', function(config) {
|
|
|
|
var pht = JX.phtize(config.pht);
|
|
|
|
|
|
|
|
function update() {
|
|
|
|
var client = JX.Aphlict.getInstance();
|
|
|
|
if (!client) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var node;
|
|
|
|
try {
|
|
|
|
node = JX.$(config.nodeID);
|
|
|
|
} catch (ignored) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var status = client.getStatus();
|
2016-10-02 05:37:28 +02:00
|
|
|
var icon = config.icon[status];
|
2014-06-24 01:26:16 +02:00
|
|
|
var status_node = JX.$N(
|
|
|
|
'span',
|
|
|
|
{
|
2016-10-02 05:37:28 +02:00
|
|
|
className: 'connection-status-text aphlict-connection-status-' + status
|
2014-06-24 01:26:16 +02:00
|
|
|
},
|
|
|
|
pht(status));
|
|
|
|
|
2016-10-02 05:37:28 +02:00
|
|
|
var icon_node = new JX.PHUIXIconView()
|
|
|
|
.setIcon(icon['icon'])
|
|
|
|
.setColor(icon['color'])
|
|
|
|
.getNode();
|
|
|
|
|
|
|
|
var content = [icon_node, ' ', status_node];
|
|
|
|
|
|
|
|
JX.DOM.setContent(node, content);
|
2014-06-24 01:26:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
JX.Aphlict.listen('didChangeStatus', update);
|
|
|
|
update();
|
|
|
|
});
|