-
Notifications
You must be signed in to change notification settings - Fork 1
/
signup2.js
52 lines (42 loc) · 1.7 KB
/
signup2.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
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.6.0/firebase-app.js";
import { getDatabase, ref, set } from "https://www.gstatic.com/firebasejs/10.6.0/firebase-database.js";
const firebaseConfig = {
apiKey: "AIzaSyD6nDqwgjdIjbdlq9EvPnRTr7tAwyYaSgE",
authDomain: "codejam-4934c.firebaseapp.com",
databaseURL: "https://codejam-4934c-default-rtdb.firebaseio.com",
projectId: "codejam-4934c",
storageBucket: "codejam-4934c.appspot.com",
messagingSenderId: "1030276208419",
appId: "1:1030276208419:web:bd48475b7a045271bd5e96",
measurementId: "G-HS4QR21Y3P"
};
const app = initializeApp(firebaseConfig);
const database = getDatabase(app);
async function writeUserData(userId, username, photo, item, swap_info) {
console.log(username);
await set(ref(database, 'users/' + userId), {
username : username,
item : item,
photo : photo,
swap_info : swap_info
});
}
function inputs() {
let submitButton = document.getElementById('submit');
submitButton.addEventListener('click', async function() {
let username = document.getElementById('name').value;
let item = document.getElementById('item').value;
let photo = document.getElementById('photo').value;
let swap_info = document.getElementById('swapinfo').value;
await writeUserData(username, username, photo, item, swap_info);
window.location.href = "main.html";
})
}
inputs();
document.getElementById("signupButton").addEventListener("click", function() {
var wrapper = document.querySelector(".wrapper");
wrapper.classList.add("shake");
setTimeout(function() {
wrapper.classList.remove("shake");
}, 1000);
});