mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 01:02:58 +00:00
37 lines
972 B
JavaScript
37 lines
972 B
JavaScript
import { t } from '../util/locale';
|
|
export function Status(context) {
|
|
var connection = context.connection(),
|
|
errCount = 0;
|
|
|
|
return function(selection) {
|
|
|
|
function update() {
|
|
|
|
connection.status(function(err, apiStatus) {
|
|
|
|
selection.html('');
|
|
|
|
if (err && errCount++ < 2) return;
|
|
|
|
if (err) {
|
|
selection.text(t('status.error'));
|
|
|
|
} else if (apiStatus === 'readonly') {
|
|
selection.text(t('status.readonly'));
|
|
|
|
} else if (apiStatus === 'offline') {
|
|
selection.text(t('status.offline'));
|
|
}
|
|
|
|
selection.attr('class', 'api-status ' + (err ? 'error' : apiStatus));
|
|
if (!err) errCount = 0;
|
|
|
|
});
|
|
}
|
|
|
|
connection.on('auth', function() { update(selection); });
|
|
window.setInterval(update, 90000);
|
|
update(selection);
|
|
};
|
|
}
|