Skip to content

Commit

Permalink
Add files via upload (pranjay-poddar#4821)
Browse files Browse the repository at this point in the history
  • Loading branch information
code-soubhik authored Aug 7, 2023
1 parent 29d62c4 commit 5ed87c4
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 0 deletions.
31 changes: 31 additions & 0 deletions Frontend-Projects/Encoder Decoder/index.html
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>
17 changes: 17 additions & 0 deletions Frontend-Projects/Encoder Decoder/script.js
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;
}
60 changes: 60 additions & 0 deletions Frontend-Projects/Encoder Decoder/styles.css
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;
}

0 comments on commit 5ed87c4

Please sign in to comment.