-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathcron-expression-builder.html
More file actions
247 lines (220 loc) · 6.8 KB
/
Copy pathcron-expression-builder.html
File metadata and controls
247 lines (220 loc) · 6.8 KB
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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Cron Expression Builder — One File Tools</title>
<style>
:root {
--app-bg: #0d1117;
--app-text: #c9d1d9;
--app-primary: #58a6ff;
--app-primary-hover: #79c0ff;
--app-secondary: #21262d;
--app-panel: #161b22;
--app-border: #30363d;
--accent-green: #2ea043;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family:
"Inter",
-apple-system,
sans-serif;
background-color: var(--app-bg);
color: var(--app-text);
padding: 2rem;
display: flex;
flex-direction: column;
align-items: center;
min-height: 100vh;
}
header {
text-align: center;
margin-bottom: 2rem;
}
h1 {
color: var(--app-primary);
font-size: 2rem;
margin-bottom: 0.5rem;
}
main {
width: 100%;
max-width: 900px;
display: flex;
flex-direction: column;
gap: 1.5rem;
}
.panel {
background: var(--app-panel);
border: 1px solid var(--app-border);
border-radius: 12px;
padding: 1.5rem;
}
.cron-display {
font-family: monospace;
font-size: 3rem;
text-align: center;
margin: 1rem 0;
letter-spacing: 0.5rem;
color: var(--app-primary);
}
.explanation {
text-align: center;
font-size: 1.2rem;
margin-bottom: 1.5rem;
color: var(--accent-green);
}
.inputs-grid {
display: grid;
grid-template-columns: repeat(5, 1fr);
gap: 1rem;
}
@media (max-width: 768px) {
.inputs-grid {
grid-template-columns: 1fr;
}
.cron-display {
font-size: 2rem;
}
}
.field-group {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
label {
font-size: 0.85rem;
font-weight: bold;
color: #8b949e;
text-align: center;
}
input[type="text"] {
width: 100%;
padding: 0.8rem;
border-radius: 6px;
border: 1px solid var(--app-border);
background: var(--app-secondary);
color: var(--app-text);
font-family: monospace;
text-align: center;
font-size: 1.2rem;
}
input[type="text"]:focus {
border-color: var(--app-primary);
outline: none;
}
.presets {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
justify-content: center;
margin-top: 1.5rem;
padding-top: 1.5rem;
border-top: 1px solid var(--app-border);
}
.btn {
background: var(--app-secondary);
color: var(--app-text);
border: 1px solid var(--app-border);
padding: 0.5rem 1rem;
border-radius: 6px;
cursor: pointer;
font-size: 0.9rem;
transition: all 0.2s;
}
.btn:hover {
background: var(--app-primary);
color: #000;
}
.btn-primary {
background: var(--app-primary);
color: #000;
font-weight: bold;
width: 100%;
padding: 0.8rem;
font-size: 1.1rem;
margin-top: 1.5rem;
}
.btn-primary:hover {
background: var(--app-primary-hover);
}
</style>
</head>
<body>
<header>
<h1>Cron Expression Builder</h1>
<p>Design cron schedules with instant validation and human-readable explanations.</p>
</header>
<main>
<div class="panel">
<div class="cron-display" id="cronDisplay">* * * * *</div>
<div class="explanation" id="explanation">Every minute</div>
<div class="inputs-grid">
<div class="field-group">
<label>Minute (0-59)</label>
<input type="text" id="cron-minute" value="*" oninput="updateCron()" />
</div>
<div class="field-group">
<label>Hour (0-23)</label>
<input type="text" id="cron-hour" value="*" oninput="updateCron()" />
</div>
<div class="field-group">
<label>Day / Month (1-31)</label>
<input type="text" id="cron-dom" value="*" oninput="updateCron()" />
</div>
<div class="field-group">
<label>Month (1-12)</label>
<input type="text" id="cron-month" value="*" oninput="updateCron()" />
</div>
<div class="field-group">
<label>Day / Week (0-6)</label>
<input type="text" id="cron-dow" value="*" oninput="updateCron()" />
</div>
</div>
<button class="btn btn-primary" onclick="copyCron()">Copy Cron Expression</button>
<div class="presets">
<button class="btn" onclick="setPreset('* * * * *')">Every Minute</button>
<button class="btn" onclick="setPreset('*/5 * * * *')">Every 5 Minutes</button>
<button class="btn" onclick="setPreset('0 * * * *')">Every Hour</button>
<button class="btn" onclick="setPreset('0 0 * * *')">Every Day at Midnight</button>
<button class="btn" onclick="setPreset('0 0 * * 0')">Every Sunday</button>
<button class="btn" onclick="setPreset('0 0 1 * *')">First Day of Month</button>
</div>
</div>
</main>
<script>
function updateCron() {
const m = document.getElementById("cron-minute").value || "*";
const h = document.getElementById("cron-hour").value || "*";
const dom = document.getElementById("cron-dom").value || "*";
const mon = document.getElementById("cron-month").value || "*";
const dow = document.getElementById("cron-dow").value || "*";
const cronStr = `${m} ${h} ${dom} ${mon} ${dow}`;
document.getElementById("cronDisplay").textContent = cronStr;
// Basic human-readable parser fallback
document.getElementById("explanation").textContent = "Expression Updated";
}
window.setPreset = (cron) => {
const parts = cron.split(" ");
document.getElementById("cron-minute").value = parts[0];
document.getElementById("cron-hour").value = parts[1];
document.getElementById("cron-dom").value = parts[2];
document.getElementById("cron-month").value = parts[3];
document.getElementById("cron-dow").value = parts[4];
updateCron();
};
window.copyCron = () => {
const cronStr = document.getElementById("cronDisplay").textContent;
navigator.clipboard.writeText(cronStr);
alert("Copied: " + cronStr);
};
// Init
updateCron();
</script>
</body>
</html>