2016-05-04 04:40:46 +08:00
|
|
|
import React from 'react';
|
2016-04-29 03:02:51 +08:00
|
|
|
import { Meteor } from 'meteor/meteor';
|
|
|
|
import { render } from 'react-dom';
|
|
|
|
import { renderRoutes } from '../imports/startup/client/routes.js';
|
2016-05-04 04:40:46 +08:00
|
|
|
import { IntlProvider, addLocaleData } from 'react-intl';
|
2016-06-09 04:09:43 +08:00
|
|
|
import {vertoInitialize} from '/imports/api/verto';
|
2016-05-04 04:40:46 +08:00
|
|
|
|
|
|
|
import Locales from '../imports/locales';
|
|
|
|
|
|
|
|
import en from 'react-intl/locale-data/en';
|
|
|
|
import es from 'react-intl/locale-data/es';
|
|
|
|
import pt from 'react-intl/locale-data/pt';
|
|
|
|
|
|
|
|
/* TODO: Add this dynamically */
|
|
|
|
addLocaleData([...en, ...es, ...pt]);
|
|
|
|
|
|
|
|
// Safari sends us en-us instead of en-US
|
2016-05-06 06:30:57 +08:00
|
|
|
let locale = navigator.language.split('-');
|
2016-05-04 04:40:46 +08:00
|
|
|
locale = locale[1] ? `${locale[0]}-${locale[1].toUpperCase()}` : navigator.language;
|
|
|
|
|
2016-06-03 04:32:42 +08:00
|
|
|
// locale = 'pt-BR'; // Set a locale for testing
|
|
|
|
|
2016-05-04 04:40:46 +08:00
|
|
|
/* TODO: We should load the en first then merge with the en-US
|
|
|
|
(eg: load country translation then region) */
|
2016-06-03 04:32:42 +08:00
|
|
|
let messages = Locales[locale] || Locales.en || {};
|
2016-03-01 22:53:56 +08:00
|
|
|
|
2016-05-12 04:43:07 +08:00
|
|
|
// Helper to load javascript libraries from the BBB server
|
2016-05-27 04:46:11 +08:00
|
|
|
function loadLib(libname, success, fail) {
|
2016-05-28 00:34:03 +08:00
|
|
|
const successCallback = function (cb) {
|
2016-05-27 03:57:44 +08:00
|
|
|
console.log(`successfully loaded lib - ${this}`);
|
2016-05-27 04:46:11 +08:00
|
|
|
if (typeof (cb) == 'function' || cb instanceof Function) {
|
|
|
|
cb();
|
|
|
|
}
|
2016-05-12 04:43:07 +08:00
|
|
|
};
|
|
|
|
|
2016-06-09 04:09:43 +08:00
|
|
|
const failCallback = function (cb, issue) {
|
|
|
|
console.error(`failed to load lib - ${this}`);
|
|
|
|
console.error(issue);
|
2016-05-27 04:46:11 +08:00
|
|
|
if (typeof (cb) == 'function' || cb instanceof Function) {
|
|
|
|
cb();
|
|
|
|
}
|
2016-05-27 03:57:44 +08:00
|
|
|
};
|
|
|
|
|
2016-05-28 00:34:03 +08:00
|
|
|
return Meteor.Loader.loadJs(`${window.location.origin}/client/lib/${libname}`,
|
|
|
|
successCallback.bind(libname, success), 10000).fail(failCallback.bind(libname, fail));
|
2016-05-12 04:43:07 +08:00
|
|
|
};
|
|
|
|
|
2016-01-13 04:15:16 +08:00
|
|
|
Meteor.startup(() => {
|
2016-05-12 04:43:07 +08:00
|
|
|
loadLib('sip.js');
|
|
|
|
loadLib('bbb_webrtc_bridge_sip.js');
|
|
|
|
loadLib('bbblogger.js');
|
2016-05-27 03:58:30 +08:00
|
|
|
loadLib('jquery.json-2.4.min.js');
|
2016-05-20 04:18:05 +08:00
|
|
|
loadLib('jquery.FSRTC.js');
|
2016-06-09 04:09:43 +08:00
|
|
|
loadLib('jquery.verto.js');
|
|
|
|
loadLib('verto_extension.js', vertoInitialize);
|
2016-05-20 04:18:05 +08:00
|
|
|
loadLib('jquery.jsonrpcclient.js');
|
|
|
|
loadLib('verto_extension_share.js');
|
2016-05-12 04:43:07 +08:00
|
|
|
|
2016-05-04 04:40:46 +08:00
|
|
|
render((
|
|
|
|
<IntlProvider locale={locale} messages={messages}>
|
|
|
|
{renderRoutes()}
|
|
|
|
</IntlProvider>
|
|
|
|
), document.getElementById('app'));
|
2016-01-13 04:15:16 +08:00
|
|
|
});
|