-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathurl-encode-decode.html
35 lines (34 loc) · 1.06 KB
/
url-encode-decode.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Tools - URL encode/decode</title>
<script src="components/sidebar-component.js"></script>
<script src="components/header-component.js"></script>
<link href="index.css" rel="stylesheet">
</head>
<body>
<header-component></header-component>
<sidebar-component></sidebar-component>
<main>
<textarea id="content"></textarea>
<button onclick="performOperation()">Submit</button>
<select id="operation-choice" title="Operation choice">
<option value="encode">Encode</option>
<option value="decode">Decode</option>
</select>
<code id="output"></code>
</main>
<script>
function performOperation() {
const content = document.getElementById('content').value;
const operation = document.getElementById('operation-choice').value;
if (operation === 'encode') {
document.getElementById('output').innerHTML = encodeURI(content)
} else {
document.getElementById('output').innerHTML = decodeURI(content)
}
}
</script>
</body>
</html>