diff --git a/content.js b/content.js index 11753b3..fd644df 100644 --- a/content.js +++ b/content.js @@ -2,7 +2,7 @@ window.addEventListener("load", myMain, false); function updateUI() { "use strict"; - //add link 'Copy emails to clipboard' to all divs. Links id are 0, 1, 2 + //add link 'Copy emails to clipboard' to all divs. Links id are div0, div1, div2 $('.js-list.list-wrapper').each(function (i) { "use strict"; $(this).find('.icon-sm.icon-overflow-menu-horizontal').click(function () { @@ -12,11 +12,13 @@ function updateUI() { //addclickListener let numberOfDiv = $('.js-list.list-wrapper').length; for (let i = 0; i < numberOfDiv; i++) { - $('#div' + i).click(function (i) { - console.log('hello from ' + i); + $('#div' + i).click(function () { + let str = getEmails(i); + console.log(str); + window.prompt("Copy to clipboard: Ctrl+C, Enter", str); }); } - }, 50); + }, 100); }); }); } @@ -27,17 +29,26 @@ function extractEmails(text) { } function getEmails(idDiv) { + let str = ''; "use strict"; $('.js-list.list-wrapper').each(function (i) { $(this).find('.list-card.js-member-droppable.ui-droppable').each(function (j) { //test card label - if (!$(this).find('.card-label').hasClass('card-label-black')) { + if (!$(this).find('.card-label').hasClass('card-label-black') && i === idDiv) { let email = $(this).find('.list-card-title.js-card-name').text().trim(); email = extractEmails(email); - console.log('bloc ' + i + ' ligne ' + j + ' ' + email); + if (email) { + if (!str) { + str += email; + } else { + str += ', ' + email + ' '; + } + + } } }); }); + return str.trim(); } function myMain(evt) { diff --git a/manifest.json b/manifest.json index ef7966d..3b05572 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,5 @@ { "manifest_version": 2, - "name": "Chez Nestor Trello Addon", "description": "Improves Trello and other internal tools for our use-cases", "version": "1.0.1", @@ -11,8 +10,13 @@ }, "content_scripts": [ { - "matches": ["https://trello.com/*"], - "js": ["content.js", "jquery.js"] + "matches": [ + "https://trello.com/*" + ], + "js": [ + "content.js", + "jquery.js" + ] } ], "browser_action": {