bigbluebutton-Github/bigbluebutton-html5/client/main.jsx

90 lines
2.4 KiB
React
Raw Normal View History

import React from 'react';
2016-04-29 03:02:51 +08:00
import { Meteor } from 'meteor/meteor';
import { render } from 'react-dom';
2017-01-11 07:14:23 +08:00
import { showModal } from '/imports/ui/components/app/service';
2016-04-29 03:02:51 +08:00
import { renderRoutes } from '../imports/startup/client/routes.js';
2016-10-02 23:46:15 +08:00
import { IntlProvider } from 'react-intl';
import Singleton from '/imports/ui/services/storage/local.js';
2017-01-11 07:14:23 +08:00
import AudioModalContainer from '/imports/ui/components/audio-modal/container';
function loadUserSettings() {
const userSavedFontSize = Singleton.getItem('bbbSavedFontSizePixels');
if (userSavedFontSize) {
document.getElementsByTagName('html')[0].style.fontSize = userSavedFontSize;
}
}
2017-01-11 07:14:23 +08:00
function setAudio() {
const LOG_CONFIG = Meteor.settings || {};
let autoJoinAudio = LOG_CONFIG.public.app.autoJoinAudio;
if (autoJoinAudio) {
showModal( <AudioModalContainer /> );
}
}
2016-10-13 09:16:34 +08:00
function setMessages(data) {
let messages = data;
let defaultLocale = 'en';
2016-10-13 09:16:34 +08:00
render((
<IntlProvider locale={defaultLocale} messages={messages}>
{renderRoutes()}
</IntlProvider>
), document.getElementById('app'));
2017-01-11 07:14:23 +08:00
setAudio();
}
2016-05-12 04:43:07 +08:00
// Helper to load javascript libraries from the BBB server
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}`);
if (typeof (cb) == 'function' || cb instanceof Function) {
cb();
}
2016-05-12 04:43:07 +08:00
};
const failCallback = function (cb, issue) {
console.error(`failed to load lib - ${this}`);
console.error(issue);
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');
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
loadUserSettings();
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-01-13 04:15:16 +08:00
});