-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathUrlShortner.html
123 lines (108 loc) · 3.53 KB
/
UrlShortner.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>URL-Shortner</title>
<style>
.button {
background-color: #4CAF50;
/* Green */
border: none;
color: white;
padding: 16px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
transition-duration: 0.4s;
cursor: pointer;
}
.submit {
background-color: white;
color: black;
border: 2px solid #008CBA;
border-radius: 10px;
height: 54px;
width: 150px;
}
.submit:hover {
background-color: #008CBA;
color: white;
}
.copy {
background-color: white;
color: black;
border: 2px solid #41F0D1;
border-radius: 10px;
height: 54px;
width: 150px;
}
.copy:hover {
background-color: #41F0D1;
color: white;
}
input[type=text] {
width: 50%;
padding: 12px 20px;
margin: 8px 0;
box-sizing: border-box;
border-radius: 10px;
}
</style>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-iYQeCzEYFbKjA/T2uDLTpkwGzCiq6soy8tYaI1GyVh/UjpbCx/TYkiZhlZB6+fzT" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-u1OknCvxWvY5kfmNBILK2hRnQC3Pr17a+RTT6rIHI7NnikvbZlHgTPOOmMi466C8"
crossorigin="anonymous"></script>
<script src="index.js">
</script>
</head>
<body style="background-color: #ffffff">
<center>
<div class="container">
<h2 style="
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
color: #1993fd;font-size: 50px;
margin-top: 40px;">
<b>Short URL</b>
</h2>
</div>
<div class="box" style="border:5px solid whitesmoke ; width:800px; height: 300px;
padding: 40px;margin-top: 40px;">
<b>
<h1
style="font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;">
Paste the URL to be shortened</h1>
</b>
<div class="buttoncontainer">
<input id="inputText" type="text" placeholder="Enter the link here">
<button class="submit" onclick="result()">Shorten URL</button>
<button class="copy" onclick="copyToClipboard()">Copy URL</button>
</div>
<p id="paragraph" style="padding:20px;">ShortURL is a free tool to shorten a URL or reduce a link
Use our URL Shortener to create a shortened link making it easy to remember</p>
</div>
</div>
</center>
<script>
async function result() {
let inputValue = document.getElementById("inputText").value;
let shortUrl = document.getElementById("paragraph");
await fetch(`https://api.shrtco.de/v2/shorten?url=${inputValue}`)
.then((response) => response.json())
.then((json) => {
shortUrl.innerText = `Your Short URL : ${json.result.full_short_link}`;
document.getElementById("inputText").value = json.result.full_short_link;
});
}
async function copyToClipboard() {
let inputValue = document.getElementById("inputText").value;
const copied = alert(`Copied to clipboard successfully `);
}
</script>
</body>
</html>