This repository has been archived by the owner on Oct 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
index.js
executable file
·89 lines (81 loc) · 3.01 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
console.debug('Loading Theme');
import React from 'react';
import {render} from 'react-dom';
import injectTapEventPlugin from 'react-tap-event-plugin';
// Needed for onTouchTap
// http://stackoverflow.com/a/34015469/988941
injectTapEventPlugin();
// Load mock if in development mode
if (!lightdm && process.env.NODE_ENV === 'development') {
const LightDMMock = require("../LightDMMock/mock/LightDMMock.js");
// const LightDMMock = require("../LightDMMock/src/LightDMMock.js");
window.lightdm = new LightDMMock(true, 0, false);
window.lightdm.languages.push({code: 'es-ES', name: 'Spanish', territory: null});
window.lightdm.languages.push({code: 'af-AF', name: 'Africanese', territory: null});
window.lightdm.languages.push({code: 'ar-SR', name: 'Arabic', territory: null});
window.lightdm.languages.push({code: 'ja-JP', name: 'Japanese', territory: null});
window.lightdm.languages.push({code: 'zh-HK', name: 'Chinese', territory: null});
window.lightdm.languages.push({code: 'he-IS', name: 'Hebrew', territory: null});
for (let user of lightdm.users) {
user.username = user.name;
}
console.info('Mock users loaded:', lightdm.users)
lightdm.can_shutdown = lightdm.can_restart = lightdm.can_suspend = lightdm.can_hibernate = true;
if (!("config" in window)) {
window.config = {
get_bool: function(key) {
return true;
},
get_str: function(key) {
return "";
},
get_num: function(key) {
return 0;
}
};
}
if (!("greeterutil" in window)) {
window.greeterutil = {
dirlist: function(dir) {
return undefined;
}
}
}
}
if (!lightdm || !lightdm.languages) {
const timeout = setTimeout(() => {
clearInterval(interval);
document.body.innerHTML += '<h1 style="background-color: white; color: red;">Lightdm did not load</h1>';
throw new Error('lightdm did not load in time');
}, 1000);
const interval = setInterval(() => {
if (lightdm && lightdm.languages) {
clearInterval(interval);
clearTimeout(timeout);
return init();
}
}, 100);
} else {
init();
}
function init() {
let Main = require('./components/Main.jsx').default;
render(< Main / >, document.getElementById('wrapper'));
}
if (module.hot) {
module.hot.accept('./components/Main.jsx', () => requestAnimationFrame(() => {
// flushLogs();
init();
}));
// optional: mute HMR/WDS logs
// let log = console.log,
// logs = [];
// console.log = (t, ...args) => {
// if (typeof t === 'string' && t.match(/^\[(HMR|WDS)\]/)) {
// if (t.match(/(up to date|err)/i)) logs.push(t.replace(/^.*?\]\s*/m, ''), ...args);
// } else {
// log.call(console, t, ...args);
// }
// };
// let flushLogs = () => console.log(`%c🚀 ${logs.splice(0,logs.length).join(' ')}`, 'color:#888;');
}