-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
44 lines (35 loc) · 1.09 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
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import registerServiceWorker from './registerServiceWorker';
import './index.css';
import * as firebase from 'firebase'
let config = {
apiKey: "AIzaSyAq6GLAZRaxTamJP7PWycWp3akQj0AUkGQ",
authDomain: "chat-4bbc0.firebaseapp.com",
databaseURL: "https://chat-4bbc0.firebaseio.com",
projectId: "chat-4bbc0",
storageBucket: "chat-4bbc0.appspot.com",
messagingSenderId: "10795783710"
};
// Initialize Firebase
firebase.initializeApp(config);
function getUserName() {
const person = prompt("Please choose a username", "username");
if (person) {
return person;
}
//Generate a username if not given
else {
const randomNumber = getRandomInt(0, 1000);
return "user" + randomNumber;
}
}
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min;
}
let person = getUserName();
ReactDOM.render(<App username={person} />, document.getElementById('root'));
registerServiceWorker();