Skip to content

Commit 212076c

Browse files
authored
Merge branch 'master' into merged-label
2 parents 1a4364c + 695840d commit 212076c

File tree

4 files changed

+119
-82
lines changed

4 files changed

+119
-82
lines changed

src/popup.html

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,11 @@ <h4>Your Github Username</h4>
7474
<p class="text-sm">Fetch your contributions between:</p>
7575
<div class="flex justify-between items-center my-2 mx-4">
7676
<div class="flex items-center gap-2">
77-
<input type="radio" id="lastWeekContribution" name="timeframe" class="form-radio"
78-
onclick="toggleRadio(this)">
77+
<input type="radio" id="lastWeekContribution" name="timeframe" class="form-radio">
7978
<label for="lastWeekContribution">Last 7 days</label>
8079
</div>
8180
<div class="flex items-center gap-2">
82-
<input type="radio" id="yesterdayContribution" name="timeframe" class="form-radio"
83-
onclick="toggleRadio(this)">
81+
<input type="radio" id="yesterdayContribution" name="timeframe" class="form-radio">
8482
<label for="yesterdayContribution">Last 1 day</label>
8583
</div>
8684
</div>
@@ -132,19 +130,19 @@ <h6 class="text-base font-semibold">Scrum Report</h6>
132130
<div id="settingsSection" class="tab-content hidden">
133131
<div class="">
134132
<div class="flex items-center mt-4">
135-
<h4>Organisation Name</h4>
133+
<h4>Organization Name</h4>
136134
<span class="tooltip-container ml-2">
137135
<i class="fa fa-question-circle question-icon"></i>
138136
<span class="tooltip-bubble">
139-
<b>Which organisation's GitHub activity?</b><br>
140-
Enter the GitHub organisation name to fetch activites for. Default is <b>fossasia</b>.
141-
Organisation name is not case-sensitive.
137+
<b>Which organization's GitHub activity?</b><br>
138+
Enter the GitHub organization name to fetch activites for. Default is <b>fossasia</b>.
139+
Organization name is not case-sensitive.
142140
</span>
143141
</span>
144142
</div>
145143
<input id="orgInput" type="text"
146144
class="w-full border-2 border-gray-200 bg-gray-200 rounded-xl text-gray-800 p-2 my-2"
147-
placeholder="Enter organisation name (default: fossasia)">
145+
placeholder="Enter organization name (default: fossasia)">
148146
</div>
149147
<div class="">
150148
<div class="flex items-center justify-between">

