-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
151 lines (149 loc) · 5.09 KB
/
index.html
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
/>
<script src="generate_passowrd.js"></script>
<script src="mobileview.js"></script>
<script src="config.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"></script>
<title>Password Generator</title>
<style>
body {
background-color: #f8f9fa;
}
.rounded-container {
border-radius: 10px;
background-color: #ffffff;
padding: 20px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
margin-top: 50px;
}
.btn-generate {
margin-top: 20px;
}
</style>
</head>
<body>
<div class="container rounded-container" id="container_background">
<form onsubmit="getReq(); return false;" id="passform">
<div class="row justify-content-center">
<div class="col-md-6">
<h2 class="text-center mb-4">Password Generator</h2>
<div class="mb-3">
<label for="wname" class="form-label">Website Name:</label>
<input
type="text"
class="form-control"
id="wname"
placeholder="Enter website name"
required
/>
</div>
<div class="mb-3">
<label for="uname" class="form-label">User Name:</label>
<input
type="text"
class="form-control"
id="uname"
placeholder="Enter Username"
required
/>
</div>
<div class="mb-3">
<label for="plen" class="form-label">Password Length:</label>
<input
type="number"
class="form-control"
id="plen"
placeholder="Enter password length"
required
/>
</div>
<div class="input-group mb-3">
<span class="input-group-text" id="gp">Generated passowrd </span>
<input
type="text"
aria-label="Generated passowrd"
class="form-control"
readonly
disabled
id="generated_passowrd"
/>
</div>
<div class="btn-group text-center">
<button type="submit" class="btn btn-primary">
Generate Password
</button>
<button type="button" class="btn btn-success" id="savebtn">
Save Password
</button>
<button type="button" class="btn btn-danger" onclick="clearall()">
Clear All
</button>
<button
type="button"
class="btn btn-primary"
onclick="window.location.href='show.html'"
;
>
Show passowrds
</button>
</div>
</div>
</div>
</form>
</div>
<script type="module">
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.7.1/firebase-app.js";
import { getAnalytics } from "https://www.gstatic.com/firebasejs/10.7.1/firebase-analytics.js";
import {
getAuth,
signInWithEmailAndPassword,
createUserWithEmailAndPassword,
} from "https://www.gstatic.com/firebasejs/10.7.1/firebase-auth.js";
import {
getDatabase,
ref,
update,
} from "https://www.gstatic.com/firebasejs/10.7.1/firebase-database.js";
const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
const db = getDatabase();
const dbref = ref(db);
let webname = document.getElementById("wname");
let uname = document.getElementById("uname");
let plength = document.getElementById("plen");
let generated_passowrd = document.getElementById("generated_passowrd");
let userid = sessionStorage.getItem("userid");
function savetodb() {
let website_name = String(webname.value);
let user_name = uname.value;
let pass_word = generated_passowrd.value;
if (sessionStorage.getItem("userid") != null) {
if (
update(ref(db, "useres/" + userid + "/saved_passowrds/"), {
[website_name]: {
username: user_name,
Password: pass_word,
},
})
) {
alert("Saved in your databse");
} else {
alert("Couldnt save your password! Please try again");
}
} else {
alert("Please login before saving data");
window.location.href = "login.html";
}
}
document.getElementById("savebtn").addEventListener("click", savetodb);
</script>
</body>
</html>