-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathapp.js
More file actions
38 lines (29 loc) · 921 Bytes
/
app.js
File metadata and controls
38 lines (29 loc) · 921 Bytes
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
'use strict';
var formInput;
function PlayerInfo(name, email, level, cardset) {
this.name = name;
this.email = email;
this.level = level;
this.cardset = cardset;
this.score = 0;
};
function storeData(key, object) {
var jsonString = JSON.stringify(object);
localStorage.setItem(key, jsonString);
};
function submitData(event) {
event.preventDefault();
var name = event.target.name.value.trim();
var email = event.target.email.value.trim();
var level = event.target.level.value.trim();
var cardset = event.target.cardset.value.trim();
var player = new PlayerInfo(name, email, level, cardset);
storeData('current_player', player);
event.target.name.value = null;
event.target.email.value = null;
event.target.level.value = null;
window.location = 'game.html';
};
//main
formInput = document.getElementById('front_form');
formInput.addEventListener('submit', submitData, false);