Changed around line 1
+ document.getElementById('commitForm').addEventListener('submit', async function(event) {
+ event.preventDefault();
+
+ const token = document.getElementById('token').value;
+ const repo = document.getElementById('repo').value;
+ const startDate = document.getElementById('startDate').value;
+ const endDate = document.getElementById('endDate').value;
+
+ const resultDiv = document.getElementById('result');
+ resultDiv.textContent = 'Generating commits...';
+
+ try {
+ const response = await fetch(`https://api.github.com/repos/${repo}/commits`, {
+ method: 'POST',
+ headers: {
+ 'Authorization': `token ${token}`,
+ 'Content-Type': 'application/json'
+ },
+ body: JSON.stringify({
+ start_date: startDate,
+ end_date: endDate
+ })
+ });
+
+ if (response.ok) {
+ resultDiv.textContent = 'Commits generated successfully!';
+ } else {
+ const errorData = await response.json();
+ resultDiv.textContent = `Error: ${errorData.message}`;
+ }
+ } catch (error) {
+ resultDiv.textContent = 'An error occurred while generating commits.';
+ }
+ });