src/scripts/main.js

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ function handleBodyOnLoad() {
1919
'startingDate',
2020
'endingDate',
2121
'showOpenLabel',
22-
'showClosedLabel',
2322
'userReason',
2423
'lastWeekContribution',
2524
'yesterdayContribution',
@@ -99,7 +98,7 @@ document.getElementById('refreshCache').addEventListener('click', async (e) => {
9998

10099
Materialize.toast({ html: 'Data refreshed successfully!', classes: 'green' });
101100
} catch (err) {
102-
console.error('Refresh failed:', err);
101+
console.log('Refresh successful',);
103102
} finally {
104103
setTimeout(() => {
105104
button.classList.remove('loading');
@@ -124,19 +123,19 @@ function handleLastWeekContributionChange() {
124123
let value = lastWeekContributionElement.checked;
125124
let labelElement = document.querySelector("label[for='lastWeekContribution']");
126125
if (value) {
127-
startingDateElement.disabled = true;
128-
endingDateElement.disabled = true;
129-
endingDateElement.value = getToday();
130-
startingDateElement.value = getLastWeek();
131-
handleEndingDateChange();
132-
handleStartingDateChange();
133-
labelElement.classList.add("selectedLabel");
134-
labelElement.classList.remove("unselectedLabel");
126+
startingDateElement.readOnly = true;
127+
endingDateElement.readOnly = true;
128+
endingDateElement.value = getToday();
129+
startingDateElement.value = getLastWeek();
130+
handleEndingDateChange();
131+
handleStartingDateChange();
132+
labelElement.classList.add("selectedLabel");
133+
labelElement.classList.remove("unselectedLabel");
135134
} else {
136-
startingDateElement.disabled = false;
137-
endingDateElement.disabled = false;
138-
labelElement.classList.add("unselectedLabel");
139-
labelElement.classList.remove("selectedLabel");
135+
startingDateElement.readOnly = false;
136+
endingDateElement.readOnly = false;
137+
labelElement.classList.add("unselectedLabel");
138+
labelElement.classList.remove("selectedLabel");
140139
}
141140

142141
chrome.storage.local.set({ lastWeekContribution: value });
@@ -147,17 +146,17 @@ function handleYesterdayContributionChange() {
147146
let labelElement = document.querySelector("label[for='yesterdayContribution']");
148147

149148
if (value) {
150-
startingDateElement.disabled = true;
151-
endingDateElement.disabled = true;
149+
startingDateElement.readOnly = true;
150+
endingDateElement.readOnly = true;
152151
endingDateElement.value = getToday();
153152
startingDateElement.value = getYesterday();
154153
handleEndingDateChange();
155154
handleStartingDateChange();
156155
labelElement.classList.add("selectedLabel");
157156
labelElement.classList.remove("unselectedLabel");
158157
} else {
159-
startingDateElement.disabled = false;
160-
endingDateElement.disabled = false;
158+
startingDateElement.readOnly = false;
159+
endingDateElement.readOnly = false;
161160
labelElement.classList.add("unselectedLabel");
162161
labelElement.classList.remove("selectedLabel");
163162
}

src/scripts/popup.js

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,8 @@ document.addEventListener('DOMContentLoaded', function () {
256256

257257
const startDateInput = document.getElementById('startingDate');
258258
const endDateInput = document.getElementById('endingDate');
259-
startDateInput.disabled = false;
260-
endDateInput.disabled = false;
259+
startDateInput.readOnly = false;
260+
endDateInput.readOnly = false;
261261

262262
chrome.storage.local.set({
263263
lastWeekContribution: false,
@@ -294,9 +294,8 @@ document.addEventListener('DOMContentLoaded', function () {
294294
startDateInput.value = getYesterday();
295295
endDateInput.value = getToday();
296296
}
297-
298-
startDateInput.disabled = endDateInput.disabled = true;
299-
297+
startDateInput.readOnly = endDateInput.readOnly = true;
298+
300299
chrome.storage.local.set({
301300
startingDate: startDateInput.value,
302301
endingDate: endDateInput.value,
@@ -369,11 +368,9 @@ document.addEventListener('DOMContentLoaded', function () {
369368
.then(res => {
370369
console.log('[Org Check] Response status for', org, ':', res.status);
371370
if (res.status === 404) {
372-
console.log('[Org Check] Organisation not found on GitHub:', org);
373-
// Remove any existing toast with the same id
371+
console.log('[Org Check] Organization not found on GitHub:', org);
374372
const oldToast = document.getElementById('invalid-org-toast');
375373
if (oldToast) oldToast.parentNode.removeChild(oldToast);
376-
// Create a new toast div
377374
const toastDiv = document.createElement('div');
378375
toastDiv.id = 'invalid-org-toast';
379376
toastDiv.className = 'toast';
@@ -387,29 +384,25 @@ document.addEventListener('DOMContentLoaded', function () {
387384
toastDiv.style.left = '50%';
388385
toastDiv.style.transform = 'translateX(-50%)';
389386
toastDiv.style.zIndex = '9999';
390-
toastDiv.innerText = 'Organisation not found on GitHub.';
387+
toastDiv.innerText = 'Organization not found on GitHub.';
391388
document.body.appendChild(toastDiv);
392389
setTimeout(() => {
393390
if (toastDiv.parentNode) toastDiv.parentNode.removeChild(toastDiv);
394391
}, 3000);
395-
// Do NOT update storage or fetch data for invalid org
396392
return;
397393
}
398-
// Remove any existing toast with the same id (for valid orgs)
399394
const oldToast = document.getElementById('invalid-org-toast');
400395
if (oldToast) oldToast.parentNode.removeChild(oldToast);
401396
console.log('[Org Check] Organisation exists on GitHub:', org);
402-
// Valid org: update storage and fetch data
397+
console.log('[Org Check] Organization exists on GitHub:', org);
403398
chrome.storage.local.set({ orgName: org }, function () {
404399
if (window.generateScrumReport) window.generateScrumReport();
405400
});
406401
})
407402
.catch((err) => {
408403
console.log('[Org Check] Error validating organisation:', org, err);
409-
// Remove any existing toast with the same id
410404
const oldToast = document.getElementById('invalid-org-toast');
411405
if (oldToast) oldToast.parentNode.removeChild(oldToast);
412-
// Create a new toast div
413406
const toastDiv = document.createElement('div');
414407
toastDiv.id = 'invalid-org-toast';
415408
toastDiv.className = 'toast';
@@ -423,12 +416,11 @@ document.addEventListener('DOMContentLoaded', function () {
423416
toastDiv.style.left = '50%';
424417
toastDiv.style.transform = 'translateX(-50%)';
425418
toastDiv.style.zIndex = '9999';
426-
toastDiv.innerText = 'Error validating organisation.';
419+
toastDiv.innerText = 'Error validating organization.';
427420
document.body.appendChild(toastDiv);
428421
setTimeout(() => {
429422
if (toastDiv.parentNode) toastDiv.parentNode.removeChild(toastDiv);
430423
}, 3000);
431-
// Do NOT update storage or fetch data for invalid org
432424
});
433425
}, 3000);
434426

@@ -485,8 +477,8 @@ document.querySelectorAll('input[name="timeframe"]').forEach(radio => {
485477

486478
const startDateInput = document.getElementById('startingDate');
487479
const endDateInput = document.getElementById('endingDate');
488-
startDateInput.disabled = false;
489-
endDateInput.disabled = false;
480+
startDateInput.readOnly = false;
481+
endDateInput.readOnly = false;
490482

491483
chrome.storage.local.set({
492484
lastWeekContribution: false,
@@ -558,7 +550,7 @@ function toggleRadio(radio) {
558550
endDateInput.value = getToday();
559551
}
560552

561-
startDateInput.disabled = endDateInput.disabled = true;
553+
startDateInput.readOnly = endDateInput.readOnly = true;
562554

563555
chrome.storage.local.set({
564556
startingDate: startDateInput.value,
@@ -576,7 +568,7 @@ function toggleRadio(radio) {
576568
});
577569
}
578570

579-
const cacheInput = document.getElementById('cacheInput');
571+
let cacheInput = document.getElementById('cacheInput');
580572
if (cacheInput) {
581573
chrome.storage.local.get(['cacheInput'], function (result) {
582574
if (result.cacheInput) {

0 commit comments

Comments
 (0)