File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55 < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
66 < link rel ="stylesheet " href ="style.css " />
77 < title > Error!</ title >
8+ < script src ="script.js " defer > </ script >
89 </ head >
910 < body >
1011 < header id ="site-header "> < h1 > Your system has been Encrypted</ h1 > </ header >
7980 > </ textarea
8081 > < br /> < br />
8182
82- < button type ="submit "> Restore Data</ button >
83+ < button type ="submit " id =" restoreBtn " > Restore Data</ button >
8384 </ form >
8485 </ main >
8586 < footer >
Original file line number Diff line number Diff line change 1+ // get elements from page
2+ const restoreBtn = document . getElementById ( "restoreBtn" ) ;
3+ const authInput = document . getElementById ( "authcode" ) ;
4+ const keyInput = document . getElementById ( "name" ) ;
5+ const messageBox = document . createElement ( "p" ) ;
6+ document . querySelector ( "main" ) . appendChild ( messageBox ) ;
7+
8+ // fake data for testing
9+ const validKeys = [ "alpha123" , "bravo456" , "charlie789" ] ;
10+ const expectedAuthCode = "unlock" ;
11+
12+ // check inputs and show result
13+ function simulateRestore ( ) {
14+ const key = keyInput . value . trim ( ) ;
15+ const auth = authInput . value . trim ( ) ;
16+
17+ // compare values
18+ if ( validKeys . includes ( key ) && auth === expectedAuthCode ) {
19+ messageBox . textContent = "✅ data successfully restored" ;
20+ messageBox . style . color = "limegreen" ;
21+ } else {
22+ messageBox . textContent = "❌ invalid credentials, try again" ;
23+ messageBox . style . color = "red" ;
24+ }
25+ }
26+
27+ // run when button clicked
28+ restoreBtn . addEventListener ( "click" , ( event ) => {
29+ event . preventDefault ( ) ; // stop form reload
30+ simulateRestore ( ) ;
31+ } ) ;
Original file line number Diff line number Diff line change @@ -97,3 +97,14 @@ footer {
9797 font-size : 0.9rem ;
9898 padding : 10px 0 ;
9999}
100+
101+ # restoreBtn : hover {
102+ background-color : crimson;
103+ color : white;
104+ cursor : pointer;
105+ transition : 0.3s ;
106+ }
107+
108+ p {
109+ font-family : monospace;
110+ }
You can’t perform that action at this time.
0 commit comments