Skip to content

Commit 42dd982

Browse files
committed
Removed extensive logging and comments, updated readme, removed unused
functions Signed-off-by: Vedansh Saini <[email protected]>
1 parent ec3d21e commit 42dd982

File tree

3 files changed

+20
-44
lines changed

3 files changed

+20
-44
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,18 @@
3232
- Ensure the Scrum Helper settings are applied (follow step 6 above)
3333
- The extension will prefill scrum content for you to edit
3434

35+
### New Features
36+
1. **Standalone Popup Interface**
37+
- Generate reports directly from the extension popup
38+
- Live preview of the report before sending
39+
- Rich text formatting with clickable links
40+
- Copy report to clipboard with proper formatting
41+
42+
### Usage Standalone
43+
- Click on `GENERATE` button to generate the scrum preview.
44+
- Edit it in the window.
45+
- Copy the rich HTML using the `COPY` button.
46+
3547
## Setting up the code locally
3648

3749
```
@@ -44,6 +56,8 @@ $ npm install
4456

4557
![POPUP](/docs/images/popup.png)
4658

59+
![STANDALONE](docs/images/standalone.png)
60+
4761
## About contributing
4862
- Follow the Issues and PRs templates as far as possible.
4963
- If you want to make a PR, please mention in the corresponding issue that you are working on it.

src/scripts/popup.js

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,15 @@ document.addEventListener('DOMContentLoaded', function() {
66
this.innerHTML = '<i class="fa fa-spinner fa-spin"></i> Generating...';
77
this.disabled = true;
88

9-
// Call the scrum generation function
109
window.generateScrumReport();
1110
});
1211

1312
copyBtn.addEventListener('click', function() {
1413
const scrumReport = document.getElementById('scrumReport');
1514

16-
// Create a temporary div to manipulate the content
1715
const tempDiv = document.createElement('div');
1816
tempDiv.innerHTML = scrumReport.innerHTML;
1917

20-
// Convert all links to markdown format
2118
const links = tempDiv.getElementsByTagName('a');
2219
Array.from(links).forEach(link => {
2320
const title = link.textContent;
@@ -26,33 +23,23 @@ document.addEventListener('DOMContentLoaded', function() {
2623
link.outerHTML = markdownLink;
2724
});
2825

29-
// Remove the state buttons (open/closed labels)
3026
const stateButtons = tempDiv.getElementsByClassName('State');
3127
Array.from(stateButtons).forEach(button => {
3228
button.remove();
3329
});
3430

35-
// Replace <br> with newlines
3631
tempDiv.innerHTML = tempDiv.innerHTML.replace(/<br\s*\/?>/gi, '\n');
3732

38-
// Replace list items with proper formatting
3933
const listItems = tempDiv.getElementsByTagName('li');
4034
Array.from(listItems).forEach(item => {
41-
// Add a newline before each list item and indent with a dash
4235
item.innerHTML = '\n- ' + item.innerHTML;
4336
});
4437

45-
// Replace <ul> and </ul> with newlines
4638
tempDiv.innerHTML = tempDiv.innerHTML.replace(/<\/?ul>/gi, '\n');
47-
48-
// Get the text content
4939
let textContent = tempDiv.textContent;
40+
textContent = textContent.replace(/\n\s*\n/g, '\n\n');
41+
textContent = textContent.trim();
5042

51-
// Clean up multiple newlines and spaces
52-
textContent = textContent.replace(/\n\s*\n/g, '\n\n'); // Replace multiple newlines with double newlines
53-
textContent = textContent.trim(); // Remove leading/trailing whitespace
54-
55-
// Copy to clipboard
5643
const textarea = document.createElement('textarea');
5744
textarea.value = textContent;
5845
document.body.appendChild(textarea);

src/scripts/scrumHelper.js

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,13 @@ function allIncluded(outputTarget = 'email') {
148148
}
149149
// fetch github data
150150
function fetchGithubData() {
151-
console.log("Starting GitHub data fetch...");
152151
var issueUrl = 'https://api.github.com/search/issues?q=author%3A' +
153152
githubUsername +
154153
'+org%3Afossasia+created%3A' +
155154
startingDate +
156155
'..' +
157156
endingDate +
158157
'&per_page=100';
159-
console.log("Fetching issues from:", issueUrl);
160158

161159
$.ajax({
162160
dataType: 'json',
@@ -170,7 +168,6 @@ function allIncluded(outputTarget = 'email') {
170168
});
171169
},
172170
success: (data) => {
173-
console.log("Received GitHub issues data:", data);
174171
githubIssuesData = data;
175172
writeGithubIssuesPrs();
176173
},
@@ -184,7 +181,6 @@ function allIncluded(outputTarget = 'email') {
184181
'..' +
185182
endingDate +
186183
'&per_page=100';
187-
console.log("Fetching PR reviews from:", prUrl);
188184

189185
$.ajax({
190186
dataType: 'json',
@@ -198,7 +194,6 @@ function allIncluded(outputTarget = 'email') {
198194
});
199195
},
200196
success: (data) => {
201-
console.log("Received PR reviews data:", data);
202197
githubPrsReviewData = data;
203198
writeGithubPrsReviews();
204199
},
@@ -226,11 +221,9 @@ function allIncluded(outputTarget = 'email') {
226221

227222
//load initial text in scrum body
228223
function writeScrumBody() {
229-
console.log("writeScrumBody called");
230224
if (!enableToggle) return;
231225

232226
setTimeout(() => {
233-
console.log("generating content");
234227
// Generate content first
235228
var lastWeekUl = '<ul>';
236229
var i;
@@ -264,7 +257,6 @@ ${userReason}`;
264257
}
265258

