Skip to content

Commit cd223e9

Browse files
committed
upd login
1 parent c2775be commit cd223e9

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

src/App.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,6 @@
5757
right: 1em;
5858
font-size:small;
5959
color:lightgray;
60+
transition: 1s;
6061
}
6162

src/DataService.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,18 @@ export default function DataService() {
99
////////////////////////////////////////////////////////////
1010
function login() {
1111
let submit = null
12-
function tryLogin() {
12+
function tryLogin(username) {
1313
new Promise((res, rej) => {
14-
checkLogin(prompt("Введите логин", user || "")).then(res, rej)
15-
}).then(() => {
16-
submit()
17-
console.log('Login: ', user)
18-
$(".show_login").text(`Login: ${user}`).on("click", (e) => $(e.target).fadeOut(1000))
19-
}, tryLogin)
14+
checkLogin(prompt("Введите логин", username || "")).then(res, rej)
15+
}).then(onLogin, tryLogin)
16+
}
17+
function onLogin(username) {
18+
user = username
19+
submit()
20+
console.log('Login: ', user)
21+
const label = document.getElementsByClassName("show_login")[0]
22+
label.textContent = ''
23+
label.onclick = () => label.style.opacity = label.style.opacity !== '0' ? '0' : '1'
2024
}
2125
return new Promise((resolve) => {
2226
submit = resolve
@@ -26,13 +30,14 @@ export default function DataService() {
2630

2731
function checkLogin(str) {
2832
return new Promise((res, rej) => {
33+
let username
2934
try {
30-
user = str.replace(/@|;|:|\.|,|\/|\\|\||\$|\?|!|#|%|\*|\^|\+|=|\[|\]| |\\ |«|<|>/gi, "").trim()
31-
user && user.length > 3 && user.length < 20 && user === str
32-
? res()
33-
: rej()
35+
username = str.replace(/@|;|:|\.|,|\/|\\|\||\$|\?|!|#|%|\*|\^|\+|=|\[|\]| |\\ |«|<|>/gi, "").trim()
36+
username && username.length > 3 && username.length < 20 && username === str
37+
? res(username)
38+
: rej(username)
3439
} catch {
35-
rej()
40+
rej(username)
3641
}
3742
})
3843
}

0 commit comments

Comments
 (0)