Skip to content

Commit 34097a1

Browse files
committed
improved date and radio selection logic
Signed-off-by: Vedansh Saini <[email protected]>
1 parent 6f7b349 commit 34097a1

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

src/popup.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ <h4>Your Github Username</h4>
6464
<p class="text-sm">Fetch your contributions between:</p>
6565
<div class="flex justify-between items-center my-2 mx-4">
6666
<div class="flex items-center gap-2">
67-
<input type="radio" id="lastWeekContribution" name="timeframe" class="form-radio" onclick="toggleRadio(this)">
67+
<input type="radio" id="lastWeekContribution" name="timeframe" class="form-radio">
6868
<label for="lastWeekContribution">Last 7 days</label>
6969
</div>
7070
<div class="flex items-center gap-2">
71-
<input type="radio" id="yesterdayContribution" name="timeframe" class="form-radio" onclick="toggleRadio(this)">
71+
<input type="radio" id="yesterdayContribution" name="timeframe" class="form-radio">
7272
<label for="yesterdayContribution">Last 1 day</label>
7373
</div>
7474
</div>

src/scripts/main.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,17 +124,17 @@ function handleLastWeekContributionChange() {
124124
let value = lastWeekContributionElement.checked;
125125
let labelElement = document.querySelector("label[for='lastWeekContribution']");
126126
if (value) {
127-
startingDateElement.disabled = true;
128-
endingDateElement.disabled = true;
127+
startingDateElement.readOnly = true;
128+
endingDateElement.readOnly = true;
129129
endingDateElement.value = getToday();
130130
startingDateElement.value = getLastWeek();
131131
handleEndingDateChange();
132132
handleStartingDateChange();
133133
labelElement.classList.add("selectedLabel");
134134
labelElement.classList.remove("unselectedLabel");
135135
} else {
136-
startingDateElement.disabled = false;
137-
endingDateElement.disabled = false;
136+
startingDateElement.readOnly = false;
137+
endingDateElement.readOnly = false;
138138
labelElement.classList.add("unselectedLabel");
139139
labelElement.classList.remove("selectedLabel");
140140
}
@@ -147,17 +147,17 @@ function handleYesterdayContributionChange() {
147147
let labelElement = document.querySelector("label[for='yesterdayContribution']");
148148

149149
if (value) {
150-
startingDateElement.disabled = true;
151-
endingDateElement.disabled = true;
150+
startingDateElement.readOnly = true;
151+
endingDateElement.readOnly = true;
152152
endingDateElement.value = getToday();
153153
startingDateElement.value = getYesterday();
154154
handleEndingDateChange();
155155
handleStartingDateChange();
156156
labelElement.classList.add("selectedLabel");
157157
labelElement.classList.remove("unselectedLabel");
158158
} else {
159-
startingDateElement.disabled = false;
160-
endingDateElement.disabled = false;
159+
startingDateElement.readOnly = false;
160+
endingDateElement.readOnly = false;
161161
labelElement.classList.add("unselectedLabel");
162162
labelElement.classList.remove("selectedLabel");
163163
}

src/scripts/popup.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@ document.addEventListener('DOMContentLoaded', function() {
253253

254254
const startDateInput = document.getElementById('startingDate');
255255
const endDateInput = document.getElementById('endingDate');
256-
startDateInput.disabled = false;
257-
endDateInput.disabled = false;
256+
startDateInput.readOnly = false;
257+
endDateInput.readOnly = false;
258258

259259
chrome.storage.local.set({
260260
lastWeekContribution: false,
@@ -292,7 +292,7 @@ document.addEventListener('DOMContentLoaded', function() {
292292
endDateInput.value = getToday();
293293
}
294294

295-
startDateInput.disabled = endDateInput.disabled = true;
295+
startDateInput.readOnly = endDateInput.readOnly = true;
296296

297297
chrome.storage.local.set({
298298
startingDate: startDateInput.value,
@@ -391,8 +391,8 @@ document.querySelectorAll('input[name="timeframe"]').forEach(radio => {
391391

392392
const startDateInput = document.getElementById('startingDate');
393393
const endDateInput = document.getElementById('endingDate');
394-
startDateInput.disabled = false;
395-
endDateInput.disabled = false;
394+
startDateInput.readOnly = false;
395+
endDateInput.readOnly = false;
396396

397397
chrome.storage.local.set({
398398
lastWeekContribution: false,
@@ -464,7 +464,7 @@ function toggleRadio(radio) {
464464
endDateInput.value = getToday();
465465
}
466466

467-
startDateInput.disabled = endDateInput.disabled = true;
467+
startDateInput.readOnly = endDateInput.readOnly = true;
468468

469469
chrome.storage.local.set({
470470
startingDate: startDateInput.value,

0 commit comments

Comments
 (0)