266259
if (outputTarget === 'popup') {
267-
console.log("trying to update popup textarea");
268260
const scrumReport = document.getElementById('scrumReport');
269261
if (scrumReport) {
270262
console.log("found div, updating content");
@@ -279,7 +271,6 @@ ${userReason}`;
279271
}
280272
} else {
281273

282-
// Use the adapter to inject content
283274
const elements = window.emailClientAdapter.getEditorElements();
284275
if (!elements || !elements.body) {
285276
console.error('Email client editor not found');
@@ -300,11 +291,9 @@ ${userReason}`;
300291
else if (projectUrl === 'open-event') project = 'Open Event';
301292
return project;
302293
}
303-
//load initial scrum subject
304294
function scrumSubjectLoaded() {
305295
if (!enableToggle) return;
306296
setTimeout(() => {
307-
//to apply this after google has autofilled
308297
var name = githubUserData.name || githubUsername;
309298
var project = getProject();
310299
var curDate = new Date();
@@ -320,18 +309,17 @@ ${userReason}`;
320309
});
321310
}
322311

323-
// write PRs Reviewed
324312
function writeGithubPrsReviews() {
325-
console.log("Starting to process PR reviews");
326313
var items = githubPrsReviewData.items;
327314

328315
reviewedPrsArray = [];
329316
githubPrsReviewDataProcessed = {};
330317

331318
for (var i = 0; i < items.length; i++) {
332319
var item = items[i];
333-
//skip if its your own pr
320+
334321
if (item.user.login === githubUsername) {
322+
// skips own pr from review
335323
continue;
336324
}
337325

@@ -393,18 +381,14 @@ ${userReason}`;
393381
}
394382
repoLi += '</li>';
395383
reviewedPrsArray.push(repoLi);
396-
console.log(`Added repo ${repo} to reviewedPrsArray`);
397384
}
398385

399386
writeScrumBody();
400387
}
401388
function writeGithubIssuesPrs() {
402-
console.log("Starting to process issues/PRs");
403389
var data = githubIssuesData;
404-
console.log("Total items to process:", data.items.length);
405390
var items = data.items;
406391

407-
// Reset arrays at the start
408392
lastWeekArray = [];
409393
nextWeekArray = [];
410394

@@ -427,7 +411,6 @@ ${userReason}`;
427411
if (item.state === 'open' && item.body && item.body.toUpperCase().indexOf('YES') > 0) {
428412
var li2 = `<li><i>(${project})</i> - Work on Issue(#${number}) - <a href='${html_url}'>${title}</a> ${issue_opened_button}</li>`;
429413
nextWeekArray.push(li2);
430-
console.log("Added to nextWeekArray (contains YES)");
431414
}
432415
if (item.state === 'open') {
433416
li = `<li><i>(${project})</i> - Opened Issue(#${number}) - <a href='${html_url}'>${title}</a> ${issue_opened_button}</li>`;
@@ -440,15 +423,8 @@ ${userReason}`;
440423
} else {
441424
}
442425
}
443-
console.log("Final arrays:", {
444-
lastWeekItems: lastWeekArray.length,
445-
nextWeekItems: nextWeekArray.length,
446-
lastWeekContents: lastWeekArray,
447-
nextWeekContents: nextWeekArray
448-
});
449426
writeScrumBody();
450427
}
451-
452428
var intervalBody = setInterval(() => {
453429
if (!window.emailClientAdapter) return;
454430

@@ -480,13 +456,12 @@ ${userReason}`;
480456
}
481457
}, 500);
482458
}
483-
allIncluded('email'); // Auto-trigger on page load
459+
allIncluded('email');
484460
$('button>span:contains(New conversation)').parent('button').click(() => {
485-
allIncluded(); // Auto-trigger on new conversation
461+
allIncluded();
486462
});
487463

488464
window.generateScrumReport = function() {
489-
console.log('generateScrumReport called');
490465
allIncluded('popup');
491466
};
492467

0 commit comments

Comments
 (0)