11var refreshButton_Placed = false ;
22var enableToggle = true ;
33function allIncluded ( outputTarget = 'email' ) {
4- console . log ( 'allIncluded called with outputTarget:' , outputTarget ) ;
5- console . log ( 'Current window context:' , window . location . href ) ; // Add this to see where we are
64
75 /* global $*/
86 var scrumBody = null ;
@@ -36,7 +34,6 @@ function allIncluded(outputTarget = 'email') {
3634
3735 var linkStyle = '' ;
3836 function getChromeData ( ) {
39- console . log ( "Getting Chrome data for context:" , outputTarget ) ; // Add this
4037 chrome . storage . local . get (
4138 [
4239 'githubUsername' ,
@@ -51,7 +48,6 @@ function allIncluded(outputTarget = 'email') {
5148 'gsoc' ,
5249 ] ,
5350 ( items ) => {
54- console . log ( "Storage items received:" , items ) ; // Add this
5551 if ( items . gsoc ) {
5652 //gsoc
5753 gsoc = 1 ;
@@ -73,20 +69,16 @@ function allIncluded(outputTarget = 'email') {
7369 }
7470 if ( items . githubUsername ) {
7571 githubUsername = items . githubUsername ;
76- console . log ( "About to fetch GitHub data for:" , githubUsername ) ; // Add this
7772 fetchGithubData ( ) ;
7873 } else {
7974 if ( outputTarget === 'popup' ) {
80- console . log ( "No username found - popup context" ) ; // Add this
81- // Show error in popup
8275 const generateBtn = document . getElementById ( 'generateReport' ) ;
8376 if ( generateBtn ) {
8477 generateBtn . innerHTML = '<i class="fa fa-refresh"></i> Generate Report' ;
8578 generateBtn . disabled = false ;
8679 }
8780 Materialize . toast ( 'Please enter your GitHub username' , 3000 ) ;
8881 } else {
89- console . log ( "No username found - email context" ) ; // Add this
9082 console . warn ( 'No GitHub username found in storage' ) ;
9183 }
9284 }
@@ -150,15 +142,13 @@ function allIncluded(outputTarget = 'email') {
150142 }
151143 // fetch github data
152144 function fetchGithubData ( ) {
153- console . log ( "Starting GitHub data fetch..." ) ;
154145 var issueUrl = 'https://api.github.com/search/issues?q=author%3A' +
155146 githubUsername +
156147 '+org%3Afossasia+created%3A' +
157148 startingDate +
158149 '..' +
159150 endingDate +
160151 '&per_page=100' ;
161- console . log ( "Fetching issues from:" , issueUrl ) ;
162152
163153 $ . ajax ( {
164154 dataType : 'json' ,
@@ -172,7 +162,6 @@ function allIncluded(outputTarget = 'email') {
172162 } ) ;
173163 } ,
174164 success : ( data ) => {
175- console . log ( "Received GitHub issues data:" , data ) ;
176165 githubIssuesData = data ;
177166 writeGithubIssuesPrs ( ) ;
178167 } ,
@@ -186,7 +175,6 @@ function allIncluded(outputTarget = 'email') {
186175 '..' +
187176 endingDate +
188177 '&per_page=100' ;
189- console . log ( "Fetching PR reviews from:" , prUrl ) ;
190178
191179 $ . ajax ( {
192180 dataType : 'json' ,
@@ -200,7 +188,6 @@ function allIncluded(outputTarget = 'email') {
200188 } ) ;
201189 } ,
202190 success : ( data ) => {
203- console . log ( "Received PR reviews data:" , data ) ;
204191 githubPrsReviewData = data ;
205192 writeGithubPrsReviews ( ) ;
206193 } ,
@@ -228,11 +215,9 @@ function allIncluded(outputTarget = 'email') {
228215
229216 //load initial text in scrum body
230217 function writeScrumBody ( ) {
231- console . log ( "writeScrumBody called" ) ;
232218 if ( ! enableToggle ) return ;
233219
234220 setTimeout ( ( ) => {
235- console . log ( "generating content" ) ;
236221 // Generate content first
237222 var lastWeekUl = '<ul>' ;
238223 var i ;
@@ -266,11 +251,9 @@ ${userReason}`;
266251 }
267252
268253 if ( outputTarget === 'popup' ) {
269- console . log ( "trying to update popup textarea" ) ;
270254 const scrumReport = document . getElementById ( 'scrumReport' ) ;
271255 if ( scrumReport ) {
272- console . log ( "found div, updating content" ) ;
273- scrumReport . innerHTML = content ; // Use innerHTML instead of value
256+ scrumReport . innerHTML = content ;
274257
275258 // Reset generate button
276259 const generateBtn = document . getElementById ( 'generateReport' ) ;
@@ -281,7 +264,6 @@ ${userReason}`;
281264 }
282265 } else {
283266
284- // Use the adapter to inject content
285267 const elements = window . emailClientAdapter . getEditorElements ( ) ;
286268 if ( ! elements || ! elements . body ) {
287269 console . error ( 'Email client editor not found' ) ;
@@ -302,11 +284,9 @@ ${userReason}`;
302284 else if ( projectUrl === 'open-event' ) project = 'Open Event' ;
303285 return project ;
304286 }
305- //load initial scrum subject
306287 function scrumSubjectLoaded ( ) {
307288 if ( ! enableToggle ) return ;
308289 setTimeout ( ( ) => {
309- //to apply this after google has autofilled
310290 var name = githubUserData . name || githubUsername ;
311291 var project = getProject ( ) ;
312292 var curDate = new Date ( ) ;
@@ -322,28 +302,17 @@ ${userReason}`;
322302 } ) ;
323303 }
324304
325- // write PRs Reviewed
326305 function writeGithubPrsReviews ( ) {
327- console . log ( "Starting to process PR reviews" ) ;
328306 var items = githubPrsReviewData . items ;
329- console . log ( "Total review items:" , items . length ) ;
330307
331308 reviewedPrsArray = [ ] ;
332309 githubPrsReviewDataProccessed = { } ;
333310
334311 for ( var i = 0 ; i < items . length ; i ++ ) {
335312 var item = items [ i ] ;
336- console . log ( `Review item ${ i + 1 } /${ items . length } :` , {
337- number : item . number ,
338- author : item . user . login ,
339- type : item . pull_request ? "PR" : "Issue" ,
340- state : item . state ,
341- title : item . title
342- } ) ;
343313
344- // Only skip if it's your own PR, but keep all PRs you've reviewed
345314 if ( item . user . login === githubUsername ) {
346- console . log ( `Skipping # ${ item . number } - Own PR` ) ;
315+ // skips own pr from review
347316 continue ;
348317 }
349318
@@ -364,7 +333,6 @@ ${userReason}`;
364333 state : item . state ,
365334 } ;
366335 githubPrsReviewDataProccessed [ project ] . push ( obj ) ;
367- console . log ( `Added PR #${ number } to project ${ project } ` ) ;
368336 }
369337
370338 for ( var repo in githubPrsReviewDataProccessed ) {
@@ -406,33 +374,19 @@ ${userReason}`;
406374 }
407375 repoLi += '</li>' ;
408376 reviewedPrsArray . push ( repoLi ) ;
409- console . log ( `Added repo ${ repo } to reviewedPrsArray` ) ;
410377 }
411378
412- console . log ( "Final reviewedPrsArray:" , reviewedPrsArray ) ;
413- writeScrumBody ( ) ; // Call writeScrumBody to update the content
379+ writeScrumBody ( ) ;
414380 }
415- //write issues and Prs from github
416381 function writeGithubIssuesPrs ( ) {
417- console . log ( "Starting to process issues/PRs" ) ;
418382 var data = githubIssuesData ;
419- console . log ( "Total items to process:" , data . items . length ) ;
420383 var items = data . items ;
421384
422- // Reset arrays at the start
423385 lastWeekArray = [ ] ;
424386 nextWeekArray = [ ] ;
425387
426388 for ( var i = 0 ; i < items . length ; i ++ ) {
427389 var item = items [ i ] ;
428- console . log ( `Processing item ${ i + 1 } /${ items . length } :` , {
429- number : item . number ,
430- title : item . title ,
431- state : item . state ,
432- isPR : ! ! item . pull_request ,
433- body : item . body ? item . body . substring ( 0 , 100 ) + "..." : "no body"
434- } ) ;
435-
436390 var html_url = item . html_url ;
437391 var repository_url = item . repository_url ;
438392 var project = repository_url . substr ( repository_url . lastIndexOf ( '/' ) + 1 ) ;
@@ -441,59 +395,29 @@ ${userReason}`;
441395 var li = '' ;
442396
443397 if ( item . pull_request ) {
444- console . log ( `Item #${ number } is a PR with state ${ item . state } ` ) ;
445398 if ( item . state === 'closed' ) {
446399 li = `<li><i>(${ project } )</i> - Made PR (#${ number } ) - <a href='${ html_url } '>${ title } </a> ${ pr_merged_button } </li>` ;
447- console . log ( "Added closed PR to lastWeekArray" ) ;
448400 } else if ( item . state === 'open' ) {
449401 li = `<li><i>(${ project } )</i> - Made PR (#${ number } ) - <a href='${ html_url } '>${ title } </a> ${ pr_unmerged_button } </li>` ;
450- console . log ( "Added open PR to lastWeekArray" ) ;
451402 }
452403 } else {
453- console . log ( `Item #${ number } is an Issue with state ${ item . state } ` ) ;
454404 if ( item . state === 'open' && item . body && item . body . toUpperCase ( ) . indexOf ( 'YES' ) > 0 ) {
455405 var li2 = `<li><i>(${ project } )</i> - Work on Issue(#${ number } ) - <a href='${ html_url } '>${ title } </a> ${ issue_opened_button } </li>` ;
456406 nextWeekArray . push ( li2 ) ;
457- console . log ( "Added to nextWeekArray (contains YES)" ) ;
458407 }
459408 if ( item . state === 'open' ) {
460409 li = `<li><i>(${ project } )</i> - Opened Issue(#${ number } ) - <a href='${ html_url } '>${ title } </a> ${ issue_opened_button } </li>` ;
461- console . log ( "Added open issue to lastWeekArray" ) ;
462410 } else if ( item . state === 'closed' ) {
463411 li = `<li><i>(${ project } )</i> - Opened Issue(#${ number } ) - <a href='${ html_url } '>${ title } </a> ${ issue_closed_button } </li>` ;
464- console . log ( "Added closed issue to lastWeekArray" ) ;
465412 }
466413 }
467414 if ( li ) {
468415 lastWeekArray . push ( li ) ;
469- console . log ( "Added to lastWeekArray:" , li ) ;
470416 } else {
471- console . log ( `No li generated for item #${ number } ` ) ;
472417 }
473418 }
474- console . log ( "Final arrays:" , {
475- lastWeekItems : lastWeekArray . length ,
476- nextWeekItems : nextWeekArray . length ,
477- lastWeekContents : lastWeekArray ,
478- nextWeekContents : nextWeekArray
479- } ) ;
480419 writeScrumBody ( ) ;
481420 }
482- //check for scrum body loaded
483- // var intervalBody = setInterval(function(){
484- // var bodies = [
485- // document.getElementById("p-b-0"),
486- // document.getElementById("p-b-1"),
487- // document.getElementById("p-b-2"),
488- // document.querySelector("c-wiz [aria-label='Compose a message'][role=textbox]")];
489- // for (var body of bodies) {
490- // if (!body)
491- // continue;
492- // clearInterval(intervalBody);
493- // scrumBody=body;
494- // writeScrumBody();
495- // }
496- // },500);
497421 var intervalBody = setInterval ( ( ) => {
498422 if ( ! window . emailClientAdapter ) return ;
499423
@@ -505,23 +429,6 @@ ${userReason}`;
505429 writeScrumBody ( ) ;
506430 } , 500 ) ;
507431
508- //check for subject loaded
509- // var intervalSubject = setInterval(function(){
510- // if (!githubUserData)
511- // return;
512- // var subjects = [
513- // document.getElementById("p-s-0"),
514- // document.getElementById("p-s-1"),
515- // document.getElementById("p-s-2"),
516- // document.querySelector("c-wiz input[aria-label=Subject]")];
517- // for (var subject of subjects) {
518- // if (!subject)
519- // continue;
520- // clearInterval(intervalSubject);
521- // scrumSubject=subject;
522- // scrumSubjectLoaded();
523- // }
524- // },500);
525432 var intervalSubject = setInterval ( ( ) => {
526433 if ( ! githubUserData || ! window . emailClientAdapter ) return ;
527434
@@ -570,13 +477,12 @@ ${userReason}`;
570477 allIncluded ( 'email' ) ;
571478 }
572479}
573- allIncluded ( 'email' ) ; // Auto-trigger on page load
480+ allIncluded ( 'email' ) ;
574481$ ( 'button>span:contains(New conversation)' ) . parent ( 'button' ) . click ( ( ) => {
575- allIncluded ( ) ; // Auto-trigger on new conversation
482+ allIncluded ( ) ;
576483} ) ;
577484
578485window . generateScrumReport = function ( ) {
579- console . log ( 'generateScrumReport called' ) ;
580486 allIncluded ( 'popup' ) ;
581487} ;
582488
0 commit comments