-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcredentials.js
37 lines (30 loc) · 1.23 KB
/
credentials.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
function credentialsUpdate() {
const textArea = document.getElementById("textArea");
const user = localStorage.getItem("user");
const password = localStorage.getItem("password");
const host = localStorage.getItem("host");
const database = localStorage.getItem("database");
if (user && password && host && database) {
textArea.value = `Credentials \nUser: ${user}\nPassword: ${password}\nHost: ${host}\nDatabase: ${database}`;
} else {
console.log("No credentials found in localStorage.");
}
const credentials = prompt(
"Enter credentials in format: USER PASSWORD HOST DATABASE"
);
if (credentials) {
const [user, password, host, database] = credentials.split(" ");
if (user && password && host && database) {
alert(
`User: ${user}\nPassword: ${password}\nHost: ${host}\nDatabase: ${database}`
);
localStorage.setItem("user", user);
localStorage.setItem("password", password);
localStorage.setItem("host", host);
localStorage.setItem("database", database);
textArea.value = `Credentials \nUser: ${user}\nPassword: ${password}\nHost: ${host}\nDatabase: ${database}`;
} else {
alert("Please enter all four values: USER PASSWORD HOST DATABASE");
}
}
}