Skip to content

Commit e797517

Browse files
committed
maybe works
Signed-off-by: Vedansh Saini <[email protected]>
1 parent 67925df commit e797517

File tree

2 files changed

+89
-14
lines changed

2 files changed

+89
-14
lines changed

src/popup.html

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,19 @@ <h6 class="center">
7373
<input placeholder="Reason" id="userReason" type="text">
7474
<label for="userReason">What is stopping you from doing your work?</label>
7575
</div>
76+
<div>
77+
<h6>Scrum Report</h3>
78+
<textarea name="" id="scrumReport" class="materialize-textarea" style="min-height: 200px;" placeholder="Your scrum report will appear here..."></textarea>
79+
</div>
80+
<div style="display: flex; justify-content: space-between; gap: 10px;">
81+
<button id="generateReport" class="btn waves-effect waves-light">
82+
<i class="fa fa-refresh"></i> Generate Report
83+
</button>
84+
<button id="copyReport" class="btn waves-effect waves-light">
85+
<i class="fa fa-copy"></i> Copy Report
86+
</button>
87+
88+
</div>
7689
<div class="col s12">
7790

7891
<h5>Note:</h5>
@@ -97,5 +110,26 @@ <h6>
97110
<script src="scripts/jquery-3.2.1.min.js"></script>
98111
<script type="text/javascript" type="text/javascript" src="materialize/js/materialize.min.js"></script>
99112
<script src="scripts/main.js"></script>
113+
<script>
114+
document.addEventListener('DOMContentLoaded', function() {
115+
const generateBtn = document.getElementById('generateReport');
116+
const copyBtn = document.getElementById('copyReport');
117+
118+
generateBtn.addEventListener('click', function() {
119+
this.innerHTML = '<i class="fa fa-spinner fa-spin"></i> Generating...';
120+
this.disabled = true;
121+
122+
// Call the scrum generation function
123+
window.generateScrumReport();
124+
});
125+
126+
copyBtn.addEventListener('click', function() {
127+
const scrumReport = document.getElementById('scrumReport');
128+
scrumReport.select();
129+
document.execCommand('copy');
130+
Materialize.toast('Report copied to clipboard!', 3000);
131+
});
132+
});
133+
</script>
100134
</body>
101135
</html>

src/scripts/scrumHelper.js

Lines changed: 55 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var refreshButton_Placed = false;
22
var enableToggle = true;
3-
function allIncluded() {
3+
function allIncluded(outputTarget = 'email') {
44
/* global $*/
55
var scrumBody = null;
66
var scrumSubject = null;
@@ -69,9 +69,19 @@ function allIncluded() {
6969
if (items.githubUsername) {
7070
githubUsername = items.githubUsername;
7171
fetchGithubData();
72-
} else {
73-
console.warn('No GitHub username found in storage');
74-
}
72+
} else {
73+
if (outputTarget === 'popup') {
74+
// Show error in popup
75+
const generateBtn = document.getElementById('generateReport');
76+
if (generateBtn) {
77+
generateBtn.innerHTML = '<i class="fa fa-refresh"></i> Generate Report';
78+
generateBtn.disabled = false;
79+
}
80+
Materialize.toast('Please enter your GitHub username', 3000);
81+
} else {
82+
console.warn('No GitHub username found in storage');
83+
}
84+
}
7585
if (items.projectName) {
7686
projectName = items.projectName;
7787
}
@@ -230,14 +240,37 @@ function allIncluded() {
230240
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;${userReason}</p>`;
231241
}
232242

233-
// Use the adapter to inject content
234-
const elements = window.emailClientAdapter.getEditorElements();
235-
if (!elements || !elements.body) {
236-
console.error('Email client editor not found');
237-
return;
238-
}
243+
if (outputTarget === 'popup') {
244+
// Update popup textarea
245+
const scrumReport = document.getElementById('scrumReport');
246+
if (scrumReport) {
247+
// Convert HTML to plain text for textarea
248+
const plainContent = content
249+
.replace(/<br>/g, '\n')
250+
.replace(/<\/?[^>]+(>|$)/g, '')
251+
.replace(/&nbsp;/g, ' ');
252+
253+
scrumReport.value = plainContent;
254+
Materialize.textareaAutoResize(scrumReport);
239255

240-
window.emailClientAdapter.injectContent(elements.body, content, elements.eventTypes.contentChange);
256+
// Reset generate button
257+
const generateBtn = document.getElementById('generateReport');
258+
if (generateBtn) {
259+
generateBtn.innerHTML = '<i class="fa fa-refresh"></i> Generate Report';
260+
generateBtn.disabled = false;
261+
}
262+
263+
Materialize.toast('Report generated successfully!', 3000);
264+
}
265+
} else {
266+
// Use the adapter to inject content
267+
const elements = window.emailClientAdapter.getEditorElements();
268+
if (!elements || !elements.body) {
269+
console.error('Email client editor not found');
270+
return;
271+
}
272+
window.emailClientAdapter.injectContent(elements.body, content, elements.eventTypes.contentChange);
273+
}
241274
});
242275
}
243276

@@ -547,13 +580,21 @@ function allIncluded() {
547580
}, 1000);
548581
}
549582
function handleRefresh() {
550-
allIncluded();
583+
allIncluded('email');
551584
}
552585
}
553-
allIncluded();
586+
allIncluded('email'); // Auto-trigger on page load
587+
$('button>span:contains(New conversation)').parent('button').click(() => {
588+
allIncluded('email'); // Auto-trigger on new conversation
589+
});
554590

555591
$('button>span:contains(New conversation)')
556592
.parent('button')
557593
.click(() => {
558-
allIncluded();
594+
allIncluded('email');
559595
});
596+
597+
// Export for use in popup
598+
window.generateScrumReport = function() {
599+
allIncluded('popup');
600+
};

0 commit comments

Comments
 (0)