-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
182 lines (157 loc) · 6.9 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Circuit Name Converter</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
.container {
max-width: 600px;
margin: auto;
}
label, textarea, input, button {
display: block;
width: 100%; /* Keep this for responsive design */
max-width: 100%; /* Ensure full width in container */
margin-bottom: 10px;
}
textarea, input {
padding: 10px;
font-size: 1em;
border-radius: 8px; /* Rounded corners */
border: 1px solid #ccc;
box-sizing: border-box; /* Ensures padding doesn't affect total width */
}
button {
background-color: #0056b3; /* Lighter blue color for main buttons */
color: white;
padding: 10px;
font-size: 1.2em;
border: none;
cursor: pointer;
border-radius: 8px; /* Rounded corners */
transition: background-color 0.3s ease; /* Smooth transition */
}
button:hover {
background-color: #004494; /* Darker shade on hover */
}
/* Style for the copy buttons */
button.copyButton {
background-color: #388E3C; /* Darker green for contrast */
}
button.copyButton:hover {
background-color: #2C6D2B; /* Darker shade on hover */
}
.output {
margin-top: 20px;
white-space: pre-line;
}
#copyButton1, #copyButton2 {
margin-top: 10px;
display: none; /* Initially hidden */
}
.template {
margin-bottom: 60px; /* Adds space between two templates */
}
hr {
border: 1px solid #ddd;
}
.copied-message {
color: green;
font-size: 0.9em;
display: none;
margin-top: 5px;
text-align: center; /* Center the message */
}
</style>
</head>
<body>
<div class="container">
<h2>Circuit Name Converter</h2>
<!-- Template for Circuit Name Conversion with Date -->
<div class="template">
<label for="circuitsWithDate">Enter circuit names (each on a new line) for conversion with date:</label>
<textarea id="circuitsWithDate" rows="6" placeholder="TX/VLXP/601760/001/WINW/ TX/VLXP/601760/002/WINW/"></textarea>
<label for="datePicker">Select Date (defaults to today, MM/DD/YYYY format):</label>
<input type="date" id="datePicker" placeholder="MM/DD/YYYY" pattern="\d{4}-\d{2}-\d{2}">
<button id="convertWithDate" onclick="convertCircuitsWithDate()">Convert with Date (RFC2544)</button>
<div class="output" id="outputWithDate"></div>
<button id="copyButton1" class="copyButton" onclick="copyToClipboard('outputWithDate', 'copyMessage1')">Copy to Clipboard</button>
<div class="copied-message" id="copyMessage1">Copied!</div>
</div>
<hr>
<!-- Template for Circuit Name Conversion without Date -->
<div class="template">
<label for="circuitsWithoutDate">Enter circuit names (each on a new line) for simple conversion:</label>
<textarea id="circuitsWithoutDate" rows="6" placeholder="TX/VLXP/601760/001/WINW/ TX/VLXP/601760/002/WINW/"></textarea>
<button id="convertWithoutDate" onclick="convertCircuitsWithoutDate()">Convert without Date</button>
<div class="output" id="outputWithoutDate"></div>
<button id="copyButton2" class="copyButton" onclick="copyToClipboard('outputWithoutDate', 'copyMessage2')">Copy to Clipboard</button>
<div class="copied-message" id="copyMessage2">Copied!</div>
</div>
</div>
<script>
// Set the default date as today
document.addEventListener('DOMContentLoaded', (event) => {
const today = new Date();
const formattedDate = today.toISOString().split('T')[0]; // Format YYYY-MM-DD
document.getElementById('datePicker').value = formattedDate;
});
function convertCircuitsWithDate() {
const input = document.getElementById('circuitsWithDate').value.trim();
// Get selected date, default to today if none is selected
const selectedDate = document.getElementById('datePicker').value || new Date().toISOString().split('T')[0];
const [year, month, day] = selectedDate.split('-');
// Date format for US: MM/DD/YYYY
const dateString = `RFC2544.${month}.${day}.${year}`;
const lines = input.split('\n');
const result = lines.map(line => {
// Remove spaces, convert / to ., and remove trailing / if present
let converted = line.replace(/\s+/g, '').replace(/\//g, '.').replace(/\.$/, '');
// Remove consecutive dots
converted = converted.replace(/\.{2,}/g, '.');
// Append the RFC2544 date string
return `${converted}.${dateString}`;
}).join('\n');
document.getElementById('outputWithDate').textContent = result;
// Show the copy button after conversion
document.getElementById('copyButton1').style.display = 'block';
}
function convertCircuitsWithoutDate() {
const input = document.getElementById('circuitsWithoutDate').value.trim();
const lines = input.split('\n');
const result = lines.map(line => {
// Remove spaces, convert / to ., and remove trailing / if present
let converted = line.replace(/\s+/g, '').replace(/\//g, '.').replace(/\.$/, '');
// Remove consecutive dots
converted = converted.replace(/\.{2,}/g, '.');
return converted;
}).join('\n');
document.getElementById('outputWithoutDate').textContent = result;
// Show the copy button after conversion
document.getElementById('copyButton2').style.display = 'block';
}
function copyToClipboard(outputId, messageId) {
const outputText = document.getElementById(outputId).textContent;
// Create a temporary textarea element to hold the text for copying
const tempTextarea = document.createElement('textarea');
tempTextarea.value = outputText;
document.body.appendChild(tempTextarea);
tempTextarea.select();
document.execCommand('copy');
document.body.removeChild(tempTextarea);
// Show the copied message
const messageElement = document.getElementById(messageId);
messageElement.style.display = 'block';
// Hide the message after 3 seconds
setTimeout(() => {
messageElement.style.display = 'none';
}, 3000);
}
</script>
</body>
</html>