-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.js
31 lines (29 loc) · 955 Bytes
/
init.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
function store() {
let input = document.getElementById("input");
let username = input.value;
if(username !== "" && username.length <= 10){
console.log(username.length);
localStorage.setItem("gamer_name", username);
window.location.href = ("../main.html");
}else{
if(username.length > 10){
console.log("Ошибка");
window.alert("Имя не может быть длиннее 10 символов!");
}
else {
console.log("Ошибка");
window.alert("Введите имя");
}
}
}
function set_name() {
if(localStorage.hasOwnProperty("gamer_name")){
let name = localStorage.getItem("gamer_name");
console.log(name)
let input = document.getElementById("input");
input.value = name;
}
}
function read(){
document.getElementById("username").innerHTML = localStorage["gamer_name"];
}