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-10-02 23:46:15 +08:00
|
|
|
import { IntlProvider } from 'react-intl';
|
2016-10-08 00:36:27 +08:00
|
|
|
|
2016-10-13 09:16:34 +08:00
|
|
|
function setMessages(data) {
|
|
|
|
let messages = data;
|
|
|
|
let defaultLocale = 'en';
|
2016-10-08 00:36:27 +08:00
|
|
|
|
2016-10-13 09:16:34 +08:00
|
|
|
render((
|
|
|
|
<IntlProvider locale={defaultLocale} messages={messages}>
|
|
|
|
{renderRoutes()}
|
|
|
|
</IntlProvider>
|
|
|
|
), document.getElementById('app'));
|
2016-10-08 00:36:27 +08:00
|
|
|
}
|
2016-05-04 04:40:46 +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');
|
2016-06-18 01:47:24 +08:00
|
|
|
loadLib('verto_extension.js');
|
2016-05-20 04:18:05 +08:00
|
|
|
loadLib('jquery.jsonrpcclient.js');
|
2016-05-12 04:43:07 +08:00
|
|
|
|
2016-10-13 09:16:34 +08:00
|
|
|
let browserLanguage = navigator.language;
|
|
|
|
let request = new Request
|
|
|
|
(`${window.location.origin}/html5client/locale?locale=${browserLanguage}`);
|
|
|
|
|
|
|
|
fetch(request, { method: 'GET' })
|
|
|
|
.then(function (response) {
|
|
|
|
return response.json();
|
|
|
|
})
|
2016-10-14 02:19:53 +08:00
|
|
|
.then(function (data) {
|
2016-10-13 09:16:34 +08:00
|
|
|
setMessages(data);
|
|
|
|
})
|
2016-10-14 02:19:53 +08:00
|
|
|
.catch(function error(err) {
|
|
|
|
console.log('request failed', err);
|
2016-10-13 09:16:34 +08:00
|
|
|
});
|
2016-10-08 00:36:27 +08:00
|
|
|
|
2016-01-13 04:15:16 +08:00
|
|
|
});
|