2019-01-07 05:53:44 -06:00
|
|
|
import { ipcRenderer } from 'electron';
|
2018-10-29 13:52:58 -05:00
|
|
|
import * as React from 'react';
|
|
|
|
import * as ReactDOM from 'react-dom';
|
2018-11-16 02:38:38 -06:00
|
|
|
|
2019-01-07 05:53:44 -06:00
|
|
|
import { i18n } from '../common/i18n-preload';
|
2018-12-19 00:16:03 -06:00
|
|
|
import AboutBox from './components/about-app';
|
2019-01-07 05:53:44 -06:00
|
|
|
import BasicAuth from './components/basic-auth';
|
2018-12-19 00:16:03 -06:00
|
|
|
import LoadingScreen from './components/loading-screen';
|
|
|
|
import MoreInfo from './components/more-info';
|
|
|
|
import ScreenPicker from './components/screen-picker';
|
2019-01-02 04:19:50 -06:00
|
|
|
import ScreenSharingIndicator from './components/screen-sharing-indicator';
|
|
|
|
|
|
|
|
const enum components {
|
|
|
|
aboutApp = 'about-app',
|
|
|
|
loadingScreen = 'loading-screen',
|
|
|
|
moreInfo = 'more-info',
|
|
|
|
screenPicker = 'screen-picker',
|
|
|
|
screenSharingIndicator = 'screen-sharing-indicator',
|
2019-01-07 05:53:44 -06:00
|
|
|
basicAuth = 'basic-auth',
|
2019-01-02 04:19:50 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
const loadStyle = (style) => {
|
|
|
|
const styles = document.createElement('link');
|
|
|
|
styles.rel = 'stylesheet';
|
|
|
|
styles.type = 'text/css';
|
|
|
|
styles.href = `./styles/${style}.css`;
|
|
|
|
document.getElementsByTagName('head')[0].appendChild(styles);
|
|
|
|
};
|
2018-10-29 13:52:58 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Loads the appropriate component
|
|
|
|
*/
|
2018-12-04 00:46:38 -06:00
|
|
|
const load = () => {
|
2018-10-29 13:52:58 -05:00
|
|
|
const query = new URL(window.location.href).searchParams;
|
2018-11-16 02:38:38 -06:00
|
|
|
const componentName = query.get('componentName');
|
2018-10-29 13:52:58 -05:00
|
|
|
|
|
|
|
let component;
|
|
|
|
switch (componentName) {
|
2019-01-02 04:19:50 -06:00
|
|
|
case components.aboutApp:
|
|
|
|
loadStyle(components.aboutApp);
|
2018-10-29 13:52:58 -05:00
|
|
|
component = AboutBox;
|
|
|
|
break;
|
2019-01-02 04:19:50 -06:00
|
|
|
case components.loadingScreen:
|
|
|
|
loadStyle(components.loadingScreen);
|
2018-11-16 02:38:38 -06:00
|
|
|
component = LoadingScreen;
|
|
|
|
break;
|
2019-01-02 04:19:50 -06:00
|
|
|
case components.moreInfo:
|
|
|
|
loadStyle(components.moreInfo);
|
2018-12-03 11:46:47 -06:00
|
|
|
component = MoreInfo;
|
|
|
|
break;
|
2019-01-02 04:19:50 -06:00
|
|
|
case components.screenPicker:
|
|
|
|
loadStyle(components.screenPicker);
|
2018-12-19 00:16:03 -06:00
|
|
|
component = ScreenPicker;
|
|
|
|
break;
|
2019-01-02 04:19:50 -06:00
|
|
|
case components.screenSharingIndicator:
|
|
|
|
loadStyle(components.screenSharingIndicator);
|
|
|
|
component = ScreenSharingIndicator;
|
|
|
|
break;
|
2019-01-07 05:53:44 -06:00
|
|
|
case components.basicAuth:
|
|
|
|
loadStyle(components.basicAuth);
|
|
|
|
component = BasicAuth;
|
|
|
|
break;
|
2018-10-29 13:52:58 -05:00
|
|
|
}
|
2018-11-15 03:15:37 -06:00
|
|
|
const element = React.createElement(component);
|
|
|
|
ReactDOM.render(element, document.getElementById('Root'));
|
2018-12-04 00:46:38 -06:00
|
|
|
};
|
|
|
|
|
2019-01-07 05:53:44 -06:00
|
|
|
document.addEventListener('DOMContentLoaded', load);
|
|
|
|
|
|
|
|
ipcRenderer.on('set-locale-resource', (_event, data) => {
|
|
|
|
const { locale, resource } = data;
|
|
|
|
i18n.setResource(locale, resource);
|
|
|
|
});
|