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';
|
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';
|
2016-12-20 05:45:09 +08:00
|
|
|
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';
|
2016-12-20 05:45:09 +08:00
|
|
|
|
|
|
|
function loadUserSettings() {
|
|
|
|
const userSavedFontSize = Singleton.getItem('bbbSavedFontSizePixels');
|
|
|
|
|
|
|
|
if (userSavedFontSize) {
|
|
|
|
document.getElementsByTagName('html')[0].style.fontSize = userSavedFontSize;
|
|
|
|
}
|
|
|
|
}
|
2016-10-08 00:36:27 +08:00
|
|
|
|
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-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'));
|
2017-01-11 07:14:23 +08:00
|
|
|
|
|
|
|
setAudio();
|
2016-10-08 00:36:27 +08:00
|
|
|
}
|
2016-05-04 04:40:46 +08:00
|
|
|
|
2016-01-13 04:15:16 +08:00
|
|
|
Meteor.startup(() => {
|
2016-12-14 11:40:32 +08:00
|
|
|
|
2016-12-20 05:45:09 +08:00
|
|
|
loadUserSettings();
|
|
|
|
|
2017-01-24 05:19:53 +08:00
|
|
|
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-10-08 00:36:27 +08:00
|
|
|
|
2016-01-13 04:15:16 +08:00
|
|
|
});
|