-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
328 lines (299 loc) · 11.5 KB
/
index.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>URL Manager</title>
<style>
body {
font-family: 'Arial', sans-serif;
background-color: #eaf4f8;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.container {
background-color: #ffffff;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
padding: 30px;
max-width: 800px;
width: 100%;
}
h2 {
color: #3b2a78;
font-weight: bold;
font-size: 26px;
margin-bottom: 20px;
}
h3 {
color: #3b2a78;
font-weight: bold;
font-size: 16px;
border-bottom: 2px solid #3b2a78; /* Adjust thickness, style, and color */
padding-bottom: 5px; /* Optional padding to add space between text and border */
margin-bottom: 15px; /* Space below the border for separation */
}
label {
color: rgb(40, 145, 186);
font-size: 14px;
margin-bottom: 5px;
font-weight: bold;
display: block;
}
input[type="url"], input[type="text"] {
width: 96%;
padding: 10px;
margin-bottom: 15px;
border: 1px solid #efefef;
border-radius: 4px;
font-size: 14px;
color: #000; /* Black for user-entered text */
}
/* Change border color when input is active (focused) */
input[type="url"]:focus, input[type="text"]:focus {
border-color: #005f99; /* New border color when active */
outline: none; /* Remove default outline for a cleaner look */
}
/* Styling for placeholders */
input::placeholder {
color: #a9a9a9; /* Light gray for placeholder */
font-style: italic; /* Italic for placeholder text */
}
button {
background-color: #1aa469;
color: #ffffff;
padding: 10px 15px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 14px;
}
button:hover {
background-color: #1fbd6f;
}
.output, .form-group {
margin-top: 20px;
}
.url-output {
display: flex;
align-items: center;
justify-content: space-between;
margin: 5px 0;
font-size: 14px;
flex-wrap: wrap;
}
.url-output a {
color: #1aa469;
text-decoration: none;
flex-grow: 1;
margin-right: 10px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.url-output a:hover {
text-decoration: underline;
color:#005f99;
}
.timestamp {
font-size: 10px;
color: #888;
margin-right: 10px;
}
.empty {
font-size: 14px;
color: #888;
}
.remove-btn, .edit-btn, .copy-btn {
background-color: #d6094d;
color: #fff;
padding: 5px 10px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 12px;
margin-left: 5px;
}
.copy-btn {
background-color: #007acc;
}
.edit-btn {
background-color: #ff9900;
}
.remove-btn:hover {
background-color: #e02baa;
}
.copy-btn:hover {
background-color: rgb(40, 145, 186);
}
.edit-btn:hover {
background-color: #ffad33;
}
#clearButton {
background-color: #d6094d;
margin-top: 15px;
}
#clearButton:hover {
background-color: #e02baa;
}
</style>
</head>
<body>
<div class="container">
<h2 id="title">URL Manager</h2>
<!-- Base URL Input -->
<label for="baseUrl" id="baseUrlLabel">Enter your URL:</label>
<input type="url" id="baseUrl" placeholder="https://your-url.com" required>
<!-- Form for adding custom routes and parameters -->
<div class="form-group">
<label for="route" id="routeLabel">Add Route (optional):</label>
<input type="text" id="route" placeholder="/webhook">
<label for="params" id="paramsLabel">Add Parameters (optional, format: key=value):</label>
<input type="text" id="params" placeholder="?name=Kim&location=Paris">
<button id="addButton" onclick="addCustomUrl()">Save URL</button>
<button id="clearButton" onclick="clearStorage()">Clear All</button>
</div>
<!-- Search Bar -->
<div class="form-group">
<label for="search" id="searchLabel">Search URLs:</label>
<input type="text" id="search" placeholder="Search URLs" oninput="filterUrls()">
</div>
<!-- Display generated URLs -->
<div id="output" class="output"></div>
<!-- Footer Disclaimer inside the container for alignment -->
<p style="text-align: center; font-size: 10px; color: #007acc; margin-top: 40px;">
Brought to you by weberi, 2024. No guarantees or warranties implied.
</p>
</div>
<script>
// Language translations
const translations = {
en: {
title: "URL Manager",
baseUrlLabel: "Enter your URL:",
routeLabel: "Add Route (optional):",
paramsLabel: "Add Parameters (optional):",
addButton: "Save URL",
clearButton: "Clear All",
searchLabel: "Search URLs:",
generatedUrls: "URLs",
alertBaseUrl: "Please enter a URL."
},
de: {
title: "URL Manager",
baseUrlLabel: "URL eingeben:",
routeLabel: "Pfad hinzufügen (optional):",
paramsLabel: "Parameter hinzufügen (optional):",
addButton: "URL speichern",
clearButton: "Alle löschen",
searchLabel: "URLs suchen:",
generatedUrls: "URLs",
alertBaseUrl: "Bitte geben Sie eine URL ein."
}
};
// Detect user's language
const userLang = navigator.language.startsWith('de') ? 'de' : 'en';
const text = translations[userLang];
// Apply translations to the HTML
document.getElementById('title').textContent = text.title;
document.getElementById('baseUrlLabel').textContent = text.baseUrlLabel;
document.getElementById('routeLabel').textContent = text.routeLabel;
document.getElementById('paramsLabel').textContent = text.paramsLabel;
document.getElementById('addButton').textContent = text.addButton;
document.getElementById('clearButton').textContent = text.clearButton;
document.getElementById('searchLabel').textContent = text.searchLabel;
// Load URLs from localStorage
let customUrls = JSON.parse(localStorage.getItem('customUrls')) || [];
function addCustomUrl() {
const baseUrl = document.getElementById('baseUrl').value.trim();
const route = document.getElementById('route').value.trim();
const params = document.getElementById('params').value.trim();
if (!baseUrl) {
alert(text.alertBaseUrl);
return;
}
// Build full URL with optional route and parameters
let fullUrl = baseUrl;
if (route) {
fullUrl += route.startsWith('/') ? route : `/${route}`;
}
if (params) {
fullUrl += `${params}`;
}
// Add URL with timestamp
customUrls.push({ url: fullUrl, addedAt: new Date().toLocaleString() });
localStorage.setItem('customUrls', JSON.stringify(customUrls));
displayUrls();
// document.getElementById('route').value = '';
document.getElementById('params').value = '';
}
function displayUrls() {
const outputDiv = document.getElementById('output');
outputDiv.innerHTML = `<h3>${text.generatedUrls}</h3>`;
if (customUrls.length === 0) {
outputDiv.innerHTML = `<h3>${text.generatedUrls}</h3><p class="empty">No URLs saved yet.</p>`;
return; // Exit the function if no URLs are saved
}
customUrls.forEach((item, index) => {
const urlElement = document.createElement('div');
urlElement.className = 'url-output';
urlElement.innerHTML = `
<a href="${item.url}" target="_blank">${item.url}</a>
<span class="timestamp">(${item.addedAt})</span>
<button class="copy-btn" onclick="copyUrl('${item.url}')">Copy</button>
<button class="edit-btn" onclick="editUrl(${index})">Edit</button>
<button class="remove-btn" onclick="removeUrl(${index})">Clear</button>
`;
outputDiv.appendChild(urlElement);
});
}
function copyUrl(url) {
navigator.clipboard.writeText(url).then(() => alert('URL copied to clipboard'));
}
function editUrl(index) {
const newUrl = prompt('Edit URL:', customUrls[index].url);
if (newUrl) {
customUrls[index].url = newUrl;
localStorage.setItem('customUrls', JSON.stringify(customUrls));
displayUrls();
}
}
function removeUrl(index) {
customUrls.splice(index, 1);
localStorage.setItem('customUrls', JSON.stringify(customUrls));
displayUrls();
}
function clearStorage() {
localStorage.removeItem('customUrls');
customUrls = [];
displayUrls();
}
function filterUrls() {
const query = document.getElementById('search').value.toLowerCase();
const filteredUrls = customUrls.filter(item => item.url.toLowerCase().includes(query));
displayFilteredUrls(filteredUrls);
}
function displayFilteredUrls(filteredUrls) {
const outputDiv = document.getElementById('output');
outputDiv.innerHTML = `<h3>${text.generatedUrls}</h3>`;
filteredUrls.forEach((item, index) => {
const urlElement = document.createElement('div');
urlElement.className = 'url-output';
urlElement.innerHTML = `
<a href="${item.url}" target="_blank">${item.url}</a>
<span class="timestamp">(Added: ${item.addedAt})</span>
<button class="copy-btn" onclick="copyUrl('${item.url}')">Copy</button>
<button class="edit-btn" onclick="editUrl(${index})">Edit</button>
<button class="remove-btn" onclick="removeUrl(${index})">Clear</button>
`;
outputDiv.appendChild(urlElement);
});
}
document.addEventListener('DOMContentLoaded', displayUrls);
</script>
</body>
</html>