-
-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathleetcode-commit-message.html
More file actions
298 lines (269 loc) · 9.64 KB
/
Copy pathleetcode-commit-message.html
File metadata and controls
298 lines (269 loc) · 9.64 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Leetcode Commit Message Generator — DevDunia</title>
<meta name="description" content="Generate file names and commit messages for Leetcode problems. Free online Leetcode commit message generator for developers.">
<meta property="og:type" content="website">
<meta property="og:url" content="https://devdunia.com/leetcode-commit-message.html">
<meta property="og:title" content="Leetcode Commit Message Generator — DevDunia">
<meta property="og:description" content="Generate file names and commit messages for Leetcode problems. Free online tool.">
<meta property="og:image" content="https://devdunia.com/images/logo.png">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="stylesheet" href="css/comic.css">
<link href="https://fonts.googleapis.com/css2?family=Bangers&family=Comic+Neue:wght@400;700&family=Space+Mono:wght@400;700&display=swap" rel="stylesheet">
<style>
/* ---- TODO migrate: page-specific overrides, not yet centralized in css/comic.css ---- */
.hero-text h1 {
font-family: 'Bangers', cursive;
font-size: 2.6rem;
letter-spacing: 2px;
color: var(--green);
-webkit-text-stroke: 1px var(--ink);
text-shadow: 4px 4px 0 var(--ink);
line-height: 1;
text-transform: uppercase;
}
/* ── TEXTAREA ── */
.comic-textarea {
width: 100%;
background: #fff;
border: 3px solid var(--ink);
border-radius: 6px;
padding: 12px 14px;
font-family: 'Space Mono', monospace;
font-size: .82rem;
color: var(--ink);
line-height: 1.6;
resize: vertical;
min-height: 80px;
box-shadow: inset 3px 3px 0 rgba(0,0,0,.06);
outline: none;
transition: border-color .15s;
}
.comic-textarea:focus { border-color: var(--green); }
.btn-primary { background: var(--blue); color: #fff; }
/* ── OUTPUT COPY WRAP ── */
.output-wrap { position: relative; margin-bottom: 18px; }
/* ── EXAMPLES GRID ── */
.examples-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 14px;
}
.example-card {
background: var(--paper2);
border: 3px solid var(--ink);
border-radius: 6px;
box-shadow: 4px 4px 0 var(--ink);
padding: 12px 14px;
font-size: .82rem;
line-height: 1.5;
}
.example-card strong { font-family: 'Bangers', cursive; letter-spacing: 1px; font-size: .95rem; display: block; margin-bottom: 4px; }
.example-card code {
font-family: 'Space Mono', monospace;
font-size: .72rem;
background: var(--ink);
color: var(--yellow);
padding: 1px 4px;
border-radius: 3px;
}
/* ── HINT ── */
.hint {
font-size: .82rem;
color: #888;
margin-top: 6px;
font-style: italic;
}
/* ── MOBILE ── */
@media (max-width: 600px) {
.examples-grid { grid-template-columns: 1fr; }
.hero { flex-direction: column; gap: 10px; }
.hero-text h1 { font-size: 2rem; }
}
</style>
</head>
<body>
<div class="paper-overlay"></div>
<div data-masthead></div>
<div class="page-wrap">
<div data-tool-hero
data-title="Leetcode Commit Message Generator"
data-chapter="30"
data-category="Developer Tools"
data-icon="🦠"
data-desc="Paste a Leetcode problem name and instantly get a proper snake_case filename and a ready-to-run git commit message. Level up your Leetcode grind!"
data-color="blue"
data-badges="SNAKE_CASE,GIT COMMIT,INSTANT,FREE"
data-badge-colors="green,blue,orange,yellow">
</div>
<!-- MASTHEAD -->
<!-- HERO -->
<!-- INPUT PANEL -->
<div class="panel">
<div class="panel-header">
📥 ENTER LEETCODE PROBLEM
<span class="panel-tag">INPUT</span>
</div>
<div class="panel-body">
<div class="section-label">Problem Name</div>
<textarea
id="problem-input"
class="comic-textarea"
rows="3"
placeholder="Enter Leetcode problem name (e.g., 1304. Find N Unique Integers Sum up to Zero)"
></textarea>
<div class="hint">💡 Format: "Problem Number. Problem Title" (e.g., "1304. Find N Unique Integers Sum up to Zero")</div>
<div class="btn-row">
<button id="generate-btn" class="btn btn-success">⚡ Generate!</button>
<button id="clear-btn" class="btn btn-danger">🗑 Clear All</button>
</div>
<div id="error-bubble" class="error-bubble">
💥 <span id="error-msg">Invalid format. Please use: "123. Problem Title"</span>
</div>
</div>
</div>
<!-- OUTPUT PANEL -->
<div class="panel" id="output-section" style="display:none;">
<div class="panel-header">
📤 GENERATED OUTPUT
<span class="panel-tag">OUTPUT</span>
</div>
<div class="panel-body">
<div class="section-label">File Name</div>
<div class="output-wrap">
<textarea id="filename-output" class="comic-textarea" rows="2" readonly></textarea>
<button class="copy-btn" data-target="filename-output">📋 COPY</button>
</div>
<div class="section-label">Commit Message</div>
<div class="output-wrap">
<textarea id="commit-output" class="comic-textarea" rows="2" readonly></textarea>
<button class="copy-btn" data-target="commit-output">📋 COPY</button>
</div>
</div>
</div>
<!-- EXAMPLES PANEL -->
<div class="panel">
<div class="panel-header">
📚 EXAMPLES
<span class="panel-tag">HOW IT WORKS</span>
</div>
<div class="panel-body">
<div class="examples-grid">
<div class="example-card">
<strong style="color:var(--blue);">Input:</strong>
1304. Find N Unique Integers Sum up to Zero
<br><br>
<strong style="color:var(--green);">File:</strong>
<code>find_n_unique_integers_sum_up_to_zero_1304.py</code>
<br><br>
<strong style="color:var(--orange);">Commit:</strong>
<code>git commit -m "Solve Leetcode Problem 1304. Find N Unique Integers Sum up to Zero"</code>
</div>
<div class="example-card">
<strong style="color:var(--blue);">Input:</strong>
1. Two Sum
<br><br>
<strong style="color:var(--green);">File:</strong>
<code>two_sum_1.py</code>
<br><br>
<strong style="color:var(--orange);">Commit:</strong>
<code>git commit -m "Solve Leetcode Problem 1. Two Sum"</code>
</div>
</div>
</div>
</div>
</div><!-- /page-wrap -->
<script>
(function() {
var problemInput = document.getElementById('problem-input');
var filenameOutput = document.getElementById('filename-output');
var commitOutput = document.getElementById('commit-output');
var generateBtn = document.getElementById('generate-btn');
var clearBtn = document.getElementById('clear-btn');
var outputSection = document.getElementById('output-section');
var errBubble = document.getElementById('error-bubble');
var errMsg = document.getElementById('error-msg');
function showError(msg) {
errMsg.textContent = msg;
errBubble.classList.add('show');
}
function hideError() { errBubble.classList.remove('show'); }
function showOutput() { outputSection.style.display = 'block'; }
function generateFilename(title, number) {
var filename = title
.toLowerCase()
.replace(/[^\w\s]/g, '')
.replace(/\s+/g, '_')
.replace(/_+/g, '_')
.replace(/^_|_$/g, '');
return filename + '_' + number + '.py';
}
function generateLeetcodeOutputs(problemName) {
var match = problemName.match(/^(\d+)\.\s*(.+)$/);
if (!match) {
throw new Error('Invalid format. Please use format: "123. Problem Title"');
}
var problemNumber = match[1];
var problemTitle = match[2].trim();
var filename = generateFilename(problemTitle, problemNumber);
var commitMessage = 'git commit -m "Solve Leetcode Problem ' + problemNumber + '. ' + problemTitle + '"';
return { filename: filename, commitMessage: commitMessage };
}
generateBtn.addEventListener('click', function() {
var input = problemInput.value.trim();
if (!input) { showError('Please enter a Leetcode problem name'); return; }
try {
var result = generateLeetcodeOutputs(input);
filenameOutput.value = result.filename;
commitOutput.value = result.commitMessage;
showOutput();
hideError();
} catch(e) {
showError(e.message);
}
});
clearBtn.addEventListener('click', function() {
problemInput.value = '';
filenameOutput.value = '';
commitOutput.value = '';
outputSection.style.display = 'none';
hideError();
});
// Copy buttons
document.querySelectorAll('.copy-btn').forEach(function(btn) {
btn.addEventListener('click', function() {
var targetId = this.dataset.target;
var el = document.getElementById(targetId);
try {
el.select();
document.execCommand('copy');
navigator.clipboard.writeText(el.value).catch(function(){});
} catch(e) {}
var orig = this.textContent;
this.textContent = '✔ COPIED!';
this.style.background = 'var(--green)';
var b = this;
setTimeout(function() {
b.textContent = orig;
b.style.background = 'var(--ink)';
}, 1800);
});
});
// Keyboard shortcut: Enter to generate
problemInput.addEventListener('keydown', function(e) {
if ((e.ctrlKey || e.metaKey) && e.key === 'Enter') { generateBtn.click(); }
});
// Preload example (same as original)
window.addEventListener('load', function() {
problemInput.value = '1304. Find N Unique Integers Sum up to Zero';
});
})();
</script>
<script src="masthead.js"></script>
<script src="hero-banner.js"></script>
<script src="author-card.js"></script>
</body>
</html>