[TASK] Wait for loaded language

This commit is contained in:
Xaver Maierhofer 2017-11-05 16:58:41 +01:00 committed by GitHub
parent b89e99b79e
commit 6add4f0916
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 2 deletions

View File

@ -1,5 +1,6 @@
define(['sorttable', 'snabbdom', 'helper'], function (SortTable, V, helper) {
'use strict';
V = V.default;
function linkName(d) {
return (d.source ? d.source.hostname : d.source.id) + ' ' + d.target.hostname;
@ -30,7 +31,6 @@ define(['sorttable', 'snabbdom', 'helper'], function (SortTable, V, helper) {
return function (linkScale) {
var table = new SortTable(headings, 2, renderRow);
V = V.default;
function renderRow(d) {
var td1Content = [V.h('a', {

View File

@ -87,6 +87,21 @@ define(['moment', 'utils/router', 'leaflet', 'gui', 'helper', 'utils/language'],
}
update()
.then(function (d) {
return new Promise(function (resolve, reject) {
var count = 0;
(function waitForLanguage() {
if (Object.keys(_.phrases).length > 0) {
resolve(d);
} else if (count > 500) {
reject(new Error('translation not loaded after 10 seconds'));
} else {
setTimeout(waitForLanguage.bind(this), 20);
}
count++;
})();
});
})
.then(function (d) {
var gui = new GUI(language);
gui.setData(d);

View File

@ -1,11 +1,11 @@
define(['d3-interpolate', 'snabbdom', 'filters/genericnode', 'helper'],
function (d3Interpolate, V, Filter, helper) {
'use strict';
V = V.default;
return function (filterManager) {
var self = this;
var scale = d3Interpolate.interpolate('#770038', '#dc0067');
V = V.default;
var statusTable;
var fwTable;