This repository was archived by the owner on Jan 3, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +106
-0
lines changed Expand file tree Collapse file tree 3 files changed +106
-0
lines changed Original file line number Diff line number Diff line change 1+ const genBtn = document . querySelector ( ".btn1" ) ;
2+ const copyBtn = document . querySelector ( ".btn2" ) ;
3+
4+ genBtn . addEventListener ( "click" , ( ) => genPassword ( ) ) ;
5+ copyBtn . addEventListener ( "click" , ( ) => copyPassword ( ) ) ;
6+
7+ function genPassword ( ) {
8+ let chars =
9+ "0123456789abcdefghijklmnopqristuvwxyz!@#$%^&*()ABCDEFGHIJKLMNOPQRSTUVWXYZ" ;
10+ passwordLength = 7 ;
11+ password = "" ;
12+
13+ for ( let i = 0 ; i <= passwordLength ; i ++ ) {
14+ let randomNumber = Math . floor ( Math . random ( ) * chars . length ) ;
15+ password += chars . substring ( randomNumber , randomNumber + 1 ) ;
16+ }
17+ document . getElementById ( "password" ) . value = password ;
18+ }
19+
20+ function copyPassword ( ) {
21+ let copyText = document . getElementById ( "password" ) ;
22+ copyText . select ( ) ;
23+ document . execCommand ( "copy" ) ;
24+ }
Original file line number Diff line number Diff line change 1+ < html lang ="en ">
2+ < head >
3+ < meta charset ="UTF-8 " />
4+ < meta http-equiv ="X-UA-Compatible " content ="IE=edge " />
5+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
6+ < title > Random Password Generator</ title >
7+ < link rel ="stylesheet " href ="style.css " />
8+ </ head >
9+ < body >
10+ < div class ="container ">
11+ < h2 > Random Password Generator</ h2 >
12+ < input type ="text " placeholder ="Create a Password " id ="password " />
13+ < div class ="buttons ">
14+ < button class ="btn1 "> Generate</ button >
15+ < button class ="btn2 "> Copy</ button >
16+ </ div >
17+ </ div >
18+
19+ < script src ="app.js "> </ script >
20+ </ body >
21+ </ html >
Original file line number Diff line number Diff line change 1+ * {
2+ margin : 0 ;
3+ padding : 0 ;
4+ box-sizing : border-box;
5+ user-select : none;
6+ font-family : sans-serif;
7+ }
8+
9+ : root {
10+ --main-color : rgb (7 , 7 , 55 );
11+ }
12+
13+ body {
14+ display : flex;
15+ justify-content : center;
16+ align-items : center;
17+ min-height : 100vh ;
18+ background : var (--main-color );
19+ }
20+
21+ .container {
22+ background : # fff ;
23+ padding : 30px ;
24+ }
25+
26+ .container h2 {
27+ margin-bottom : 40px ;
28+ text-align : center;
29+ font-size : 26px ;
30+ color : var (--main-color );
31+ }
32+
33+ input {
34+ padding : 20px ;
35+ user-select : none;
36+ height : 50px ;
37+ width : 400px ;
38+ border : none;
39+ outline : none;
40+ border : 2px solid var (--main-color );
41+ font-size : 20px ;
42+ }
43+
44+ .buttons {
45+ display : flex;
46+ justify-content : space-around;
47+ align-items : center;
48+ }
49+
50+ button {
51+ font-size : 15px ;
52+ margin-top : 40px ;
53+ border : 2px solid var (--main-color );
54+ width : 155px ;
55+ height : 50px ;
56+ text-align : center;
57+ background-color : var (--main-color );
58+ color : white;
59+ text-transform : uppercase;
60+ cursor : pointer;
61+ }
You can’t perform that action at this time.
0 commit comments