forked from pranjay-poddar/Dev-Geeks
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add files via upload (pranjay-poddar#4821)
- Loading branch information
1 parent
29d62c4
commit 5ed87c4
Showing
3 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>URL Encoder/Decoder</title> | ||
<link rel="stylesheet" href="styles.css"> | ||
</head> | ||
|
||
<body> | ||
<div class="container"> | ||
<h1>URL Encoder/Decoder</h1> | ||
<input type="text" id="inputUrl" placeholder="Enter URL"> | ||
<div class="encodeDecode"> | ||
<div class="opt"> | ||
<input type="radio" name="action" id="encode" value="encode" checked> | ||
<label for="encode">Encode</label> | ||
</div> | ||
<div class="opt"> | ||
<input type="radio" name="action" id="decode" value="decode"> | ||
<label for="decode">Decode</label> | ||
</div> | ||
</div> | ||
<button onclick="process()">Submit</button> | ||
<div id="result"></div> | ||
</div> | ||
<script src="script.js"></script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
function process() { | ||
const inputUrl = document.getElementById('inputUrl').value; | ||
const action = document.querySelector('input[name="action"]:checked').value; | ||
let result; | ||
|
||
if (action === 'encode') { | ||
result = encodeURIComponent(inputUrl); | ||
} else if (action === 'decode') { | ||
try { | ||
result = decodeURIComponent(inputUrl); | ||
} catch (error) { | ||
result = 'Invalid URL'; | ||
} | ||
} | ||
|
||
document.getElementById('result').innerText = result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
body { | ||
font-family: Arial, sans-serif; | ||
background-color: #f4f4f4; | ||
margin: 0; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100vh; | ||
} | ||
|
||
.container { | ||
background-color: #fff; | ||
padding: 20px; | ||
border-radius: 5px; | ||
box-shadow: 0 0 5px rgba(0, 0, 0, 0.3); | ||
text-align: center; | ||
} | ||
|
||
h1 { | ||
margin-bottom: 20px; | ||
} | ||
|
||
input[type="text"] { | ||
width: 100%; | ||
max-width: -webkit-fill-available; | ||
padding: 10px; | ||
margin-bottom: 10px; | ||
border: 1px solid #ccc; | ||
border-radius: 5px; | ||
} | ||
.encodeDecode{ | ||
display: flex; | ||
justify-content: space-around; | ||
align-items: center; | ||
height: 50px; | ||
} | ||
|
||
button { | ||
padding: 10px 20px; | ||
background-color: #007bff; | ||
color: #fff; | ||
border: none; | ||
border-radius: 5px; | ||
cursor: pointer; | ||
} | ||
|
||
#result { | ||
margin-top: 20px; | ||
font-weight: bold; | ||
} | ||
|
||
.opt{ | ||
gap: 10px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
.opt>input{ | ||
margin: 0; | ||
} |