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

60 lines
1.6 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-01-13 04:15:16 +08:00
Meteor.startup(() => {
loadUserSettings();
let browserLanguage = navigator.language; //set this manually to force localization in a specific language
2016-10-13 09:16:34 +08:00
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
});